Skip to content

Instantly share code, notes, and snippets.

no_stop_en = [token for token in doc_en if token.is_stop is not True]
no_stop_pt = [token for token in doc_pt if token.is_stop is not True]
no_stop_fr = [token for token in doc_fr if token.is_stop is not True]
print(no_stop_en)
print(no_stop_pt)
print(no_stop_fr)
minister = nlp_en('minister')
president = nlp_en('president')
print('EN - Similarity Minister vs President:', minister.similarity(president))
car = nlp_en('car')
banana = nlp_en('banana')
print('EN - Similarity Car vs Banana:', car.similarity(banana))
for entity in doc_en.ents:
print(entity.text, entity.label_)
for entity in doc_pt.ents:
print(entity.text, entity.label_)
for entity in doc_fr.ents:
print(entity.text, entity.label_)
for token in doc_en:
print(token.text + ': [' + token.pos_ + ' - ' + token.dep_ + ']')
for token in doc_pt:
print(token.text + ': [' + token.pos_ + ' - ' + token.dep_ + ']')
for token in doc_fr:
print(token.text + ': [' + token.pos_ + ' - ' + token.dep_ + ']')
print(doc_en)
print(doc_pt)
print(doc_fr)
import spacy
from spacy import displacy
nlp_en = spacy.load('en_core_web_sm')
nlp_pt = spacy.load('pt_core_news_sm')
nlp_fr = spacy.load('fr_core_news_sm')
doc_en = nlp_en(u'Brazil\'s new foreign minister believes climate change is a Marxist plot.')
doc_pt = nlp_pt(u'Novo ministro das Relações Exteriores do Brasil acredita que as mudanças climáticas são uma conspiração marxista.')
doc_fr = nlp_fr(u'Le nouveau Ministre des Affaires Etrangers brésilien croit que le changement climatique est une conspiration Marxiste.')
Training, wait...
training completed.
Starting to predict...
{'entities': [{'confidence': 0.6932068507429364,
'end': 183,
'entity': 'evaluation',
'extractor': 'ner_crf',
'start': 165,
'value': '5.0 out of 5 stars'},
{'confidence': 0.8902309284196319,
from rasa_nlu.training_data import load_data
from rasa_nlu.config import RasaNLUModelConfig
from rasa_nlu.model import Trainer, Metadata, Interpreter
from rasa_nlu import config
from bs4 import BeautifulSoup
from urllib.request import Request, urlopen
import jsonpickle
def remove_html(filename):
{
"rasa_nlu_data": {
"common_examples": [
{
"text": "U Watch Smart Watch Bluetooth Watch for Android smartphones and iPhone(Black) by u8 2.6 out of 5 stars 634 customer reviews | 529 answered questions Price: $6.30 & FREE Shipping This item at this price, sold by Amazon.com, is currently ",
"intent": "",
"entities": [
{
"start": 84,
"end": 102,
{
"rasa_nlu_data": {
"common_examples": []
}
}