Exemple #1
0
func testPinyin() {
	pinyin, err := pinyin.NewPinyin("../../../resources/wordpinyins.new.txt")

	if err != nil {
		log.Println(err)
		return
	}

	log.Println(pinyin.Get("和"))
	log.Println(pinyin.Get("了"))
	log.Println(pinyin.Get("我"))
	//err = pinyin.Dump("../../../resources/dump.txt");
	if err != nil {
		log.Println(err)
	}
	return
}
func NewSuggestion(pinyinFile string, suggestionItemFile string) (suggestion *Suggestion, err error) {
	suggestion = &Suggestion{}
	suggestion.pinyin, err = pinyin.NewPinyin(pinyinFile)

	if err != nil {
		return
	}

	items, err := load(suggestionItemFile)
	if err != nil {
		return
	}

	suggestion.buildOrigSuggestionMap(items)
	suggestion.buildPinyinSuggestionMap(items)
	suggestion.buildAbbrSuggestionMap(items)

	return
}