Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Name field in dict.Dict struct for dictionary name #49

Closed
KEINOS opened this issue May 24, 2024 · 2 comments
Closed

feat: Name field in dict.Dict struct for dictionary name #49

KEINOS opened this issue May 24, 2024 · 2 comments

Comments

@KEINOS
Copy link
Contributor

KEINOS commented May 24, 2024

I want to add Name field for a dictionary name as an ID.

type Dict struct {
	Morphs       Morphs
	POSTable     POSTable
	ContentsMeta ContentsMeta
	Contents     Contents
	Connection   ConnectionTable
	Index        IndexTable
	CharClass    CharClass
	CharCategory CharCategory
	InvokeList   InvokeList
	GroupList    GroupList
	UnkDict      UnkDict
+	Name         string
}

Since POS info varies between dictionaries, enabling to retrieve dictionary name is useful for changing the behavior depending on the dictionary.

// import (
//   "github.com/ikawaha/kagome-dict/dict"
//   "github.com/ikawaha/kagome-dict/ipa"
//   "github.com/ikawaha/kagome/v2/tokenizer"
// )

sysDict := ipa.Dict()
fmt.Println(sysDict.Name)

tkn, _ := tokenizer.New(sysDict, tokenizer.OmitBosEos())
fmt.Println(tkn.DictName())

// Output:
// IPA
// IPA

If it sounds OK, I would like to PR this.

@ikawaha
Copy link
Owner

ikawaha commented May 24, 2024

It seems very good! 👍 Thank you!

KEINOS added a commit to KEINOS/Fork_kagome-dict that referenced this issue May 25, 2024
KEINOS added a commit to KEINOS/Fork_kagome-dict that referenced this issue May 25, 2024
ikawaha pushed a commit that referenced this issue May 28, 2024
* fix: ioutil.ReadAll --> io.ReadAll

As of go 1.16 "io/ioutil" package is deprecated. Replace to the stable one.

* chore: add tests for feat #49

* chore: edit test err msg for readablity

* feat: #49 add name field to identify dictionary

* fix: adapt feat 49 changes to IPA dict

* fix: adapt feat 49 changes to Uni dict

* fix: comment msg to describe it right
@ikawaha
Copy link
Owner

ikawaha commented Jun 15, 2024

@KEINOS

Hi,

Your contribution has been invaluable, and I'm pleased to inform you that we have successfully merged your PR and included it in our latest release.

If you have any more ideas or suggestions, please do not hesitate to share them. We look forward to your continued contributions and collaboration.

Thank you once again for your excellent work!

@ikawaha ikawaha closed this as completed Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants