versae commited on
Commit
07568d4
1 Parent(s): 55fbe9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -52,6 +52,8 @@ def detect_lang(
52
  tuple with the language code and probability of detection if
53
  return_proba is set to True.
54
  """
 
 
55
  if langs:
56
  langs = set(langs)
57
  else:
@@ -73,7 +75,7 @@ def identify(text):
73
 
74
  iface = gr.Interface(
75
  title="NB Nordic Language Identification",
76
- description="""This demo uses the [NB-Nordic-LID](https://huggingface.co/NbAiLab/nb-nordic-lid) model to classify a given text into one of the 12 Nordic languages supported.""",
77
  fn=identify,
78
  inputs="text",
79
  outputs="label")
 
52
  tuple with the language code and probability of detection if
53
  return_proba is set to True.
54
  """
55
+ if len(text.split()) < 4:
56
+ return [("und", 1.0)] if return_proba else "und"
57
  if langs:
58
  langs = set(langs)
59
  else:
 
75
 
76
  iface = gr.Interface(
77
  title="NB Nordic Language Identification",
78
+ description="""This demo uses the [NB-Nordic-LID](https://huggingface.co/NbAiLab/nb-nordic-lid) model to classify a given text into one of the 12 Nordic languages supported. <b>At least 3 or 4 words are needed to identify the language.</b>""",
79
  fn=identify,
80
  inputs="text",
81
  outputs="label")