Example #1
0
 def test_one_simple_twice(self):
     text = '''
     快速的棕色狐狸跳过了懒惰的狗
     '''
     segmented = '''
     快速 的 棕色 狐狸 跳过 了 懒惰 的 狗
     '''
     client = CoreNlpWebClient(URL)
     annotator = make_annotator()
     for _ in range(2):
         result = client.api_call(text, annotator)
         self.assertEqual(join_chain_words(result), segmented.strip())
Example #2
0
    def test_two_with_zh_boundary_twice(self):
        text = '''
        快速的棕色狐狸跳过了懒惰的狗。狗却没有反应。
        '''
        segmented = '''
快速 的 棕色 狐狸 跳过 了 懒惰 的 狗 。
狗 却 没有 反应 。
        '''
        client = CoreNlpWebClient(URL)
        annotator = make_annotator(boundary_token_regex=r'[.。]|[!?!?]+')
        for _ in range(2):
            result = client.api_call(text, annotator)
            self.assertEqual(len(result['sentences']), 2)
            self.assertEqual(join_extract_words(result), segmented.strip())
Example #3
0
 def test_one_simple_no_options(self):
     text = '''
     快速的棕色狐狸跳过了懒惰的狗
     '''
     segmented = '''
     快速 的 棕色 狐狸 跳过 了 懒惰 的 狗
     '''
     result = CoreNlpWebClient(URL).api_call(text, make_annotator())
     self.assertEqual(join_chain_words(result), segmented.strip())
Example #4
0
 def test_one_has_comma_without_zh_boundary(self):
     text = '''
     快速的棕色狐狸跳过了懒惰的狗,狗却没有反应。
     '''
     segmented = '''
     快速 的 棕色 狐狸 跳过 了 懒惰 的 狗 , 狗 却 没有 反应 。
     '''
     result = CoreNlpWebClient(URL).api_call(text, make_annotator())
     self.assertEqual(join_chain_words(result), segmented.strip())
     self.assertEqual(len(result['sentences']), 1)