1
12
如果你有马力,你可以 尝试 下面的算法。我举了一个例子,把枯燥的工作交给你:)
我们可以假设
|
2
6
首先用strtotime()检查整个字符串是否是有效的日期。如果是这样,你就完了。
循环每个n-1单词组合,并使用strotime()查看短语是否为有效日期。如果是这样,您已经在原始字符串中找到了最长的有效日期字符串。 如果不是,则循环每个n-2单词组合,并使用strotime()查看短语是否为有效日期。如果是这样,您已经在原始字符串中找到了最长的有效日期字符串。
|
3
3
受胡安·科尔特斯(juancortes)基于多尔夫算法的断链的启发,我自己写了出来。请注意,我决定在第一场成功的比赛中回来。
输入
输出
|
4
2
可以 动手吧:
可能做另一个循环来检查其他工作日或其他格式,或者只是嵌套。 |
5
2
当然,您需要设置一些规则来解析它们,因为您需要除去字符串上的所有额外内容,但除此之外,它是一个非常灵活的函数,在这里很可能会对您有所帮助。 例如,它可以采用“nextfridy”和“June 15th”这样的字符串,并为字符串中的日期返回相应的UNIX时间戳。我想如果你考虑一些基本的规则,比如寻找“下一个X”和周和月的名字,你就能做到这一点。
下周五
“来自”
下星期五我要打槌球
“你可以提取日期。看起来是个有趣的项目!但请记住
这将返回字符串中提到的下一个工作日的日期,只要它遵循规则!在这个特殊的例子中,输出是
就像已经指出的,有了正则表达式和一点耐心,你就可以做到这一点。编码最困难的部分是决定你要用什么方法来处理你的问题,而不是一旦你知道了什么就编码! |
6
2
多尔夫马修斯
输入 : 下星期五我要打槌球
: 加佐克斯,现在已经是6月17日了吗?
我希望它能帮助别人。 |
7
2
基于 根据我的建议,我写了一个函数,我认为它可以达到这个目的。
你可以这样称呼它: parse_date('现在设置截止日期2017年1月5日',0,0) |
8
1
the Wikipedia article 开始吧。请记住,解析器可能会变得非常复杂,因为这实际上是一个语言识别问题。这是人工智能/计算语言学领域通常要解决的问题。 |
9
1
我跳过了几个月,因为我不确定我记得他们在正确的顺序。
|
XYZ · 如何将每行的每个字转换为数据帧的数值 2 年前 |
John · 使用R中的单词嵌入从文本变量预测数字变量 2 年前 |
Sab Garduño · w2v_列中出现错误(trainFile=file_列,modelFile=model,stopWordsFile=file_stopwords)(下面是完整的错误文本) 2 年前 |
Michael W · 从数据帧创建术语频率矩阵的有效方法 2 年前 |