ekonlpy

Korean NLP Python Library for Economic Analysis

https://github.com/entelecheia/ekonlpy

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.6%) to scientific vocabulary

Keywords

mecab mecab-ko-dic monetary-policy pos-tagger sentiment-analysis

Keywords from Contributors

transformation profiles benchmarking mpi charts interactive astronomy annotation embedded data-profilers
Last synced: 6 months ago · JSON representation ·

Repository

Korean NLP Python Library for Economic Analysis

Basic Info
Statistics
  • Stars: 55
  • Watchers: 2
  • Forks: 24
  • Open Issues: 4
  • Releases: 18
Topics
mecab mecab-ko-dic monetary-policy pos-tagger sentiment-analysis
Created almost 8 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

eKoNLPy: Korean NLP Python Library for Economic Analysis

pypi-image version-image release-date-image pypi-downloads-image license-image codecov zenodo-image

eKoNLPy is a Korean Natural Language Processing (NLP) Python library specifically designed for economic analysis. It extends the functionality of the Mecab tagger from KoNLPy to improve the handling of economic terms, financial institutions, and company names, classifying them as single nouns. Additionally, it incorporates sentiment analysis features to determine the tone of monetary policy statements, such as Hawkish or Dovish.

Note

From version 2.0.0, eKoNLPy integrates the extended tagger with the original tagger. If you want to use the original tagger, please set use_original_tagger=True when you create the instance of Mecab class. Additionally, the Mecab class can be directly imported from ekonlpy module. The default input text parameter of Mecab.pos() is changed from phrase to text to be consistent with the original tagger.

Note

eKoNLPy is built on the fugashi and mecab-ko-dic libraries. For more information on using the Mecab tagger, please refer to the fugashi documentation. As eKoNLPy no longer relies on the KoNLPy library, Java is not required for its use. This makes eKoNLPy compatible with Windows, Linux, and Mac OS, without the need for Java installation. You can also use eKoNLPy on Google Colab.

If you wish to tokenize general Korean text with eKoNLPy, you do not need to install the KoNLPy library. Instead, utilize the same ekonlpy.Mecab class with the use_original_tagger=True option.

However, if you plan to use the Korean Sentiment Analyzer (KSA), which employs the Kkma morpheme analyzer, you will need to install the KoNLPy library.

Installation

To install eKoNLPy, run the following command:

bash pip install ekonlpy

Usage

Part of Speech Tagging

To use the part of speech tagging feature, input Mecab.pos(phrase) just like KoNLPy. First, the input is processed using KoNLPy's Mecab morpheme analyzer. Then, if a combination of consecutive tokens matches a term in the user dictionary, the phrase is separated into compound nouns.

```python from ekonlpy import Mecab

mecab = Mecab() mecab.pos('금통위는 따라서 물가안정과 병행, 경기상황에 유의하는 금리정책을 펼쳐나가기로 했다고 밝혔다.') ```

[('금', 'MAJ'), ('통', 'MAG'), ('위', 'NNG'), ('는', 'JX'), ('따라서', 'MAJ'), ('물가', 'NNG'), ('안정', 'NNG'), ('과', 'JC'), ('병행', 'NNG'), (',', 'SC'), ('경기', 'NNG'), ('상황', 'NNG'), ('에', 'JKB'), ('유의', 'NNG'), ('하', 'XSV'), ('는', 'ETM'), ('금리', 'NNG'), ('정책', 'NNG'), ('을', 'JKO'), ('펼쳐', 'VV+EC'), ('나가', 'VX'), ('기', 'ETN'), ('로', 'JKB'), ('했', 'VV+EP'), ('다고', 'EC'), ('밝혔', 'VV+EP'), ('다', 'EF'), ('.', 'SF')]

You can also use the Command Line Interface (CLI) to perform part of speech tagging:

bash ekonlpy --input "안녕하세요"

[('안녕', 'NNG'), ('하', 'XSV'), ('세요', 'EP')]

cf. Original Mecab POS Tagging (fugashi)

```python from ekonlpy import Mecab

mecab = Mecab(useoriginaltagger=True) # set useoriginaltagger=True mecab.pos('금통위는 따라서 물가안정과 병행, 경기상황에 유의하는 금리정책을 펼쳐나가기로 했다고 밝혔다.') ```

[('금', 'MAJ'), ('통', 'MAG'), ('위', 'NNG'), ('는', 'JX'), ('따라서', 'MAJ'), ('물가', 'NNG'), ('안정', 'NNG'), ('과', 'JC'), ('병행', 'NNG'), (',', 'SC'), ('경기', 'NNG'), ('상황', 'NNG'), ('에', 'JKB'), ('유의', 'NNG'), ('하', 'XSV'), ('는', 'ETM'), ('금리', 'NNG'), ('정책', 'NNG'), ('을', 'JKO'), ('펼쳐', 'VV+EC'), ('나가', 'VX'), ('기', 'ETN'), ('로', 'JKB'), ('했', 'VV+EP'), ('다고', 'EC'), ('밝혔', 'VV+EP'), ('다', 'EF'), ('.', 'SF')]

Lemmatization and Synonyms

To enhance the accuracy of sentiment analysis, eKoNLPy offers lemmatization and synonym handling features.

Adding Words to Dictionary

You can add words to the dictionary in the ekonlpy.tag module's Mecab class, either as a string or a list of strings, using the add_dictionary method.

```python from ekonlpy.tag import Mecab

mecab = Mecab() mecab.add_dictionary('금통위', 'NNG') ```

Sentiment Analysis

Korean Monetary Policy Dictionary (MPKO)

To perform sentiment analysis using the Korean Monetary Policy dictionary, create an instance of the MPKO class in ekonlpy.sentiment:

```python from ekonlpy.sentiment import MPKO

mpko = MPKO(kind=1) tokens = mpko.tokenize(text) score = mpko.get_score(tokens) ```

The kind parameter in the MPKO class is used to select a lexicon file:

  • 0: A lexicon file generated using a Naive-Bayes classifier with 5-gram tokens as features and changes of call rates as positive/negative labels.
  • 1: A lexicon file generated by polarity induction and seed propagation method with 5-gram tokens.

Korean Monetary Policy Classifier (MPCK)

To use a classifier for monetary policy sentiment analysis, utilize the MPCK class from ekonlpy.sentiment:

```python from ekonlpy.sentiment import MPCK

mpck = MPCK() tokens = mpck.tokenize(text) ngrams = mpck.ngramize(tokens) score = mpck.classify(tokens + ngrams, intensity_cutoff=1.5) ```

You can set the intensity_cutoff parameter to adjust the intensity for classifying low-accuracy sentences as neutral (default: 1.3).

Korean Sentiment Analyzer (KSA)

For general Korean sentiment analysis, use the KSA class. The morpheme analyzer used in this class is Kkma developed by Seoul National University's IDS Lab. The sentiment dictionary is also from the same lab (reference: http://kkma.snu.ac.kr/).

```python from ekonlpy.sentiment import KSA

ksa = KSA() tokens = ksa.tokenize(text) score = ksa.get_score(tokens) ```

Harvard IV-4 Dictionary

For general English sentiment analysis, use the Harvard IV-4 dictionary:

```python from ekonlpy.sentiment import HIV4

hiv = HIV4() tokens = hiv.tokenize(text) score = hiv.get_score(tokens) ```

Loughran and McDonald Dictionary

For sentiment analysis in the financial domain, use the Loughran and McDonald dictionary:

```python from ekonlpy.sentiment import LM

lm = LM() tokens = lm.tokenize(text) score = lm.get_score(tokens) ```

Changelog

See the CHANGELOG for more information.

Contributing

Contributions are welcome! Please see the contributing guidelines for more information.

License

eKoNLPy is an open-source software library for Korean Natural Language Processing (NLP), specifically designed for economic analysis. The library is released under the MIT License, allowing developers and researchers to use, modify, and distribute the software as they see fit.

Citation

If you use eKoNLPy in your work or research, please cite the following sources:

  • Lee, Young Joon, eKoNLPy: A Korean NLP Python Library for Economic Analysis, 2018. Available at: https://github.com/entelecheia/eKoNLPy.
  • Lee, Young Joon, Soohyon Kim, and Ki Young Park. "Deciphering Monetary Policy Board Minutes with Text Mining: The Case of South Korea." Korean Economic Review 35 (2019): 471-511.

You can also use the following BibTeX entry for citation:

bibtex @misc{lee2018ekonlpy, author= {Lee, Young Joon}, year = {2018}, title = {{eKoNLPy: A Korean NLP Python Library for Economic Analysis}}, note = {\url{https://github.com/entelecheia/eKoNLPy}} }

By citing eKoNLPy in your work, you acknowledge the efforts and contributions of its creators and help promote further development and research in the field of Korean NLP for economic analysis.

Owner

  • Name: Young Joon Lee
  • Login: entelecheia
  • Kind: user
  • Location: Jeju, South Korea
  • Company: Cheju Halla University

Professor at Cheju Halla University

Citation (CITATION.cff)

cff-version: 1.2.0
preferred-citation:
  type: article
  message: "If you use eKoNLPy in research, it would be appreciated if you site this."
  authors:
  - family-names: "Lee"
    given-names: "Young Joon"
  title: "eKoNLPy: A Korean NLP Python Library for Economic Analysis"
  journal: "GitHub"
  year: 2018

GitHub Events

Total
  • Release event: 1
  • Watch event: 2
  • Delete event: 39
  • Issue comment event: 133
  • Push event: 39
  • Pull request review comment event: 1
  • Pull request review event: 45
  • Pull request event: 85
  • Create event: 46
Last Year
  • Release event: 1
  • Watch event: 2
  • Delete event: 39
  • Issue comment event: 133
  • Push event: 39
  • Pull request review comment event: 1
  • Pull request review event: 45
  • Pull request event: 85
  • Create event: 46

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 526
  • Total Committers: 6
  • Avg Commits per committer: 87.667
  • Development Distribution Score (DDS): 0.12
Past Year
  • Commits: 42
  • Committers: 4
  • Avg Commits per committer: 10.5
  • Development Distribution Score (DDS): 0.262
Top Committers
Name Email Commits
Youngjoon Lee y****e@y****r 463
dependabot[bot] 4****] 42
semantic-release s****e 14
github-actions g****s@g****m 5
github-actions a****s 1
Sourcery AI 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 5
  • Total pull requests: 106
  • Average time to close issues: 25 minutes
  • Average time to close pull requests: 4 days
  • Total issue authors: 1
  • Total pull request authors: 3
  • Average comments per issue: 0.0
  • Average comments per pull request: 2.72
  • Merged pull requests: 73
  • Bot issues: 0
  • Bot pull requests: 94
Past Year
  • Issues: 0
  • Pull requests: 76
  • Average time to close issues: N/A
  • Average time to close pull requests: 4 days
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 3.12
  • Merged pull requests: 46
  • Bot issues: 0
  • Bot pull requests: 75
Top Authors
Issue Authors
  • entelecheia (3)
Pull Request Authors
  • dependabot[bot] (115)
  • entelecheia (16)
  • sourcery-ai[bot] (1)
Top Labels
Issue Labels
security (1) documentation (1) enhancement (1)
Pull Request Labels
[zube]: Inbox (49) Extra Small (11) [zube]: Done (10) Small (2) Medium (1) enhancement (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 156 last-month
  • Total dependent packages: 2
  • Total dependent repositories: 0
  • Total versions: 17
  • Total maintainers: 1
pypi.org: ekonlpy

A Korean natural language processing toolkit for economic analysis

  • Versions: 17
  • Dependent Packages: 2
  • Dependent Repositories: 0
  • Downloads: 156 Last month
Rankings
Dependent packages count: 7.0%
Forks count: 8.2%
Stargazers count: 9.9%
Average: 13.9%
Dependent repos count: 30.4%
Maintainers (1)
Last synced: 6 months ago

Dependencies

setup.py pypi
  • gensim *
  • konlpy >=0.4.4
  • nltk *
  • numpy *
  • scipy *