duck-duck-go 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,825 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'test/unit'
4
+ require 'duck_duck_go/zero_click_info'
5
+ require 'uri'
6
+
7
+ class TestZCI < Test::Unit::TestCase
8
+
9
+ def test_zci_article
10
+
11
+ # example data - a search for Stephen Fry
12
+ data = {"AbstractSource"=>"Wikipedia",
13
+ "Answer"=>"",
14
+ "Definition"=>"",
15
+ "Results"=>
16
+ [{"Text"=>"Official site",
17
+ "Icon"=>
18
+ {"URL"=>"http://i.duck.co/i/stephenfry.com.ico",
19
+ "Width"=>16,
20
+ "Height"=>16},
21
+ "Result"=>
22
+ "<a href=\"http://www.stephenfry.com\"><b>Official site</b></a><a href=\"http://www.stephenfry.com\"></a>",
23
+ "FirstURL"=>"http://www.stephenfry.com"},
24
+ {"Text"=>
25
+ "Five Minutes With: Stephen Fry, interview with Matthew Stadlen for the BBC",
26
+ "Icon"=>
27
+ {"URL"=>"http://i.duck.co/i/news.bbc.co.uk.ico",
28
+ "Width"=>16,
29
+ "Height"=>16},
30
+ "Result"=>
31
+ "<a href=\"http://news.bbc.co.uk/1/hi/entertainment/7895351.stm\">Five Minutes With: Stephen Fry</a><a href=\"http://news.bbc.co.uk/1/hi/entertainment/7895351.stm\">, interview with Matthew Stadlen for the BBC</a>",
32
+ "FirstURL"=>"http://news.bbc.co.uk/1/hi/entertainment/7895351.stm"}],
33
+ "AnswerType"=>"",
34
+ "Abstract"=>
35
+ "Stephen John Fry is an English actor, screenwriter, author, playwright, journalist, poet, comedian, television presenter and film director, and a director of Norwich City Football Club.",
36
+ "Heading"=>"Stephen Fry",
37
+ "RelatedTopics"=>
38
+ [{"Text"=>"Stephen Fry (cricketer) - Stephen Fry was an English cricketer.",
39
+ "Icon"=>{},
40
+ "Result"=>
41
+ "<a href=\"http://duckduckgo.com/Stephen_Fry_(cricketer)\">Stephen Fry (cricketer)</a> - Stephen Fry was an English cricketer.",
42
+ "FirstURL"=>"http://duckduckgo.com/Stephen_Fry_(cricketer)"},
43
+ {"Text"=>"English podcasters",
44
+ "Icon"=>{},
45
+ "Result"=>
46
+ "<a href=\"http://duckduckgo.com/c/English_podcasters\">English podcasters</a>",
47
+ "FirstURL"=>"http://duckduckgo.com/c/English_podcasters"},
48
+ {"Text"=>"Rectors of the University of Dundee",
49
+ "Icon"=>{},
50
+ "Result"=>
51
+ "<a href=\"http://duckduckgo.com/c/Rectors_of_the_University_of_Dundee\">Rectors of the University of Dundee</a>",
52
+ "FirstURL"=>"http://duckduckgo.com/c/Rectors_of_the_University_of_Dundee"},
53
+ {"Text"=>"Real people associated with the Harry Potter books",
54
+ "Icon"=>{},
55
+ "Result"=>
56
+ "<a href=\"http://duckduckgo.com/c/Real_people_associated_with_the_Harry_Potter_books\">Real people associated with the Harry Potter books</a>",
57
+ "FirstURL"=>
58
+ "http://duckduckgo.com/c/Real_people_associated_with_the_Harry_Potter_books"},
59
+ {"Text"=>"Sidewise Award winning authors",
60
+ "Icon"=>{},
61
+ "Result"=>
62
+ "<a href=\"http://duckduckgo.com/c/Sidewise_Award_winning_authors\">Sidewise Award winning authors</a>",
63
+ "FirstURL"=>"http://duckduckgo.com/c/Sidewise_Award_winning_authors"},
64
+ {"Text"=>"British actors of Hungarian descent",
65
+ "Icon"=>{},
66
+ "Result"=>
67
+ "<a href=\"http://duckduckgo.com/c/British_actors_of_Hungarian_descent\">British actors of Hungarian descent</a>",
68
+ "FirstURL"=>"http://duckduckgo.com/c/British_actors_of_Hungarian_descent"},
69
+ {"Text"=>"University Challenge contestants",
70
+ "Icon"=>{},
71
+ "Result"=>
72
+ "<a href=\"http://duckduckgo.com/c/University_Challenge_contestants\">University Challenge contestants</a>",
73
+ "FirstURL"=>"http://duckduckgo.com/c/University_Challenge_contestants"},
74
+ {"Text"=>"English radio writers",
75
+ "Icon"=>{},
76
+ "Result"=>
77
+ "<a href=\"http://duckduckgo.com/c/English_radio_writers\">English radio writers</a>",
78
+ "FirstURL"=>"http://duckduckgo.com/c/English_radio_writers"},
79
+ {"Text"=>"English humanists",
80
+ "Icon"=>{},
81
+ "Result"=>
82
+ "<a href=\"http://duckduckgo.com/c/English_humanists\">English humanists</a>",
83
+ "FirstURL"=>"http://duckduckgo.com/c/English_humanists"},
84
+ {"Text"=>"English game show hosts",
85
+ "Icon"=>{},
86
+ "Result"=>
87
+ "<a href=\"http://duckduckgo.com/c/English_game_show_hosts\">English game show hosts</a>",
88
+ "FirstURL"=>"http://duckduckgo.com/c/English_game_show_hosts"},
89
+ {"Text"=>"Alternate history writers",
90
+ "Icon"=>{},
91
+ "Result"=>
92
+ "<a href=\"http://duckduckgo.com/c/Alternate_history_writers\">Alternate history writers</a>",
93
+ "FirstURL"=>"http://duckduckgo.com/c/Alternate_history_writers"},
94
+ {"Text"=>"People associated with the University of Dundee",
95
+ "Icon"=>{},
96
+ "Result"=>
97
+ "<a href=\"http://duckduckgo.com/c/People_associated_with_the_University_of_Dundee\">People associated with the University of Dundee</a>",
98
+ "FirstURL"=>
99
+ "http://duckduckgo.com/c/People_associated_with_the_University_of_Dundee"},
100
+ {"Text"=>"English comedy writers",
101
+ "Icon"=>{},
102
+ "Result"=>
103
+ "<a href=\"http://duckduckgo.com/c/English_comedy_writers\">English comedy writers</a>",
104
+ "FirstURL"=>"http://duckduckgo.com/c/English_comedy_writers"},
105
+ {"Text"=>"Old Uppinghamians",
106
+ "Icon"=>{},
107
+ "Result"=>
108
+ "<a href=\"http://duckduckgo.com/c/Old_Uppinghamians\">Old Uppinghamians</a>",
109
+ "FirstURL"=>"http://duckduckgo.com/c/Old_Uppinghamians"},
110
+ {"Text"=>"Audio book narrators",
111
+ "Icon"=>{},
112
+ "Result"=>
113
+ "<a href=\"http://duckduckgo.com/c/Audio_book_narrators\">Audio book narrators</a>",
114
+ "FirstURL"=>"http://duckduckgo.com/c/Audio_book_narrators"},
115
+ {"Text"=>"People from Hampstead",
116
+ "Icon"=>{},
117
+ "Result"=>
118
+ "<a href=\"http://duckduckgo.com/c/People_from_Hampstead\">People from Hampstead</a>",
119
+ "FirstURL"=>"http://duckduckgo.com/c/People_from_Hampstead"},
120
+ {"Text"=>"Atheism activists",
121
+ "Icon"=>{},
122
+ "Result"=>
123
+ "<a href=\"http://duckduckgo.com/c/Atheism_activists\">Atheism activists</a>",
124
+ "FirstURL"=>"http://duckduckgo.com/c/Atheism_activists"},
125
+ {"Text"=>"LGBT television personalities",
126
+ "Icon"=>{},
127
+ "Result"=>
128
+ "<a href=\"http://duckduckgo.com/c/LGBT_television_personalities\">LGBT television personalities</a>",
129
+ "FirstURL"=>"http://duckduckgo.com/c/LGBT_television_personalities"},
130
+ {"Text"=>
131
+ "Outstanding Performance by a Cast in a Motion Picture Screen Actors Guild Award winners",
132
+ "Icon"=>{},
133
+ "Result"=>
134
+ "<a href=\"http://duckduckgo.com/c/Outstanding_Performance_by_a_Cast_in_a_Motion_Picture_Screen_Actors_Guild_Award_winners\">Outstanding Performance by a Cast in a Motion Picture Screen Actors Guild Award winners</a>",
135
+ "FirstURL"=>
136
+ "http://duckduckgo.com/c/Outstanding_Performance_by_a_Cast_in_a_Motion_Picture_Screen_Actors_Guild_Award_winners"},
137
+ {"Text"=>"Jewish atheists",
138
+ "Icon"=>{},
139
+ "Result"=>
140
+ "<a href=\"http://duckduckgo.com/c/Jewish_atheists\">Jewish atheists</a>",
141
+ "FirstURL"=>"http://duckduckgo.com/c/Jewish_atheists"},
142
+ {"Text"=>"English atheists",
143
+ "Icon"=>{},
144
+ "Result"=>
145
+ "<a href=\"http://duckduckgo.com/c/English_atheists\">English atheists</a>",
146
+ "FirstURL"=>"http://duckduckgo.com/c/English_atheists"},
147
+ {"Text"=>"Alumni of Queens' College, Cambridge",
148
+ "Icon"=>{},
149
+ "Result"=>
150
+ "<a href=\"http://duckduckgo.com/c/Alumni_of_Queens'_College%2C_Cambridge\">Alumni of Queens' College, Cambridge</a>",
151
+ "FirstURL"=>
152
+ "http://duckduckgo.com/c/Alumni_of_Queens'_College%2C_Cambridge"},
153
+ {"Text"=>"English television writers",
154
+ "Icon"=>{},
155
+ "Result"=>
156
+ "<a href=\"http://duckduckgo.com/c/English_television_writers\">English television writers</a>",
157
+ "FirstURL"=>"http://duckduckgo.com/c/English_television_writers"},
158
+ {"Text"=>"People with bipolar disorder",
159
+ "Icon"=>{},
160
+ "Result"=>
161
+ "<a href=\"http://duckduckgo.com/c/People_with_bipolar_disorder\">People with bipolar disorder</a>",
162
+ "FirstURL"=>"http://duckduckgo.com/c/People_with_bipolar_disorder"},
163
+ {"Text"=>"English film directors",
164
+ "Icon"=>{},
165
+ "Result"=>
166
+ "<a href=\"http://duckduckgo.com/c/English_film_directors\">English film directors</a>",
167
+ "FirstURL"=>"http://duckduckgo.com/c/English_film_directors"},
168
+ {"Text"=>"English comedians",
169
+ "Icon"=>{},
170
+ "Result"=>
171
+ "<a href=\"http://duckduckgo.com/c/English_comedians\">English comedians</a>",
172
+ "FirstURL"=>"http://duckduckgo.com/c/English_comedians"}],
173
+ "AbstractURL"=>"http://en.wikipedia.org/wiki/Stephen_Fry",
174
+ "Image"=>"http://i.duck.co/i/72880df1.jpg",
175
+ "DefinitionURL"=>"",
176
+ "DefinitionSource"=>"",
177
+ "AbstractText"=>
178
+ "Stephen John Fry is an English actor, screenwriter, author, playwright, journalist, poet, comedian, television presenter and film director, and a director of Norwich City Football Club.",
179
+ "Type"=>"A"}
180
+
181
+
182
+ zci = DuckDuckGo::ZeroClickInfo.by(data)
183
+
184
+ assert_equal("Stephen Fry", zci.heading)
185
+ assert_equal("Wikipedia", zci.abstract_source)
186
+ assert_instance_of(URI::HTTP, zci.image)
187
+ assert_equal('i.duck.co', zci.image.host)
188
+ assert_equal("Stephen John Fry is an English actor, screenwriter, author, playwright, journalist, poet, comedian, television presenter and film director, and a director of Norwich City Football Club.", zci.abstract_text)
189
+ assert_equal("Stephen John Fry is an English actor, screenwriter, author, playwright, journalist, poet, comedian, television presenter and film director, and a director of Norwich City Football Club.", zci.abstract)
190
+ assert_nil(zci.answer_type)
191
+ assert_equal("A", zci.type)
192
+ assert_equal("article", zci.type_long)
193
+ assert_nil(zci.definition_url)
194
+ assert_nil(zci.answer)
195
+ assert_instance_of(URI::HTTP, zci.abstract_url)
196
+ assert_equal('en.wikipedia.org', zci.abstract_url.host)
197
+ assert_equal(2, zci.results.size)
198
+ assert_equal("Official site", zci.results[0].text)
199
+ assert_equal(1, zci.related_topics.size)
200
+ assert_equal(26, zci.related_topics["_"].size)
201
+ assert_equal("Stephen Fry (cricketer) - Stephen Fry was an English cricketer.", zci.related_topics["_"][0].text)
202
+ end
203
+
204
+ def test_zci_disambiguation
205
+
206
+ data = {"AbstractSource"=>"Wikipedia",
207
+ "Answer"=>"",
208
+ "Definition"=>
209
+ "A deciduous Eurasian tree having alternate simple leaves and white or pink flowers.",
210
+ "Results"=>[],
211
+ "AnswerType"=>"",
212
+ "Abstract"=>"",
213
+ "Heading"=>"Apple",
214
+ "RelatedTopics"=>
215
+ [{"Text"=>"The apple is a tree and its pomaceous fruit.",
216
+ "Icon"=>{"URL"=>"http://i.duck.co/i/b5c79bb9.jpg"},
217
+ "Result"=>
218
+ "The <a href=\"http://duckduckgo.com/apple\">apple</a> is a tree and its pomaceous fruit.",
219
+ "FirstURL"=>"http://duckduckgo.com/apple"},
220
+ {"Name"=>"Companies",
221
+ "Topics"=>
222
+ [{"Text"=>"Apple Inc., a consumer electronics and software company",
223
+ "Icon"=>{"URL"=>"http://i.duck.co/i/794fb31f.png"},
224
+ "Result"=>
225
+ "<a href=\"http://duckduckgo.com/Apple_Inc.\">Apple Inc.</a>, a consumer electronics and software company",
226
+ "FirstURL"=>"http://duckduckgo.com/Apple_Inc."},
227
+ {"Text"=>"Apple Corps, a multimedia corporation founded by The Beatles",
228
+ "Icon"=>{"URL"=>"http://i.duck.co/i/9e15faeb.jpg"},
229
+ "Result"=>
230
+ "<a href=\"http://duckduckgo.com/Apple_Corps\">Apple Corps</a>, a multimedia corporation founded by The Beatles",
231
+ "FirstURL"=>"http://duckduckgo.com/Apple_Corps"}]},
232
+ {"Name"=>"Films",
233
+ "Topics"=>
234
+ [{"Text"=>"The Apple (1980 film), a 1980 musical science fiction film",
235
+ "Icon"=>{"URL"=>"http://i.duck.co/i/ca3778cb.jpg"},
236
+ "Result"=>
237
+ "<a href=\"http://duckduckgo.com/The_Apple_(1980_film)\"><i>The Apple</i> (1980 film)</a>, a 1980 musical science fiction film",
238
+ "FirstURL"=>"http://duckduckgo.com/The_Apple_(1980_film)"},
239
+ {"Text"=>"The Apple (1998 film), by Samira Makhmalbaf",
240
+ "Icon"=>{"URL"=>"http://i.duck.co/i/51c5a500.jpg"},
241
+ "Result"=>
242
+ "<a href=\"http://duckduckgo.com/The_Apple_(1998_film)\"><i>The Apple</i> (1998 film)</a>, by Samira Makhmalbaf",
243
+ "FirstURL"=>"http://duckduckgo.com/The_Apple_(1998_film)"}]},
244
+ {"Name"=>"Television",
245
+ "Topics"=>
246
+ [{"Text"=>
247
+ "\"The Apple\" (Star Trek: The Original Series), a second season episode",
248
+ "Icon"=>{"URL"=>"http://i.duck.co/i/7fc88794.jpg"},
249
+ "Result"=>
250
+ "<a href=\"http://duckduckgo.com/The_Apple_(Star_Trek%3A_The_Original_Series)\">\"The Apple\" (<i>Star Trek: The Original Series</i>)</a>, a second season episode",
251
+ "FirstURL"=>
252
+ "http://duckduckgo.com/The_Apple_(Star_Trek%3A_The_Original_Series)"}]},
253
+ {"Name"=>"Music",
254
+ "Topics"=>
255
+ [{"Text"=>"Apple (album), an album by Mother Love Bone",
256
+ "Icon"=>{"URL"=>"http://i.duck.co/i/9ca01bdb.jpg"},
257
+ "Result"=>
258
+ "<a href=\"http://duckduckgo.com/Apple_(album)\"><i>Apple</i> (album)</a>, an album by Mother Love Bone",
259
+ "FirstURL"=>"http://duckduckgo.com/Apple_(album)"},
260
+ {"Text"=>"Apple (band), a British psychedelic rock band",
261
+ "Icon"=>{},
262
+ "Result"=>
263
+ "<a href=\"http://duckduckgo.com/Apple_(band)\">Apple (band)</a>, a British psychedelic rock band",
264
+ "FirstURL"=>"http://duckduckgo.com/Apple_(band)"},
265
+ {"Text"=>"The Apples, an early 90s Scottish indie-dance band",
266
+ "Icon"=>{},
267
+ "Result"=>
268
+ "<a href=\"http://duckduckgo.com/The_Apples\">The Apples</a>, an early 90s Scottish indie-dance band",
269
+ "FirstURL"=>"http://duckduckgo.com/The_Apples"},
270
+ {"Text"=>"The Apples (Israeli), a mid 2000s Israeli funk band",
271
+ "Icon"=>{},
272
+ "Result"=>
273
+ "<a href=\"http://duckduckgo.com/The_Apples_(Israeli)\">The Apples (Israeli)</a>, a mid 2000s Israeli funk band",
274
+ "FirstURL"=>"http://duckduckgo.com/The_Apples_(Israeli)"},
275
+ {"Text"=>"Apple Records, record label founded by The Beatles",
276
+ "Icon"=>{"URL"=>"http://i.duck.co/i/9e15faeb.jpg"},
277
+ "Result"=>
278
+ "<a href=\"http://duckduckgo.com/Apple_Records\">Apple Records</a>, record label founded by The Beatles",
279
+ "FirstURL"=>"http://duckduckgo.com/Apple_Records"}]},
280
+ {"Name"=>"People",
281
+ "Topics"=>
282
+ [{"Text"=>
283
+ "Apple Martin, the daughter of Gwyneth Paltrow and Chris Martin",
284
+ "Icon"=>{"URL"=>"http://i.duck.co/i/f762256a.jpg"},
285
+ "Result"=>
286
+ "Apple Martin, the daughter of <a href=\"http://duckduckgo.com/Gwyneth_Paltrow\">Gwyneth Paltrow</a> and <a href=\"http://duckduckgo.com/?q=Chris Martin\">Chris Martin</a>",
287
+ "FirstURL"=>"http://duckduckgo.com/Gwyneth_Paltrow"},
288
+ {"Text"=>"Billy Apple, artist",
289
+ "Icon"=>{},
290
+ "Result"=>
291
+ "<a href=\"http://duckduckgo.com/Billy_Apple\">Billy Apple</a>, artist",
292
+ "FirstURL"=>"http://duckduckgo.com/Billy_Apple"},
293
+ {"Text"=>
294
+ "Fiona Apple, a Grammy award winning American singer-songwriter",
295
+ "Icon"=>{"URL"=>"http://i.duck.co/i/f5f38669.jpg"},
296
+ "Result"=>
297
+ "<a href=\"http://duckduckgo.com/Fiona_Apple\">Fiona Apple</a>, a Grammy award winning American singer-songwriter",
298
+ "FirstURL"=>"http://duckduckgo.com/Fiona_Apple"},
299
+ {"Text"=>"Raymond Apple (rabbi), from Australia",
300
+ "Icon"=>{},
301
+ "Result"=>
302
+ "<a href=\"http://duckduckgo.com/Raymond_Apple_(rabbi)\">Raymond Apple (rabbi)</a>, from Australia",
303
+ "FirstURL"=>"http://duckduckgo.com/Raymond_Apple_(rabbi)"},
304
+ {"Text"=>
305
+ "Constance M. K. Applebee (1873\342\200\2231981), athlete, known as \"The Apple\"",
306
+ "Icon"=>{},
307
+ "Result"=>
308
+ "<a href=\"http://duckduckgo.com/Constance_M._K._Applebee\">Constance M. K. Applebee</a> (1873\342\200\2231981), athlete, known as \"The Apple\"",
309
+ "FirstURL"=>"http://duckduckgo.com/Constance_M._K._Applebee"}]},
310
+ {"Name"=>"Places",
311
+ "Topics"=>
312
+ [{"Text"=>"Apple River Meanings",
313
+ "Icon"=>{},
314
+ "Result"=>
315
+ "<a href=\"http://duckduckgo.com/d/Apple_River\">Apple River Meanings</a>",
316
+ "FirstURL"=>"http://duckduckgo.com/d/Apple_River"},
317
+ {"Text"=>"Apple Valley Meanings",
318
+ "Icon"=>{},
319
+ "Result"=>
320
+ "<a href=\"http://duckduckgo.com/d/Apple_Valley\">Apple Valley Meanings</a>",
321
+ "FirstURL"=>"http://duckduckgo.com/d/Apple_Valley"},
322
+ {"Text"=>"Big Apple, nickname for New York City",
323
+ "Icon"=>{"URL"=>"http://i.duck.co/i/a8cb4202.jpg"},
324
+ "Result"=>
325
+ "<a href=\"http://duckduckgo.com/Big_Apple\">Big Apple</a>, nickname for New York City",
326
+ "FirstURL"=>"http://duckduckgo.com/Big_Apple"}]},
327
+ {"Name"=>"Technology",
328
+ "Topics"=>
329
+ [{"Text"=>
330
+ "Apple I - The Apple I, also known as the Apple-1, was an early personal computer.",
331
+ "Icon"=>{"URL"=>"http://i.duck.co/i/020104f2.jpg"},
332
+ "Result"=>
333
+ "<a href=\"http://duckduckgo.com/Apple_I\">Apple I</a> - The Apple I, also known as the Apple-1, was an early personal computer.",
334
+ "FirstURL"=>"http://duckduckgo.com/Apple_I"},
335
+ {"Text"=>
336
+ "Apple II - The Apple II is an 8-bit home computer, one of the first highly successful mass-produced microcomputer products, designed primarily by Steve Wozniak, manufactured by Apple Computer and introduce...",
337
+ "Icon"=>{"URL"=>"http://i.duck.co/i/e96a6b64.jpg"},
338
+ "Result"=>
339
+ "<a href=\"http://duckduckgo.com/Apple_II_series\">Apple II</a> - The Apple II is an 8-bit home computer, one of the first highly successful mass-produced microcomputer products, designed primarily by Steve Wozniak, manufactured by Apple Computer and introduce...",
340
+ "FirstURL"=>"http://duckduckgo.com/Apple_II_series"},
341
+ {"Text"=>
342
+ "Apple III - The Apple III is a business-oriented personal computer produced and released by Apple Computer and was intended as the successor to the Apple II series, but largely considered a failure in the m...",
343
+ "Icon"=>{"URL"=>"http://i.duck.co/i/3702da39.jpg"},
344
+ "Result"=>
345
+ "<a href=\"http://duckduckgo.com/Apple_III\">Apple III</a> - The Apple III is a business-oriented personal computer produced and released by Apple Computer and was intended as the successor to the Apple II series, but largely considered a failure in the m...",
346
+ "FirstURL"=>"http://duckduckgo.com/Apple_III"},
347
+ {"Text"=>
348
+ "APPLE (Ariane Passenger Payload Experiment), an Indian experimental communication satellite launched in 1981",
349
+ "Icon"=>{},
350
+ "Result"=>
351
+ "APPLE (<a href=\"http://duckduckgo.com/Ariane_Passenger_Payload_Experiment\">Ariane Passenger Payload Experiment</a>), an Indian experimental communication satellite launched in 1981",
352
+ "FirstURL"=>
353
+ "http://duckduckgo.com/Ariane_Passenger_Payload_Experiment"},
354
+ {"Text"=>
355
+ "Apple (automobile), an American automobile manufactured by Apple Automobile Company from 1917 to 1918",
356
+ "Icon"=>{},
357
+ "Result"=>
358
+ "<a href=\"http://duckduckgo.com/Apple_(automobile)\">Apple (automobile)</a>, an American automobile manufactured by Apple Automobile Company from 1917 to 1918",
359
+ "FirstURL"=>"http://duckduckgo.com/Apple_(automobile)"}]},
360
+ {"Name"=>"Other uses",
361
+ "Topics"=>
362
+ [{"Text"=>
363
+ "APPLE (Accumulation Program for Part-time and Limited-service Employees), a deferred compensation program in California",
364
+ "Icon"=>{},
365
+ "Result"=>
366
+ "APPLE (Accumulation Program for Part-time and Limited-service Employees), a <a href=\"http://duckduckgo.com/deferred_compensation\">deferred compensation</a> program in California",
367
+ "FirstURL"=>"http://duckduckgo.com/deferred_compensation"},
368
+ {"Text"=>
369
+ "Apples (card game) - Apples is a 4-player trick-based game similar in play to hearts, spades, and bridge.",
370
+ "Icon"=>{},
371
+ "Result"=>
372
+ "<a href=\"http://duckduckgo.com/Apples_(card_game)\">Apples (card game)</a> - Apples is a 4-player trick-based game similar in play to hearts, spades, and bridge.",
373
+ "FirstURL"=>"http://duckduckgo.com/Apples_(card_game)"},
374
+ {"Text"=>
375
+ "Apple Cup, the annual college football game between state rivals the University of Washington and Washington State University",
376
+ "Icon"=>{},
377
+ "Result"=>
378
+ "<a href=\"http://duckduckgo.com/Apple_Cup\">Apple Cup</a>, the annual college football game between state rivals the University of Washington and Washington State University",
379
+ "FirstURL"=>"http://duckduckgo.com/Apple_Cup"},
380
+ {"Text"=>"Apple Daily, a Hong-Kong-based newspaper",
381
+ "Icon"=>{"URL"=>"http://i.duck.co/i/a220d44b.jpg"},
382
+ "Result"=>
383
+ "<i><a href=\"http://duckduckgo.com/Apple_Daily\">Apple Daily</a></i>, a Hong-Kong-based newspaper",
384
+ "FirstURL"=>"http://duckduckgo.com/Apple_Daily"},
385
+ {"Text"=>
386
+ "Apple (symbolism) - Apples appear in many religious traditions, often as a mystical or forbidden fruit.",
387
+ "Icon"=>{"URL"=>"http://i.duck.co/i/b58eb2b4.jpg"},
388
+ "Result"=>
389
+ "<a href=\"http://duckduckgo.com/Apple_(symbolism)\">Apple (symbolism)</a> - Apples appear in many religious traditions, often as a mystical or forbidden fruit.",
390
+ "FirstURL"=>"http://duckduckgo.com/Apple_(symbolism)"},
391
+ {"Text"=>"Apples, Vaud, a municipality in Switzerland",
392
+ "Icon"=>{"URL"=>"http://i.duck.co/i/88722dce.png"},
393
+ "Result"=>
394
+ "<a href=\"http://duckduckgo.com/Apples%2C_Vaud\">Apples, Vaud</a>, a municipality in Switzerland",
395
+ "FirstURL"=>"http://duckduckgo.com/Apples%2C_Vaud"}]},
396
+ {"Name"=>"See also",
397
+ "Topics"=>
398
+ [{"Text"=>"Apple shape, one of the four basic female body shapes",
399
+ "Icon"=>{"URL"=>"http://i.duck.co/i/458fcf42.jpg"},
400
+ "Result"=>
401
+ "Apple shape, one of the four basic <a href=\"http://duckduckgo.com/female_body_shape\">female body shape</a>s",
402
+ "FirstURL"=>"http://duckduckgo.com/female_body_shape"},
403
+ {"Text"=>
404
+ "Apple Store (online) - The Apple Store is the online store of Apple Inc.. All of Apple's product lines are carried as well as select brands of accessories for its products.",
405
+ "Icon"=>{},
406
+ "Result"=>
407
+ "<a href=\"http://duckduckgo.com/Apple_Store_(online)\">Apple Store (online)</a> - The Apple Store is the online store of Apple Inc.. All of Apple's product lines are carried as well as select brands of accessories for its products.",
408
+ "FirstURL"=>"http://duckduckgo.com/Apple_Store_(online)"},
409
+ {"Text"=>"Big Apple Meanings",
410
+ "Icon"=>{},
411
+ "Result"=>
412
+ "<a href=\"http://duckduckgo.com/d/Big_Apple\">Big Apple Meanings</a>",
413
+ "FirstURL"=>"http://duckduckgo.com/d/Big_Apple"},
414
+ {"Text"=>"Golden apple Meanings",
415
+ "Icon"=>{},
416
+ "Result"=>
417
+ "<a href=\"http://duckduckgo.com/d/Golden_apple\">Golden apple Meanings</a>",
418
+ "FirstURL"=>"http://duckduckgo.com/d/Golden_apple"},
419
+ {"Text"=>"The Apple Meanings",
420
+ "Icon"=>{},
421
+ "Result"=>
422
+ "<a href=\"http://duckduckgo.com/d/The_Apple\">The Apple Meanings</a>",
423
+ "FirstURL"=>"http://duckduckgo.com/d/The_Apple"},
424
+ {"Text"=>"The Little Apple Meanings",
425
+ "Icon"=>{},
426
+ "Result"=>
427
+ "<a href=\"http://duckduckgo.com/d/The_Little_Apple\">The Little Apple Meanings</a>",
428
+ "FirstURL"=>"http://duckduckgo.com/d/The_Little_Apple"},
429
+ {"Text"=>"Apel - Apel is a German surname.",
430
+ "Icon"=>{},
431
+ "Result"=>
432
+ "<a href=\"http://duckduckgo.com/Apel\">Apel</a> - Apel is a German surname.",
433
+ "FirstURL"=>"http://duckduckgo.com/Apel"},
434
+ {"Text"=>"Appel Meanings",
435
+ "Icon"=>{},
436
+ "Result"=>
437
+ "<a href=\"http://duckduckgo.com/d/Appel\">Appel Meanings</a>",
438
+ "FirstURL"=>"http://duckduckgo.com/d/Appel"},
439
+ {"Text"=>"APPEL Meanings",
440
+ "Icon"=>{},
441
+ "Result"=>
442
+ "<a href=\"http://duckduckgo.com/d/APPEL\">APPEL Meanings</a>",
443
+ "FirstURL"=>"http://duckduckgo.com/d/APPEL"},
444
+ {"Text"=>"Apple Trees, a 1992 German film",
445
+ "Icon"=>{},
446
+ "Result"=>
447
+ "<i><a href=\"http://duckduckgo.com/Apple_Trees\">Apple Trees</a></i>, a 1992 German film",
448
+ "FirstURL"=>"http://duckduckgo.com/Apple_Trees"},
449
+ {"Text"=>"The Apple Tree, a series of three musical playlets",
450
+ "Icon"=>{"URL"=>"http://i.duck.co/i/a53248fd.png"},
451
+ "Result"=>
452
+ "<i><a href=\"http://duckduckgo.com/The_Apple_Tree\">The Apple Tree</a></i>, a series of three musical playlets",
453
+ "FirstURL"=>"http://duckduckgo.com/The_Apple_Tree"}]}],
454
+ "AbstractURL"=>"http://en.wikipedia.org/wiki/Apple_(disambiguation)",
455
+ "Image"=>"",
456
+ "DefinitionURL"=>
457
+ "http://www.thefreedictionary.com/_/search.aspx?pid=aff18&word=apple",
458
+ "DefinitionSource"=>"TheFreeDictionary",
459
+ "AbstractText"=>"",
460
+ "Type"=>"D"}
461
+
462
+
463
+ zci = DuckDuckGo::ZeroClickInfo.by(data)
464
+
465
+ assert_equal("Apple", zci.heading)
466
+ assert_equal("Wikipedia", zci.abstract_source)
467
+ assert_nil(zci.image)
468
+ assert_nil(zci.abstract_text)
469
+ assert_equal("TheFreeDictionary", zci.definition_source)
470
+ assert_equal("A deciduous Eurasian tree having alternate simple leaves and white or pink flowers.", zci.definition)
471
+ assert_instance_of(URI::HTTP, zci.definition_url)
472
+ assert_nil(zci.answer_type)
473
+ assert_equal("D", zci.type)
474
+ assert_equal("disambiguation", zci.type_long)
475
+ assert_nil(zci.answer)
476
+ assert_instance_of(URI::HTTP, zci.abstract_url)
477
+ assert_equal('en.wikipedia.org', zci.abstract_url.host)
478
+ assert_equal(0, zci.results.size)
479
+ assert_equal(10, zci.related_topics.size)
480
+ assert_equal(1, zci.related_topics["_"].size)
481
+ assert_equal("The apple is a tree and its pomaceous fruit.", zci.related_topics["_"][0].text)
482
+ assert_not_nil(zci.related_topics["Companies"])
483
+ assert_equal(2, zci.related_topics["Companies"].size)
484
+ assert_equal("Apple Inc., a consumer electronics and software company", zci.related_topics["Companies"][0].text)
485
+ end
486
+
487
+ def test_zci_category
488
+
489
+ data = {"AbstractSource"=>"Wikipedia",
490
+ "Answer"=>"",
491
+ "Definition"=>"",
492
+ "Results"=>[],
493
+ "AnswerType"=>"",
494
+ "Abstract"=>"",
495
+ "Heading"=>"The Simpsons characters",
496
+ "RelatedTopics"=>
497
+ [{"Text"=>
498
+ "Abraham Simpson - Abraham Jay \"Abe\" Simpson (voiced by Dan Castellaneta), known near universally simply as Grampa, is a fictional character in the animated television series The Simpsons.",
499
+ "Icon"=>{"URL"=>"http://i.duck.co/i/7b1c968b.png"},
500
+ "Result"=>
501
+ "<a href=\"http://duckduckgo.com/Abraham_Simpson\">Abraham Simpson</a><br>Abraham Jay \"Abe\" Simpson (voiced by Dan Castellaneta), known near universally simply as Grampa, is a fictional character in the animated television series <i>The Simpsons</i>.",
502
+ "FirstURL"=>"http://duckduckgo.com/Abraham_Simpson"},
503
+ {"Text"=>
504
+ "Apu Nahasapeemapetilon - Apu Nahasapeemapetilon, Ph.D. is a character in the animated television series The Simpsons.",
505
+ "Icon"=>{"URL"=>"http://i.duck.co/i/3dfa3dc3.png"},
506
+ "Result"=>
507
+ "<a href=\"http://duckduckgo.com/Apu_Nahasapeemapetilon\">Apu Nahasapeemapetilon</a><br>Apu Nahasapeemapetilon, Ph.D. is a character in the animated television series <i>The Simpsons</i>.",
508
+ "FirstURL"=>"http://duckduckgo.com/Apu_Nahasapeemapetilon"},
509
+ {"Text"=>
510
+ "Barney Gumble - Barnard \"Barney\" Gumble is a fictional character on the American animated sitcom The Simpsons.",
511
+ "Icon"=>{"URL"=>"http://i.duck.co/i/39ce98c0.png"},
512
+ "Result"=>
513
+ "<a href=\"http://duckduckgo.com/Barney_Gumble\">Barney Gumble</a><br>Barnard \"Barney\" Gumble is a fictional character on the American animated sitcom <i>The Simpsons</i>.",
514
+ "FirstURL"=>"http://duckduckgo.com/Barney_Gumble"},
515
+ {"Text"=>
516
+ "Bart Simpson - Bartholomew JoJo \"Bart\" Simpson is a fictional character in the animated television series The Simpsons and part of the eponymous family.",
517
+ "Icon"=>{"URL"=>"http://i.duck.co/i/62a07d9e.png"},
518
+ "Result"=>
519
+ "<a href=\"http://duckduckgo.com/Bart_Simpson\">Bart Simpson</a><br>Bartholomew JoJo \"Bart\" Simpson is a fictional character in the animated television series <i>The Simpsons</i> and part of the eponymous family.",
520
+ "FirstURL"=>"http://duckduckgo.com/Bart_Simpson"},
521
+ {"Text"=>
522
+ "Carl Carlson - Carl Carlson, usually known simply as Carl, is a supporting character in the animated television series The Simpsons voiced by Hank Azaria.",
523
+ "Icon"=>{"URL"=>"http://i.duck.co/i/f572e9ae.png"},
524
+ "Result"=>
525
+ "<a href=\"http://duckduckgo.com/Carl_Carlson\">Carl Carlson</a><br>Carl Carlson, usually known simply as Carl, is a supporting character in the animated television series <i>The Simpsons</i> voiced by Hank Azaria.",
526
+ "FirstURL"=>"http://duckduckgo.com/Carl_Carlson"},
527
+ {"Text"=>
528
+ "Clancy Wiggum - Chief Clancy Wiggum is a fictional character from the animated television series The Simpsons, voiced by Hank Azaria.",
529
+ "Icon"=>{"URL"=>"http://i.duck.co/i/f0eb79ee.png"},
530
+ "Result"=>
531
+ "<a href=\"http://duckduckgo.com/Clancy_Wiggum\">Clancy Wiggum</a><br>Chief Clancy Wiggum is a fictional character from the animated television series <i>The Simpsons</i>, voiced by Hank Azaria.",
532
+ "FirstURL"=>"http://duckduckgo.com/Clancy_Wiggum"},
533
+ {"Text"=>
534
+ "Cletus Spuckler - Cletus Delroy Spuckler is a recurring character in the Fox animated series, The Simpsons, and is voiced by Hank Azaria.",
535
+ "Icon"=>{"URL"=>"http://i.duck.co/i/4d663a85.gif"},
536
+ "Result"=>
537
+ "<a href=\"http://duckduckgo.com/Cletus_Spuckler\">Cletus Spuckler</a><br>Cletus Delroy Spuckler is a recurring character in the Fox animated series, <i>The Simpsons</i>, and is voiced by Hank Azaria.",
538
+ "FirstURL"=>"http://duckduckgo.com/Cletus_Spuckler"},
539
+ {"Text"=>
540
+ "Comic Book Guy - Jeff Albertson, best known as the Comic Book Guy, is a recurring fictional character in the animated television series The Simpsons.",
541
+ "Icon"=>{"URL"=>"http://i.duck.co/i/911ab519.png"},
542
+ "Result"=>
543
+ "<a href=\"http://duckduckgo.com/Comic_Book_Guy\">Comic Book Guy</a><br>Jeff Albertson, best known as the Comic Book Guy, is a recurring fictional character in the animated television series <i>The Simpsons.</i>",
544
+ "FirstURL"=>"http://duckduckgo.com/Comic_Book_Guy"},
545
+ {"Text"=>
546
+ "Edna Krabappel - Edna Krabappel is a fictional character from the animated TV series The Simpsons, voiced by Marcia Wallace.",
547
+ "Icon"=>{"URL"=>"http://i.duck.co/i/1bdfff5e.png"},
548
+ "Result"=>
549
+ "<a href=\"http://duckduckgo.com/Edna_Krabappel\">Edna Krabappel</a><br>Edna Krabappel is a fictional character from the animated TV series <i>The Simpsons</i>, voiced by Marcia Wallace.",
550
+ "FirstURL"=>"http://duckduckgo.com/Edna_Krabappel"},
551
+ {"Text"=>
552
+ "Fat Tony - Fat Tony is a recurring character in the animated sitcom The Simpsons.",
553
+ "Icon"=>{"URL"=>"http://i.duck.co/i/a4583d66.png"},
554
+ "Result"=>
555
+ "<a href=\"http://duckduckgo.com/Fat_Tony\">Fat Tony</a><br>Fat Tony is a recurring character in the animated sitcom <i>The Simpsons</i>.",
556
+ "FirstURL"=>"http://duckduckgo.com/Fat_Tony"},
557
+ {"Text"=>
558
+ "Groundskeeper Willie - Groundskeeper Willie born William Mcdougal is a recurring character on The Simpsons, voiced by Dan Castellaneta.",
559
+ "Icon"=>{"URL"=>"http://i.duck.co/i/f845601f.png"},
560
+ "Result"=>
561
+ "<a href=\"http://duckduckgo.com/Groundskeeper_Willie\">Groundskeeper Willie</a><br>Groundskeeper Willie born William Mcdougal is a recurring character on <i>The Simpsons</i>, voiced by Dan Castellaneta.",
562
+ "FirstURL"=>"http://duckduckgo.com/Groundskeeper_Willie"},
563
+ {"Text"=>
564
+ "Hans Moleman - Hans Moleman is a recurring character in the animated television series The Simpsons.",
565
+ "Icon"=>{"URL"=>"http://i.duck.co/i/9f651728.png"},
566
+ "Result"=>
567
+ "<a href=\"http://duckduckgo.com/Hans_Moleman\">Hans Moleman</a><br>Hans Moleman is a recurring character in the animated television series <i>The Simpsons</i>.",
568
+ "FirstURL"=>"http://duckduckgo.com/Hans_Moleman"},
569
+ {"Text"=>
570
+ "Homer Simpson - Homer Jay Simpson is a fictional main character in the animated television series The Simpsons and the father of the eponymous family.",
571
+ "Icon"=>{"URL"=>"http://i.duck.co/i/bf0eb228.png"},
572
+ "Result"=>
573
+ "<a href=\"http://duckduckgo.com/Homer_Simpson\">Homer Simpson</a><br>Homer Jay Simpson is a fictional main character in the animated television series <i>The Simpsons</i> and the father of the eponymous family.",
574
+ "FirstURL"=>"http://duckduckgo.com/Homer_Simpson"},
575
+ {"Text"=>
576
+ "Joe Quimby - Mayor Joseph \"Joe\" Quimby, nicknamed \"Diamond Joe,\" is a recurring character from the animated television series The Simpsons.",
577
+ "Icon"=>{"URL"=>"http://i.duck.co/i/93d80e95.png"},
578
+ "Result"=>
579
+ "<a href=\"http://duckduckgo.com/Joe_Quimby\">Joe Quimby</a><br>Mayor Joseph \"Joe\" Quimby, nicknamed \"Diamond Joe,\" is a recurring character from the animated television series <i>The Simpsons</i>.",
580
+ "FirstURL"=>"http://duckduckgo.com/Joe_Quimby"},
581
+ {"Text"=>
582
+ "Julius Hibbert - Dr. Julius M. Hibbert, M.D., is a recurring character on the animated series The Simpsons.",
583
+ "Icon"=>{"URL"=>"http://i.duck.co/i/c9497b7e.png"},
584
+ "Result"=>
585
+ "<a href=\"http://duckduckgo.com/Julius_Hibbert\">Julius Hibbert</a><br>Dr. Julius M. Hibbert, M.D., is a recurring character on the animated series <i>The Simpsons</i>.",
586
+ "FirstURL"=>"http://duckduckgo.com/Julius_Hibbert"},
587
+ {"Text"=>
588
+ "Kang and Kodos - Kang and Kodos are a duo of recurring characters in the animated television series The Simpsons.",
589
+ "Icon"=>{"URL"=>"http://i.duck.co/i/be84f45b.png"},
590
+ "Result"=>
591
+ "<a href=\"http://duckduckgo.com/Kang_and_Kodos\">Kang and Kodos</a><br>Kang and Kodos are a duo of recurring characters in the animated television series <i>The Simpsons</i>.",
592
+ "FirstURL"=>"http://duckduckgo.com/Kang_and_Kodos"},
593
+ {"Text"=>
594
+ "Kent Brockman - Kent Brockman is a fictional character in the animated television series The Simpsons.",
595
+ "Icon"=>{"URL"=>"http://i.duck.co/i/b6c36d00.jpg"},
596
+ "Result"=>
597
+ "<a href=\"http://duckduckgo.com/Kent_Brockman\">Kent Brockman</a><br>Kent Brockman is a fictional character in the animated television series <i>The Simpsons</i>.",
598
+ "FirstURL"=>"http://duckduckgo.com/Kent_Brockman"},
599
+ {"Text"=>
600
+ "Krusty the Clown - Herschel Shmoikel Pinchas Yerucham Krustofski, better known by the stage name Krusty the Clown, is a fictional character who suffers bipolarity in the animated television series The Simp...",
601
+ "Icon"=>{"URL"=>"http://i.duck.co/i/caa07f01.png"},
602
+ "Result"=>
603
+ "<a href=\"http://duckduckgo.com/Krusty_the_Clown\">Krusty the Clown</a><br>Herschel Shmoikel Pinchas Yerucham Krustofski, better known by the stage name Krusty the Clown, is a fictional character who suffers bipolarity in the animated television series The Simp...",
604
+ "FirstURL"=>"http://duckduckgo.com/Krusty_the_Clown"},
605
+ {"Text"=>
606
+ "Lenny Leonard - Lenford Leonard, MPhys usually known simply as Lenny, is a supporting character in the Fox animated series The Simpsons, and is voiced by Harry Shearer.",
607
+ "Icon"=>{"URL"=>"http://i.duck.co/i/76575c43.png"},
608
+ "Result"=>
609
+ "<a href=\"http://duckduckgo.com/Lenny_Leonard\">Lenny Leonard</a><br>Lenford Leonard, MPhys usually known simply as Lenny, is a supporting character in the Fox animated series <i>The Simpsons</i>, and is voiced by Harry Shearer.",
610
+ "FirstURL"=>"http://duckduckgo.com/Lenny_Leonard"},
611
+ {"Text"=>
612
+ "Lionel Hutz - Lionel Hutz is a recurring character from the animated television series The Simpsons.",
613
+ "Icon"=>{"URL"=>"http://i.duck.co/i/94d72e52.jpg"},
614
+ "Result"=>
615
+ "<a href=\"http://duckduckgo.com/Lionel_Hutz\">Lionel Hutz</a><br>Lionel Hutz is a recurring character from the animated television series <i>The Simpsons</i>.",
616
+ "FirstURL"=>"http://duckduckgo.com/Lionel_Hutz"},
617
+ {"Text"=>
618
+ "Lisa Simpson - Lisa Marie Simpson is a fictional main character in the animated television series The Simpsons.",
619
+ "Icon"=>{"URL"=>"http://i.duck.co/i/0c6d3b53.png"},
620
+ "Result"=>
621
+ "<a href=\"http://duckduckgo.com/Lisa_Simpson\">Lisa Simpson</a><br>Lisa Marie Simpson is a fictional main character in the animated television series <i>The Simpsons</i>.",
622
+ "FirstURL"=>"http://duckduckgo.com/Lisa_Simpson"},
623
+ {"Text"=>
624
+ "Maggie Simpson - Margaret \"Maggie\" Simpson is a fictional character in the animated television series The Simpsons.",
625
+ "Icon"=>{"URL"=>"http://i.duck.co/i/c018dead.png"},
626
+ "Result"=>
627
+ "<a href=\"http://duckduckgo.com/Maggie_Simpson\">Maggie Simpson</a><br>Margaret \"Maggie\" Simpson is a fictional character in the animated television series <i>The Simpsons</i>.",
628
+ "FirstURL"=>"http://duckduckgo.com/Maggie_Simpson"},
629
+ {"Text"=>
630
+ "Marge Simpson - Marjorie \"Marge\" Simpson is a fictional main character in the animated television series The Simpsons and the matriarch of the eponymous family.",
631
+ "Icon"=>{"URL"=>"http://i.duck.co/i/b75bd67d.png"},
632
+ "Result"=>
633
+ "<a href=\"http://duckduckgo.com/Marge_Simpson\">Marge Simpson</a><br>Marjorie \"Marge\" Simpson is a fictional main character in the animated television series <i>The Simpsons</i> and the matriarch of the eponymous family.",
634
+ "FirstURL"=>"http://duckduckgo.com/Marge_Simpson"},
635
+ {"Text"=>
636
+ "Martin Prince - Martin Prince, Jr. is a recurring character in the Fox animated series, The Simpsons, and is voiced by Russi Taylor.",
637
+ "Icon"=>{"URL"=>"http://i.duck.co/i/eb68975c.png"},
638
+ "Result"=>
639
+ "<a href=\"http://duckduckgo.com/Martin_Prince\">Martin Prince</a><br>Martin Prince, Jr. is a recurring character in the Fox animated series, <i>The Simpsons</i>, and is voiced by Russi Taylor.",
640
+ "FirstURL"=>"http://duckduckgo.com/Martin_Prince"},
641
+ {"Text"=>
642
+ "Milhouse Van Houten - Milhouse Mussolini Van Houten is a fictional character featured in the animated television series The Simpsons, voiced by Pamela Hayden.",
643
+ "Icon"=>{"URL"=>"http://i.duck.co/i/c1923cb1.png"},
644
+ "Result"=>
645
+ "<a href=\"http://duckduckgo.com/Milhouse_Van_Houten\">Milhouse Van Houten</a><br>Milhouse Mussolini Van Houten is a fictional character featured in the animated television series <i>The Simpsons</i>, voiced by Pamela Hayden.",
646
+ "FirstURL"=>"http://duckduckgo.com/Milhouse_Van_Houten"},
647
+ {"Text"=>
648
+ "Moe Szyslak - Momar \"Moe\" Szyslak () is a fictional character in the American animated television series, The Simpsons.",
649
+ "Icon"=>{"URL"=>"http://i.duck.co/i/388580ad.png"},
650
+ "Result"=>
651
+ "<a href=\"http://duckduckgo.com/Moe_Szyslak\">Moe Szyslak</a><br>Momar \"Moe\" Szyslak () is a fictional character in the American animated television series, <i>The Simpsons</i>.",
652
+ "FirstURL"=>"http://duckduckgo.com/Moe_Szyslak"},
653
+ {"Text"=>
654
+ "Mona Simpson (The Simpsons) - Mona J. Simpson is a recurring fictional character in the animated television series The Simpsons.",
655
+ "Icon"=>{"URL"=>"http://i.duck.co/i/ba6285fb.png"},
656
+ "Result"=>
657
+ "<a href=\"http://duckduckgo.com/Mona_Simpson_(The_Simpsons)\">Mona Simpson (The Simpsons)</a><br>Mona J. Simpson is a recurring fictional character in the animated television series <i>The Simpsons</i>.",
658
+ "FirstURL"=>"http://duckduckgo.com/Mona_Simpson_(The_Simpsons)"},
659
+ {"Text"=>
660
+ "Mr. Burns - Charles Montgomery Plantagenet Schicklgruber\"Monty\" Burns, usually referred to as Mr. Burns, is a recurring fictional character in the animated television series The Simpsons,...",
661
+ "Icon"=>{"URL"=>"http://i.duck.co/i/cf311517.png"},
662
+ "Result"=>
663
+ "<a href=\"http://duckduckgo.com/Mr._Burns\">Mr. Burns</a><br>Charles Montgomery Plantagenet Schicklgruber\"Monty\" Burns, usually referred to as Mr. Burns, is a recurring fictional character in the animated television series <i>The Simpsons</i>,...",
664
+ "FirstURL"=>"http://duckduckgo.com/Mr._Burns"},
665
+ {"Text"=>
666
+ "Ned Flanders - Nedward \"Ned\" Flanders is a recurring fictional character in the animated television series The Simpsons.",
667
+ "Icon"=>{"URL"=>"http://i.duck.co/i/e66f380d.png"},
668
+ "Result"=>
669
+ "<a href=\"http://duckduckgo.com/Ned_Flanders\">Ned Flanders</a><br>Nedward \"Ned\" Flanders is a recurring fictional character in the animated television series <i>The Simpsons</i>.",
670
+ "FirstURL"=>"http://duckduckgo.com/Ned_Flanders"},
671
+ {"Text"=>
672
+ "Nelson Muntz - Nelson Mandela Muntz is a fictional character from the animated TV series The Simpsons.",
673
+ "Icon"=>{"URL"=>"http://i.duck.co/i/23702790.png"},
674
+ "Result"=>
675
+ "<a href=\"http://duckduckgo.com/Nelson_Muntz\">Nelson Muntz</a><br>Nelson Mandela Muntz is a fictional character from the animated TV series <i>The Simpsons</i>.",
676
+ "FirstURL"=>"http://duckduckgo.com/Nelson_Muntz"},
677
+ {"Text"=>
678
+ "Nick Riviera - Dr. Nick Riviera, M.D. is a fictional character on the animated television series The Simpsons.",
679
+ "Icon"=>{"URL"=>"http://i.duck.co/i/db757c91.png"},
680
+ "Result"=>
681
+ "<a href=\"http://duckduckgo.com/Nick_Riviera\">Nick Riviera</a><br>Dr. Nick Riviera, M.D. is a fictional character on the animated television series <i>The Simpsons</i>.",
682
+ "FirstURL"=>"http://duckduckgo.com/Nick_Riviera"},
683
+ {"Text"=>
684
+ "Otto Mann - Otto Mann is a fictional character on the animated TV series The Simpsons, voiced by Harry Shearer.",
685
+ "Icon"=>{"URL"=>"http://i.duck.co/i/9ba5c930.png"},
686
+ "Result"=>
687
+ "<a href=\"http://duckduckgo.com/Otto_Mann\">Otto Mann</a><br>Otto Mann is a fictional character on the animated TV series <i>The Simpsons</i>, voiced by Harry Shearer.",
688
+ "FirstURL"=>"http://duckduckgo.com/Otto_Mann"},
689
+ {"Text"=>
690
+ "Patty and Selma Bouvier - Patty and Selma Bouvier () are fictional twins in the Fox Broadcasting animated series, The Simpsons, and are voiced by Julie Kavner.",
691
+ "Icon"=>{"URL"=>"http://i.duck.co/i/9f1ecf46.png"},
692
+ "Result"=>
693
+ "<a href=\"http://duckduckgo.com/Patty_and_Selma_Bouvier\">Patty and Selma Bouvier</a><br>Patty and Selma Bouvier () are fictional twins in the Fox Broadcasting animated series, <i>The Simpsons</i>, and are voiced by Julie Kavner.",
694
+ "FirstURL"=>"http://duckduckgo.com/Patty_and_Selma_Bouvier"},
695
+ {"Text"=>
696
+ "Professor Frink - Professor John Nerdelbaum Frink, Jr. is a recurring character in the American animated television series The Simpsons.",
697
+ "Icon"=>{"URL"=>"http://i.duck.co/i/c9dc0e13.png"},
698
+ "Result"=>
699
+ "<a href=\"http://duckduckgo.com/Professor_Frink\">Professor Frink</a><br>Professor John Nerdelbaum Frink, Jr. is a recurring character in the American animated television series <i>The Simpsons</i>.",
700
+ "FirstURL"=>"http://duckduckgo.com/Professor_Frink"},
701
+ {"Text"=>
702
+ "Ralph Wiggum - Ralph Wiggum is a recurring fictional character on the animated series The Simpsons, voiced by Nancy Cartwright.",
703
+ "Icon"=>{"URL"=>"http://i.duck.co/i/2f9c97eb.png"},
704
+ "Result"=>
705
+ "<a href=\"http://duckduckgo.com/Ralph_Wiggum\">Ralph Wiggum</a><br>Ralph Wiggum is a recurring fictional character on the animated series <i>The Simpsons</i>, voiced by Nancy Cartwright.",
706
+ "FirstURL"=>"http://duckduckgo.com/Ralph_Wiggum"},
707
+ {"Text"=>
708
+ "Reverend Timothy Lovejoy - The Reverend Timothy Lovejoy is a recurring character in the animated television series The Simpsons.",
709
+ "Icon"=>{"URL"=>"http://i.duck.co/i/5359e785.png"},
710
+ "Result"=>
711
+ "<a href=\"http://duckduckgo.com/Reverend_Timothy_Lovejoy\">Reverend Timothy Lovejoy</a><br>The Reverend Timothy Lovejoy is a recurring character in the animated television series <i>The Simpsons</i>.",
712
+ "FirstURL"=>"http://duckduckgo.com/Reverend_Timothy_Lovejoy"},
713
+ {"Text"=>
714
+ "Santa's Little Helper - Santa's Little Helper is a fictional dog.",
715
+ "Icon"=>{"URL"=>"http://i.duck.co/i/6825f3f5.png"},
716
+ "Result"=>
717
+ "<a href=\"http://duckduckgo.com/Santa's_Little_Helper\">Santa's Little Helper</a><br>Santa's Little Helper is a fictional dog.",
718
+ "FirstURL"=>"http://duckduckgo.com/Santa's_Little_Helper"},
719
+ {"Text"=>
720
+ "Seymour Skinner - W. Seymour Skinner (born Armin Tamzarian) is a fictional character on the animated sitcom The Simpsons who is voiced by Harry Shearer.",
721
+ "Icon"=>{"URL"=>"http://i.duck.co/i/785a66ec.png"},
722
+ "Result"=>
723
+ "<a href=\"http://duckduckgo.com/Seymour_Skinner\">Seymour Skinner</a><br>W. Seymour Skinner (born Armin Tamzarian) is a fictional character on the animated sitcom <i>The Simpsons</i> who is voiced by Harry Shearer.",
724
+ "FirstURL"=>"http://duckduckgo.com/Seymour_Skinner"},
725
+ {"Text"=>
726
+ "Sideshow Bob - Robert Underdunk-Terwilliger, better known by his stage name Sideshow Bob, is a recurring character in the animated television series The Simpsons.",
727
+ "Icon"=>{"URL"=>"http://i.duck.co/i/922b6a1c.png"},
728
+ "Result"=>
729
+ "<a href=\"http://duckduckgo.com/Sideshow_Bob\">Sideshow Bob</a><br>Robert Underdunk-Terwilliger, better known by his stage name Sideshow Bob, is a recurring character in the animated television series <i>The Simpsons</i>.",
730
+ "FirstURL"=>"http://duckduckgo.com/Sideshow_Bob"},
731
+ {"Text"=>
732
+ "Snowball (The Simpsons) - The name Snowball refers to five fictional cats that have been owned by the Simpson family in the TV show The Simpsons.",
733
+ "Icon"=>{"URL"=>"http://i.duck.co/i/6a833a5a.png"},
734
+ "Result"=>
735
+ "<a href=\"http://duckduckgo.com/Snowball_(The_Simpsons)\">Snowball (The Simpsons)</a><br>The name Snowball refers to five fictional cats that have been owned by the Simpson family in the TV show <i>The Simpsons</i>.",
736
+ "FirstURL"=>"http://duckduckgo.com/Snowball_(The_Simpsons)"},
737
+ {"Text"=>
738
+ "The Itchy & Scratchy Show - The Itchy & Scratchy Show is a fictional animated television series from The Simpsons.",
739
+ "Icon"=>{"URL"=>"http://i.duck.co/i/d8a3a294.png"},
740
+ "Result"=>
741
+ "<a href=\"http://duckduckgo.com/The_Itchy_%26_Scratchy_Show\">The Itchy & Scratchy Show</a><br><i>The Itchy & Scratchy Show</i> is a fictional animated television series from <i>The Simpsons</i>.",
742
+ "FirstURL"=>"http://duckduckgo.com/The_Itchy_%26_Scratchy_Show"},
743
+ {"Text"=>
744
+ "Troy McClure - Troy McClure is a fictional character in the American animated sitcom The Simpsons.",
745
+ "Icon"=>{"URL"=>"http://i.duck.co/i/20433a15.png"},
746
+ "Result"=>
747
+ "<a href=\"http://duckduckgo.com/Troy_McClure\">Troy McClure</a><br>Troy McClure is a fictional character in the American animated sitcom <i>The Simpsons</i>.",
748
+ "FirstURL"=>"http://duckduckgo.com/Troy_McClure"},
749
+ {"Text"=>
750
+ "Waylon Smithers - Waylon Smithers, Jr. usually referred to as Smithers is a recurring fictional character in the animated series The Simpsons, who is voiced by Harry Shearer.",
751
+ "Icon"=>{"URL"=>"http://i.duck.co/i/12f25a94.png"},
752
+ "Result"=>
753
+ "<a href=\"http://duckduckgo.com/Waylon_Smithers\">Waylon Smithers</a><br>Waylon Smithers, Jr. usually referred to as Smithers is a recurring fictional character in the animated series <i>The Simpsons</i>, who is voiced by Harry Shearer.",
754
+ "FirstURL"=>"http://duckduckgo.com/Waylon_Smithers"}],
755
+ "AbstractURL"=>"http://en.wikipedia.org/wiki/The_Simpsons_characters",
756
+ "Image"=>"",
757
+ "DefinitionURL"=>"",
758
+ "DefinitionSource"=>"",
759
+ "AbstractText"=>"",
760
+ "Type"=>"C"}
761
+
762
+ zci = DuckDuckGo::ZeroClickInfo.by(data)
763
+
764
+ assert_equal("The Simpsons characters", zci.heading)
765
+ assert_equal("Wikipedia", zci.abstract_source)
766
+ assert_nil(zci.image)
767
+ assert_nil(zci.abstract_text)
768
+ assert_nil(zci.definition_source)
769
+ assert_nil(zci.definition_url)
770
+ assert_nil(zci.answer_type)
771
+ assert_equal("C", zci.type)
772
+ assert_equal("category", zci.type_long)
773
+ assert_nil(zci.answer)
774
+ assert_instance_of(URI::HTTP, zci.abstract_url)
775
+ assert_equal('en.wikipedia.org', zci.abstract_url.host)
776
+ assert_equal(0, zci.results.size)
777
+ assert_equal(1, zci.related_topics.size)
778
+ assert_equal(43, zci.related_topics["_"].size)
779
+ assert_equal("Abraham Simpson - Abraham Jay \"Abe\" Simpson (voiced by Dan Castellaneta), known near universally simply as Grampa, is a fictional character in the animated television series The Simpsons.", zci.related_topics["_"][0].text)
780
+ end
781
+
782
+ def test_zci_exclusive
783
+
784
+ data = {"AbstractSource"=>"Wikipedia",
785
+ "Answer"=>"",
786
+ "Definition"=>
787
+ "Lorem ipsum - A common piece of text used as mock- content when testing a given page layout or font.",
788
+ "Results"=>
789
+ [{"Text"=>
790
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.<p> - Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies. Curabitur ornare, ligula semper consectetur sagittis, nisi diam iaculis velit, id fringilla sem nunc vel mi. Nam dictum, odio nec pretium volutpat, arcu ante placerat erat, non tristique elit urna et turpis. Quisque mi metus, ornare sit amet fermentum et, tincidunt et orci. Fusce eget orci a orci congue vestibulum. Ut dolor diam, elementum et vestibulum eu, porttitor vel elit. Curabitur venenatis pulvinar tellus gravida ornare. Sed et erat faucibus nunc euismod ultricies ut id justo. Nullam cursus suscipit nisi, et ultrices justo sodales nec. Fusce venenatis facilisis lectus ac semper. Aliquam at massa ipsum. Quisque bibendum purus convallis nulla ultrices ultricies. Nullam aliquam, mi eu aliquam tincidunt, purus velit laoreet tortor, viverra pretium nisi quam vitae mi. Fusce vel volutpat elit. Nam sagittis nisi dui.<p> - Suspendisse lectus leo, consectetur in tempor sit amet, placerat quis neque. Etiam luctus porttitor lorem, sed suscipit est rutrum non. Curabitur lobortis nisl a enim congue semper. Aenean commodo ultrices imperdiet. Vestibulum ut justo vel sapien venenatis tincidunt. Phasellus eget dolor sit amet ipsum dapibus condimentum vitae quis lectus. Aliquam ut massa in turpis dapibus convallis. Praesent elit lacus, vestibulum at malesuada et, ornare et est. Ut augue nunc, sodales ut euismod non, adipiscing vitae orci. Mauris ut placerat justo. Mauris in ultricies enim. Quisque nec est eleifend nulla ultrices egestas quis ut quam. Donec sollicitudin lectus a mauris pulvinar id aliquam urna cursus. Cras quis ligula sem, vel elementum mi. Phasellus non ullamcorper urna.<p> - Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In euismod ultrices facilisis. Vestibulum porta sapien adipiscing augue congue id pretium lectus molestie. Proin quis dictum nisl. Morbi id quam sapien, sed vestibulum sem. Duis elementum rutrum mauris sed convallis. Proin vestibulum magna mi. Aenean tristique hendrerit magna, ac facilisis nulla hendrerit ut. Sed non tortor sodales quam auctor elementum. Donec hendrerit nunc eget elit pharetra pulvinar. Suspendisse id tempus tortor. Aenean luctus, elit commodo laoreet commodo, justo nisi consequat massa, sed vulputate quam urna quis eros. Donec vel. &nbsp;",
791
+ "Icon"=>{"URL"=>"", "Width"=>16, "Height"=>16},
792
+ "Result"=>
793
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.<p><br>Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies. Curabitur ornare, ligula semper consectetur sagittis, nisi diam iaculis velit, id fringilla sem nunc vel mi. Nam dictum, odio nec pretium volutpat, arcu ante placerat erat, non tristique elit urna et turpis. Quisque mi metus, ornare sit amet fermentum et, tincidunt et orci. Fusce eget orci a orci congue vestibulum. Ut dolor diam, elementum et vestibulum eu, porttitor vel elit. Curabitur venenatis pulvinar tellus gravida ornare. Sed et erat faucibus nunc euismod ultricies ut id justo. Nullam cursus suscipit nisi, et ultrices justo sodales nec. Fusce venenatis facilisis lectus ac semper. Aliquam at massa ipsum. Quisque bibendum purus convallis nulla ultrices ultricies. Nullam aliquam, mi eu aliquam tincidunt, purus velit laoreet tortor, viverra pretium nisi quam vitae mi. Fusce vel volutpat elit. Nam sagittis nisi dui.<p><br>Suspendisse lectus leo, consectetur in tempor sit amet, placerat quis neque. Etiam luctus porttitor lorem, sed suscipit est rutrum non. Curabitur lobortis nisl a enim congue semper. Aenean commodo ultrices imperdiet. Vestibulum ut justo vel sapien venenatis tincidunt. Phasellus eget dolor sit amet ipsum dapibus condimentum vitae quis lectus. Aliquam ut massa in turpis dapibus convallis. Praesent elit lacus, vestibulum at malesuada et, ornare et est. Ut augue nunc, sodales ut euismod non, adipiscing vitae orci. Mauris ut placerat justo. Mauris in ultricies enim. Quisque nec est eleifend nulla ultrices egestas quis ut quam. Donec sollicitudin lectus a mauris pulvinar id aliquam urna cursus. Cras quis ligula sem, vel elementum mi. Phasellus non ullamcorper urna.<p><br>Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In euismod ultrices facilisis. Vestibulum porta sapien adipiscing augue congue id pretium lectus molestie. Proin quis dictum nisl. Morbi id quam sapien, sed vestibulum sem. Duis elementum rutrum mauris sed convallis. Proin vestibulum magna mi. Aenean tristique hendrerit magna, ac facilisis nulla hendrerit ut. Sed non tortor sodales quam auctor elementum. Donec hendrerit nunc eget elit pharetra pulvinar. Suspendisse id tempus tortor. Aenean luctus, elit commodo laoreet commodo, justo nisi consequat massa, sed vulputate quam urna quis eros. Donec vel. <a href=\"http://lipsum.com\">&nbsp;</a>",
794
+ "FirstURL"=>"http://lipsum.com"}],
795
+ "AnswerType"=>"",
796
+ "Abstract"=>"",
797
+ "Heading"=>"Lorem Ipsum",
798
+ "RelatedTopics"=>[],
799
+ "AbstractURL"=>"http://en.wikipedia.org/wiki/Lorem_Ipsum",
800
+ "Image"=>"",
801
+ "DefinitionURL"=>
802
+ "http://www.thefreedictionary.com/_/search.aspx?pid=aff18&word=lorem%2520ipsum",
803
+ "DefinitionSource"=>"TheFreeDictionary",
804
+ "AbstractText"=>"",
805
+ "Type"=>"E"}
806
+
807
+ zci = DuckDuckGo::ZeroClickInfo.by(data)
808
+
809
+ assert_equal("Lorem Ipsum", zci.heading)
810
+ assert_equal("Wikipedia", zci.abstract_source)
811
+ assert_nil(zci.image)
812
+ assert_nil(zci.abstract_text)
813
+ assert_equal("TheFreeDictionary", zci.definition_source)
814
+ assert_equal("Lorem ipsum - A common piece of text used as mock- content when testing a given page layout or font.", zci.definition)
815
+ assert_instance_of(URI::HTTP, zci.definition_url)
816
+ assert_nil(zci.answer_type)
817
+ assert_equal("E", zci.type)
818
+ assert_equal("exclusive", zci.type_long)
819
+ assert_nil(zci.answer)
820
+ assert_instance_of(URI::HTTP, zci.abstract_url)
821
+ assert_equal('en.wikipedia.org', zci.abstract_url.host)
822
+ assert_equal(1, zci.results.size)
823
+ assert_equal(0, zci.related_topics.size)
824
+ end
825
+ end