Exemplo n.º 1
0
 def testProperName(self):
     self.assertEquals(flatten(englishdict.reading(u"珍・奥斯汀")),
                       u"Zhen1 · Ao4 si1 ting1")
     self.assertEquals(self.flatmeanings(englishdict, u"珍・奥斯汀"), [
         u"Jane Austen (1775-1817), English novelist",
         u"also written 简・奥斯汀 - Jian3 · Ao4 si1 ting1"
     ])
Exemplo n.º 2
0
 def testFrenchDictionary(self):
     self.assertEquals(flatten(frenchdict.reading(u"評論")), "ping2 lun4")
     self.assertEquals(flatten(frenchdict.reading(u"评论")), "ping2 lun4")
     self.assertEquals(self.flatmeanings(frenchdict, u"评论"),
                       [u"commentaire (n.v.) (n)"])
Exemplo n.º 3
0
 def testGermanDictionary(self):
     self.assertEquals(flatten(germandict.reading(u"请")), "qing3")
     self.assertEquals(flatten(germandict.reading(u"請")), "qing3")
     self.assertEquals(
         self.flatmeanings(germandict, u"請"),
         ["Bitte ! (u.E.) (Int)", "bitten, einladen (u.E.) (V)"])
Exemplo n.º 4
0
 def testNumbersWherePinyinLengthDoesntMatchCharacters(self):
     self.assertEquals(flatten(englishdict.tonedchars(u"1000000000")),
                       u"1000000000")
     # Invalidated by removal of numbers from the dictionary:
     # self.assertEquals(flatten(englishdict.reading(u"1000000000")), u"yi1 shi2 yi4")
     self.assertEquals(self.flatmeanings(englishdict, u"1000000000"), None)
Exemplo n.º 5
0
 def testTonedTokensWithoutTone(self):
     toned = englishdict.tonedchars(u"U盤")
     self.assertEquals(flatten(toned), u"U盤")
     self.assertEquals(toned[0][1].toneinfo, ToneInfo(written=2))
Exemplo n.º 6
0
 def testTonedCharactersPreservesWhitespace(self):
     self.assertEquals(flatten(englishdict.tonedchars(u"\t一个")), u"\t一个")
Exemplo n.º 7
0
 def testTonedTokens(self):
     toned = englishdict.tonedchars(u"一个")
     self.assertEquals(flatten(toned), u"一个")
     self.assertEquals(toned[0][0].toneinfo, ToneInfo(written=1))
     self.assertEquals(toned[0][1].toneinfo, ToneInfo(written=4))
Exemplo n.º 8
0
 def testFallsBackOnCEDICTForMissingPinyinAndForeignLanguage(self):
     self.assertEquals(flatten(frenchdict.reading(u"数量积")),
                       "shu4 liang4 ji1")
     self.assertEquals(self.flatmeanings(frenchdict, u"数量积"), None)
Exemplo n.º 9
0
 def testMissingLanguage(self):
     dict = dictionaries('foobar')
     self.assertEquals(flatten(dict.reading(u"个")), "ge4")
     self.assertEquals(self.flatmeanings(dict, u"个"), None)
Exemplo n.º 10
0
 def testNumbersWherePinyinLengthDoesntMatchCharacters(self):
     self.assertEquals(flatten(englishdict.tonedchars(u"1000000000")), u"1000000000")
     # Invalidated by removal of numbers from the dictionary:
     # self.assertEquals(flatten(englishdict.reading(u"1000000000")), u"yi1 shi2 yi4")
     self.assertEquals(self.flatmeanings(englishdict, u"1000000000"), None)
Exemplo n.º 11
0
 def testTonedTokenNumbers(self):
     # Although it kind of makes sense to return the arabic numbers with tone colors, users don't expect it :-)
     toned = englishdict.tonedchars(u"1994")
     self.assertEquals(flatten(toned), u"1994")
     self.assertFalse(any([hasattr(token, "tone") for token in toned]))
Exemplo n.º 12
0
 def testTonedTokensWithoutTone(self):
     toned = englishdict.tonedchars(u"U盤")
     self.assertEquals(flatten(toned), u"U盤")
     self.assertEquals(toned[0][1].toneinfo, ToneInfo(written=2))
Exemplo n.º 13
0
 def testTonedCharactersPreservesWhitespace(self):
     self.assertEquals(flatten(englishdict.tonedchars(u"\t一个")), u"\t一个")
Exemplo n.º 14
0
 def reading(self, what):
     return flatten(englishdict.reading(what))
Exemplo n.º 15
0
 def flattenall(self, tokens):
     if tokens:
         return [flatten(token) for token in tokens]
     else:
         return None
Exemplo n.º 16
0
 def testGermanDictionary(self):
     self.assertEquals(flatten(germandict.reading(u"请")), "qing3")
     self.assertEquals(flatten(germandict.reading(u"請")), "qing3")
     self.assertEquals(self.flatmeanings(germandict, u"請"), ["Bitte ! (u.E.) (Int)", "bitten, einladen (u.E.) (V)"])
Exemplo n.º 17
0
 def testTonedTokens(self):
     toned = englishdict.tonedchars(u"一个")
     self.assertEquals(flatten(toned), u"一个")
     self.assertEquals(toned[0][0].toneinfo, ToneInfo(written=1))
     self.assertEquals(toned[0][1].toneinfo, ToneInfo(written=4))
Exemplo n.º 18
0
 def testEnglishDictionary(self):
     self.assertEquals(flatten(englishdict.reading(u"鼓聲")), "gu3 sheng1")
     self.assertEquals(flatten(englishdict.reading(u"鼓声")), "gu3 sheng1")
     self.assertEquals(self.flatmeanings(englishdict, u"鼓聲"), ["sound of a drum", "drumbeat"])
Exemplo n.º 19
0
 def testErhuaSpacedInReadingForKnownWords(self):
     self.assertEquals(flatten(englishdict.reading(u"两头儿")), "liang3 tou2r")
Exemplo n.º 20
0
 def testFrenchDictionary(self):
     self.assertEquals(flatten(frenchdict.reading(u"評論")), "ping2 lun4")
     self.assertEquals(flatten(frenchdict.reading(u"评论")), "ping2 lun4")
     self.assertEquals(self.flatmeanings(frenchdict, u"评论"), [u"commentaire (n.v.) (n)"])
Exemplo n.º 21
0
 def flattenall(self, tokens):
     if tokens:
         return [flatten(token) for token in tokens]
     else:
         return None
Exemplo n.º 22
0
 def testWordsWhosePrefixIsNotInDictionary(self):
     self.assertEquals(flatten(germandict.reading(u"生日")), "sheng1 ri4")
     self.assertEquals(self.flatmeanings(germandict, u"生日"), [u"Geburtstag (S)"])
Exemplo n.º 23
0
 def reading(self, what):
     return flatten(englishdict.reading(what))
Exemplo n.º 24
0
 def testProperName(self):
     self.assertEquals(flatten(englishdict.reading(u"珍・奥斯汀")), u"Zhen1 · Ao4 si1 ting1")
     self.assertEquals(self.flatmeanings(englishdict, u"珍・奥斯汀"), [u"Jane Austen (1775-1817), English novelist", u"also written 简・奥斯汀 - Jian3 · Ao4 si1 ting1"])
Exemplo n.º 25
0
 def testTonedTokenNumbers(self):
     # Although it kind of makes sense to return the arabic numbers with tone colors, users don't expect it :-)
     toned = englishdict.tonedchars(u"1994")
     self.assertEquals(flatten(toned), u"1994")
     self.assertFalse(any([hasattr(token, "tone") for token in toned]))
Exemplo n.º 26
0
 def testShortPinyin(self):
     self.assertEquals(flatten(englishdict.reading(u"股指")), "gu3 zhi3")
     self.assertEquals(self.flatmeanings(englishdict, u"股指"), [u"stock market index", u"share price index", u"abbr. for 股票指数 - gu3 piao4 zhi3 shu4"])
Exemplo n.º 27
0
 def testMissingLanguage(self):
     dict = dictionaries('foobar')
     self.assertEquals(flatten(dict.reading(u"个")), "ge4")
     self.assertEquals(self.flatmeanings(dict, u"个"), None)
Exemplo n.º 28
0
 def testPinyinFromUnihan(self):
     self.assertEquals(flatten(englishdict.reading(u"諓")), "jian4")
     self.assertEquals(self.flatmeanings(englishdict, u"諓"), None)
Exemplo n.º 29
0
 def testEnglishDictionary(self):
     self.assertEquals(flatten(englishdict.reading(u"鼓聲")), "gu3 sheng1")
     self.assertEquals(flatten(englishdict.reading(u"鼓声")), "gu3 sheng1")
     self.assertEquals(self.flatmeanings(englishdict, u"鼓聲"),
                       ["sound of a drum", "drumbeat"])
Exemplo n.º 30
0
 def testFallsBackOnCEDICTForMissingPinyinAndForeignLanguage(self):
     self.assertEquals(flatten(frenchdict.reading(u"数量积")), "shu4 liang4 ji1")
     self.assertEquals(self.flatmeanings(frenchdict, u"数量积"), None)
Exemplo n.º 31
0
 def testWordsWhosePrefixIsNotInDictionary(self):
     self.assertEquals(flatten(germandict.reading(u"生日")), "sheng1 ri4")
     self.assertEquals(self.flatmeanings(germandict, u"生日"),
                       [u"Geburtstag (S)"])
Exemplo n.º 32
0
 def testPinyinFromUnihan(self):
     self.assertEquals(flatten(englishdict.reading(u"諓")), "jian4")
     self.assertEquals(self.flatmeanings(englishdict, u"諓"), None)
Exemplo n.º 33
0
 def testShortPinyin(self):
     self.assertEquals(flatten(englishdict.reading(u"股指")), "gu3 zhi3")
     self.assertEquals(self.flatmeanings(englishdict, u"股指"), [
         u"stock market index", u"share price index",
         u"abbr. for 股票指数 - gu3 piao4 zhi3 shu4"
     ])
Exemplo n.º 34
0
 def testErhuaSpacedInReadingForKnownWords(self):
     self.assertEquals(flatten(englishdict.reading(u"两头儿")), "liang3 tou2r")