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.8.tar.gz (17.7 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.8-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ktmu-0.1.8.tar.gz
  • Upload date:
  • Size: 17.7 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.8.tar.gz
Algorithm Hash digest
SHA256 b32fdfdbaf82d47c0c4114c387518a198603c41b1902c63e5b5319ea540375a8
MD5 3ed2ad00e15f33bbf3a597f29d021b7c
BLAKE2b-256 ec65a525c9d668c25e3f6dc1d7ef20a5003a7e3abb016763f12edab9ea6e30f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ktmu-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 17.9 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d602d9e50d5d6c6e7cfe8fe0077fd9f4848fd0ccf87fcadc50281f3b9b717a9d
MD5 113fa8d64033517b64a38270a8a64550
BLAKE2b-256 9d65eebd2237d4b7a165c4e5f39ebbd94dfdb0dc6041b6fd5bd25fae57061e49

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