Skip to content

Commit

Permalink
drop old internal api's before release
Browse files Browse the repository at this point in the history
  • Loading branch information
neurlang authored and Your Name committed Oct 12, 2024
1 parent 24d68cc commit 50c43e6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 67 deletions.
18 changes: 5 additions & 13 deletions repo/dict_phonemizer_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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))
Expand Down Expand Up @@ -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}
Expand Down
8 changes: 0 additions & 8 deletions repo/hashtron_phonemizer_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 0 additions & 11 deletions repo/services/parts_of_speech_selector_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 0 additions & 19 deletions repo/services/phonemize_word_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}
Expand All @@ -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)
}
}
Expand Down
18 changes: 2 additions & 16 deletions repo/word_caching_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -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 {

Expand Down

0 comments on commit 50c43e6

Please sign in to comment.