shinyke / time-nlp Goto Github PK
View Code? Open in Web Editor NEW中文语句中的时间语义识别。即通过分析中文语句,识别出话语中提到的时间。
中文语句中的时间语义识别。即通过分析中文语句,识别出话语中提到的时间。
Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 3
[鐨刔+
^
at java.util.regex.Pattern.error(Pattern.java:1955)
at java.util.regex.Pattern.clazz(Pattern.java:2548)
at java.util.regex.Pattern.sequence(Pattern.java:2063)
at java.util.regex.Pattern.expr(Pattern.java:1996)
at java.util.regex.Pattern.compile(Pattern.java:1696)
at java.util.regex.Pattern.(Pattern.java:1351)
at java.util.regex.Pattern.compile(Pattern.java:1028)
at com.time.nlp.stringPreHandlingModule.delKeyword(stringPreHandlingModule.java:23)
作者的这个包还不错,
不过用的过程中还是发现一些问题
1.如 “晚上10点开会”,当前时间为下午4点,会解出 第二天的晚上10点。按我理解应该解出当天的10点。因为还没有到嘛
2.“帮我看一下星期五的天气”,这种场景会匹配“下星期五”而不是“星期五”,导至不精确。
String path = TimeNormalizer.class.getResource("").getPath();
String classPath = path.substring(0, path.indexOf("/com/time"));
System.out.println(classPath+"/TimeExp.m");
TimeNormalizer normalizer = new TimeNormalizer(classPath+"/TimeExp.m");
如果将项目打成jar包加入到工程中,这种加载方式无法工作,因为jar中的资源是无法用FileInputStream读取的
类似于"一个小时后"这样的语句不能识别.
如果发现时间解析有bug,那就来这里试一下另一个工具吧
JioNLP
import time
import jionlp as jio
res = jio.parse_time('今年9月', time_base={'year': 2021})
res = jio.parse_time('零三年元宵节晚上8点半', time_base=time.time())
res = jio.parse_time('一万个小时')
res = jio.parse_time('100天之后', time.time())
res = jio.parse_time('每周五下午4点', time.time())
print(res)
# {'type': 'time_span', 'definition': 'accurate', 'time': ['2021-09-01 00:00:00', '2021-09-30 23:59:59']}
# {'type': 'time_point', 'definition': 'accurate', 'time': ['2003-02-15 20:30:00', '2003-02-15 20:30:59']}
# {'type': 'time_delta', 'definition': 'accurate', 'time': {'hour': 10000.0}}
# {'type': 'time_span', 'definition': 'blur', 'time': ['2021-10-22 00:00:00', 'inf']}
# {'type': 'time_period', 'definition': 'accurate', 'time': {'delta': {'day': 7},
# 'point': {'time': ['2021-07-16 16:00:00', '2021-07-16 16:59:59'], 'string': '周五下午4点'}}}
你好,请问代码中的rpointer为什么会有自增然后自减的操作?TimeNormalizer类的第220+行
java初学者求回复
下礼拜一无法解析出来
——3个BUG,
第一个
时间识别,isPreferFuture=ture时
下午7点到8点,识别到第二天的7点到8点
问题在于TimeUnit.java中的下面语句:
if(curTime < _tp.tunit[checkTimeIndex]){
return;
}
curTime =16点, _tp.tunit[checkTimeIndex] =7
这个7不对,应该是12+7 =19
这是一个bug
第二个
今天下午7到8点
由于【7】后面没加【点】所以识别为今天下午的默认时间【15:00】
第三个
今天6月28日,周三,
【周五下午7点到8点】,识别为【7月7日】
normalizer.parse("收录时间:2016-05-24TimeNLP 详细介绍");// 抽取时间
TimeUnit[] unit = normalizer.getTimeUnit();
System.out.println("收录时间:2016-05-24TimeNLP 详细介绍");
System.out.println(DateUtil.formatDateDefault(unit[0].getTime()) + "-" + unit[0].getIsAllDayTime());
运行结果是:
2017-05-03 10:17:15
收录时间:2016-05-24TimeNLP 详细介绍
2017-06-05 00:00:00-true
Time-NLP/src/com/time/nlp/TimeNormalizer.java
Lines 221 to 222 in e8dabd5
想问这是bug吗?
如题
2019-01-10-02:15 会被解析为
2019-09-01 00:00:00-true
2019-09-01 02:15:00-false
这个没有做吗?
例1:从上海到北京,一共花了只消4.5小时
解析后的时间为:2019-04-05 00:00:00
例2:买花用了10.1元
时间为:2018-10-01 00:00:00
项目打成jar包,执行test报错,无法使用
hi 你好
我希望可以添加识别节假日和农历的识别。如果可以的话,我希望可以将这个功能添加到您的github工程中来。这里我简单说一下我的需求,然后希望可以得到您的指点和建议
比如说 “端午回家过节” 可以识别出来2017-05-30 00:00:00
比如说 “农历五月初三放假” 可以识别出来 2017-05-27 00:00:00
要完成上面的需求,我觉得需要做以下几个事情
期待您的回复
Thanks
Ting
将TimeExp.m放到本地项目的resources目录下,加载时发生如下异常:
java.util.zip.ZipException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:165)
at java.util.zip.GZIPInputStream.(GZIPInputStream.java:79)
at java.util.zip.GZIPInputStream.(GZIPInputStream.java:91)
at com.time.nlp.TimeNormalizer.readModel(TimeNormalizer.java:265)
at com.time.nlp.TimeNormalizer.(TimeNormalizer.java:52)
我是新手,用了很多的方法都是不能使用。我把文件复制到工程,可是好像读取不到.m的那个文件。报错
如:输入2022-01-20。会输出2023-02-01 00:00:00
能否将例如上午,下午、明天、下周一、下月1号等时间识别为一个时间段,而不是一个单独的时间点。
例如,今天上午可以识别为[2018-05-30 08:00:00, 2018-05-30 12:00:00],明天识别为[2018-05-31 00:00:00, 2018-05-31 23:59:59]
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1967)
at com.time.nlp.TimeNormalizer.main(TimeNormalizer.java:294)
我想试着训练一下模型,能否提供下数据呀?谢谢
数据:依大端序,第1202538828478502551459097860527993021号,是“白日依山尽”
有问题的正则部分:((一|二|两|三|四|五|六|七|八|九|十|百|千|万|几|多|上|\d+)+个?(天|日|周|月|年)(后|前|半))
\d+后面还有一个+
可以把\d后面的+去掉,只用括号后的那个+号
希望能修正一下TimeExp.m文件,谢谢!
最近两年试了下识别不出来
"下星期提醒我吃饭"
居然识别的时间是1970-1-1 0:0:0
下载下来用编辑器打开TimeExp.m发现中文乱码,修改编辑器的编码也还是乱码,请问这个文件原来的内容是什么?
例如 星期三(11月29日)8点半 会识别为星期三 丢失对日期的识别 而且以星期三之后的星期四 星期五等识别还是之前的星期三 是不是可以修改timeunit中的 norm_setCurRelated方法 进行下判断 如果是有精确地时间了 就不在进行这个规范化
如:三天,半个小时,一个月,一年
请输入要识别的时间:9月10日到9月1日
当前时间:2020-07-06 17:32:28
timespan: 2020-09-10 00:00:00, 2020-09-01 00:00:00
如果能支持 Docker 容器化部署,可以更容易的被集成使用
我是新手,在开发一个有提醒功能的app,想问这个如何放到android studio中运行?TimeExp.m是怎么放到project里面去呢?
Is it possible to support Traditional Chinese?
博主您好,我在学习您的代码,TimeNormalizer类的TimeEx方法中,有两段代码都用到了rpointer--; rpointer++;这种写法。
我自己写了测试类,发现这样做了之后rpointer的值似乎是没有任何变化的,那么这种用法的奥秘在哪儿呢?
若博主看到了消息,很期待能被老师您指点一下,万分感激!!!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.