paralleldots 3.0.0 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +82 -75
  3. data/lib/paralleldots.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5b397135bcdfc263e1f946e30fe4ff634519506
4
- data.tar.gz: df2e6cc05b4e5b40ae04f6ee020396181364ac0c
3
+ metadata.gz: 78031e9d223767180ec3aa0832ca5e2140b48684
4
+ data.tar.gz: 582b4f3982a249d24697b531ebecc1b92e2432d1
5
5
  SHA512:
6
- metadata.gz: f5d9a90f1d5654965c9011af5efc0f325e1d4a01b43d94d47b63645926d1bf63f5d3d55a798bd4266ef39b51175e6ecd56817aeaed54470d54c27135b5d99bb0
7
- data.tar.gz: 429fcf21c8d804a29c9f03621af138434d594cd8507c25c62ad7e33d8bc14849c7d3f8013920f4f1a1a7b2d7759ec74dcd697e47fe53b9b920b361f45ef4bf07
6
+ metadata.gz: cd4ef61aada8078d6cf2c697f074dc84bfd27ad803a9ab180523802443f82c86d8519820b598add243ab993409d9ad0f27563ad562ea9b45539b185b6754034d
7
+ data.tar.gz: b5d8f4dc3af3224b98aa4be3b2b4e474eee4a3bc72d4a5f2118dfa26cd0f15081a86b0413a9148272099cdc4e0ac329937ffebe46dfe793929cfa635b90cb066
data/README.md CHANGED
@@ -31,90 +31,97 @@ Configuration:
31
31
  Supported APIs:
32
32
  ---------------
33
33
 
34
- - [Semantic Similarity](https://tinyurl.com/k23nqs9)
35
- - [Sentiment Analysis](https://tinyurl.com/km99mzb)
36
- - Taxonomy
37
- - [Named Entity Extraction/Recognition ( NER )](https://tinyurl.com/k9yglwc)
38
- - [Keywords](https://tinyurl.com/kujcu8o)
39
- - [Intent](https://tinyurl.com/n568bqw)
40
- - [Emotion](http://blog.paralleldots.com/technology/deep-learning/emotion-detection-using-machine-learning/)
41
34
  - Abuse
42
- - Multiple Language Sentiment ( The function encodes the input text )
43
- - Portuguese ( pt )
44
- - Chinese ( cn )
45
- - Spanish ( sp )
46
- - Sentiment Social
47
35
  - Custom Classifier
36
+ - Emotion ( Supports all [ISO 639-1 Languages via their language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) )
37
+ - Intent
38
+ - Keywords
39
+ - Multilanguage Keywords ( Supports Multiple Languages )
40
+ - Named Entity Extraction/Recognition ( NER )
41
+ - Not Safe For Work ( NSFW Image Classifier )
42
+ - Phrase Extractor
43
+ - Popularity ( Image Classifier )
44
+ - Sentiment Analysis ( Supports all [ISO 639-1 Languages via their language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) )
45
+ - Semantic Similarity
46
+ - Taxonomy
47
+ - Text Parser
48
48
  - Usage
49
49
 
50
50
  Examples
51
51
  --------
52
52
 
53
+ > set_api_key( "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" )
54
+ > get_api_key
53
55
 
54
- > require 'paralleldots'
56
+ > path = "/home/my_computer/Downloads/image_1.jpg"
57
+ > text = "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."
58
+ > category = { "finance": [ "markets", "economy", "shares" ], "world politics": [ "diplomacy", "UN", "war" ] }
59
+ > lang_code = "fr"
60
+ > lang_text = "C'est un environnement très hostile, si vous choisissez de débattre ici, vous serez vicieusement attaqué par l'opposition."
61
+
62
+ > puts( "\nAbuse" )
63
+ > puts( abuse( text ) )
64
+ {"usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "sentence_type"=>"Non Abusive", "confidence_score"=>0.876953}
65
+
66
+ > puts( "\nCustom Classifier" )
67
+ > puts( custom_classifier( text, category ) )
68
+ {"usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "taxonomy"=>[{"tag"=>"world politics", "confidence_score"=>0.580833}, {"tag"=>"finance", "confidence_score"=>0.259185}]}
69
+
70
+ > puts( "\nEmotion" )
71
+ > puts( emotion( text ) )
72
+ {"emotion"=>{"emotion"=>"Happy", "probabilities"=>{"Sarcasm"=>0.0, "Angry"=>0.04090321436524391, "Sad"=>0.0, "Fear"=>0.0, "Bored"=>0.0, "Excited"=>0.07638891041278839, "Happy"=>0.1223890483379364}}, "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions"}
73
+
74
+ > puts( "\nEmotion - Lang: Fr". )
75
+ > puts( emotion( lang_text, lang_code ) )
76
+ {"emotion"=>{"emotion"=>"Angry", "probabilities"=>{"Sarcasm"=>0.052613839507102966, "Angry"=>0.07304570078849792, "Sad"=>0.051657479256391525, "Fear"=>0.07096020132303238, "Bored"=>0.0, "Excited"=>0.0, "Happy"=>0.0}}, "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions"}
77
+
78
+ > puts( "\nIntent" )
79
+ > puts( intent( text ) )
80
+ {"probabilities"=>{"marketing"=>0.042, "spam/junk"=>0.003, "news"=>0.927, "feedback/opinion"=>0.024, "query"=>0.004}, "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "intent"=>"news"}
81
+
82
+ > puts( "\nKeywords" )
83
+ > puts( keywords( text ) )
84
+ {"keywords"=>[{"keyword"=>"Prime Minister Narendra Modi", "confidence_score"=>0.857594}, {"keyword"=>"link", "confidence_score"=>0.913924}, {"keyword"=>"speech Human Resource", "confidence_score"=>0.70655}, {"keyword"=>"Smriti", "confidence_score"=>0.860351}, {"keyword"=>"Lok", "confidence_score"=>0.945534}], "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions"}
85
+
86
+ > puts( "\nMultilang Keywords - Lang: Fr". )
87
+ > puts( multilang_keywords( lang_text, lang_code ) )
88
+ {"keywords"=>["cest", "très", "vicieusement", "attaqué", "hostile", "environnement", "débattre", "choisissez", "lopposition", "si"], "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions"}
89
+
90
+ > puts( "\nNER" )
91
+ > puts( ner( text ) )
92
+ {"usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "entities"=>[{"category"=>"name", "name"=>"Narendra Modi", "confidence_score"=>0.990574}, {"category"=>"name", "name"=>"Smriti Irani", "confidence_score"=>0.989922}, {"category"=>"name", "name"=>"Rohith Vemula", "confidence_score"=>0.839291}, {"category"=>"group", "name"=>"Lok Sabha", "confidence_score"=>0.80819}, {"category"=>"group", "name"=>"Dalit", "confidence_score"=>0.655424}, {"category"=>"group", "name"=>"Central University", "confidence_score"=>0.708817}, {"category"=>"place", "name"=>"Hyderabad", "confidence_score"=>0.591985}]}
93
+
94
+ > puts( "\nNSFW" )
95
+ > puts( nsfw( path ) )
96
+ {"Popular"=>"38.1271243095", "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "Not Popular"=>"61.8728756905"}
97
+
98
+ > puts( "\nPhrase Extractor" )
99
+ > puts( phrase_extractor( text ) )
100
+ {"keywords"=>[{"relevance_score"=>3, "keyword"=>"Hyderabad Central University"}, {"relevance_score"=>2, "keyword"=>"Rohith Vemula"}, {"relevance_score"=>2, "keyword"=>"JNU row"}, {"relevance_score"=>6, "keyword"=>"Human Resource Development Minister Smriti Irani"}, {"relevance_score"=>2, "keyword"=>"Lok Sabha"}, {"relevance_score"=>4, "keyword"=>"Prime Minister Narendra Modi"}, {"relevance_score"=>2, "keyword"=>"Dalit scholar"}], "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions"}
101
+
102
+ > puts( "\nPopularity" )
103
+ > puts( popularity( path ) )
104
+ {"Popular"=>"38.1271243095", "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "Not Popular"=>"61.8728756905"}
105
+
106
+ > puts( "\nSentiment" )
107
+ > puts( sentiment( text ) )
108
+ {"probabilities"=>{"positive"=>0.266, "neutral"=>0.549, "negative"=>0.185}, "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "sentiment"=>"neutral"}
109
+
110
+ > puts( "\nSentiment - Lang: Fr". )
111
+ > puts( sentiment( lang_text, lang_code ) )
112
+ {"probabilities"=>{"positive"=>0.02, "neutral"=>0.291, "negative"=>0.689}, "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "sentiment"=>"negative"}
113
+
114
+ > puts( "\nSimilarity" )
115
+ > puts( similarity( "I love fish and ice cream!", "fish and ice cream are the best!" ) )
116
+ {"usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "actual_score"=>0.848528, "normalized_score"=>4.936506}
117
+
118
+ > puts( "\nTaxonomy" )
119
+ > puts( taxonomy( text ) )
120
+ {"usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "taxonomy"=>[{"tag"=>"News and Politics/Law", "confidence_score"=>0.845402}, {"tag"=>"Hobbies & Interests/Workshops and Classes", "confidence_score"=>0.878964}, {"tag"=>"Business and Finance/Industries", "confidence_score"=>0.7353}]}
55
121
 
56
- > similarity( "Sachin is the greatest batsman", "Tendulkar is the finest cricketer" )
57
- {"actual_score"=>0.842932, "normalized_score"=>4.931469}
58
-
59
- > sentiment( "Come on, lets play together" )
60
- {"probabilities"=>{"positive"=>0.568817, "neutral"=>0.400776, "negative"=>0.030407}, "sentiment"=>"positive"}
61
-
62
- > taxonomy( "Narendra Modi is the prime minister of India" )
63
- {"taxonomy"=>[
64
- {"tag"=>"terrorism", "confidence_score"=>0.531435},
65
- {"tag"=>"world politics", "confidence_score"=>0.391963},
66
- {"tag"=>"politics", "confidence_score"=>0.358955},
67
- {"tag"=>"religion", "confidence_score"=>0.308195},
68
- {"tag"=>"defense", "confidence_score"=>0.26187},
69
- {"tag"=>"business", "confidence_score"=>0.20885},
70
- {"tag"=>"entrepreneurship", "confidence_score"=>0.18349},
71
- {"tag"=>"health", "confidence_score"=>0.171121},
72
- {"tag"=>"technology", "confidence_score"=>0.168591},
73
- {"tag"=>"law", "confidence_score"=>0.156953},
74
- {"tag"=>"education", "confidence_score"=>0.146511},
75
- {"tag"=>"science", "confidence_score"=>0.101002},
76
- {"tag"=>"crime", "confidence_score"=>0.085016},
77
- {"tag"=>"entertainment", "confidence_score"=>0.080634},
78
- {"tag"=>"environment", "confidence_score"=>0.078024},
79
- {"tag"=>"disaster", "confidence_score"=>0.075295},
80
- {"tag"=>"weather", "confidence_score"=>0.06784},
81
- {"tag"=>"accident", "confidence_score"=>0.066831},
82
- {"tag"=>"sports", "confidence_score"=>0.058329},
83
- {"tag"=>"advertising", "confidence_score"=>0.054868},
84
- {"tag"=>"history", "confidence_score"=>0.043581},
85
- {"tag"=>"mining", "confidence_score"=>0.03833},
86
- {"tag"=>"travel", "confidence_score"=>0.025517},
87
- {"tag"=>"geography", "confidence_score"=>0.022372},
88
- {"tag"=>"nature", "confidence_score"=>0.013477},
89
- {"tag"=>"lifestyle", "confidence_score"=>0.006467},
90
- {"tag"=>"automobile", "confidence_score"=>0.001161},
91
- {"tag"=>"personal care", "confidence_score"=>0.000275}
92
- ]}
93
-
94
- > ner( "Narendra Modi is the prime minister of India" )
95
- {"entities"=>[{"category"=>"name", "name"=>"Narendra Modi", "confidence_score"=>0.951439}, {"category"=>"place", "name"=>"India", "confidence_score"=>0.9263}]}
96
-
97
- > 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." )
98
- {:keywords=>{"keywords"=>[{"relevance_score"=>4, "keyword"=>"Prime Minister Narendra Modi"}, {"relevance_score"=>1, "keyword"=>"link"}, {"relevance_score"=>3, "keyword"=>"speech Human Resource"}, {"relevance_score"=>1, "keyword"=>"Smriti"}, {"relevance_score"=>1, "keyword"=>"Lok"}], "usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions"}}
99
-
100
- > emotion("Did you hear the latest Porcupine Tree song ? It's rocking !")
101
- {"emotion"=>"other", "probabilities"=>{"angry"=>0.010629, "other"=>0.453988, "sad"=>0.028748, "excited"=>0.2596, "happy"=>0.247035}}
102
-
103
- > intent("Finance ministry calls banks to discuss new facility to drain cash")
104
- {"probabilities"=>{"news"=>0.946028, "other"=>0.015853, "query"=>0.000412, "feedback/opinion"=>0.014115, "spam"=>0.023591}, "intent"=>"news"}
105
-
106
- > abuse("you f**king a$$hole")
107
- {"confidence_score"=>0.998047, "sentence_type"=>"Abusive"}
108
-
109
- > multilang("Me encanta jugar al baloncesto", "es") # The text is encoded in the function
110
- {"sentiment": "positive", "confidence_score": 1.0}
111
-
112
- > sentiment_social("I left my camera at home")
113
- {"probabilities"=>{"positive"=>0.040374, "neutral"=>0.491032, "negative"=>0.468594}, "sentiment"=>"neutral"}
114
-
115
- > custom_classifier( TEXT, ID )
116
- Get your custom classifier id by loggin to your [dashboard](https://user.apis.paralleldots.com/login) and publishing your categories.
117
- { "taxonomy": [ { "tag": tag1, "confidence_score": score1 }, { "tag": tag2, "confidence_score": score2 }, ... ] }
122
+ > puts( "\nText Parser" )
123
+ > puts( text_parser( text ) )
124
+ {"usage"=>"By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions", "output"=>[{"text"=>"Prime", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Minister", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Narendra", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Modi", "Dependency"=>"nominal subject", "Tags"=>"noun"}, {"text"=>"tweeted", "Dependency"=>"root", "Tags"=>"verb"}, {"text"=>"a", "Dependency"=>"determiner", "Tags"=>"determiner"}, {"text"=>"link", "Dependency"=>"direct object", "Tags"=>"noun"}, {"text"=>"to", "Dependency"=>"prepositional modifier", "Tags"=>"preposition or conjunction"}, {"text"=>"the", "Dependency"=>"determiner", "Tags"=>"determiner"}, {"text"=>"speech", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Human", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Resource", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Development", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Minister", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Smriti", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Irani", "Dependency"=>"object of a preposition", "Tags"=>"noun"}, {"text"=>"in", "Dependency"=>"prepositional modifier", "Tags"=>"preposition or conjunction"}, {"text"=>"the", "Dependency"=>"determiner", "Tags"=>"determiner"}, {"text"=>"Lok", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Sabha", "Dependency"=>"object of a preposition", "Tags"=>"noun"}, {"text"=>"during", "Dependency"=>"prepositional modifier", "Tags"=>"preposition or conjunction"}, {"text"=>"the", "Dependency"=>"determiner", "Tags"=>"determiner"}, {"text"=>"debate", "Dependency"=>"object of a preposition", "Tags"=>"noun"}, {"text"=>"on", "Dependency"=>"prepositional modifier", "Tags"=>"preposition or conjunction"}, {"text"=>"the", "Dependency"=>"determiner", "Tags"=>"determiner"}, {"text"=>"ongoing", "Dependency"=>"adjectival modifier", "Tags"=>"adjective"}, {"text"=>"JNU", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"row", "Dependency"=>"object of a preposition", "Tags"=>"noun"}, {"text"=>"and", "Dependency"=>"coordinating conjunction", "Tags"=>"conjuction"}, {"text"=>"the", "Dependency"=>"determiner", "Tags"=>"determiner"}, {"text"=>"suicide", "Dependency"=>"conjunct", "Tags"=>"noun"}, {"text"=>"of", "Dependency"=>"prepositional modifier", "Tags"=>"preposition or conjunction"}, {"text"=>"Dalit", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"scholar", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Rohith", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Vemula", "Dependency"=>"object of a preposition", "Tags"=>"noun"}, {"text"=>"at", "Dependency"=>"prepositional modifier", "Tags"=>"preposition or conjunction"}, {"text"=>"the", "Dependency"=>"determiner", "Tags"=>"determiner"}, {"text"=>"Hyderabad", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"Central", "Dependency"=>"compound", "Tags"=>"noun"}, {"text"=>"University", "Dependency"=>"object of a preposition", "Tags"=>"noun"}]}
118
125
 
119
126
  > usage()
120
127
  {
data/lib/paralleldots.rb CHANGED
@@ -48,7 +48,7 @@ def keywords( text )
48
48
  end
49
49
  response = RestClient.post "http://apis.paralleldots.com/v3/keywords", { api_key: api_key, text: text }
50
50
  response = JSON.parse( response )
51
- response = { "keywords": response, "usage": "By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions" }
51
+ response[ "usage" ] = "By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions"
52
52
  return response
53
53
  end
54
54
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paralleldots
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meghdeep Ray