HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
tests.test_LangDetector.LangDetectorTest Class Reference
Inheritance diagram for tests.test_LangDetector.LangDetectorTest:
Collaboration diagram for tests.test_LangDetector.LangDetectorTest:

Public Member Functions

def testGuessLanguage (self)
 
def testLangid (self)
 
def testDetectLanguage (self)
 

Detailed Description

Definition at line 8 of file test_LangDetector.py.

Member Function Documentation

◆ testDetectLanguage()

def tests.test_LangDetector.LangDetectorTest.testDetectLanguage (   self)

Definition at line 32 of file test_LangDetector.py.

32  def testDetectLanguage(self):
33  config = ConfigParser.ConfigParser()
34  config.add_section(LangDetector.CONFIG_SECTION)
35  config.set(LangDetector.CONFIG_SECTION, LangDetector.CONFIG_DETECTOR, LangDetector.DETECTOR_DETECTLANGUAGE)
36  config.set(LangDetector.CONFIG_SECTION, LangDetector.CONFIG_DETECT_MAX_LENGTH, "1000")
37  config.set(LangDetector.CONFIG_SECTION, LangDetector.CONFIG_DETECTLANGUAGE_APIKEYS, "a31d934a633d86cfe5a401340d98fb52")
38  LangDetector.init(config)
39  self.assertEqual(LangDetector.detect(u"hello, how old are you, between options"), ["en"])
40  self.assertEqual(LangDetector.detect(u"要订餐,上饿了么,现已加入肯德基豪华午餐,学挖掘机那家强"),["zh"])
41  self.assertEqual(LangDetector.detect(u"中国の上海で行われたフィギュアスケート"), ["ja"])
42  self.assertEqual(LangDetector.detect(u"往年の人気特急に体験乗車"), ["ja"])
43  self.assertEqual(set(LangDetector.detect(u'''学挖掘机那家强,山东济南找蓝翔
44  You might end up using just a few of them, but the rest will still be there for when you need them'''))
45  ,set(["zh", "en"]))
46 
47 

◆ testGuessLanguage()

def tests.test_LangDetector.LangDetectorTest.testGuessLanguage (   self)

Definition at line 10 of file test_LangDetector.py.

10  def testGuessLanguage(self):
11  config = ConfigParser.ConfigParser()
12  config.add_section(LangDetector.CONFIG_SECTION)
13  config.set(LangDetector.CONFIG_SECTION, LangDetector.CONFIG_DETECTOR, LangDetector.DETECTOR_GUESS_LANGUAGE)
14  config.set(LangDetector.CONFIG_SECTION, LangDetector.CONFIG_DETECT_MAX_LENGTH, "1000")
15  LangDetector.init(config)
16  self.assertEqual(LangDetector.detect(u"hello, how old are you, between options"), ["en"])
17  self.assertEqual(LangDetector.detect(u"要订餐,上饿了么,现已加入肯德基豪华午餐,学挖掘机那家强"),["zh"])
18  self.assertEqual(LangDetector.detect(u"中国の上海で行われたフィギュアスケート"), ["ja"])
19  self.assertEqual(LangDetector.detect(u"の人気特急に体験乗車,戦前から戦後にかけて親しまれた京阪電鉄の特急電車"), ["ja"])
20 

◆ testLangid()

def tests.test_LangDetector.LangDetectorTest.testLangid (   self)

Definition at line 21 of file test_LangDetector.py.

21  def testLangid(self):
22  config = ConfigParser.ConfigParser()
23  config.add_section(LangDetector.CONFIG_SECTION)
24  config.set(LangDetector.CONFIG_SECTION, LangDetector.CONFIG_DETECTOR, LangDetector.DETECTOR_LANGID)
25  config.set(LangDetector.CONFIG_SECTION, LangDetector.CONFIG_DETECT_MAX_LENGTH, "1000")
26  LangDetector.init(config)
27  self.assertEqual(LangDetector.detect(u"hello, how old are you, between options"), ["en"])
28  self.assertEqual(LangDetector.detect(u"要订餐,上饿了么,现已加入肯德基豪华午餐,学挖掘机那家强"),["zh"])
29  self.assertEqual(LangDetector.detect(u"中国の上海で行われたフィギュアスケート"), ["ja"])
30  self.assertEqual(LangDetector.detect(u"の人気特急に体験乗車,戦前から戦後にかけて親しまれた京阪電鉄の特急電車"), ["ja"])
31 

The documentation for this class was generated from the following file: