Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,18 +36,20 @@ def sentiment_analysis(sentence, model_name):
|
|
| 36 |
"CCCC/RoBERTa_English_FinancialNews_tuned":"roberta",
|
| 37 |
}
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
|
| 49 |
testdata = []
|
| 50 |
-
for i,sentence in enumerate(
|
| 51 |
testdata.append(InputExample(guid=i,text_a=sentence,label=0))
|
| 52 |
|
| 53 |
plm, tokenizer, model_config, WrapperClass = load_plm(type_dic[model_name], model_name)
|
|
|
|
| 36 |
"CCCC/RoBERTa_English_FinancialNews_tuned":"roberta",
|
| 37 |
}
|
| 38 |
|
| 39 |
+
if 'Chinese' in modelname:
|
| 40 |
+
tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-zh-en")
|
| 41 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Helsinki-NLP/opus-mt-zh-en")
|
| 42 |
+
|
| 43 |
+
translated_tokens = model.generate(
|
| 44 |
+
**tokenizer(sentences, return_tensors="pt", padding=True)
|
| 45 |
+
)
|
| 46 |
+
sentences = []
|
| 47 |
+
for t in translated_tokens:
|
| 48 |
+
sentences.append(tokenizer.decode(t, skip_special_tokens=True))
|
| 49 |
+
|
| 50 |
|
| 51 |
testdata = []
|
| 52 |
+
for i,sentence in enumerate(sentences):
|
| 53 |
testdata.append(InputExample(guid=i,text_a=sentence,label=0))
|
| 54 |
|
| 55 |
plm, tokenizer, model_config, WrapperClass = load_plm(type_dic[model_name], model_name)
|