Skip to content
This repository has been archived by the owner on Aug 22, 2020. It is now read-only.

Commit

Permalink
Cosme (#22)
Browse files Browse the repository at this point in the history
Cosme
  • Loading branch information
ikawaha committed Nov 21, 2019
2 parents 42fd558 + c70ff28 commit a00ab7d
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 89 deletions.
2 changes: 1 addition & 1 deletion cmd/_dictool/ipa/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func command(opt *option) error {
return err
}
if saveIpaDic(d, opt.output, opt.archive); err != nil {
return fmt.Errorf("build error: %v\n", err)
return fmt.Errorf("build error: %v", err)
}
return nil
}
Expand Down
26 changes: 13 additions & 13 deletions cmd/kagome/server/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ type TokenizeDemoHandler struct {

func (h *TokenizeDemoHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
type record struct {
Surface string
Pos string
Baseform string
Reading string
Pronounciation string
Surface string
Pos string
Baseform string
Reading string
Pronunciation string
}
sen := r.FormValue("s")
mode := r.FormValue("r")
Expand Down Expand Up @@ -280,27 +280,27 @@ func (h *TokenizeDemoHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
m.Pos = strings.Join(fs[0:5], ",")
m.Baseform = fs[10]
m.Reading = fs[6]
m.Pronounciation = fs[9]
m.Pronunciation = fs[9]
case 9:
m.Pos = strings.Join(fs[0:5], ",")
m.Baseform = fs[6]
m.Reading = fs[7]
m.Pronounciation = fs[8]
m.Pronunciation = fs[8]
case 7:
m.Pos = strings.Join(fs[0:5], ",")
m.Baseform = fs[6]
m.Reading = "*"
m.Pronounciation = "*"
m.Pronunciation = "*"
case 6: // unidic
m.Pos = strings.Join(fs[0:5], ",")
m.Baseform = "*"
m.Reading = "*"
m.Pronounciation = "*"
m.Pronunciation = "*"
case 3:
m.Pos = fs[0]
m.Baseform = fs[1]
m.Reading = fs[2]
m.Pronounciation = "*"
m.Pronunciation = "*"

}
records = append(records, m)
Expand Down Expand Up @@ -393,7 +393,7 @@ var graphHTML = `
<th>Part-of-Speech</th>
<th>Base Form</th>
<th>Reading</th>
<th>Pronounciation</th>
<th>Pronunciation</th>
</tr></thread>
<tbody id="morphs">
{{range .Tokens}}
Expand All @@ -402,7 +402,7 @@ var graphHTML = `
<td>{{.Pos}}</td>
<td>{{.Baseform}}</td>
<td>{{.Reading}}</td>
<td>{{.Pronounciation}}</td>
<td>{{.Pronunciation}}</td>
</tr>
{{end}}
</tbody>
Expand Down Expand Up @@ -528,7 +528,7 @@ var demoHTML = `
<th>Part-of-Speech</th>
<th>Base Form</th>
<th>Reading</th>
<th>Pronounciation</th>
<th>Pronunciation</th>
</tr></thread>
<tbody id="morphs">
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions internal/da/da_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestDaBuildAndSearch03(t *testing.T) {
}
for _, k := range keywords {
if _, ok := d.Find(k); !ok {
t.Errorf("does not detected: %v\n", k)
t.Errorf("does not detected: %v", k)
}
}

Expand Down Expand Up @@ -248,7 +248,7 @@ func TestDaBuildWithIDsAndPrefixSearch03(t *testing.T) {
ids = ids[0 : len(ids)-1]
d, err := BuildWithIDs(keywords, ids)
if err != nil {
t.Errorf("unexpected error: %v\n", err)
t.Errorf("unexpected error: %v", err)
}
for key, expectedID := range h {
if id, ok := d.Find(key); !ok || id != expectedID {
Expand Down
2 changes: 1 addition & 1 deletion internal/dic/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestConnectionTableAt(t *testing.T) {
for j := 0; j < col; j++ {
expected := int16(i*col + j)
if r := ct.At(i, j); r != expected {
t.Errorf("got %v, expected %v\n", r, expected)
t.Errorf("got %v, expected %v", r, expected)
}
}
}
Expand Down
26 changes: 13 additions & 13 deletions internal/dic/data/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions internal/dic/data/bindata00.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package data

import(
import (
"os"
"time"
)
Expand All @@ -24,4 +24,3 @@ func dicIpaChardefDic() (*asset, error) {
a := &asset{bytes: bytes, info: info}
return a, nil
}

3 changes: 1 addition & 2 deletions internal/dic/data/bindata01.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package data

import(
import (
"os"
"time"
)
Expand All @@ -24,4 +24,3 @@ func dicIpaConnectionDic() (*asset, error) {
a := &asset{bytes: bytes, info: info}
return a, nil
}

3 changes: 1 addition & 2 deletions internal/dic/data/bindata02.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package data

import(
import (
"os"
"time"
)
Expand All @@ -24,4 +24,3 @@ func dicIpaContentDic() (*asset, error) {
a := &asset{bytes: bytes, info: info}
return a, nil
}

3 changes: 1 addition & 2 deletions internal/dic/data/bindata03.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package data

import(
import (
"os"
"time"
)
Expand All @@ -24,4 +24,3 @@ func dicIpaIndexDic() (*asset, error) {
a := &asset{bytes: bytes, info: info}
return a, nil
}

3 changes: 1 addition & 2 deletions internal/dic/data/bindata04.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package data

import(
import (
"os"
"time"
)
Expand All @@ -24,4 +24,3 @@ func dicIpaMorphDic() (*asset, error) {
a := &asset{bytes: bytes, info: info}
return a, nil
}

3 changes: 1 addition & 2 deletions internal/dic/data/bindata05.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package data

import(
import (
"os"
"time"
)
Expand All @@ -24,4 +24,3 @@ func dicIpaPosDic() (*asset, error) {
a := &asset{bytes: bytes, info: info}
return a, nil
}

3 changes: 1 addition & 2 deletions internal/dic/data/bindata06.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package data

import(
import (
"os"
"time"
)
Expand All @@ -24,4 +24,3 @@ func dicIpaUnkDic() (*asset, error) {
a := &asset{bytes: bytes, info: info}
return a, nil
}

26 changes: 13 additions & 13 deletions internal/dic/dic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

var testDic = "../../_sample/ipa.dic"

const(
const (
IPADICEntrySize = 392126 + 1
)

Expand All @@ -32,13 +32,13 @@ func TestDicLoad(t *testing.T) {
}
const expected = IPADICEntrySize
if c := len(dic.Morphs); c != expected {
t.Errorf("morphs got %v, expected %v\n", c, expected)
t.Errorf("morphs got %v, expected %v", c, expected)
}
if c := len(dic.POSTable.POSs); c != expected {
t.Errorf("POSs got %v, expected %v\n", c, expected)
t.Errorf("POSs got %v, expected %v", c, expected)
}
if c := len(dic.Contents); c != expected {
t.Errorf("contents got %v, expected %v\n", c, expected)
t.Errorf("contents got %v, expected %v", c, expected)
}
}

Expand All @@ -57,7 +57,7 @@ func TestDicIndex01(t *testing.T) {
for _, cr := range testSet {
ids := dic.Index.Search(cr.input)
if !reflect.DeepEqual(ids, cr.ids) {
t.Errorf("input %v, got %v, expected %v\n", cr.input, ids, cr.ids)
t.Errorf("input %v, got %v, expected %v", cr.input, ids, cr.ids)
}
}
}
Expand Down Expand Up @@ -94,13 +94,13 @@ func TestDicIndex02(t *testing.T) {
for _, cr := range testSet {
lens, ids := dic.Index.CommonPrefixSearch(cr.input)
if !reflect.DeepEqual(lens, cr.lens) {
t.Errorf("input %v, got lens %v,\n expected %v\n", cr.input, lens, cr.lens)
t.Errorf("input %v, got lens %v,\n expected %v", cr.input, lens, cr.lens)
}
if len(ids) != len(cr.ids) {
t.Errorf("input %v, got ids len %v, expected len %v\n", cr.input, len(ids), len(cr.ids))
t.Errorf("input %v, got ids len %v, expected len %v", cr.input, len(ids), len(cr.ids))
}
if !reflect.DeepEqual(ids, cr.ids) {
t.Errorf("input %v, got ids %v,\n expected %v\n", cr.input, ids, cr.ids)
t.Errorf("input %v, got ids %v,\n expected %v", cr.input, ids, cr.ids)
}
}

Expand All @@ -125,7 +125,7 @@ func TestDicCharClass01(t *testing.T) {
"CYRILLIC", //10
}
if !reflect.DeepEqual(dic.CharClass, expected) {
t.Errorf("got %v, expected %v\n", dic.CharClass, expected)
t.Errorf("got %v, expected %v", dic.CharClass, expected)
}
}

Expand Down Expand Up @@ -304,11 +304,11 @@ func TestDicCharCategory01(t *testing.T) {
for _, cr := range testSet {
category := dic.CharCategory[cr.input]
if category != cr.category {
t.Errorf("input %04X, got %v, expected %v\n", cr.input, category, cr.category)
t.Errorf("input %04X, got %v, expected %v", cr.input, category, cr.category)
}
category = dic.CharacterCategory(rune(cr.input))
if category != cr.category {
t.Errorf("input %04X, got %v, expected %v\n", cr.input, category, cr.category)
t.Errorf("input %04X, got %v, expected %v", cr.input, category, cr.category)
}
}
}
Expand Down Expand Up @@ -362,7 +362,7 @@ func TestDicInvokeList01(t *testing.T) {
}
for _, cr := range crs {
if iv := dic.InvokeList[cr.class]; iv != cr.invoke {
t.Errorf("input %v: got %v, expected %v\n", cr.class, iv, cr.invoke)
t.Errorf("input %v: got %v, expected %v", cr.class, iv, cr.invoke)
}
}
}
Expand Down Expand Up @@ -403,7 +403,7 @@ func TestDicGroupList01(t *testing.T) {
}
for _, cr := range crs {
if iv := dic.GroupList[cr.class]; iv != cr.invoke {
t.Errorf("input %v: got %v, expected %v\n", cr.class, iv, cr.invoke)
t.Errorf("input %v: got %v, expected %v", cr.class, iv, cr.invoke)
}
}
}
4 changes: 2 additions & 2 deletions internal/dic/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestCommonPrefixSearch(t *testing.T) {
}
expectdOutputs := [][]int{{0}, {1, 2, 3, 4}, {5, 6}}
if !reflect.DeepEqual(outputs, expectdOutputs) {
t.Errorf("common prefix search outputs, got %v, expected %v\n", outputs, expectdOutputs)
t.Errorf("common prefix search outputs, got %v, expected %v", outputs, expectdOutputs)
}
}

Expand Down Expand Up @@ -130,7 +130,7 @@ func TestIndexTableReadAndWrite(t *testing.T) {
var b bytes.Buffer
n, err := org.WriteTo(&b)
if err != nil {
t.Errorf("unexpected error: %v\n", err)
t.Errorf("unexpected error: %v", err)
}
if n != int64(b.Len()) {
t.Errorf("write len: got %v, expected %v", n, b.Len())
Expand Down
6 changes: 3 additions & 3 deletions internal/dic/pos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestPOSTableAdd(t *testing.T) {
for i, d := range data {
pos := m.Add(d.In)
if !reflect.DeepEqual(pos, d.Exp) {
t.Errorf("%d, input %v, got %+v, expected %+v\n", i, d.In, pos, d.Exp)
t.Errorf("%d, input %v, got %+v, expected %+v", i, d.In, pos, d.Exp)
}
}
}
Expand All @@ -60,7 +60,7 @@ func TestPOSString(t *testing.T) {
got = append(got, table.NameList[id])
}
if !reflect.DeepEqual(got, want) {
t.Errorf("%d, input %v, got %+v, expected %+v\n", i, want, got, want)
t.Errorf("%d, input %v, got %+v, expected %+v", i, want, got, want)
}
}
}
Expand All @@ -84,7 +84,7 @@ func TestPOSTableReadAndWrite(t *testing.T) {
var b bytes.Buffer
n, err := org.WriteTo(&b)
if err != nil {
t.Errorf("unexpected error: %v\n", err)
t.Errorf("unexpected error: %v", err)
}
if n != int64(b.Len()) {
t.Errorf("write len: got %v, expected %v", n, b.Len())
Expand Down

0 comments on commit a00ab7d

Please sign in to comment.