Пример #1
0
Файл: main.go Проект: sbl/ner
func main() {
	path := flag.String("model-path", "/usr/local/share/MITIE-models/english/ner_model.dat", "path to mitie model data")
	flag.Parse()

	ext, err := ner.NewExtractor(*path)
	if err != nil {
		log.Fatal(err)
	}
	defer ext.Free()

	log.Printf("available tags: %+v", ext.Tags())

	txt, err := ioutil.ReadFile("11231.txt")
	if err != nil {
		log.Fatal(err)
	}

	tokens := ner.Tokenize(string(txt))

	es, err := ext.Extract(tokens)
	if err != nil {
		log.Fatal(err)
	}

	for _, v := range es {
		log.Printf("%+v", v)
	}
}
Пример #2
0
func TestSmokeTest(t *testing.T) {
	ext, err := ner.NewExtractor("/usr/local/share/MITIE-models/english/ner_model.dat")
	if err != nil {
		t.Fatal(err)
	}
	defer ext.Free()

	if want, have := 4, len(ext.Tags()); want != have {
		t.Errorf("want: %+v tags, have: %+v", want, have)
	}

	tokens := ner.Tokenize(txt)

	es, err := ext.Extract(tokens)
	if err != nil {
		t.Fatal(err)
	}

	if got := es[0].Name; got != "Pegasus Airlines" {
		t.Errorf("unexpected token %s", got)
	}
}