anti-cursing

The package that detect & switch the curse word in the sentence by using deep learning


Keywords
bert, natural-language-processing, nlp, pypi, python
License
MIT
Install
pip install anti-cursing==0.0.1

Documentation

anti-cursing

"anti-cursing" is a python package that detects and switches negative or any kind of cursing word from sentences or comments whatever🀬

You just install the package the way you install any other package and then you can use it in your code.

The whole thing is gonna be updated soon.

So this is the very first idea

But you can find my package in pypi(https://pypi.org/project/anti-cursing/0.0.1/)

πŸ™πŸ»Plz bare with the program to install model's weight and bias from huggingface at the first time you use the package.

image


Concept

There are often situations where you have to code something, detect a forbidden word, and change it to another word. Hardcoding all parts is very inconvenient, and in the Python ecosystem, there are many packages to address. One of them is "anti-cursing".

The package, which operates exclusively for Korean, does not simply change the banned word by setting it up, but detects and replaces the banned word by learning a deep learning model.

Therefore, it is easy to cope with new malicious words as long as they are learned. For this purpose, semi-supervied learning through pseudo labeling is used.

Additionally, instead of changing malicious words to special characters such as --- or ***, you can convert them into emojis to make them more natural.

Contents

Installation

You can install the package using pip:

pip install anti-cursing

it doesn't work yet, but it will soon!!πŸ‘¨πŸ»β€πŸ’»

Usage

from anti_cursing.utils import antiCursing

antiCursing.anti_cur("λ‚˜λŠ” λ„ˆκ°€ μ’‹μ§€λ§Œ, λ„ˆλŠ” λ„ˆλ¬΄ κ°œμƒˆλΌμ•Ό")
λ‚˜λŠ” λ„ˆκ°€ μ’‹μ§€λ§Œ, λ„ˆλŠ” λ„ˆλ¬΄ πŸ‘ΌπŸ»μ•Ό

Model-comparison

Classification KcElectra KoBERT RoBERTa-base RoBERTa-large
Validation Accuracy 0.88680 0.85721 0.83421 0.86994
Validation Loss 1.00431 1.23237 1.30012 1.16179
Training Loss 0.09908 0.03761 0.0039 0.06255
Epoch 10 40 20 20
Batch-size 8 32 16 32
transformers beomi/KcELECTRA-base skt/kobert-base-v1 xlm-roberta-base klue/roberta-large

Dataset

Used-api

Google translator

License

This repository is licensed under the MIT license. See LICENSE for details.

Click here to see the License information --> License

Working-example

---- some video is gonna be placed here ----

References

Sentiment Analysis Based on Deep Learning : A Comparative Study

  • Nhan Cach Dang, Maria N. Moreno-Garcia, Fernando De la Prieta. 2006. Sentiment Analysis Based on Deep Learning : A Comparative Study. In Proceedings of the 2006 Conference on Empirical Methods in Natural Language Processing (EMNLP 2006), pages 1–8, Prague, Czech Republic. Association for Computational Linguistics.

Attention is all you need

  • Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In Advances in Neural Information Processing Systems, pages 6000–6010.

BERT : Pre-training of Deep Bidirectional Transformers for Language Understanding

  • Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2018. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pages 4171–4186.

Electra : Pre-training Text Encoders as Discriminators Rather Than Generators

  • Kevin Clark, Minh-Thang Luong, Quoc V. Le, Christopher D. Manning. 2019. Electra: Pre-training text encoders as discriminators rather than generators. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pages 4171–4186.

BIDAF : Bidirectional Attention Flow for Machine Comprehension

  • Minjoon Seo, Aniruddha Kembhavi, Ali Farhadi, Hannaneh Hajishirzi. 2016. Bidirectional Attention Flow for Machine Comprehension. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pages 2129–2139.

Effect of Negation in Sentences on Sentiment Analysis and Polarity Detection

  • Partha Mukherjeea, Saptarshi Ghoshb, and Saptarshi Ghoshc. 2018. Effect of Negation in Sentences on Sentiment Analysis and Polarity Detection. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 2129–2139.

KOAS : Korean Text Offensiveness Analysis System

  • Seonghwan Kim, Seongwon Lee, and Seungwon Do. 2019. KOAS: Korean Text Offensiveness Analysis System. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 1–11.

Korean Unsmile Dataset

  • Seonghwan Kim, Seongwon Lee, and Seungwon Do. 2019. Korean Unsmile Dataset. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 1–11.

Project-status

80%

Future-work

update soon plz bare with me πŸ™πŸ»


KOREAN FROM HERE / μ—¬κΈ°λΆ€ν„΄ ν•œκ΅­μ–΄ μ„€λͺ…μž…λ‹ˆλ‹€.

anti-cursing

**"anti-cursing"**은 λ¬Έμž₯μ΄λ‚˜ λŒ“κΈ€μ—μ„œ λΆ€μ •μ μ΄κ±°λ‚˜ λͺ¨λ“  μ’…λ₯˜μ˜ μš•μ„€μ„ κ°μ§€ν•˜κ³  μ „ν™˜ν•˜λŠ” 파이썬 νŒ¨ν‚€μ§€μž…λ‹ˆλ‹€πŸ€¬

λ‹€λ₯Έ νŒ¨ν‚€μ§€λ₯Ό μ„€μΉ˜ν•˜λŠ” 방식과 λ™μΌν•˜κ²Œ νŒ¨ν‚€μ§€λ₯Ό μ„€μΉ˜ν•œ λ‹€μŒ μ½”λ“œμ—μ„œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

아직 아이디어 ꡬ상 단계이기 λ•Œλ¬Έμ— 아무것도 μž‘λ™ν•˜μ§€ μ•Šμ§€λ§Œ 곧 μž‘λ™ν•˜λ„λ‘ μ—…λ°μ΄νŠΈν•  μ˜ˆμ •μž…λ‹ˆλ‹€.

Pypi(https://pypi.org/project/anti-cursing/0.0.1/)에 νŒ¨ν‚€μ§€λ₯΄ μ—…λ‘œλ“œν–ˆμŠ΅λ‹ˆλ‹€. ν™•μΈν•˜μ‹œ 수 μžˆμŠ΅λ‹ˆλ‹€.

πŸ™πŸ»νŒ¨ν‚€μ§€λ₯Ό 처음 μ„€μΉ˜ν•˜μ‹œκ³  μ‚¬μš©ν•˜μ‹€ λ•Œ λ”₯λŸ¬λ‹ λͺ¨λΈμ„ 뢈러였기 μœ„ν•΄ huggingfaceμ—μ„œ parsing을 μ‹œλ„ν•©λ‹ˆλ‹€. μ²˜μŒμ—λ§Œ ν•΄λ‹Ή μž‘μ—…μ΄ ν•„μš”ν•˜λ‹ˆ μ‹œκ°„μ΄ 쑰금 κ±Έλ¦Όκ³Ό μš©λŸ‰μ„ 차지함을 κ³ λ €ν•΄μ£Όμ„Έμš”

image


Concept

무언가 코딩을 ν•˜λ©°, κΈˆμ§€ 단어λ₯Ό κ°μ§€ν•˜κ³  그것을 λ‹€λ₯Έ λ‹¨μ–΄λ‘œ λ°”κΏ”μ•Όν•  상황이 μ’…μ’… μƒκΉλ‹ˆλ‹€. λͺ¨λ“  뢀뢄을 ν•˜λ“œμ½”λ”©ν•˜λŠ” 것이 맀우 λΆˆνŽΈν•˜λ©°, 파이썬 μƒνƒœκ³„μ—μ„œλŠ” 이λ₯Ό ν•΄κ²°ν•˜κΈ° μœ„ν•œ λ§Žμ€ νŒ¨ν‚€μ§€κ°€ μžˆμŠ΅λ‹ˆλ‹€. κ·Έ 쀑 ν•˜λ‚˜κ°€ **"anti-cursing"**μž…λ‹ˆλ‹€.

ν•œκ΅­μ–΄ μ „μš©μœΌλ‘œ λ™μž‘ν•˜λŠ” ν•΄λ‹Ή νŒ¨ν‚€μ§€λŠ” λ‹¨μˆœνžˆ κΈˆμ§€ 단어λ₯Ό 기쑴에 μ„€μ •ν•˜μ—¬ λ°”κΎΈλŠ” 것이 μ•„λ‹Œ, λ”₯λŸ¬λ‹ λͺ¨λΈμ„ ν•™μŠ΅ν•˜μ—¬ κΈˆμ§€ 단어λ₯Ό κ°μ§€ν•˜κ³  λ°”κΏ‰λ‹ˆλ‹€. λ”°λΌμ„œ μƒˆλ‘­κ²Œ μƒκΈ°λŠ” μ•…μ„± 단어에 λŒ€ν•΄μ„œλ„ ν•™μŠ΅λ§Œ 이루어진닀면 μ‰½κ²Œ λŒ€μ²˜ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 이λ₯Ό μœ„ν•΄ pseudo labeling을 ν†΅ν•œ semi-supervied learning을 μ‚¬μš©ν•©λ‹ˆλ‹€.

μΆ”κ°€λ‘œ 악성단어λ₯Ό ---λ‚˜ ***같은 특수문자둜 λ³€κ²½ν•˜λŠ” 것이 μ•„λ‹Œ, 이λͺ¨μ§€λ‘œ λ³€ν™˜ν•˜μ—¬ λ”μš± μžμ—°μŠ€λŸ½κ²Œ λ°”κΏ€ 수 μžˆμŠ΅λ‹ˆλ‹€.

λͺ©μ°¨

μ„€μΉ˜

pipλ₯Ό μ‚¬μš©ν•˜μ—¬ νŒ¨ν‚€μ§€λ₯Ό μ„€μΉ˜ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

pip install anti-cursing

아직 아무것도 μž‘λ™ν•˜μ§€ μ•Šμ§€λ§Œ, 곧 μž‘λ™ν•˜λ„λ‘ μ—…λ°μ΄νŠΈν•  μ˜ˆμ •μž…λ‹ˆλ‹€πŸ‘¨πŸ»β€πŸ’».

μ‚¬μš©λ²•

from anti_cursing.utils import antiCursing

antiCursing.anti_cur("λ‚˜λŠ” λ„ˆκ°€ μ’‹μ§€λ§Œ, λ„ˆλŠ” λ„ˆλ¬΄ κ°œμƒˆλΌμ•Ό")
λ‚˜λŠ” λ„ˆκ°€ μ’‹μ§€λ§Œ, λ„ˆλŠ” λ„ˆλ¬΄ πŸ‘ΌπŸ»μ•Ό

λͺ¨λΈ μ„±λŠ₯ 비ꡐ

Classification KcElectra KoBERT RoBERTa-base RoBERTa-large
Validation Accuracy 0.88680 0.85721 0.83421 0.86994
Validation Loss 1.00431 1.23237 1.30012 1.16179
Training Loss 0.09908 0.03761 0.0039 0.06255
Epoch 10 40 20 20
Batch-size 8 32 16 32
transformers beomi/KcELECTRA-base skt/kobert-base-v1 xlm-roberta-base klue/roberta-large

데이터셋

μ‚¬μš© API

Google translator

License

이 ν”„λ‘œμ νŠΈλŠ” MIT λΌμ΄μ„ΌμŠ€λ₯Ό λ”°λ¦…λ‹ˆλ‹€. μžμ„Έν•œ λ‚΄μš©μ€ LICENSE νŒŒμΌμ„ μ°Έκ³ ν•΄μ£Όμ„Έμš”.

λΌμ΄μ„ΌμŠ€ 정보 --> License

μž‘λ™ μ˜ˆμ‹œ

---- μž‘λ™ μ˜ˆμ‹œκ°€ 좔가될 μ˜ˆμ •μž…λ‹ˆλ‹€ ----

μ°Έκ³ λ¬Έν—Œ

Sentiment Analysis Based on Deep Learning : A Comparative Study

  • Nhan Cach Dang, Maria N. Moreno-Garcia, Fernando De la Prieta. 2006. Sentiment Analysis Based on Deep Learning : A Comparative Study. In Proceedings of the 2006 Conference on Empirical Methods in Natural Language Processing (EMNLP 2006), pages 1–8, Prague, Czech Republic. Association for Computational Linguistics.

Attention is all you need

  • Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In Advances in Neural Information Processing Systems, pages 6000–6010.

BERT : Pre-training of Deep Bidirectional Transformers for Language Understanding

  • Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2018. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pages 4171–4186.

Electra : Pre-training Text Encoders as Discriminators Rather Than Generators

  • Kevin Clark, Minh-Thang Luong, Quoc V. Le, Christopher D. Manning. 2019. Electra: Pre-training text encoders as discriminators rather than generators. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pages 4171–4186.

BIDAF : Bidirectional Attention Flow for Machine Comprehension

  • Minjoon Seo, Aniruddha Kembhavi, Ali Farhadi, Hannaneh Hajishirzi. 2016. Bidirectional Attention Flow for Machine Comprehension. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pages 2129–2139.

Effect of Negation in Sentences on Sentiment Analysis and Polarity Detection

  • Partha Mukherjeea, Saptarshi Ghoshb, and Saptarshi Ghoshc. 2018. Effect of Negation in Sentences on Sentiment Analysis and Polarity Detection. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 2129–2139.

KOAS : Korean Text Offensiveness Analysis System

  • Seonghwan Kim, Seongwon Lee, and Seungwon Do. 2019. KOAS: Korean Text Offensiveness Analysis System. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 1–11.

Korean Unsmile Dataset

  • Seonghwan Kim, Seongwon Lee, and Seungwon Do. 2019. Korean Unsmile Dataset. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 1–11.

진행상황

80%

λ°œμ „

μ•žμœΌλ‘œ 좔가될 μ˜ˆμ •μž…λ‹ˆλ‹€ μž μ‹œλ§Œ κΈ°λ‹€λ €μ£Όμ„Έμš”πŸ™πŸ»