ark_tweet_nlp 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ark_tweet_nlp/parser.rb +4 -1
- data/lib/ark_tweet_nlp/version.rb +1 -1
- data/spec/parser_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e871d9a343c2765aa5ffe330399d65186a8f53d
|
4
|
+
data.tar.gz: e38987b047782875d9da857935b0570fda9ed8fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96f63bbdd0534f4b63a5a93c96c5d14702ea572c2286febc45dccda9ee6844c0070e878286557bb66dc2a6c89bc34cc146cf75095d48a99324f82d1efff09c54
|
7
|
+
data.tar.gz: 5f709d7f6ef82b0942cad0380afc827d4c080ea9acc9f5ec6294797691a893f1582e820a2c66636ea10d5fc5edb2b4149dcc19c488e838e57e1d34e8b6aa82b7
|
data/lib/ark_tweet_nlp/parser.rb
CHANGED
@@ -45,7 +45,10 @@ module ArkTweetNlp
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def Parser.get_words_tagged_as tagged_result, *tags
|
48
|
-
|
48
|
+
tagged_result.inject({}) do |acum,m|
|
49
|
+
m.each{ |key, value| acum[value] == nil ? acum[value] = Array.new( [key] ) : acum[value] << key }
|
50
|
+
acum
|
51
|
+
end.select{ |m| tags.include?( m ) }
|
49
52
|
end
|
50
53
|
|
51
54
|
private
|
data/spec/parser_spec.rb
CHANGED
@@ -27,15 +27,15 @@ describe ArkTweetNlp::Parser do
|
|
27
27
|
describe '#get_words_tagged_as' do
|
28
28
|
it "returns only the words that where tagged with the specified tags" do
|
29
29
|
tagged_result =[{'faceboooooooook' => :^,'is' => :V,'awesome' => :A}]
|
30
|
-
expect(ArkTweetNlp::Parser.get_words_tagged_as(tagged_result, :A)).to eq(:A
|
30
|
+
expect(ArkTweetNlp::Parser.get_words_tagged_as(tagged_result, :A)).to eq({:A=>["awesome"]} )
|
31
31
|
end
|
32
32
|
it "supports multiple tags" do
|
33
33
|
tagged_result = [{'faceboooooooook' => :^,'is' => :V,'awesome' => :A}]
|
34
|
-
expect(ArkTweetNlp::Parser.get_words_tagged_as(tagged_result, :A,:V,:^)).to eq(
|
34
|
+
expect(ArkTweetNlp::Parser.get_words_tagged_as(tagged_result, :A,:V,:^)).to eq({:^ => ["faceboooooooook"], :V => ["is"], :A => ["awesome"]})
|
35
35
|
end
|
36
36
|
it "supports muliple hashes" do
|
37
37
|
tagged_result = [{'faceboooooooook' => :^,'is' => :V,'awesome' => :A},{'faceboooooooook' => :^,'is' => :V,'awesome' => :A, 'blossom' => :A}]
|
38
|
-
expect(ArkTweetNlp::Parser.get_words_tagged_as(tagged_result, :A,:V,:^)).to eq(
|
38
|
+
expect(ArkTweetNlp::Parser.get_words_tagged_as(tagged_result, :A,:V,:^)).to eq({:^ => ["faceboooooooook", "faceboooooooook"], :V => ["is", "is"], :A => ["awesome", "awesome", "blossom"]})
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|