예제 #1
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_retokenize(self, conjugation):
     doc = Doc(TEXT, conjugation)
     doc.retokenize()
     assert doc.get_text() == TEXT
     text = "今日はいい天気ですね。"
     doc.retokenize(text)
     assert doc.get_text() == text
예제 #2
0
def test():
    doc = Doc("本を書きました。")

    # print surface forms of the tokens.
    surfaces = [word.surface for word in doc.words]
    print("/".join(surfaces))  # 本/を/書き/まし/た/。

    # print plain text
    print(doc.get_text())  # 本を書きました。

    # delete a word
    doc.delete(3)  # Word conjugation will be done as needed.
    print(doc.get_text())  # 本を書いた。

    # update a word
    word = doc.conjugation.tokenize("読む")
    # In addition to conjugation, transform the peripheral words as needed.
    doc.update(2, word)
    print(doc.get_text())  # 本を読んだ。
예제 #3
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_delete(self, conjugation, text, interval, expect):
     doc = Doc(text, conjugation)
     doc.delete(interval)
     assert doc.get_text() == expect
예제 #4
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_insert(self, conjugation, text, surfaces, i, expect):
     doc = Doc(text, conjugation)
     words = conjugation.tokenize(surfaces)
     doc.insert(i, words)
     assert doc.get_text() == expect
예제 #5
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_insert_a_single_word(self, conjugation):
     doc = Doc(TEXT, conjugation)
     text = "公園"
     word = conjugation.tokenize(text)[0]
     doc.insert(1, word)
     assert doc.get_text() == SURFACES[0] + text + "".join(SURFACES[1:])
예제 #6
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_conjugate_word_in_doc(self, conjugation, text, i, c_form, expect):
     doc = Doc(text, conjugation)
     doc.conjugate(i, c_form)
     assert doc.get_text() == expect
예제 #7
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_should_be_able_to_extract_text(self, conjugation, interval, expect):
     doc = Doc(TEXT, conjugation)
     assert doc.get_text(interval) == expect
예제 #8
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_should_be_able_to_initialize_with_only_a_string(self):
     doc = Doc(TEXT)
     assert doc is not None
예제 #9
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_should_be_able_to_initialize_with_string(self, conjugation):
     doc = Doc(TEXT, conjugation)
     surfaces = [word.surface for word in doc.words]
     assert surfaces == SURFACES
예제 #10
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_to_word_list(self):
     doc = Doc(TEXT)
     for dic in doc.to_word_list():
         assert type(dic) == dict
예제 #11
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_simple_view(self):
     doc = Doc(TEXT)
     assert len(doc.simple_view()) > 0
예제 #12
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_update_surfaces(self, conjugation, text, interval, surfaces, expect):
     doc = Doc(text, conjugation)
     doc.update_surfaces(interval, surfaces)
     assert doc.get_text() == expect
예제 #13
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_update(self, conjugation, text, interval, surfaces, expect):
     doc = Doc(text, conjugation)
     words = conjugation.tokenize(surfaces)
     doc.update(interval, words)
     assert doc.get_text() == expect
예제 #14
0
파일: test_doc.py 프로젝트: poyo46/jadoc
 def test_update_a_single_word(self, conjugation):
     doc = Doc(TEXT, conjugation)
     text = "毎週"
     word = conjugation.tokenize(text)[0]
     doc.update(0, word)
     assert doc.get_text() == "毎週" + "".join(SURFACES[1:])