【发布时间】:2019-07-19 16:46:11
【问题描述】:
我正在尝试从这句话中提取一些数字,但我想验证正确的数字是否与正确的文本匹配。
nlp = spacy.load('en_core_web_sm')
s2 = 'Revenue from the advertising and subscription business for the first quarter of 2019 was RMB897.0 million (US$133.7 million), representing a 13.9% increase from RMB787.5 million (US$117.3 million) in the corresponding period in 2018.'
doc = nlp(s2)
for w in doc.ents:
print(w.text, w.label_, w.root)
for i in w.subtree:
print(" ", i, i.head)
for a in i.ancestors:
print(" ", a, a.head)
我想将RMB897.0 million 与advertising and subscription 联系起来,但不知道该怎么做。还尝试了名词分块。
for chunk in doc.noun_chunks:
print(chunk.text, chunk.root.text, chunk.root.dep_,
chunk.root.head.text)
for c in chunk.subtree:
print(" ", c, c.head)
【问题讨论】:
-
关联到底是什么意思?是否想为回指解析或文本结构执行此操作?您使用的数据中是否存在任何模式?否则只需使用依赖解析器,我的意思是它是一个简单的案例,因为复杂的名词短语通过连接动词与数字相关。
-
我想看看
RMB897.0是不是在说advertising and subscription