示例#1
0
 def test_add(self):
     profile = LangProfile('en')
     profile.add('a')
     self.assertEqual(profile.freq.get('a'), 1)
     profile.add('a')
     self.assertEqual(profile.freq.get('a'), 2)
     profile.omit_less_freq()
示例#2
0
 def test_add_illegally2(self):
     profile = LangProfile('en')
     profile.add('a')
     profile.add(
         ''
     )  # Illegal (string's length of parameter must be between 1 and 3) but ignore
     profile.add('abcd')  # as well
     self.assertEqual(profile.freq.get('a'), 1)
     self.assertIsNone(profile.freq.get(''))  # ignored
     self.assertIsNone(profile.freq.get('abcd'))  # ignored
示例#3
0
 def test_add(self):
     profile = LangProfile('en')
     profile.add('a')
     self.assertEqual(profile.freq.get('a'), 1)
     profile.add('a')
     self.assertEqual(profile.freq.get('a'), 2)
     profile.omit_less_freq()
示例#4
0
 def test_add_illegally2(self):
     profile = LangProfile('en')
     profile.add('a')
     profile.add('')  # Illegal (string's length of parameter must be between 1 and 3) but ignore
     profile.add('abcd')  # as well
     self.assertEqual(profile.freq.get('a'), 1)
     self.assertIsNone(profile.freq.get(''))  # ignored
     self.assertIsNone(profile.freq.get('abcd'))  # ignored
示例#5
0
    def test_omit_less_freq(self):
        profile = LangProfile('en')
        grams = six.u(
            'a b c \u3042 \u3044 \u3046 \u3048 \u304a \u304b \u304c \u304d \u304e \u304f'
        ).split()
        for i in xrange(5):
            for g in grams:
                profile.add(g)
        profile.add(six.u('\u3050'))

        self.assertEqual(profile.freq.get('a'), 5)
        self.assertEqual(profile.freq.get(six.u('\u3042')), 5)
        self.assertEqual(profile.freq.get(six.u('\u3050')), 1)
        profile.omit_less_freq()
        self.assertIsNone(profile.freq.get('a'))  # omitted
        self.assertEqual(profile.freq.get(six.u('\u3042')), 5)
        self.assertIsNone(profile.freq.get(six.u('\u3050')))  # omitted
示例#6
0
    def test_omit_less_freq(self):
        profile = LangProfile('en')
        grams = six.u('a b c \u3042 \u3044 \u3046 \u3048 \u304a \u304b \u304c \u304d \u304e \u304f').split()
        for i in xrange(5):
            for g in grams:
                profile.add(g)
        profile.add(six.u('\u3050'))

        self.assertEqual(profile.freq.get('a'), 5)
        self.assertEqual(profile.freq.get(six.u('\u3042')), 5)
        self.assertEqual(profile.freq.get(six.u('\u3050')), 1)
        profile.omit_less_freq()
        self.assertIsNone(profile.freq.get('a'))  # omitted
        self.assertEqual(profile.freq.get(six.u('\u3042')), 5)
        self.assertIsNone(profile.freq.get(six.u('\u3050')))  # omitted
示例#7
0
 def test_omit_less_freq_illegally(self):
     profile = LangProfile()
     profile.omit_less_freq()  # ignore
示例#8
0
 def test_add_illegally1(self):
     profile = LangProfile()
     profile.add('a')  # ignore
     self.assertIsNone(profile.freq.get('a'))  # ignored
示例#9
0
 def test_lang_profile(self):
     profile = LangProfile()
     self.assertIsNone(profile.name)
示例#10
0
 def test_omit_less_freq_illegally(self):
     profile = LangProfile()
     profile.omit_less_freq()  # ignore
示例#11
0
 def test_add_illegally1(self):
     profile = LangProfile()
     profile.add('a')  # ignore
     self.assertIsNone(profile.freq.get('a'))  # ignored
示例#12
0
 def test_lang_profile_string_int(self):
     profile = LangProfile('en')
     self.assertEqual(profile.name, 'en')
示例#13
0
 def test_lang_profile(self):
     profile = LangProfile()
     self.assertTrue(profile.name is None)
示例#14
0
    def setUp(self):
        self.factory = DetectorFactory()

        profile_en = LangProfile('en')
        for w in self.TRAINING_EN.split():
            profile_en.add(w)
        self.factory.add_profile(profile_en, 0, 3)

        profile_fr = LangProfile('fr')
        for w in self.TRAINING_FR.split():
            profile_fr.add(w)
        self.factory.add_profile(profile_fr, 1, 3)

        profile_ja = LangProfile('ja')
        for w in self.TRAINING_JA.split():
            profile_ja.add(w)
        self.factory.add_profile(profile_ja, 2, 3)