Exemplo n.º 1
0
def englishLanguage(sentence):
  """
  Sentence function
  Input: The sentence string
  If the sentence language is english, the function will return a non-empty string. Otherwise, an empty string will be returned.
  Output: String
  """
  my_lang = recognize_language(sentence, get_languages(), threshold = 0.85)
  if my_lang and my_lang.name == 'english':
    return sentence
  return ''
Exemplo n.º 2
0
 def test_recognize_language(self):
   english = Language('english', 'etc/english_training_data.txt')
   languages = [ english ]
   lang = recognize_language('this is a simple sentence', languages, 0.85)
   self.assertEqual(lang.name, english.name)