Spaces:
Running
Running
Add nltk punct
Browse files- README.md +1 -1
- extract.py +3 -3
- inference.py +1 -0
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
title: Emotion Detection
|
3 |
-
emoji:
|
4 |
colorFrom: blue
|
5 |
colorTo: yellow
|
6 |
sdk: docker
|
|
|
1 |
---
|
2 |
title: Emotion Detection
|
3 |
+
emoji: πβ‘οΈπ
|
4 |
colorFrom: blue
|
5 |
colorTo: yellow
|
6 |
sdk: docker
|
extract.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
|
2 |
-
|
3 |
|
4 |
from nltk.cluster.util import cosine_distance
|
5 |
from nltk.tokenize import sent_tokenize, word_tokenize
|
@@ -54,7 +54,7 @@ def get_pagerank(importance, top_k):
|
|
54 |
|
55 |
|
56 |
def summarize_text(text: str) -> str:
|
57 |
-
return text
|
58 |
sentences = sent_tokenize(text)[:2000]
|
59 |
top_k = max(20, int(len(sentences) ** .5))
|
60 |
mat = build_matrix(sentences)
|
|
|
1 |
+
import nltk
|
2 |
+
nltk.download('punkt')
|
3 |
|
4 |
from nltk.cluster.util import cosine_distance
|
5 |
from nltk.tokenize import sent_tokenize, word_tokenize
|
|
|
54 |
|
55 |
|
56 |
def summarize_text(text: str) -> str:
|
57 |
+
# return text
|
58 |
sentences = sent_tokenize(text)[:2000]
|
59 |
top_k = max(20, int(len(sentences) ** .5))
|
60 |
mat = build_matrix(sentences)
|
inference.py
CHANGED
@@ -27,6 +27,7 @@ def predict_emotions(text: str) -> str:
|
|
27 |
return '\n'.join(f"{k}: {v}%" for k, v in sorted(emotions_list.items(),
|
28 |
key=lambda x: -x[1]))
|
29 |
|
|
|
30 |
path_gram = './models/mbert-gram/'
|
31 |
model_gram = BertForSequenceClassification.from_pretrained(path_gram)
|
32 |
tokenizer_gram = AutoTokenizer.from_pretrained(path_gram)
|
|
|
27 |
return '\n'.join(f"{k}: {v}%" for k, v in sorted(emotions_list.items(),
|
28 |
key=lambda x: -x[1]))
|
29 |
|
30 |
+
# path_gram = 'Djacon/mbert-gram'
|
31 |
path_gram = './models/mbert-gram/'
|
32 |
model_gram = BertForSequenceClassification.from_pretrained(path_gram)
|
33 |
tokenizer_gram = AutoTokenizer.from_pretrained(path_gram)
|