TiberiuCristianLeon commited on
Commit
ea07cc3
·
verified ·
1 Parent(s): d179167

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -41,6 +41,11 @@ class Detect():
41
  from fast_langdetect import detect
42
  result = detect(text=self.text, model="auto", k=1)[0]
43
  return [result.get('lang'), abs(round(number=result.get('score') * 100, ndigits=2))]
 
 
 
 
 
44
  def fasttext(self) -> list[str, float]:
45
  import fasttext
46
  from huggingface_hub import hf_hub_download
 
41
  from fast_langdetect import detect
42
  result = detect(text=self.text, model="auto", k=1)[0]
43
  return [result.get('lang'), abs(round(number=result.get('score') * 100, ndigits=2))]
44
+ def pycld2(self) -> list[str, float]:
45
+ import pycld2 as cld2
46
+ # available_languages = cld2.LANGUAGES
47
+ isReliable, textBytesFound, details = cld2.detect(self.text, returnVectors=False, bestEffort=True)
48
+ return [details[0][1], round(details[0][2], 2)]
49
  def fasttext(self) -> list[str, float]:
50
  import fasttext
51
  from huggingface_hub import hf_hub_download