def test(): similarity("Sachin is the greatest batsman", "Tendulkar is the finest cricketer") sentiment("Come on, lets play together") taxonomy("Narendra Modi is the prime minister of India") ner("Narendra Modi is the prime minister of India") keywords( "Prime Minister Narendra Modi tweeted a link to the speech Human Resource Development Minister Smriti Irani made in the Lok Sabha during the debate on the ongoing JNU row and the suicide of Dalit scholar Rohith Vemula at the Hyderabad Central University." ) emotion("Did you hear the latest Porcupine Tree song ? It's rocking !") intent( "Finance ministry calls banks to discuss new facility to drain cash") abuse("you f**king a$$hole")
def get_taxo(string): """Returns taxonomy and confidence score of a string as a PD Series.""" try: text_taxo = taxonomy(string) # text_taxo = (sorted(((text_taxo['taxonomy']).items()), key=lambda kv: (kv[1], kv[0]), reverse=True))[0] text_tag = text_taxo['taxonomy'][0]['tag'] text_tag_score = text_taxo['taxonomy'][0]['confidence_score'] return pd.Series([text_tag, text_tag_score]) except: print("Error in ", string)
from paralleldots import keywords from paralleldots import set_api_key from paralleldots import taxonomy set_api_key("l0gClHlNjmAovHKVzHsxfSRMmPw6FcAljMCm6QZFoOI") keyw = keywords(" Hyderabad ") max = 0 keyword1 = [] #ir=keyw['keywords'] #for keydic in ir: #for eachk in keydic: #if(eachk!="confidence_score"): #keyword1.append(keydic[eachk]) place = "" keyword1 = (" is a place").split() #print(keyword1) for k in keyword1: clas = taxonomy(k) d = clas["taxonomy"] #print(clas) for e in d: if (e['tag'] == 'places' and e['confidence_score'] > max): place = k max = e['confidence_score'] print(place)
def test(): set_api_key("Put your Api key here") category = { "finance": ["markets", "economy", "shares"], "world politics": ["diplomacy", "UN", "war"], "india": ["congress", "india", "bjp"] } print( similarity("Sachin is the greatest batsman", "Tendulkar is the finest cricketer")) print(sentiment("Come on, lets play together")) print(ner("Narendra Modi is the prime minister of India", "en")) print( taxonomy( "Michael Jordan of the Chicago Bulls is getting a 10-hour Netflix documentary in 2019" )) print( keywords( "Prime Minister Narendra Modi tweeted a link to the speech Human Resource Development Minister Smriti Irani made in the Lok Sabha during the debate on the ongoing JNU row and the suicide of Dalit scholar Rohith Vemula at the Hyderabad Central University." )) print( phrase_extractor( "Prime Minister Narendra Modi tweeted a link to the speech Human Resource Development Minister Smriti Irani made in the Lok Sabha during the debate on the ongoing JNU row and the suicide of Dalit scholar Rohith Vemula at the Hyderabad Central University." )) print( emotion( "Did you hear the latest Porcupine Tree song ? It's rocking !")) print( intent( "Finance ministry calls banks to discuss new facility to drain cash" )) print(abuse("you f**king a$$hole")) print( custom_classifier("Narendra Modi is the prime minister of India", category)) print( batch_intent([ "drugs are fun", "don\'t do drugs, stay in school", "lol you a f*g son", "I have a throat infection" ])) print(batch_abuse(["drugs are fun", "dont do drugs, stay in school"])) print( batch_sentiment([ "drugs are fun", "don\'t do drugs, stay in school", "lol you a f*g son", "I have a throat infection" ])) print( batch_phrase_extractor([ "drugs are fun", "don\'t do drugs, stay in school", "lol you a f*g son", "I have a throat infection" ])) print( batch_taxonomy([ "Michael Jordan of the Chicago Bulls is getting a 10-hour Netflix documentary in 2019", "Michael Jordan of the Chicago Bulls is getting a 10-hour Netflix documentary in 2019" ])) print( batch_ner([ "Michael Jordan of the Chicago Bulls is getting a 10-hour Netflix documentary in 2019", "Michael Jordan of the Chicago Bulls is getting a 10-hour Netflix documentary in 2019" ])) print( batch_emotion([ "drugs are fun", "don\'t do drugs, stay in school", "lol you a f*g son", "I have a throat infection" ])) print(facial_emotion_url("https://i.imgur.com/klb812s.jpg")) print(object_recognizer_url("https://i.imgur.com/klb812s.jpg")) print( sarcasm( "The movie that i watched last night is so funny that i get rolled out with laughter" )) print( batch_sarcasm([ "The movie that i watched last night is so funny that i get rolled out with laughter", "I want to spend my life alone" ]))