【发布时间】:2020-09-18 10:40:02
【问题描述】:
输入文本:
text = "Wipro Limited | Hyderabad, IN Dec 2017 – Present
Project Analyst
Infosys | Delhi, IN Apr 2017 – Nov 2017
Software Developer
HCL Technologies | Hyderabad, IN Jun 2016 – Mar 2017
Software Engineer
"
我为此编写了一个代码,但它显示在每个提取的单词的列表中,并且无法执行任何操作。
regex = re.compile('(?P<month>[a-zA-Z]+)\s+(?P<year>\d{4})\s+\–\s+(?P<month1>[a-zA-Z]+)\s+(?P<year1>\d{4})')
mat = re.findall(regex, text)
mat
查看代码:https://regex101.com/r/mMlgYp/1。 我希望像下面这样的输出来预览日期并做出改变,然后计算总经验: 此处“当前”或“截止日期”应考虑当前月份和年份。
import time
Present = time.strftime("%m-%Y")
Present
# output: '05-2020'
#Desired output
Extracted dates:
[('Dec 2017 - Present'),
('Apr 2017 - Nov 2017'),
('Jun 2016 - Mar 2017')]# and so on ...should display all the search results
First experience: 1.9 years
second experience: 8 months
third experience: 7 months
# and so on ...should display all the search results
Total experience: 3.4 years
请帮我解决这个问题,我是编程语言和 NLP、正则表达式的新手。
【问题讨论】:
标签: python regex pandas datetime nlp