Skip to content

Commit

Permalink
add langcodes package
Browse files Browse the repository at this point in the history
  • Loading branch information
amydunphy authored Aug 24, 2023
1 parent 764df76 commit 7b50c89
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/model/fasttext.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import fasttext
from huggingface_hub import hf_hub_download

from langcodes import *

from lib.model.model import Model
from lib import schemas

Expand All @@ -25,7 +27,7 @@ def respond(self, docs: Union[List[schemas.Message], schemas.Message]) -> List[s
detectable_texts = [e.body.text for e in docs]
detected_langs = []
for text in detectable_texts:
detected_langs.append(self.model.predict(text)[0][0])
detected_langs.append(standardize_tag(self.model.predict(text)[0][0][9:], macro = True))

for doc, detected_lang in zip(docs, detected_langs):
doc.response = detected_lang
Expand Down

0 comments on commit 7b50c89

Please sign in to comment.