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.3.tar.gz (14.4 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.3-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ktmu-0.1.3.tar.gz
Algorithm Hash digest
SHA256 74ecefdd19e192b45a95668d1c55f6da2ba240572196f3683ae365347f2e3af5
MD5 3d91954d5feed9f63ab6f52c8ca4f696
BLAKE2b-256 8a789a13f7eae284b893e43eceedf584c041f0190dfc364f62fd13507adebda3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ktmu-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 88b8d7dc2e86a35f6a10a76944b424961afae325ba7eff450a3e5be97acb8a14
MD5 4707274a07fe624e9212c5b0f5b337ca
BLAKE2b-256 3dff55474f08a48b1650fd8ba9d48090766dee326e7c95d080d8ee37ee5643d1

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