diff --git a/summarize/readability_test.go b/summarize/readability_test.go index 84dc736..c482548 100644 --- a/summarize/readability_test.go +++ b/summarize/readability_test.go @@ -2,7 +2,6 @@ package summarize import ( "encoding/json" - "fmt" "path/filepath" "testing" @@ -10,12 +9,6 @@ import ( "github.com/stretchr/testify/assert" ) -var testdata = filepath.Join("..", "testdata") - -func check(expected, observed float64) bool { - return fmt.Sprintf("%0.2f", expected) == fmt.Sprintf("%0.2f", observed) -} - func TestReadability(t *testing.T) { tests := make([]testCase, 0) cases := util.ReadDataFile(filepath.Join(testdata, "summarize.json")) diff --git a/summarize/summarize_test.go b/summarize/summarize_test.go index d642168..8b98448 100644 --- a/summarize/summarize_test.go +++ b/summarize/summarize_test.go @@ -10,6 +10,12 @@ import ( "github.com/stretchr/testify/assert" ) +var testdata = filepath.Join("..", "testdata") + +func check(expected, observed float64) bool { + return fmt.Sprintf("%0.2f", expected) == fmt.Sprintf("%0.2f", observed) +} + type testCase struct { Text string Sentences float64 diff --git a/summarize/syllables_test.go b/summarize/syllables_test.go index 8a8b75b..18061c6 100644 --- a/summarize/syllables_test.go +++ b/summarize/syllables_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/jdkato/prose/internal/util" - "github.com/jdkato/syllables" "github.com/montanaflynn/stats" "github.com/stretchr/testify/assert" ) @@ -87,7 +86,7 @@ func BenchmarkSyllablesIn(b *testing.B) { for n := 0; n < b.N; n++ { for word := range tests { - syllables.In(word) + Syllables(word) } } } diff --git a/tokenize/regexp_test.go b/tokenize/regexp_test.go index 43a2fc6..81b1546 100644 --- a/tokenize/regexp_test.go +++ b/tokenize/regexp_test.go @@ -1,34 +1,11 @@ package tokenize import ( - "encoding/json" - "path/filepath" "testing" - "github.com/jdkato/prose/internal/util" "github.com/stretchr/testify/assert" ) -func getWordData(file string) ([]string, [][]string) { - in := util.ReadDataFile(filepath.Join(testdata, "treebank_sents.json")) - out := util.ReadDataFile(filepath.Join(testdata, file)) - - input := []string{} - output := [][]string{} - - util.CheckError(json.Unmarshal(in, &input)) - util.CheckError(json.Unmarshal(out, &output)) - - return input, output -} - -func getWordBenchData() []string { - in := util.ReadDataFile(filepath.Join(testdata, "treebank_sents.json")) - input := []string{} - util.CheckError(json.Unmarshal(in, &input)) - return input -} - func TestWordPunctTokenizer(t *testing.T) { input, output := getWordData("word_punct.json") wordTokenizer := NewWordPunctTokenizer() diff --git a/tokenize/tokenize_test.go b/tokenize/tokenize_test.go index 9e2869b..2afbf35 100644 --- a/tokenize/tokenize_test.go +++ b/tokenize/tokenize_test.go @@ -1,12 +1,37 @@ package tokenize import ( + "encoding/json" "fmt" + "path/filepath" "testing" + "github.com/jdkato/prose/internal/util" "github.com/stretchr/testify/assert" ) +var testdata = filepath.Join("..", "testdata") + +func getWordData(file string) ([]string, [][]string) { + in := util.ReadDataFile(filepath.Join(testdata, "treebank_sents.json")) + out := util.ReadDataFile(filepath.Join(testdata, file)) + + input := []string{} + output := [][]string{} + + util.CheckError(json.Unmarshal(in, &input)) + util.CheckError(json.Unmarshal(out, &output)) + + return input, output +} + +func getWordBenchData() []string { + in := util.ReadDataFile(filepath.Join(testdata, "treebank_sents.json")) + input := []string{} + util.CheckError(json.Unmarshal(in, &input)) + return input +} + func ExampleNewWordBoundaryTokenizer() { t := NewWordBoundaryTokenizer() fmt.Println(t.Tokenize("They'll save and invest more.")) diff --git a/tokenize/treebank_test.go b/tokenize/treebank_test.go index 42c3b6e..3055851 100644 --- a/tokenize/treebank_test.go +++ b/tokenize/treebank_test.go @@ -1,14 +1,11 @@ package tokenize import ( - "path/filepath" "testing" "github.com/stretchr/testify/assert" ) -var testdata = filepath.Join("..", "testdata") - func TestTreebankWordTokenizer(t *testing.T) { input, output := getWordData("treebank_words.json") word := NewTreebankWordTokenizer() diff --git a/transform/title_test.go b/transform/title_test.go index 8ae20d0..d748399 100644 --- a/transform/title_test.go +++ b/transform/title_test.go @@ -9,8 +9,6 @@ import ( "github.com/stretchr/testify/assert" ) -var testdata = filepath.Join("..", "testdata") - type testCase struct { Input string Expect string diff --git a/transform/transform_test.go b/transform/transform_test.go index 139fc44..09b08f1 100644 --- a/transform/transform_test.go +++ b/transform/transform_test.go @@ -1,6 +1,11 @@ package transform -import "fmt" +import ( + "fmt" + "path/filepath" +) + +var testdata = filepath.Join("..", "testdata") func ExampleNewTitleConverter() { tc := NewTitleConverter(APStyle)