Skip to main content

Korean Text Mining utilities for visualization, NLP, and LLM analysis

Project description

ktmu: Korean Text Mining Utilities

ktmu는 텍스트 데이터의 전처리, 시각화, 언어 모델 연동을 통합적으로 지원하기 위한 파이썬 패키지입니다. 특히 한국어(Kiwi)와 영어(spaCy) 형태소 분석을 일관된 인터페이스로 제공하며, 최신 LLM(Gemini)을 활용한 분석 기능을 포함하고 있습니다.

주요 기능

  • 다양한 시각화 지원: 토큰 빈도 막대 그래프, 워드클라우드, 임베딩 차원 축소(PCA/t-SNE), 계층적 군집화 덴드로그램 출력.
  • 통합 형태소 분석 인터페이스: SpacyTokenizer(영어) 및 KiwiTokenizer(한국어) 클래스를 통한 손쉬운 토큰화 및 표제어 추출.
  • Pandas 연동: 모든 분석 결과(토큰, 형태소 정보 등)를 즉시 DataFrame으로 변환하여 데이터 분석 파이프라인에 활용 가능.
  • LLM 감성 분석: Google Gemini API를 활용한 대규모 텍스트 데이터의 배치 감성 분석 기능.
  • 임베딩 분석: Gensim 모델과 연동하여 단어 간 유사도 비교 및 시각화.

설치 방법

패키지는 다음과 같이 설치합니다.

pip install ktmu

사용 예시

1. 한국어 형태소 분석 (Kiwi)

from ktmu import KiwiTokenizer

tokenizer = KiwiTokenizer()
text = "텍스트 마이닝은 정말 재밌는 학문입니다."

# 토큰화 및 데이터프레임 변환
df = tokenizer.get_token_dataframe(text)
print(df)

# 명사만 추출
nouns = tokenizer.noun_tokenize(text)
print(nouns)

2. 빈도 시각화

from ktmu import visualize_tokens

tokens = ["데이터", "분석", "데이터", "AI", "텍스트", "분석", "데이터"]
visualize_tokens(tokens, top_n=10)

3. Gemini를 활용한 감성 분석

import pandas as pd
from google import genai
from ktmu import analyze_sentiment_with_gemini

client = genai.Client(api_key="YOUR_API_KEY")
reviews = pd.Series(["이 영화 정말 재밌어요!", "시간 아까워요..."], name="review")

# 배치 감성 분석 수행
results = analyze_sentiment_with_gemini(client, reviews, system_message="감성 분석 전문가로서 응답해줘.")
print(results)

4. 워드 임베딩 시각화

from ktmu import visualize_embeddings

# gensim의 word vector 객체(wv)가 있다고 가정
words = ["사과", "바나나", "컴퓨터", "키보드"]
visualize_embeddings(wv, words, method='pca')

의존성

이 패키지는 다음 라이브러리들을 사용합니다:

  • pandas, numpy, matplotlib
  • spacy, kiwipiepy
  • scikit-learn, scipy
  • wordcloud, google-genai

라이선스

이 프로젝트는 LGPL-3.0 라이선스 하에 배포됩니다.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ktmu-0.1.7.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ktmu-0.1.7-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file ktmu-0.1.7.tar.gz.

File metadata

  • Download URL: ktmu-0.1.7.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for ktmu-0.1.7.tar.gz
Algorithm Hash digest
SHA256 881e6ba53ea17746d93fd8e1601c703c2f47aba8901fa509f2848fe55f086699
MD5 dd80781bab236c9475452e12eeb5718b
BLAKE2b-256 3435504db7f12496abe01b9d6b033c17b20f541ed865f91ea3e1dd242fb0323c

See more details on using hashes here.

File details

Details for the file ktmu-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: ktmu-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for ktmu-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b1d032a08f6b522516c019a860bacd219e4717de35608a76bd17456b58adb7c7
MD5 1cb848053825f63e0d66989dbe00d3b0
BLAKE2b-256 33dfc5a656b70a2683b641e1f56c701947c5df7eb94b00ba7ad082e2667d4013

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page