shixzie/nlp

Bad match ?

metal3d opened this issue · 2 comments

There is something that goes wrong when I use that example:

package main

import (
	"fmt"
	"time"

	"github.com/shixzie/nlp"
)

type Need struct {
	Name  string
	Since time.Time
}

func main() {

	nl := nlp.New()
	needSample := []string{
		"I need {Name} since {Since}",
	}

	err := nl.RegisterModel(Need{}, needSample, nlp.WithTimeFormat("2006"))
	if err != nil {
		panic(err)
	}

	err = nl.Learn()
	if err != nil {
		panic(err)
	}

	p := nl.P("Hi, I am Patrice, I need water since 2001")
	fmt.Println(p)

It only get "since" for a "Need" but doesn't match "water". If I remove "I am", or "I" from "I am", so I get "water" and "2001".

I don't have the time to check what goes wrong, if you can...

I'm looking into that, I'll let you know when it's fixed.

Release 0.1.9 is out, fixes this issue and adds some more additional tests.