Esempio n. 1
0
# Demonstrates the keyphrase extraction capability of the expert.ai (local) Edge NL API performed by the 'relevants' resource wrapped in the `relevants` method of the client.

from expertai.nlapi.edge.client import ExpertAiClient
client = ExpertAiClient()
#client.set_host('localhost', 6670)

file = open("document.txt")
text = file.read()
file.close()

output = client.keyphrase_extraction(text)

# Main lemmas

print("Main lemmas:")

for lemma in output.main_lemmas:
    print(lemma.value)
# Demonstrates the relation extraction capability of the expert.ai (local) Edge NL API performed by the 'relations' resource wrapped in the `relations` method of the client.

from expertai.nlapi.edge.client import ExpertAiClient
client = ExpertAiClient()

text = "Michael Jordan was one of the best basketball players of all time. Scoring was Jordan's stand-out skill, but he still holds a defensive NBA record, with eight steals in a half."

output = client.relations(text)

# Output relations' data

print("Output relations' data:")

for relation in output.relations:
    print(relation.verb.lemma, ":")
    for related in relation.related:
        print("\t", "(", related.relation, ")", related.lemma)
Esempio n. 3
0
# Demonstrates the named entity recognition capability of the expert.ai (local) Edge NL API performed by the 'entities' resource wrapped in the `entities` method of the client.

from expertai.nlapi.edge.client import ExpertAiClient
client = ExpertAiClient()

text = "Michael Jordan was one of the best basketball players of all time. Scoring was Jordan's stand-out skill, but he still holds a defensive NBA record, with eight steals in a half."

output = client.named_entity_recognition(text)

print(f'{"ENTITY":{50}} {"TYPE":{10}}')
print(f'{"------":{50}} {"----":{10}}')

for entity in output.entities:
    print(f'{entity.lemma:{50}} {entity.type_:{10}}')
# Demonstrates the sentiment analysis capability of the expert.ai (local) Edge NL API performed by the 'sentiment' resource wrapped in the `sentiment` method of the client.

from expertai.nlapi.edge.client import ExpertAiClient

client = ExpertAiClient()

text = "Michael Jordan was one of the best basketball players of all time. Scoring was Jordan's stand-out skill, but he still holds a defensive NBA record, with eight steals in a half."

output = client.sentiment(text)

# Output overall sentiment

print("Output overall sentiment:")

print(output.sentiment.overall)
import streamlit as st
import pandas as pd
import numpy as np
import plotly.express as px
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt
from expertai.nlapi.edge.client import ExpertAiClient
import os
client = ExpertAiClient()
#### This is completely Testing and educational purpose so please create your own account for free to test the Web App
os.environ["EAI_USERNAME"] = '******' ## Add your username 
os.environ["EAI_PASSWORD"] = '******' ## Add your password
def main():
    st.title("US Airline Tweet Analysis Experimenting with ExpertAI")
    st.sidebar.title("Experimental US Airline Tweet Analysis 😀😐😥")
    st.sidebar.subheader("By [Abid Ali Awan](https://gitlab.com/kingabzpro)")
    st.sidebar.markdown("[![View on Gitlab](https://img.shields.io/badge/Gitlab-NLP-yellow)](https://gitlab.com/kingabzpro/Airline-Tweets-NLP)")
    st.subheader("**Web App Powered by Expert.AI NLP API**")
    st.sidebar.markdown("US Airlines Tweet Analysis Using ExpertAi NLP API and Data Visualization. ")
    text=st.text_input('Enter Random Airline tweets')
    if st.button('Run'):
        document = client.sentiment(text)
        document2 = client.keyphrase_extraction(text)
        document3 = client.named_entity_recognition(text)
        st.write('Sentiment:', document.sentiment.overall)
        st.markdown('**Emotions**')
        if document.sentiment.overall>2 and document.sentiment.overall<25 :## emotions
            st.write('Happy 😃')
        elif document.sentiment.overall<-2 and document.sentiment.overall>-25:
            st.write('Sad 🙁')
        elif document.sentiment.overall<-25:
Esempio n. 6
0
import os
os.environ["EAI_USERNAME"] = '******'
os.environ["EAI_PASSWORD"] = '******'

from expertai.nlapi.edge.client import ExpertAiClient
client = ExpertAiClient()

text = """Dear Mr. Avery
I am writing today to complain about my new Blender 365HB. I purchased this blender at your Woodbury, NY store on 8/9/2020.
I purchased the blender only 3 weeks ago and it is falling apart. The insert for the blade has warped and now I must stand there and hold the blender when it is on. Also, one of the blades on the blender is bend after blending ice. Now I'm very disappointed and I hate this blender so much! This performance is unacceptable and your store would not take it back because it was past the 14-day return. This is ridiculous! How was I supposed to know that all these defects would happen within the 14 days? This is bonkers!
I have attached a pdf below of my receipt. In addition, I have attached before and after pictures of the blender. I look forward to your response and your proposed solution to this problem. I have had blenders from Universal Blenders Co before and never have had this problem. Please contact me at the email I am sending you this from or my cell phone 845*******. Thank you for your help in advanced.
Best Regards,
Jane Billings
"""

output = client.classification(text)

print("\n", text)

print("\nTab separated list of categories:")

for category in output.categories:
    print(category.id_, category.hierarchy, sep="\t")

    output = client.extraction(text)

print("\nList of extractions:")

for extraction in output.extractions:
    for field in extraction.fields:
        print(field.name, field.value, sep="\t")
Esempio n. 7
0
# Demonstrates the deep linguistic analysis capability of the expert.ai (local) Edge NL API performed by the 'disambiguation' resource wrapped in the `deep_linguistic_analysis` method of the client.

from expertai.nlapi.edge.client import ExpertAiClient
client = ExpertAiClient()

text = "Michael Jordan was one of the best basketball players of all time. Scoring was Jordan's stand-out skill, but he still holds a defensive NBA record, with eight steals in a half."

output = client.deep_linguistic_analysis(text)

# Output tokens' data

print("Output tokens' data:")

print(f'{"TEXT":{20}} {"LEMMA":{40}} {"POS":{6}}')
print(f'{"----":{20}} {"-----":{40}} {"---":{6}}')

for token in output.tokens:
    print(
        f'{text[token.start:token.end]:{20}} {token.lemma:{40}} {token.pos:{6}}'
    )
Esempio n. 8
0
from expertai.nlapi.edge.client import ExpertAiClient

client = ExpertAiClient()
client.set_host('localhost', 6670)

text = "Michael Jordan was one of the best basketball players of all time. Scoring was Jordan's stand-out skill, but he still holds a defensive NBA record, with eight steals in a half."

output = client.full_analysis(text)

# Output arrays size

print("Output arrays size:")

print("knowledge: ", len(output.knowledge))
print("paragraphs: ", len(output.paragraphs))
print("sentences: ", len(output.sentences))
print("phrases: ", len(output.phrases))
print("tokens: ", len(output.tokens))
print("mainSentences: ", len(output.main_sentences))
print("mainPhrases: ", len(output.main_phrases))
print("mainLemmas: ", len(output.main_lemmas))
print("mainSyncons: ", len(output.main_syncons))
print("topics: ", len(output.topics))
print("entities: ", len(output.entities))
print("relations: ", len(output.relations))
print("sentiment.items: ", len(output.sentiment.items))
Esempio n. 9
0
from expertai.nlapi.edge.client import ExpertAiClient
client = ExpertAiClient()

text = "Michael Jordan was one of the best basketball players of all time. Scoring was Jordan's stand-out skill, but he still holds a defensive NBA record, with eight steals in a half." 

output = client.full_analysis(text)

# Output arrays size

print("Output arrays size:");

print("knowledge: ", len(output.knowledge))
print("paragraphs: ", len(output.paragraphs))
print("sentences: ", len(output.sentences))
print("phrases: ", len(output.phrases))
print("tokens: ", len(output.tokens))
print("mainSentences: ", len(output.main_sentences))
print("mainPhrases: ", len(output.main_phrases))
print("mainLemmas: ", len(output.main_lemmas))
print("mainSyncons: ", len(output.main_syncons))
print("topics: ", len(output.topics))
print("entities: ", len(output.entities))
print("relations: ", len(output.relations))
print("sentiment.items: ", len(output.sentiment.items))