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

Fix performance #15

Merged
merged 2 commits into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func insertPunctuations(message string, config PunctuationConfig) string {
rand.Seed(time.Now().UnixNano())
result := ""
// おじさんの文句の形態素解析に使われるなんて可哀そうなライブラリだな
t := tokenizer.New()
t := tokenizer.NewWithDic(tokenizer.SysDicIPASimple())
tokens := t.Tokenize(message)
for _, token := range tokens {
if token.Class == tokenizer.DUMMY {
Expand Down
6 changes: 6 additions & 0 deletions generator/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ func TestInsertPunctuations3(t *testing.T) {
t.Errorf("handler returned unexpected body: got %v want %v", actual, expected)
}
}

func BenchmarkPunctuation(b *testing.B) {
for i:=0; i < b.N; i++ {
insertPunctuations("どうしちゃったのかな", PunctuationConfig{[]string{"助動詞", "助詞"}, 100})
}
}