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

Refactor example directory #322

Merged
merged 7 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: move user dict sample to testdata for testing
  • Loading branch information
KEINOS committed Apr 13, 2024
commit 4aaed1d8bd0e2073ec346e7cf3273b7d9fa247d0
6 changes: 3 additions & 3 deletions cmd/lattice/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestOptionCheck(t *testing.T) {
{
name: "all options and input",
args: []string{
"-udict", "../../sample/dict/userdict.txt",
"-udict", "../../testdata/userdict.txt",
"-dict", "ipa",
"-mode", "search",
"-output", "/dev/null",
Expand Down Expand Up @@ -83,7 +83,7 @@ func TestRun(t *testing.T) {
{
name: "all options and input",
args: []string{
"-udict", "../../sample/dict/userdict.txt",
"-udict", "../../testdata/userdict.txt",
"-dict", "ipa",
"-mode", "search",
"-output", "/dev/null",
Expand Down Expand Up @@ -139,7 +139,7 @@ func Test_command(t *testing.T) {
{
name: "verbose",
args: &option{
udict: "../../sample/dict/userdict.txt",
udict: "../../testdata/userdict.txt",
dict: "uni",
mode: "extended",
output: "",
Expand Down
6 changes: 3 additions & 3 deletions cmd/server/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestOptionCheck(t *testing.T) {
{
name: "all args",
args: []string{
"-userdict", "../../sample/dict/userdict.txt",
"-userdict", "../../testdata/userdict.txt",
"-http", ":8888",
"-dict", "ipa",
},
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestRun(t *testing.T) {
{
name: "normal operation w/ options",
args: []string{
"-userdict", "../../sample/dict/userdict.txt",
"-userdict", "../../testdata/userdict.txt",
"-http", ":0",
"-dict", "ipa",
},
Expand Down Expand Up @@ -127,7 +127,7 @@ func Test_command(t *testing.T) {
opt: &option{
http: ":0",
dict: "ipa",
udict: "../../sample/dict/userdict.txt",
udict: "../../testdata/userdict.txt",
flagSet: flag.NewFlagSet(CommandName, flag.ContinueOnError),
},
wantErr: false,
Expand Down
2 changes: 1 addition & 1 deletion cmd/tokenize/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func TestRun(t *testing.T) {
{
name: "normal operation w/ options",
args: []string{
"-udict", "../../sample/dict/userdict.txt",
"-udict", "../../testdata/userdict.txt",
"-file", "../../testdata/nekodearu.txt",
"-split",
},
Expand Down
15 changes: 15 additions & 0 deletions testdata/userdict.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
##
## This file should use UTF-8 encoding
##
## User dictionary format:
## <text>,<text>,<reading>,<part-of-speech>
## or
## <text>,<token1> <token2> ... <tokenn>,<reading1> <reading2> ... <readingn>,<part-of-speech>
##

# Custom reading for former sumo wrestler Asashoryu
朝青龍,朝青龍,アサショウリュウ,カスタム人名

# Custom segmentation for long entries
日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞
関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,テスト名詞
2 changes: 1 addition & 1 deletion tokenizer/lattice/lattice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func Test_LatticeBuild(t *testing.T) {
}

func Test_LatticeBuildWithUserDict(t *testing.T) {
const udictPath = "../../sample/dict/userdict.txt"
const udictPath = "../../testdata/userdict.txt"

udic, err := dict.NewUserDict(udictPath)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tokenizer/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

const (
userDictSample = "../sample/dict/userdict.txt"
userDictSample = "../testdata/userdict.txt"
)

func Test_TokenClassString(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tokenizer/tokenizer_option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const (
testUserDictPath = "../sample/dict/userdict.txt"
testUserDictPath = "../testdata/userdict.txt"
)

func TestTokenizer_Analyze_Nop(t *testing.T) {
Expand Down