diff --git a/annotate-samples.sh b/annotate-samples.sh index 98333c2..2206b54 100755 --- a/annotate-samples.sh +++ b/annotate-samples.sh @@ -1,5 +1,5 @@ #!/bin/bash -NUM_SAMPLE=789 +NUM_SAMPLE=1148 SKIP_SAMPLES=(0) diff --git a/main_test.go b/main_test.go index 8cf2c45..04d6acf 100644 --- a/main_test.go +++ b/main_test.go @@ -17,6 +17,7 @@ type TestData struct { HoujinExecutiveNames []string `yaml:"HoujinExecutiveNames"` HoujinRepresentativeNames []string `yaml:"HoujinRepresentativeNames"` HoujinCapital string `yaml:"HoujinCapital"` + HoujinStock string `yaml:"HoujinStock"` HoujinCreatedAt string `yaml:"HoujinCreatedAt"` HoujinBankruptedAt string `yaml:"HoujinBankruptedAt"` HoujinDissolvedAt string `yaml:"HoujinDissolvedAt"` @@ -24,7 +25,7 @@ type TestData struct { } func TestToukiboParser(t *testing.T) { - testCount := 1147 + testCount := 1148 for i := 1; i <= testCount; i++ { t.Run(fmt.Sprintf("test%d", i), func(t *testing.T) { @@ -119,6 +120,10 @@ func TestToukiboParser(t *testing.T) { t.Fatalf("capital is not match,\nwant : %s,\ngot : %d,", td.HoujinCapital, h.GetHoujinCapital()) } + if fmt.Sprint(h.GetHoujinStock()) != td.HoujinStock { + t.Fatalf("stock is not match,\nwant : %s,\ngot : %d,", td.HoujinStock, h.GetHoujinStock()) + } + if h.GetHoujinCreatedAt() != td.HoujinCreatedAt { t.Fatalf("created_at is not match,\nwant : %s,\ngot : %s,", td.HoujinCreatedAt, h.GetHoujinCreatedAt()) } diff --git a/toukibo/parse_body.go b/toukibo/parse_body.go index b9011fc..dae0e75 100644 --- a/toukibo/parse_body.go +++ b/toukibo/parse_body.go @@ -358,7 +358,7 @@ func (h *HoujinBody) ConsumeHoujinCapital(s string) bool { } func (h *HoujinBody) ConsumeHoujinStock(s string) bool { - return strings.Contains(s, "発行済株式の総数") + return strings.HasPrefix(s, " ┃発行済株式の総数") } func (h *HoujinBody) ConsumeHoujinToukiRecord(s string) bool { diff --git a/toukibo/stock_converter.go b/toukibo/stock_converter.go index 3b1cfde..288220c 100644 --- a/toukibo/stock_converter.go +++ b/toukibo/stock_converter.go @@ -1,10 +1,15 @@ package toukibo -import "strings" +import ( + "strings" +) func StockToNumber(stock string) int { // 発行済株式の総数5万株 → 50000 stock = strings.Replace(stock, "発行済株式の総数", "", -1) + if strings.HasPrefix(stock, "普通株式") { // sample1082用のハック + stock = strings.Replace(stock, "普通株式", "", -1) + } stock = ZenkakuToHankaku(stock) sums := 0 @@ -27,7 +32,9 @@ func StockToNumber(stock string) int { cur = 0 case '株': sums += cur - cur = 0 + return sums + // 発行済株式の総数4万8249株各種の株式の数普通株式   3万249株A種優先株式 1万株B種優先株式 8000株 + // のようなパターンでは最初の株でReturnさせる } } return sums diff --git a/toukibo/stock_converter_test.go b/toukibo/stock_converter_test.go index d7db612..40271ef 100644 --- a/toukibo/stock_converter_test.go +++ b/toukibo/stock_converter_test.go @@ -15,6 +15,11 @@ func TestStockToNumber(t *testing.T) { input: "発行済株式の総数5万株", expected: 50000, }, + { + // sample1082 + input: "発行済株式の総数普通株式     5138株A種優先株式   1250株B種優先株式   3250株", + expected: 5138, + }, } for _, tc := range testCases { diff --git a/toukibo/yen_converter_test.go b/toukibo/yen_converter_test.go index 8371888..17c0146 100644 --- a/toukibo/yen_converter_test.go +++ b/toukibo/yen_converter_test.go @@ -48,7 +48,7 @@ func TestYenToNumber(t *testing.T) { expected: 1234000000000000, }, { - input: "1234兆円1234億5678万9012円", + input: "1234兆1234億5678万9012円", expected: 1234123456789012, }, {