简体   繁体   English

使用NLP识别文本

[英]Identifying text using NLP

I'm trying to find the courses in the below line of text using some NLP technique. 我正在尝试使用一些NLP技术在下面的文本行中找到课程。

from nltk import word_tokenize, pos_tag, ne_chunk
sentence = "SDGI is offering courses like Electronics,Mechatronics, Physics,Mechanical Engineering"    
print ne_chunk(pos_tag(word_tokenize(sentence)))

Out put of this is 出来这是

(S
  (ORGANIZATION SDGI/NNP)
  is/VBZ
  offering/VBG
  courses/NNS
  like/IN
  Electronics/NNS
  ,/,
  Mechatronics/NNS
  ,/,
  (PERSON Physics/NNPS)
  ,/,
  (PERSON Mechanical/NNP Engineering/NNP))

Is there any way I can extract the courses from this line? 有什么方法可以从这一行中提取课程吗?

In my real project I will be getting so many documents from which I need to get the course names. 在我的真实项目中,我将获得如此多的文档,我需要从中获取课程名称。

Any help is appreciated! 任何帮助表示赞赏!

  1. Extract all the Nouns from a given text. 从给定文本中提取所有名词。
  2. Create a Bag of Words feature set and train the set for courses with labeled data. 创建一个单词袋功能集并训练具有标记数据的课程集。
  3. It seems the courses mostly precede or succeed a comma(,). 似乎课程大多在逗号(,)之前或之后。 A bigram or trigram approach could give accurate results. 二元组或三元组方法可以给出准确的结果。

This might be too simplistic, but, if there is is a finite number of existing course names, it might be easier just to create a large look up table, tokenize your input and try to look each word up. 这可能过于简单了,但是,如果存在有限数量的现有课程名称,则创建大型查找表可能更容易,将输入标记化并尝试查找每个单词。 There will be some edge cases, but I'm not sure you need to take an ML/NLP approach to this problem. 会有一些边缘情况,但我不确定你需要采用ML / NLP方法解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM