Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -208,7 +208,7 @@ def process_text(text, selected_model):
|
|
| 208 |
# Create comparison table data
|
| 209 |
comparison_data = []
|
| 210 |
for word in words:
|
| 211 |
-
stemmed =
|
| 212 |
lemmatized = safe_lemmatize(word)
|
| 213 |
comparison_data.append({
|
| 214 |
'Original': word,
|
|
@@ -220,8 +220,8 @@ def process_text(text, selected_model):
|
|
| 220 |
df = pd.DataFrame(comparison_data)
|
| 221 |
|
| 222 |
# Stemming results
|
| 223 |
-
stemmed_words = [
|
| 224 |
-
stemming_info = f"**Stemming Results (
|
| 225 |
stemming_info += f"- Original words: {words}\n"
|
| 226 |
stemming_info += f"- Stemmed words: {stemmed_words}\n\n"
|
| 227 |
|
|
@@ -283,7 +283,7 @@ def generate_analysis(text, tokens, other_tokens, words, stemmed_words, lemmatiz
|
|
| 283 |
analysis += f"- **tiktoken**: {running_tiktoken_decoded}\n"
|
| 284 |
|
| 285 |
# Stemming and Lemmatization analysis
|
| 286 |
-
running_stemmed =
|
| 287 |
running_lemmatized = safe_lemmatize("running")
|
| 288 |
lemma_method = "spaCy" if SPACY_AVAILABLE else "WordNet"
|
| 289 |
|
|
@@ -327,12 +327,12 @@ Try entering a sentence with "running" to see the specific analysis.
|
|
| 327 |
- **Disadvantages**: Model-dependent, may create non-interpretable tokens
|
| 328 |
- **Use case**: Input preprocessing for transformer models
|
| 329 |
|
| 330 |
-
### ✂️ **Stemming (
|
| 331 |
- **Best for**: Fast text preprocessing, search engines, basic analysis
|
| 332 |
-
- **Advantages**: Very fast, simple implementation,
|
| 333 |
-
- **Disadvantages**:
|
| 334 |
- **Use case**: Information retrieval, basic text normalization
|
| 335 |
-
- **
|
| 336 |
|
| 337 |
### 🎯 **Lemmatization (WordNet + spaCy)**
|
| 338 |
- **Best for**: Accurate linguistic analysis, semantic preservation
|
|
|
|
| 208 |
# Create comparison table data
|
| 209 |
comparison_data = []
|
| 210 |
for word in words:
|
| 211 |
+
stemmed = stemmer.stem(word)
|
| 212 |
lemmatized = safe_lemmatize(word)
|
| 213 |
comparison_data.append({
|
| 214 |
'Original': word,
|
|
|
|
| 220 |
df = pd.DataFrame(comparison_data)
|
| 221 |
|
| 222 |
# Stemming results
|
| 223 |
+
stemmed_words = [stemmer.stem(word) for word in words]
|
| 224 |
+
stemming_info = f"**Stemming Results (Porter Stemmer):**\n"
|
| 225 |
stemming_info += f"- Original words: {words}\n"
|
| 226 |
stemming_info += f"- Stemmed words: {stemmed_words}\n\n"
|
| 227 |
|
|
|
|
| 283 |
analysis += f"- **tiktoken**: {running_tiktoken_decoded}\n"
|
| 284 |
|
| 285 |
# Stemming and Lemmatization analysis
|
| 286 |
+
running_stemmed = stemmer.stem("running")
|
| 287 |
running_lemmatized = safe_lemmatize("running")
|
| 288 |
lemma_method = "spaCy" if SPACY_AVAILABLE else "WordNet"
|
| 289 |
|
|
|
|
| 327 |
- **Disadvantages**: Model-dependent, may create non-interpretable tokens
|
| 328 |
- **Use case**: Input preprocessing for transformer models
|
| 329 |
|
| 330 |
+
### ✂️ **Stemming (Porter Stemmer)**
|
| 331 |
- **Best for**: Fast text preprocessing, search engines, basic analysis
|
| 332 |
+
- **Advantages**: Very fast, simple implementation, language-independent approach
|
| 333 |
+
- **Disadvantages**: Can create non-words (like "runn", "quickli"), loses semantic precision
|
| 334 |
- **Use case**: Information retrieval, basic text normalization
|
| 335 |
+
- **Note**: Results like "quickli" and "runn" demonstrate stemming limitations
|
| 336 |
|
| 337 |
### 🎯 **Lemmatization (WordNet + spaCy)**
|
| 338 |
- **Best for**: Accurate linguistic analysis, semantic preservation
|