Spaces:
Runtime error
Runtime error
Update Sejarah.py
Browse files- Sejarah.py +8 -9
Sejarah.py
CHANGED
@@ -51,8 +51,6 @@ class Sejarah:
|
|
51 |
|
52 |
def language_converter(self, content, lang, method):
|
53 |
|
54 |
-
content = content.lower()
|
55 |
-
|
56 |
if lang == "en":
|
57 |
if method == "question":
|
58 |
tokenized_text = self.en_id_tokenizer.prepare_seq2seq_batch([content], return_tensors='pt')
|
@@ -65,7 +63,13 @@ class Sejarah:
|
|
65 |
content = self.id_en_tokenizer.batch_decode(translation, skip_special_tokens=True)[0]
|
66 |
|
67 |
return content
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
def interface(self, question):
|
70 |
language = self.detect_language(question)
|
71 |
|
@@ -82,9 +86,4 @@ class Sejarah:
|
|
82 |
answer = self.language_converter(result['answers'][0].answer, language, "answer")
|
83 |
context = self.language_converter(result['answers'][0].context, language, "answer")
|
84 |
|
85 |
-
return answer, context
|
86 |
-
|
87 |
-
|
88 |
-
def detect_language(self, content):
|
89 |
-
lang = langid.classify(content)
|
90 |
-
return lang[0]
|
|
|
51 |
|
52 |
def language_converter(self, content, lang, method):
|
53 |
|
|
|
|
|
54 |
if lang == "en":
|
55 |
if method == "question":
|
56 |
tokenized_text = self.en_id_tokenizer.prepare_seq2seq_batch([content], return_tensors='pt')
|
|
|
63 |
content = self.id_en_tokenizer.batch_decode(translation, skip_special_tokens=True)[0]
|
64 |
|
65 |
return content
|
66 |
+
|
67 |
+
|
68 |
+
def detect_language(self, content):
|
69 |
+
lang = langid.classify(content)
|
70 |
+
return lang[0]
|
71 |
+
|
72 |
+
|
73 |
def interface(self, question):
|
74 |
language = self.detect_language(question)
|
75 |
|
|
|
86 |
answer = self.language_converter(result['answers'][0].answer, language, "answer")
|
87 |
context = self.language_converter(result['answers'][0].context, language, "answer")
|
88 |
|
89 |
+
return answer, context
|
|
|
|
|
|
|
|
|
|