| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package main
- import (
- "fmt"
- "time"
- "git.wecise.com/wecise/common/nlp/when"
- "git.wecise.com/wecise/common/nlp/when/rules/cn"
- "git.wecise.com/wecise/common/nlp/when/rules/en"
- "git.wecise.com/wecise/odbserver/odb/test"
- "gitee.com/wecisecode/util/logger"
- )
- func main() {
- option := &Option{Cache: CacheAll, Keyspace: "matrix", DisableInitialHostLookup: true}
- g, err := test.NewG(option)
- if err != nil {
- logger.Error(err.Error())
- } else {
- defer g.Close()
- }
- logger.SetConsole(true)
- logger.Info("iiiiiiiiiiiiiiiiiiiiii")
- w := when.New(nil)
- w.Add(en.All...)
- w.Add(cn.All...)
- logger.Info("jjjjjjjjjjjjjjjjjjjjjj")
- //text := "drop me a line in next wednesday at 2:25 p.m"
- text := "admin昨天上传的文档"
- r, err := w.Parse(text, time.Now())
- logger.Info("kkkkkkkkkkkkkkkkkkkkkk")
- if err != nil {
- logger.Info("errr ===> ", err)
- }
- if r == nil {
- logger.Info("r is nil !!!!!")
- }
- logger.Info("HHHHHHHHHHHHHHHHHHHHHHH", r.Context)
- /*fmt.Println(
- "the time",
- r.Time.String(),
- "mentioned in",
- text[r.Index:r.Index+len(r.Text)],
- "context",
- )*/
- if r.Context.Year != nil {
- fmt.Println("year ==>", *r.Context.Year)
- }
- if r.Context.Month != nil {
- fmt.Println("Month ==>", *r.Context.Month)
- }
- if r.Context.Day != nil {
- fmt.Println("Day ==>", *r.Context.Day)
- }
- if r.Context.Hour != nil {
- fmt.Println("Hour ==>", *r.Context.Hour)
- }
- if r.Context.Minute != nil {
- fmt.Println("Minute ==>", *r.Context.Minute)
- }
- if r.Context.Second != nil {
- fmt.Println("Second ==>", *r.Context.Second)
- }
- fmt.Println("Duration ==>", r.Context.Duration)
- }
|