diff --git a/repo/dict_phonemizer_repo.go b/repo/dict_phonemizer_repo.go index 55ba6e4..5d523d8 100644 --- a/repo/dict_phonemizer_repo.go +++ b/repo/dict_phonemizer_repo.go @@ -11,7 +11,6 @@ import ( import . "github.com/martinarisk/di/dependency_injection" type IDictPhonemizerRepository interface { - PhonemizeWord(lang, word string) (ret map[uint64]string) PhonemizeWordCJK(lang, word string) (ret map[uint64][2]string) } type DictPhonemizerRepository struct { @@ -31,7 +30,7 @@ func (r *DictPhonemizerRepository) LoadLanguage(lang string) { return } - var files = []string{"clean.tsv", "missing.tsv"} + var files = []string{"missing.tsv"} for _, file := range files { clean := log.Error1((*r.getter).GetDict(lang, file)) @@ -68,23 +67,16 @@ func (r *DictPhonemizerRepository) LoadLanguage(lang string) { } } -func (r *DictPhonemizerRepository) PhonemizeWord(lang, word string) (ret map[uint64]string) { + +func (r *DictPhonemizerRepository) PhonemizeWordCJK(lang, word string) (ret map[uint64][2]string) { r.LoadLanguage(lang) - ret = (*r.lang_words)[lang][word] + found := (*r.lang_words)[lang][word] - if len(ret) == 0 { + if len(found) == 0 { return nil } - return -} - -func (r *DictPhonemizerRepository) PhonemizeWordCJK(lang, word string) (ret map[uint64][2]string) { - found := r.PhonemizeWord(lang, word) - if found == nil { - return nil - } ret = make(map[uint64][2]string) for k, v := range found { ret[k] = [2]string{v, word} diff --git a/repo/hashtron_phonemizer_repo.go b/repo/hashtron_phonemizer_repo.go index 1363a44..188394d 100644 --- a/repo/hashtron_phonemizer_repo.go +++ b/repo/hashtron_phonemizer_repo.go @@ -18,7 +18,6 @@ import ( import . "github.com/martinarisk/di/dependency_injection" type IHashtronPhonemizerRepository interface { - PhonemizeWord(lang, word string) (ret map[uint64]string) PhonemizeWordCJK(lang, word string) (ret map[uint64][2]string) CleanWord(lang, word string) string CheckWord(lang, word, ipa string) bool @@ -414,13 +413,6 @@ outer: } return true } -func (r *HashtronPhonemizerRepository) PhonemizeWord(lang, word string) (ret map[uint64]string) { - ret = make(map[uint64]string) - for k, v := range r.PhonemizeWordCJK(lang, word) { - ret[k] = v[0] - } - return -} func (r *HashtronPhonemizerRepository) PhonemizeWordCJK(lang, word string) (ret map[uint64][2]string) { r.LoadLanguage(lang) diff --git a/repo/services/parts_of_speech_selector_service.go b/repo/services/parts_of_speech_selector_service.go index 2fa97cd..dea16ff 100644 --- a/repo/services/parts_of_speech_selector_service.go +++ b/repo/services/parts_of_speech_selector_service.go @@ -4,23 +4,12 @@ import "strings" import . "github.com/martinarisk/di/dependency_injection" type IPartsOfSpeechSelectorService interface { - Select(string, []map[uint64]string) []string SelectCJK(string, []map[uint64][2]string) [2][]string } type PartsOfSpeechSelectorService struct { } -func (p *PartsOfSpeechSelectorService) Select(lang string, sentence []map[uint64]string) (ret []string) { - for _, words := range sentence { - for _, word := range words { - ret = append(ret, word) - break - } - } - return -} - func (p *PartsOfSpeechSelectorService) SelectCJK(lang string, sentence []map[uint64][2]string) (ret [2][]string) { for _, words := range sentence { for _, word := range words { diff --git a/repo/services/phonemize_word_service.go b/repo/services/phonemize_word_service.go index a7ea54d..293dc58 100644 --- a/repo/services/phonemize_word_service.go +++ b/repo/services/phonemize_word_service.go @@ -6,7 +6,6 @@ import ( import . "github.com/martinarisk/di/dependency_injection" type IPhonemizeWordService interface { - PhonemizeWord(string, string) (string, map[uint64]string) PhonemizeWordCJK(string, string) (string, map[uint64][2]string) CleanWord(lang, word string) string } @@ -18,15 +17,6 @@ type PhonemizeWordService struct { cach *repo.IWordCachingRepository } -func (p *PhonemizeWordService) PhonemizeWord(lang, word string) (wrd string, ret map[uint64]string) { - wrd, r := p.PhonemizeWordCJK(lang, word) - ret = make(map[uint64]string) - for k, v := range r { - ret[k] = v[0] - } - return -} - func (p *PhonemizeWordService) CleanWord(lang, word string) string { return (*p.ai).CleanWord(lang, word) } @@ -48,15 +38,6 @@ func (p *PhonemizeWordService) PhonemizeWordCJK(lang, word string) (wrd string, ret = (*p.cach).LoadWordCJK(hsh) if ret == nil || len(ret) == 0 { ret = (*p.ai).PhonemizeWordCJK(lang, wrd) - /* - if ret != nil { - for k, ipa := range ret { - if !(*p.ai).CheckWord(lang, wrd, ipa[0]) { - delete(ret, k) - } - } - } - */ (*p.cach).StoreWordCJK(ret, hsh) } } diff --git a/repo/word_caching_repo.go b/repo/word_caching_repo.go index 5586d94..b33172a 100644 --- a/repo/word_caching_repo.go +++ b/repo/word_caching_repo.go @@ -12,8 +12,6 @@ import . "github.com/martinarisk/di/dependency_injection" type IWordCachingRepository interface { HashWord(lang, word string) uint64 - StoreWord(value map[uint64]string, hash uint64) - LoadWord(hash uint64) (word map[uint64]string) StoreWordCJK(value map[uint64][2]string, hash uint64) LoadWordCJK(hash uint64) (word map[uint64][2]string) } @@ -42,13 +40,7 @@ func (r WordCachingRepository) LoadWordCJK(hash uint64) (word map[uint64][2]stri } return word } -func (r WordCachingRepository) LoadWord(hash uint64) (word map[uint64]string) { - word = make(map[uint64]string) - for k, v := range r.LoadWordCJK(hash) { - word[k] = v[0] - } - return -} + func (r WordCachingRepository) StoreWordCJK(value map[uint64][2]string, hash uint64) { var buf, data []byte @@ -72,13 +64,7 @@ func (r WordCachingRepository) StoreWordCJK(value map[uint64][2]string, hash uin r.cache.Set(hash, val) } -func (r WordCachingRepository) StoreWord(value map[uint64]string, hash uint64) { - word := make(map[uint64][2]string) - for k, v := range value { - word[k] = [2]string{v, ""} - } - r.StoreWordCJK(word, hash) -} + func (r WordCachingRepository) HashWord(lang, word string) uint64 {