コード例 #1
0
 def test_parse_line_toomany_split(self):
     builder = DictionaryBuilder(logger=self.logger)
     with self.assertRaises(ValueError) as cm:
         builder.parse_line(
             '京都,6,6,5293,京都,名詞,固有名詞,地名,一般,*,*,キョウト,京都,*,B,0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0/0/1/2/3/4/5/6/7/8/9/0,*,*'
             .split(','))
     self.assertEqual('too many units', cm.exception.args[0])
コード例 #2
0
 def test_parse_line_toolong_headword(self):
     builder = DictionaryBuilder(logger=self.logger)
     x = 'a' * (32767 + 1)  # max value of short in Java + 1
     x = x + ',6,6,5293,京都,名詞,固有名詞,地名,一般,*,*,キョウト,京都,*,A,*,*,*'
     with self.assertRaises(ValueError) as cm:
         builder.parse_line(x.split(','))
     self.assertEqual('string is too long', cm.exception.args[0])
コード例 #3
0
 def test_parse_line_empty_headword(self):
     builder = DictionaryBuilder(logger=self.logger)
     with self.assertRaises(ValueError) as cm:
         builder.parse_line(
             ',6,6,5293,京都,名詞,固有名詞,地名,一般,*,*,キョウト,京都,*,A,*,*,*,*'.split(
                 ','))
     self.assertEqual('headword is empty', cm.exception.args[0])
コード例 #4
0
    def test_parseline(self):
        builder = DictionaryBuilder(logger=self.logger)
        entry = builder.parse_line(
            '京都,6,6,5293,京都,名詞,固有名詞,地名,一般,*,*,キョウト,京都,*,A,*,*,*'.split(','))
        self.assertEqual('京都', entry.headword)
        self.assertEqual([6, 6, 5293], entry.parameters)
        self.assertEqual(0, entry.wordinfo.pos_id)
        self.assertEqual('*', entry.aunit_split_string)
        self.assertEqual('*', entry.bunit_split_string)

        entry = builder.parse_line(
            '京都,-1,-1,0,京都,名詞,固有名詞,地名,一般,*,*,キョウト,京都,*,A,*,*,*'.split(','))
        self.assertIsNone(entry.headword)
        self.assertEqual(0, entry.wordinfo.pos_id)
コード例 #5
0
 def test_parse_line_same_readingform(self):
     builder = DictionaryBuilder(logger=self.logger)
     entry = builder.parse_line(
         '〒,6,6,5293,〒,名詞,普通名詞,一般,*,*,*,〒,〒,*,A,*,*,*'.split(','))
     self.assertEqual('〒', entry.wordinfo.reading_form)
コード例 #6
0
 def test_parse_line_invalid_columns(self):
     builder = DictionaryBuilder(logger=self.logger)
     with self.assertRaises(ValueError) as cm:
         builder.parse_line(
             '京都,6,6,5293,京都,名詞,固有名詞,地名,一般,*,*,キョウト,京都,*,A,*,*'.split(','))
     self.assertEqual('invalid format', cm.exception.args[0])