コード例 #1
0
ファイル: testTextApi.py プロジェクト: nickkimer/boxer.ai
class TestClientTextApi(unittest.TestCase):
    def setUp(self):
        self.api = TextApi(testConfiguration.client)

    def testText(self):
        fpList = self.api.getRepresentationForText(
            testConfiguration.RETINA_NAME, inputText)
        fp = fpList[0]
        self.assertEqual(len(fpList), 1)
        self.assertNotEqual(fp, None)
        self.assertGreater(len(fp.positions), 500)

    def testKeywords(self):
        termList = self.api.getKeywordsForText(testConfiguration.RETINA_NAME,
                                               inputText)
        self.assertGreater(len(termList), 2)
        self.assertTrue(isinstance(termList[0], unicode))

    def testTokenize(self):
        tokens = self.api.getTokensForText(testConfiguration.RETINA_NAME,
                                           inputText)
        self.assertNotEquals(len(tokens), 0)
        self.assertTrue(isinstance(tokens[0], unicode))
        self.assertEquals(tokens[0].split(',')[0], "george")

    def testSlices(self):
        texts = self.api.getSlicesForText(testConfiguration.RETINA_NAME,
                                          inputText, True, 0, 2)
        self.assertEqual(len(texts), 2)
        self.assertEqual(texts[0].text.split(' ')[0], "George")
        self.assertGreater(len(texts[0].fingerprint.positions), 100)

    def testBulk(self):
        fingerprints = self.api.getRepresentationsForBulkText(
            testConfiguration.RETINA_NAME, bulkText, 1.0)
        self.assertEqual(len(fingerprints), 6)
        for fp in fingerprints:
            self.assertGreater(len(fp.positions), 100)

    def testLanguageDetection(self):
        self.assertEqual(
            self.api.getLanguage("I have a dream!").language, "English")
        self.assertEqual(
            self.api.getLanguage("Ich bin ein").wiki_url,
            "http://en.wikipedia.org/wiki/German_language")
        self.assertEqual(
            self.api.getLanguage("Der var så dejligt ude på landet.").iso_tag,
            "da")
コード例 #2
0
ファイル: testTextApi.py プロジェクト: aviyashchin/boxer.ai
class TestClientTextApi(unittest.TestCase):

    def setUp(self):
        self.api = TextApi(testConfiguration.client)

    def testText(self):
        fpList = self.api.getRepresentationForText(testConfiguration.RETINA_NAME, inputText)
        fp = fpList[0]
        self.assertEqual(len(fpList), 1)
        self.assertNotEqual(fp, None)
        self.assertGreater(len(fp.positions), 500)

    def testKeywords(self):
        termList = self.api.getKeywordsForText(testConfiguration.RETINA_NAME, inputText)
        self.assertGreater(len(termList), 2)
        self.assertTrue(isinstance(termList[0], unicode))

    def testTokenize(self):
        tokens = self.api.getTokensForText(testConfiguration.RETINA_NAME, inputText)
        self.assertNotEquals(len(tokens), 0)
        self.assertTrue(isinstance(tokens[0], unicode))
        self.assertEquals(tokens[0].split(',')[0], "george")
        
    def testSlices(self):
        texts = self.api.getSlicesForText(testConfiguration.RETINA_NAME, inputText, True, 0, 2)
        self.assertEqual(len(texts), 2)
        self.assertEqual(texts[0].text.split(' ')[0], "George")
        self.assertGreater(len(texts[0].fingerprint.positions), 100)

    def testBulk(self):
        fingerprints = self.api.getRepresentationsForBulkText(testConfiguration.RETINA_NAME, bulkText, 1.0)
        self.assertEqual(len(fingerprints), 6)
        for fp in fingerprints:
            self.assertGreater(len(fp.positions), 100)
        
    def testLanguageDetection(self):
        self.assertEqual(self.api.getLanguage("I have a dream!").language, "English")
        self.assertEqual(self.api.getLanguage("Ich bin ein").wiki_url, "http://en.wikipedia.org/wiki/German_language")
        self.assertEqual(self.api.getLanguage("Der var så dejligt ude på landet.").iso_tag, "da")