예제 #1
0
func TestExtractTags(t *testing.T) {
	jiebago.SetDictionary("../dict.txt")
	for index, sentence := range test_contents {
		result := ExtractTags(sentence, 20)
		if len(result) != len(Tags[index]) {
			t.Errorf("%s = %v", sentence, result)
		}
		for i, tag := range result {
			if tag != Tags[index][i] {
				t.Error(tag)
			}
		}
	}
}
예제 #2
0
func TestCut(t *testing.T) {
	jiebago.SetDictionary("../dict.txt")
	for index, content := range test_contents {
		result := Cut(content, true)
		if len(defaultCutResult[index]) != len(result) {
			t.Error(content)
		}
		for i, _ := range result {
			if result[i] != defaultCutResult[index][i] {
				t.Error(content)
			}
		}
		result = Cut(content, false)
		if len(noHMMCutResult[index]) != len(result) {
			t.Error(content)
		}
		for i, _ := range result {
			if result[i] != noHMMCutResult[index][i] {
				t.Error(content)
			}
		}

	}
}