ikawaha / kagome

Self-contained Japanese Morphological Analyzer written in pure Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add working examples

ikawaha opened this issue · comments

see. #277 (comment)

./sample/
├── dict
│   └── userdict.txt
├── example      ← ※ folder for adding working examples
└── wasm
    ├── README.md
    ├── go.mod
    ├── kagome.html
    └── main.go

I wish to refactor the sample directory as below, if I may.
If so, this change will ease adding other examples.

# Current
sample
├── _example
│   ├── db_search
│   │   └── main.go
│   ├── go.mod
│   ├── go.sum
│   ├── tokenize
│   │   └── main.go
│   └── wakati
│       └── main.go
├── dict
│   └── userdict.txt
└── wasm
    ├── README.md
    ├── go.mod
    ├── kagome.html
    └── main.go
# After refactor
_example
├── go.mod
├── go.sum
│
├── dict
│   └── userdict.txt
├── db_search
│   └── main.go
├── tokenize
│   └── main.go
├── wakati
│   └── main.go
└── wasm
    ├── README.md
    ├── kagome.html
    └── main.go

Thanks for the suggestion.

I had the current directory structure so as not to change the location of the sample user dictionary, but I thought it would be a good idea to change it.

I thought it would be better to put go.mod in each subdirectory. What do you think?

# After refactor
_example
│
├── dict (or user_dict)
│   └── userdict.txt
├── db_search
│   ├── go.mod
│   ├── go.sum
│   └── main.go
├── tokenize
│   ├── go.mod
│   ├── go.sum
│   └── main.go
├── wakati
│   ├── go.mod
│   ├── go.sum
│   └── main.go
└── wasm
    ├── go.mod
    ├── go.sum
    ├── README.md
    ├── kagome.html
    └── main.go

I agree.

Having go.mod and go.sum in every example directory is ideal. It looses coupling and easy to understand.

In that case we need to place go.work file for multi-module to avoid warnings from IDE/gopls.

# After refactor
_example
+├── go.work-├── dict (or user_dict)
+├── user_dict
+│   ├── go.mod
+│   ├── go.sum
+│   ├── main.go
 │   └── userdict.txt
 ├── db_search
 │   ├── go.mod
 │   ├── go.sum
 │   └── main.go
 ├── tokenize
 │   ├── go.mod
 │   ├── go.sum
 │   └── main.go
 ├── wakati
 │   ├── go.mod
 │   ├── go.sum
 │   └── main.go
 └── wasm
     ├── go.mod
     ├── go.sum
     ├── README.md
     ├── kagome.html
     └── main.go

This allows users to simply change their working directory and run the examples.
If this is okay with you, I would like to make a PR of it.

It seems to be good, looking forward to your pull request.

Thank you!