How to extract pre-defined key words from a sentence in Python? |
Üdvözöllek a Fórumban! ( Bejelentkezés | Regisztráció )
How to extract pre-defined key words from a sentence in Python? |
Oct 10 2020, 05:06 AM
Létrehozva:
#1
|
|
Newbie Csoport: Members Hozzászólások: 3 Csatlakozott: 21-September 20 Azonosító: 1,297 |
Consider the following example "10% of on all Artificial Intelligence courses online." In this example, I have to extract two predefined classes like Artificial Intelligence and courses. Even the program has to classify words like ANN, CNN, RNN, AI, etc. into the Artificial Intelligence category. I have used spacy to train but I am not impressed with the results as it is not labeling correctly. Is there any alternative to extract entities from a sentence in Python?
|
|
|
Jan 11 2021, 11:18 AM
Létrehozva:
#2
|
|
Newbie Csoport: Members Hozzászólások: 1 Csatlakozott: 11-January 21 Azonosító: 1,421 |
You can use flashtext for doing this.
from flashtext import KeywordProcessor kp = KeywordProcessor() # make a dictionary and create key , insert all keyword in one key (i.e CNN, ANN RNN will come under artificial Intelligence, whenever this value will appear it will extract key for you ) dict_= {'Artificial Intelligence': ['ANN','CNN','RNN','AI','Artificial Intelligence'],'courses' : ['courses']} kp.add_keywords_from_dict(dict_) # here Artificial Intelligence, ANN and CNN come under Artificial Intelligence key , that why it will extract the tag as Artificial Intelligence kp.extract_keywords('10% of on all Artificial Intelligence, ANN, and CNN courses.') #op ['Artificial Intelligence', 'Artificial Intelligence', 'Artificial Intelligence', 'courses'] learn more about Machine learning training in pune |
|
|
Szöveges verzió | A pontos idő: 6th October 2024 - 05:56 AM |