使用spacy区分两种类型的名词

我正在使用spacy来理解短语,并且我试图区分食物,啤酒,葡萄酒等名词和其他名词,例如昨天和今天。

我无法提出如何区分它们的想法。

#wrapper{
  min-height:100%;
  position: relative;
  display: block;
}

#wrapper:after{
  background-image: url(../img/bg.jpg);
  background-color: #0b0d89;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  content: "";
  opacity: 1;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  position: absolute;
  z-index: -1;
 }

.navbar {
  background-color: 
  rgba(11,13,137,0.5600000000000001);
  max-width: 1140px;
  margin: 0 auto;
  position: sticky;
  top: 0;
  z-index: 1020;
 }

我该如何区分前三个名词和昨天? 如图所示,二重网格渲染 图片链接=> https://imgur.com/a/cX7uQ3Z

luke_wonder 回答:使用spacy区分两种类型的名词

好吧,您可以做的是检查其实体:

sent = "Yesterday,I drank a beer"
doc = nlp(sent)
for token in doc:
   print(token.text,token.pos_,token.tag_,token.ent_type_) 
#Output:
#Yesterday NOUN NN DATE
#,PUNCT,#I PRON PRP 
#drank VERB VBD 
#a DET DT 
#beer NOUN NN 

如您所见,像昨天和今天这样的日期被识别为日期实体。在here is a list中有一些定义为空格的实体。

本文链接:https://www.f2er.com/3124514.html

大家都在问