Przejdź do treści
Biblioteka skilli
Nauka i badania · Analiza

nlp-analysis

/nlp-analysis

Analizuje teksty w badaniach: eksploracja tekstu, analiza sentymentu, modelowanie tematów, rozpoznawanie nazw własnych, klasyfikacja tekstu i analiza korpusów.

Repozytorium
scienceclaw ↗
Licencja
MIT
Ostatnia zmiana repozytorium
07.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 07.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Analizuje teksty w badaniach: eksploracja tekstu, analiza sentymentu, modelowanie tematów, rozpoznawanie nazw własnych, klasyfikacja tekstu i analiza korpusów.

Wyzwalacze z opisu

text miningsentiment analysistopic modelingNERnamed entitytext classificationword embeddingsLDA
Oryginalny opis (EN)

Natural language processing for research including text mining, sentiment analysis, topic modeling, named entity recognition, text classification, and corpus analysis. Use when user needs to analyze text data, extract information from documents, do sentiment analysis, topic modeling, or text classification for research purposes. Triggers on "text mining", "sentiment analysis", "topic modeling", "NER", "named entity", "text classification", "word embeddings", "LDA", "corpus analysis", "word frequency", "TF-IDF".

Jak działa

  1. Text Preprocessing
  2. Text Vectorization
  3. Topic Modeling
  4. Sentiment Analysis
  5. Named Entity Recognition
  6. Text Classification
  7. Word Embeddings & Similarity
  8. Corpus Statistics
  9. Chinese NLP
  10. Tips
Sekcje z nagłówków SKILL.md, w oryginale · 177 linii, 537 słów
Podgląd SKILL.md
---
name: nlp-analysis
description: Natural language processing for research including text mining, sentiment analysis, topic modeling, named entity recognition, text classification, and corpus analysis. Use when user needs to analyze text data, extract information from documents, do sentiment analysis, topic modeling, or text classification for research purposes. Triggers on "text mining", "sentiment analysis", "topic modeling", "NER", "named entity", "text classification", "word embeddings", "LDA", "corpus analysis", "word frequency", "TF-IDF".
---

# NLP Analysis

Text mining and NLP for scientific research. Venv: `source /Users/zhangmingda/clawd/.venv/bin/activate`

## Text Preprocessing

```python
import re
import nltk
from collections import Counter

# Download resources (first time)
# nltk.download('punkt')
# nltk.download('stopwords')
# nltk.download('wordnet')

from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize, sent_tokenize
from nltk.stem import WordNetLemmatizer

def preprocess(text, lang='english'):
    text = text.lower()
    text = re.sub(r'[^\w\s]', '', text)
    tokens = word_tokenize(text)
    stop_words = set(stopwords.words(lang))
    tokens = [t for t in tokens if t not in stop_words and len(t) > 2]
    lemmatizer = WordNetLemmatizer()
    tokens = [lemmatizer.lemmatize(t) for t in tokens]
    return tokens
```

## Text Vectorization

```python
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer

# TF-IDF
tfidf = TfidfVectorizer(max_features=5000, ngram_range=(1, 2), stop_words='english')
X_tfidf = tfidf.fit_transform(documents)

# Get top terms per document
feature_names = tfidf.get_feature_names_out()
for i, doc in enumerate(documents[:3]):
    scores = X_tfidf[i].toarray().flatten()
    top_idx = scores.argsort()[-10:][::-1]
    print(f"Doc {i}: {[feature_names[j] for j in top_idx]}")
```

## Topic Modeling

### LDA (Latent Dirichlet Allocation)
```python
from sklearn.decomposition import LatentDirichletAllocation

n_topics = 10
lda = LatentDirichletAllocation(n_components=n_topics, random_state=42, max_iter=20)
lda.fit(X_count)  # use CountVectorizer, not TF-IDF

# Print top words per topic
for i, topic in enumerate(lda.components_):
    top_words = [feature_names[j] for j in topic.argsort()[-10:][::-1]]
    print(f"Topic {i}: {', '.join(top_words)}")

# Topic coherence: use gensim for proper evaluation
```

### BERTopic (neural topic modeling)
```python
# pip install bertopic
from bertopic import BERTopic

topic_model = BERTopic(language="english", nr_topics="auto")
topics, probs = topic_model.fit_transform(documents)
topic_model.get_topic_info()
```

## Sentiment Analysis

```python
# Simple lexicon-based
from nltk.sentiment import SentimentIntensityAnalyzer

sia = SentimentIntensityAnalyzer()
for text in texts:
    scores = sia.polarity_scores(text)
    print(f"{scores['compound']:.3f} | {text[:80]}")

# Transformer-based (more accurate)
from transformers import pipeline
sentiment = pipeline("sentiment-analysis")
results = sentiment(texts)
```

## Named Entity Recognition

```python
# Using transformers
from transformers import pipeline

ner = pipeline("ner", aggregation_strategy="simple")
entities = ner("Albert Einstein developed the theory of relativity at Princeton University.")
for e in entities:
    print(f"{e['entity_group']}: {e['word']} (score: {e['score']:.3f})")
```

## Text Classification

```python
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline

# TF-IDF + Logistic Regression (strong baseline)
pipe = Pipeline([
    ('tfidf', TfidfVectorizer(max_features=10000, ngram_range=(1, 2))),
    ('clf', LogisticRegression(max_iter=1000))
])
scores = cross_val_score(pipe, texts, labels, cv=5, scoring='f1_macro')
print(f"F1 macro: {scores.mean():.3f} ± {scores.std():.3f}")
```

## Word Embeddings & Similarity

```python
from sklearn.metrics.pairwise import cosine_similarity

# Using TF-IDF vectors for document similarity
sim_matrix = cosine_similarity(X_tfidf)

# For word-level embeddings, use gensim Word2Vec or sentence-transformers
# pip install sentence-transformers
from sentence_transformers import SentenceTransformer
model = SentenceTransformer('all-MiniLM-L6-v2')
embeddings = model.encode(documents)
```

## Corpus Statistics

```python
def corpus_stats(documents):
    all_tokens = [word_tokenize(doc.lower()) for doc in documents]
    all_words = [w for tokens in all_tokens for w in tokens if w.isalpha()]
    
    print(f"Documents: {len(documents)}")
    print(f"Total tokens: {len(all_words)}")
    print(f"Vocabulary size: {len(set(all_words))}")
    print(f"Type-token ratio: {len(set(all_words))/len(all_words):.4f}")
    print(f"Avg doc length: {np.mean([len(t) for t in all_tokens]):.1f} tokens")
    
    freq = Counter(all_words)
    print(f"Top 20 words: {freq.most_common(20)}")
```

## Chinese NLP

```python
# For Chinese text, use jieba for segmentation
# pip install jieba
import jieba

text = "自然语言处理是人工智能的重要方向"
words = list(jieba.cut(text))
print(" / ".join(words))

# For Chinese sentiment/NER, use transformers with Chinese models
# e.g., bert-base-chinese, hfl/chinese-roberta-wwm-ext
```

## Tips
- Always report preprocessing steps for reproducibility
- Use multiple topic numbers and evaluate coherence
- For small datasets, TF-IDF + classical ML often beats deep learning
- Report inter-annotator agreement for labeled datasets
- Consider domain-specific stop words and vocabularies
- For Chinese text, jieba segmentation is essential

Wersje

W bazie nie ma innych skilli o nazwie nlp-analysis.

Identyczna treść występuje jeszcze w 1 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.

Migawka bazy z 28.10.2026 · wersja paczki 23f74bc4add0 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100nlp-engineer
    Pomaga budować produkcyjne systemy NLP: potoki przetwarzania tekstu, modele językowe oraz zadania takie jak rozpoznawanie nazw własnych, analiza sentymentu i tłumaczenie maszynowe.
  • 100nlp-engineer
    Pomaga budować produkcyjne systemy NLP: potoki przetwarzania tekstu, modele językowe oraz zadania takie jak rozpoznawanie nazw, analiza sentymentu i tłumaczenie maszynowe.
  • 100analyzing-text-with-nlp
    Prowadzi analizę tekstu metodami NLP wtyczką nlp-text-analyzer: sentyment, ekstrakcję słów kluczowych i modelowanie tematów.
  • 100analyzing-text-with-nlp
    Prowadzi analizę tekstu metodami NLP wtyczką nlp-text-analyzer: sentyment, ekstrakcję słów kluczowych i modelowanie tematów.
  • 100alterlab-digital-humanities
    Stosuje metody obliczeniowe w humanistyce: eksplorację tekstu i NLP, lingwistykę korpusową, archiwa cyfrowe TEI, GIS, analizę sieci, stylometrię, OCR i wizualizację danych.
  • 100azure-ai-textanalytics-py
    Analizuje tekst z Azure AI Text Analytics SDK: sentyment, rozpoznawanie encji, frazy kluczowe, wykrywanie języka, PII i NLP dla ochrony zdrowia.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.