我尝试在给定依赖关系树的Python中找到两个单词之间的依赖路径.
对于判刑
流行文化中的机器人在那里提醒我们无拘无束的人类机构的可怕性.
我使用了practnlptools(https://github.com/biplab-iitb/practNLPTools)来获取依赖项解析结果,如:
nsubj(are-5, Robots-1)
xsubj(remind-8, Robots-1)
amod(culture-4, popular-3)
prep_in(Robots-1, culture-4)
root(ROOT-0, are-5)
advmod(are-5, there-6)
aux(remind-8, to-7)
xcomp(are-5, remind-8)
dobj(remind-8, us-9)
det(awesomeness-12, the-11)
prep_of(remind-8, awesomeness-12)
amod(agency-16, unbound-14)
amod(agency-16, human-15)
prep_of(awesomeness-12, agency-16)
Run Code Online (Sandbox Code Playgroud)
也可视化为(图片来自https://demos.explosion.ai/displacy/)

"机器人"和"是"之间的路径长度为1,"机器人"和"可怕"之间的路径长度为4.
我的问题在上面给出了依赖解析结果,我怎样才能获得两个单词之间的依赖路径或依赖路径长度?
根据我目前的搜索结果,nltk的ParentedTree会有帮助吗?
谢谢!
我想抓取网络上发布的新闻文章的确切发布时间。
有些网页有漂亮且格式化的标题,我可以在其中提取“上次修改”或“发布日期”,标题中的信息很混乱,但可用。(顺便说一句,metadata_parser有很大帮助!)
但是像 BBC 和 CNN 这样的大型新闻机构不会在 html 标题中放置日期和时间信息。所以我试图从 html 代码中获取日期和发布时间。
对于 BBC,日期时间嵌入如下:
<div data-timestamp-inserted="true" class="date date--v2" data-seconds="1447658338" data-datetime="16 November 2015">16 November 2015</div>
Run Code Online (Sandbox Code Playgroud)
对于 CNN,它就像:
<p class="update-time">Updated 0137 GMT (0937 HKT) November 16, 2015 <span id="js-pagetop_video_source" class="video__source top_source">| Video Source: <a href="http://www.cnn.com/">CNN</a></span></p>
Run Code Online (Sandbox Code Playgroud)
对于纽约时报,
<p class="byline-dateline"><span class="byline" itemprop="author creator" itemscope="" itemtype="http://schema.org/Person">By <span class="byline-author" data-byline-name="AURELIEN BREEDEN" itemprop="name">AURELIEN BREEDEN</span>, </span><span class="byline" itemprop="author creator" itemscope="" itemtype="http://schema.org/Person"><span class="byline-author" data-byline-name="KIMIKO DE FREYTAS-TAMURA" itemprop="name">KIMIKO DE FREYTAS-TAMURA</span> and </span><span class="byline" itemprop="author creator" itemscope="" itemtype="http://schema.org/Person" itemid="http://topics.nytimes.com/top/reference/timestopics/people/b/katrin_bennhold/index.html"><a href="http://topics.nytimes.com/top/reference/timestopics/people/b/katrin_bennhold/index.html" …Run Code Online (Sandbox Code Playgroud)