/usr/share/gocode/src/github.com/jdkato/prose/summarize/summarize_test.go is in golang-github-jdkato-prose-dev 1.1.0+git20171031.e27abfd-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | package summarize
import (
"encoding/json"
"fmt"
"path/filepath"
"testing"
"github.com/jdkato/prose/internal/util"
"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
Words float64
PolyWords float64
Characters float64
AutomatedReadability float64
ColemanLiau float64
FleschKincaid float64
GunningFog float64
SMOG float64
MeanGrade float64
StdDevGrade float64
DaleChall float64
ReadingEase float64
}
func TestSummarizePrep(t *testing.T) {
tests := make([]testCase, 0)
cases := util.ReadDataFile(filepath.Join(testdata, "summarize.json"))
util.CheckError(json.Unmarshal(cases, &tests))
for _, test := range tests {
d := NewDocument(test.Text)
assert.Equal(t, test.Sentences, d.NumSentences)
assert.Equal(t, test.Words, d.NumWords)
assert.Equal(t, test.Characters, d.NumCharacters)
}
}
func TestSummarize(t *testing.T) {
data := util.ReadDataFile(filepath.Join(testdata, "article.txt"))
d := NewDocument(string(data))
text := ""
for _, paragraph := range d.Summary(7) {
for _, s := range paragraph.Sentences {
text += (s.Text + " ")
}
text += "\n\n"
}
fmt.Print(text)
}
|