I have worked with Spacy and so far, found it very intuitive and robust in NLP. I am trying to make out of text sentences search which is both ways
word base as well as
content type base search but so far, I would not find any solution with spacy.
I have the text like:
In computer science, artificial intelligence (AI), sometimes called machine intelligence, is intelligence demonstrated by machines, unlike the natural intelligence displayed by humans and animals. Leading AI textbooks define the field as the study of “intelligent agents”: any device that perceives its environment and takes actions that maximize its chance of successfully achieving its goals. Colloquially, the term “artificial intelligence” is often used to describe machines (or computers) that mimic “cognitive” functions that humans associate with the human mind, such as “learning” and “problem-solving”.
As machines become increasingly capable, tasks considered to require “intelligence” are often removed from the definition of AI, a phenomenon known as the AI effect. A quip in Tesler’s Theorem says “AI is whatever hasn’t been done yet.” For instance, optical character recognition is frequently excluded from things considered to be AI, having become a routine technology. Modern machine capabilities generally classified as AI include successfully understanding human speech, competing at the highest level in strategic game systems (such as chess and Go), autonomously operating cars, intelligent routing in content delivery networks, and military simulations.
Artificial intelligence was founded as an academic discipline in 1955, and in the years since has experienced several waves of optimism, followed by disappointment and the loss of funding (known as an “AI winter”), followed by new approaches, success, and renewed funding. For most of its history, AI research has been divided into subfields that often fail to communicate with each other. These sub-fields are based on technical considerations, such as particular goals (e.g. “robotics” or “machine learning”), the use of particular tools (“logic” or artificial neural networks), or deep philosophical differences. Sub-fields have also been based on social factors (particular institutions or the work of particular researchers).
Now, I want to extract the sentences complete in multiple with multiple words or string matching. E.g., I want to search
machine learning. and it prints all complete sentences which contain this single or both given strings.
Is there any way that the importing model of spacy with spacy can sense the phrase match … like it finds all the intelligent and machine learning containing words and print that? and also with other option, can it also finds as with search machine learning, also suggests deep learning, artificial intelligence, pattern recognition, etc?
import spacy nlp = spacy.load("en_core_web_sm") from spacy.matcher import PhraseMatcher phrase_matcher = PhraseMatcher(nlp.vocab) phrases = ['machine learning', ''intelligent, 'human'] patterns = [nlp(text) for text in phrases] phrase_matcher.add('AI', None, *patterns) sentence = nlp (processed_article) matched_phrases = phrase_matcher(sentence) for match_id, start, end in matched_phrases: string_id = nlp.vocab.strings[match_id] span = sentence[start:end] print(match_id, string_id, start, end, span.text)
I tried this which is not providing the complete sentence but only the word with matching ID number.
- I am trying to search with multiple words input and find complete sentences which contain either out of input single string or all
- I am trying to use the trained model to also find suggested sentences out of input.
Trainer for Artificial Course Online.