aloha_analyzer 0.6.0 → 0.6.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d289f940c1715018a7e9108125f9759b4ba59324
|
|
4
|
+
data.tar.gz: 30b91b3430356376349099aceafedfc5c8ae463a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5bbb88cf518745ef0b3c8f84638444ca075806f730f6160f60dc6554edfb20db5a43a24d39e1bfd2222d4321838711953cbcc70552d7c9e62870e03930f4ca33
|
|
7
|
+
data.tar.gz: ae83dcf4cf74ab222ed8275c3e008d01102915e533899945cbe7aa19358b928988eb5ea0fa4b4220f4342422b71cf75a029078092fe15c24c01858772903a1ae
|
|
@@ -23,13 +23,15 @@ module AlohaAnalyzer
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def clean_languages(languages)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
Hash.new.tap do |cleaned_languages|
|
|
27
|
+
languages.each do |language_key, count|
|
|
28
|
+
abbreviation = Language.aliases[language_key.downcase]
|
|
29
|
+
abbreviation = Language.find_by_abbreviation(language_key.downcase, network_name)['abbreviation'] if abbreviation.nil?
|
|
30
|
+
|
|
31
|
+
if cleaned_languages[abbreviation]
|
|
32
|
+
cleaned_languages[abbreviation] += count
|
|
31
33
|
else
|
|
32
|
-
|
|
34
|
+
cleaned_languages[abbreviation] = count
|
|
33
35
|
end
|
|
34
36
|
end
|
|
35
37
|
end
|
|
@@ -24,7 +24,6 @@ languages:
|
|
|
24
24
|
abbreviation: 'ja'
|
|
25
25
|
name: Japanese
|
|
26
26
|
twitter_population: 106_580_000
|
|
27
|
-
facebook_population: 0
|
|
28
27
|
countries: 'Japan, Brazil'
|
|
29
28
|
greeting: '今日は!'
|
|
30
29
|
'es':
|
|
@@ -66,7 +65,6 @@ languages:
|
|
|
66
65
|
abbreviation: 'ko'
|
|
67
66
|
name: Korean
|
|
68
67
|
twitter_population: 7_000_000
|
|
69
|
-
facebook_population: 0
|
|
70
68
|
countries: 'South Korea'
|
|
71
69
|
greeting: '안녕하세요!'
|
|
72
70
|
'tr':
|
|
@@ -80,14 +78,12 @@ languages:
|
|
|
80
78
|
abbreviation: 'ru'
|
|
81
79
|
name: Russian
|
|
82
80
|
twitter_population: 5_000_000
|
|
83
|
-
facebook_population: 0
|
|
84
81
|
countries: 'Russia, Belarus, Kazakhstan, Kyrgyzstan'
|
|
85
82
|
greeting: 'привет!'
|
|
86
83
|
'nl':
|
|
87
84
|
abbreviation: 'nl'
|
|
88
85
|
name: Dutch
|
|
89
86
|
twitter_population: 8_000_000
|
|
90
|
-
facebook_population: 0
|
|
91
87
|
countries: 'Netherlands, Belgium'
|
|
92
88
|
greeting: 'hallo!'
|
|
93
89
|
'fil':
|
|
@@ -108,7 +104,6 @@ languages:
|
|
|
108
104
|
abbreviation: 'ms'
|
|
109
105
|
name: Malay
|
|
110
106
|
twitter_population: 50_000_000
|
|
111
|
-
facebook_population: 0
|
|
112
107
|
countries: 'Malaysia, Singapore, Brunei'
|
|
113
108
|
greeting: 'hello!'
|
|
114
109
|
'zh':
|
|
@@ -122,174 +117,148 @@ languages:
|
|
|
122
117
|
abbreviation: 'hi'
|
|
123
118
|
name: Hindi
|
|
124
119
|
twitter_population: 12_000_000
|
|
125
|
-
facebook_population: 0
|
|
126
120
|
countries: 'India, Pakistan, Fiji'
|
|
127
121
|
greeting: 'नमस्ते!'
|
|
128
122
|
'no':
|
|
129
123
|
abbreviation: 'no'
|
|
130
124
|
name: Norwegian
|
|
131
125
|
twitter_population: 300_000
|
|
132
|
-
facebook_population: 0
|
|
133
126
|
countries: 'Norway'
|
|
134
127
|
greeting: 'goddag!'
|
|
135
128
|
'sv':
|
|
136
129
|
abbreviation: 'sv'
|
|
137
130
|
name: Swedish
|
|
138
131
|
twitter_population: 500_000
|
|
139
|
-
facebook_population: 0
|
|
140
132
|
countries: 'Sweden'
|
|
141
133
|
greeting: 'god dag!'
|
|
142
134
|
'fi':
|
|
143
135
|
abbreviation: 'fi'
|
|
144
136
|
name: Finnish
|
|
145
137
|
twitter_population: 100_000
|
|
146
|
-
facebook_population: 0
|
|
147
138
|
countries: 'Finnish'
|
|
148
139
|
greeting: ' terve!'
|
|
149
140
|
'da':
|
|
150
141
|
abbreviation: 'da'
|
|
151
142
|
name: Danish
|
|
152
143
|
twitter_population: 200_000
|
|
153
|
-
facebook_population: 0
|
|
154
144
|
countries: 'Danish'
|
|
155
145
|
greeting: 'hej!'
|
|
156
146
|
'pl':
|
|
157
147
|
abbreviation: 'pl'
|
|
158
148
|
name: Polish
|
|
159
149
|
twitter_population: 300_000
|
|
160
|
-
facebook_population: 0
|
|
161
150
|
countries: 'Poland'
|
|
162
151
|
greeting: 'cześć!'
|
|
163
152
|
'hu':
|
|
164
153
|
abbreviation: 'hu'
|
|
165
154
|
name: Hungarian
|
|
166
155
|
twitter_population: 1_000_000
|
|
167
|
-
facebook_population: 0
|
|
168
156
|
countries: 'Hungary'
|
|
169
157
|
greeting: ' jó napot kívánok!'
|
|
170
158
|
'fa':
|
|
171
159
|
abbreviation: 'fa'
|
|
172
160
|
name: Farsi
|
|
173
161
|
twitter_population: 1_000_000
|
|
174
|
-
facebook_population: 0
|
|
175
162
|
countries: 'Iran, Afghanistan, Tajikistan'
|
|
176
163
|
greeting: ' سلام!'
|
|
177
164
|
'he':
|
|
178
165
|
abbreviation: 'he'
|
|
179
166
|
name: Hebrew
|
|
180
167
|
twitter_population: 1_000_000
|
|
181
|
-
facebook_population: 0
|
|
182
168
|
countries: 'Israel'
|
|
183
169
|
greeting: 'שלום!'
|
|
184
170
|
'ur':
|
|
185
171
|
abbreviation: 'ur'
|
|
186
172
|
name: Urdu
|
|
187
173
|
twitter_population: 1_000_000
|
|
188
|
-
facebook_population: 0
|
|
189
174
|
countries: 'India, Pakistan, Fiji'
|
|
190
175
|
greeting: 'لسلام علیکم!'
|
|
191
176
|
'th':
|
|
192
177
|
abbreviation: 'th'
|
|
193
178
|
name: Thai
|
|
194
179
|
twitter_population: 4_500_000
|
|
195
|
-
facebook_population: 0
|
|
196
180
|
countries: 'Thailand'
|
|
197
181
|
greeting: 'วัสดี!'
|
|
198
182
|
'uk':
|
|
199
183
|
abbreviation: 'uk'
|
|
200
184
|
name: Ukrainian
|
|
201
185
|
twitter_population: 1_000_000
|
|
202
|
-
facebook_population: 0
|
|
203
186
|
countries: 'Ukraine'
|
|
204
187
|
greeting: 'вітаю!'
|
|
205
188
|
'el':
|
|
206
189
|
abbreviation: 'el'
|
|
207
190
|
name: Greek
|
|
208
191
|
twitter_population: 1_000_000
|
|
209
|
-
facebook_population: 0
|
|
210
192
|
countries: 'Greece, Cyprus'
|
|
211
193
|
greeting: 'γειά!'
|
|
212
194
|
'cs':
|
|
213
195
|
abbreviation: 'cs'
|
|
214
196
|
name: Czech
|
|
215
197
|
twitter_population: 800_000
|
|
216
|
-
facebook_population: 0
|
|
217
198
|
countries: 'Czech Republic'
|
|
218
199
|
greeting: 'ahoj!'
|
|
219
200
|
'ro':
|
|
220
201
|
abbreviation: 'ro'
|
|
221
202
|
name: Romanian
|
|
222
203
|
twitter_population: 1_000_000
|
|
223
|
-
facebook_population: 0
|
|
224
204
|
countries: 'Romania, Serbia, Moldova'
|
|
225
205
|
greeting: 'salut!'
|
|
226
206
|
'km':
|
|
227
207
|
abbreviation: 'km'
|
|
228
208
|
name: Khmer
|
|
229
209
|
twitter_population: 100_000
|
|
230
|
-
facebook_population: 0
|
|
231
210
|
countries: 'Cambodia'
|
|
232
211
|
greeting: 'chomreabsuor!'
|
|
233
212
|
'is':
|
|
234
213
|
abbreviation: 'is'
|
|
235
214
|
name: Icelandic
|
|
236
215
|
twitter_population: 50_000
|
|
237
|
-
facebook_population: 0
|
|
238
216
|
countries: 'Iceland'
|
|
239
217
|
greeting: 'halló!'
|
|
240
218
|
'sr':
|
|
241
219
|
abbreviation: 'sr'
|
|
242
220
|
name: Serbian
|
|
243
221
|
twitter_population: 1_000_000
|
|
244
|
-
facebook_population: 0
|
|
245
222
|
countries: 'Serbia, Bosnia & Herzegovina'
|
|
246
223
|
greeting: 'здраво!'
|
|
247
224
|
'lt':
|
|
248
225
|
abbreviation: 'lt'
|
|
249
226
|
name: Lithuanian
|
|
250
227
|
twitter_population: 100_000
|
|
251
|
-
facebook_population: 0
|
|
252
228
|
countries: 'Lithuania, Belarus, Latvia, Poland'
|
|
253
229
|
greeting: 'sveiki!'
|
|
254
230
|
'vi':
|
|
255
231
|
abbreviation: 'vi'
|
|
256
232
|
name: 'Vietnamese'
|
|
257
233
|
twitter_population: 7_000_000
|
|
258
|
-
facebook_population: 0
|
|
259
234
|
countries: 'Vietnam'
|
|
260
235
|
greeting: 'chào!'
|
|
261
236
|
'sl':
|
|
262
237
|
abbreviation: 'sl'
|
|
263
238
|
name: 'Slovenian'
|
|
264
239
|
twitter_population: 50_000
|
|
265
|
-
facebook_population: 0
|
|
266
240
|
countries: 'Slovenia'
|
|
267
241
|
greeting: 'pozdravi!'
|
|
268
242
|
'bg':
|
|
269
243
|
abbreviation: 'bg'
|
|
270
244
|
name: 'Bulgarian'
|
|
271
245
|
twitter_population: 500_000
|
|
272
|
-
facebook_population: 0
|
|
273
246
|
countries: 'Bulgaria'
|
|
274
247
|
greeting: 'здравей!'
|
|
275
248
|
'lv':
|
|
276
249
|
abbreviation: 'lv'
|
|
277
250
|
name: 'Latvian'
|
|
278
251
|
twitter_population: 50_000
|
|
279
|
-
facebook_population: 0
|
|
280
252
|
countries: 'Latvia'
|
|
281
253
|
greeting: 'sveiki!'
|
|
282
254
|
'mk':
|
|
283
255
|
abbreviation: 'mk'
|
|
284
256
|
name: 'Macedonian'
|
|
285
257
|
twitter_population: 50_000
|
|
286
|
-
facebook_population: 0
|
|
287
258
|
countries: 'Macedonia, Albania, Romania, Serbia'
|
|
288
259
|
greeting: 'Здраво!'
|
|
289
260
|
'other':
|
|
290
261
|
abbreviation: 'other'
|
|
291
262
|
name: 'Other'
|
|
292
|
-
twitter_population: 0
|
|
293
|
-
facebook_population: 0
|
|
294
263
|
countries: ''
|
|
295
264
|
greeting: ''
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe AlohaAnalyzer::FacebookPage do
|
|
4
|
-
# {"tr_TR"=>3677, "en_US"=>89, "ka_GE"=>49, "en_GB"=>44, "az_AZ"=>39, "fr_FR"=>35, "bg_BG"=>28, "ru_RU"=>20, "de_DE"=>19, "ar_AR"=>8, "fr_CA"=>6, "es_LA"=>6, "nl_NL"=>4, "sq_AL"=>3, "pl_PL"=>2, "pt_BR"=>2, "es_ES"=>2, "it_IT"=>2, "lt_LT"=>1, "da_DK"=>1, "cs_CZ"=>1, "el_GR"=>1, "sr_RS"=>1, "et_EE"=>1, "mk_MK"=>1, "en_IN"=>1, "pt_PT"=>1, "jv_ID"=>1}
|
|
5
4
|
subject(:facebook_page) { described_class.new(options) }
|
|
6
5
|
let(:language) { 'en' }
|
|
7
6
|
let(:options) do
|
|
@@ -12,6 +11,11 @@ describe AlohaAnalyzer::FacebookPage do
|
|
|
12
11
|
end
|
|
13
12
|
let(:analysis) { nil }
|
|
14
13
|
|
|
14
|
+
it 'returns a returns' do
|
|
15
|
+
languages = {"tr_TR"=>3677, "en_US"=>89, "ka_GE"=>49, "en_GB"=>44, "az_AZ"=>39, "fr_FR"=>35, "bg_BG"=>28, "ru_RU"=>20, "de_DE"=>19, "ar_AR"=>8, "fr_CA"=>6, "es_LA"=>6, "nl_NL"=>4, "sq_AL"=>3, "pl_PL"=>2, "pt_BR"=>2, "es_ES"=>2, "it_IT"=>2, "lt_LT"=>1, "da_DK"=>1, "cs_CZ"=>1, "el_GR"=>1, "sr_RS"=>1, "et_EE"=>1, "mk_MK"=>1, "en_IN"=>1, "pt_PT"=>1, "jv_ID"=>1}
|
|
16
|
+
expect(subject.analyze(languages)).to be_a Hash
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
describe '#new' do
|
|
16
20
|
context 'when language is british' do
|
|
17
21
|
let(:language) { 'en-gb' }
|
|
@@ -173,6 +177,43 @@ describe AlohaAnalyzer::FacebookPage do
|
|
|
173
177
|
end
|
|
174
178
|
end
|
|
175
179
|
|
|
180
|
+
context 'when unknown language' do
|
|
181
|
+
let(:users) do
|
|
182
|
+
{
|
|
183
|
+
'unknown' => 1,
|
|
184
|
+
'something' => 1,
|
|
185
|
+
'fr' => 2
|
|
186
|
+
}
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it 'returns a hash' do
|
|
190
|
+
expect(subject).to be_a Hash
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it 'includes the total count' do
|
|
194
|
+
expect(subject['count']).to eq 4
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it 'includes the correct foreign_languages_count' do
|
|
198
|
+
expect(subject['foreign_languages_count']).to eq 4
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
it 'returns results results based on the non user language' do
|
|
202
|
+
expect(subject['foreign_languages']).to eq(
|
|
203
|
+
'fr' => {
|
|
204
|
+
'count' => 2,
|
|
205
|
+
'language' => { 'abbreviation'=>'fr', 'name'=>'French', 'greeting'=>'bonjour!', 'population'=>45000000, 'countries' => 'France, Canada, Belgium, Switzerland' },
|
|
206
|
+
'users' => []
|
|
207
|
+
},
|
|
208
|
+
'other' => {
|
|
209
|
+
'count' => 2,
|
|
210
|
+
'language' => {'abbreviation'=>'other', 'name'=>'Other', 'greeting'=>'', 'population'=>nil, 'countries' => '' },
|
|
211
|
+
'users' => []
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
176
217
|
context 'when no users language users' do
|
|
177
218
|
let(:users) do
|
|
178
219
|
{
|
|
@@ -222,7 +263,7 @@ describe AlohaAnalyzer::FacebookPage do
|
|
|
222
263
|
{
|
|
223
264
|
'en' => 1,
|
|
224
265
|
'en_US' => 1,
|
|
225
|
-
'
|
|
266
|
+
'fr_CA' => 1
|
|
226
267
|
}
|
|
227
268
|
end
|
|
228
269
|
|