我使用正則表達式NLTK日期和時間提取:正則表達式來提取日期和時間
text = 'LEts have quick meeting on Wednesday at 9am'
week_day = "(monday|tuesday|wednesday|thursday|friday|saturday|sunday)"
month = "(january|february|march|april|may|june|july|august|september| \
october|november|december)"
dmy = "(year|day|week|month)"
exp2 = "(this|next|last)"
regxp2 = "(" + exp2 + " (" + dmy + "|" + week_day + "|" + month + "))"
reg2 = re.compile(regxp2, re.IGNORECASE)
found = reg2.findall(text)
found = [a[0] for a in found if len(a) > 1]
for timex in found:
timex_found.append(timex)
print timex_found
一切看起來我的權利,但它不標記Wednesday
任何線索?我應該改變什麼考慮「星期三」,以及「星期三」
威爾
regxp2 = "((this|next|last)? (" + dmy + "| " + week_day + "| " + month+ "))"
考慮我的情況?
線通過它的線,並計算出如果線產生預期的結果。當你這樣做的時候,如果你不知道如何解決這個問題,你會得到一個實際上最小的[mcve]。 – khelwood
輸入中沒有'(this | next | last)'。 –