├── .gitignore
├── ACL2018.pptx
├── LICENSE
├── ML_Comparisons.py
├── README.md
├── context2vec.py
├── data
├── 1x1_encode_map.pkl
├── 1x1_geonames.pkl
├── 1x1_outliers_map.pkl
├── 1x1_reverse_map.pkl
├── 2x2_encode_map.pkl
├── 2x2_geonames.pkl
├── 2x2_outliers_map.pkl
├── 2x2_reverse_map.pkl
├── GeoVirus.xml
├── WikToR.xml
├── eval_geovirus.txt
├── eval_geovirus_gold.txt
├── eval_lgl.txt
├── eval_lgl_gold.txt
├── eval_wiki.txt
├── eval_wiki_gold.txt.zip
├── geovirus.txt
├── geovirus_gold.txt
├── iaa_answers.txt
├── iaa_check.txt
├── iaa_test.txt
├── lgl.txt
├── lgl.xml
├── lgl_gold.txt
├── wiki.txt
├── wiki_gold.txt
└── words2index.pkl
├── geoparse.py
├── geovirus.py
├── melbourne-augmenting-geocoding.pdf
├── preprocessing.py
├── subsample.py
├── test.py
├── text2mapVec.py
└── train.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | .DS_Store
12 | env/
13 | build/
14 | develop-eggs/
15 | dist/
16 | downloads/
17 | eggs/
18 | .eggs/
19 | lib/
20 | lib64/
21 | parts/
22 | sdist/
23 | var/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 | .idea/
28 |
29 | # PyInstaller
30 | # Usually these files are written by a python script from a template
31 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 | *.manifest
33 | *.spec
34 |
35 | # Installer logs
36 | pip-log.txt
37 | pip-delete-this-directory.txt
38 |
39 | # Unit test / coverage reports
40 | htmlcov/
41 | .tox/
42 | .coverage
43 | .coverage.*
44 | .cache
45 | nosetests.xml
46 | coverage.xml
47 | *,cover
48 | .hypothesis/
49 |
50 | # Translations
51 | *.mo
52 | *.pot
53 |
54 | # Django stuff:
55 | *.log
56 | local_settings.py
57 |
58 | # Flask stuff:
59 | instance/
60 | .webassets-cache
61 |
62 | # Scrapy stuff:
63 | .scrapy
64 |
65 | # Sphinx documentation
66 | docs/_build/
67 |
68 | # PyBuilder
69 | target/
70 |
71 | # IPython Notebook
72 | .ipynb_checkpoints
73 |
74 | # pyenv
75 | .python-version
76 |
77 | # celery beat schedule file
78 | celerybeat-schedule
79 |
80 | # dotenv
81 | .env
82 |
83 | # virtualenv
84 | venv/
85 | ENV/
86 |
87 | # Spyder project settings
88 | .spyderproject
89 |
90 | # Rope project settings
91 | .ropeproject
92 |
93 | # my other temporary files
94 | data/eval_wiki_gold.txt
95 | errors.tsv
96 | gpu/
97 | output.txt
--------------------------------------------------------------------------------
/ACL2018.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milangritta/Geocoding-with-Map-Vector/69e6e590c56930ed80d346f6c2da6d58056182e3/ACL2018.pptx
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/ML_Comparisons.py:
--------------------------------------------------------------------------------
1 | import sqlite3
2 | import sys
3 | from geopy.distance import great_circle
4 | from sklearn.ensemble import RandomForestClassifier
5 | from sklearn.naive_bayes import MultinomialNB
6 | from preprocessing import generate_arrays_from_file_map2vec, index_to_coord, get_coordinates, generate_strings_from_file
7 | from preprocessing import REVERSE_MAP_2x2
8 | from preprocessing import print_stats
9 | import numpy as np
10 | from sklearn.externals import joblib
11 |
12 | # For command line use, type: python test.py such as lgl_gold or wiki (see file names)
13 | if len(sys.argv) > 1:
14 | data = sys.argv[1]
15 | else:
16 | data = u"lgl"
17 |
18 | X, Y = [], []
19 | clf = MultinomialNB()
20 | classes = range(len(REVERSE_MAP_2x2))
21 | # clf = RandomForestClassifier()
22 | for (x, y) in generate_arrays_from_file_map2vec(u"../data/train_wiki_uniform.txt", looping=False):
23 | X.extend(x[0])
24 | Y.extend(np.argmax(y, axis=1))
25 | # -------- Uncomment for Naive Bayes -------------
26 | if len(X) > 25000:
27 | print(u"Training with:", len(X), u"examples.")
28 | clf.partial_fit(X, Y, classes)
29 | X, Y = [], []
30 | # ------------------------------------------------
31 |
32 | print(u"Training with:", len(X), u"examples.")
33 | clf.partial_fit(X, Y, classes) # Naive Bayes only!
34 | # clf.fit(X, Y) # Random Forest
35 | joblib.dump(clf, u'../data/bayes.pkl') # saves the model to file
36 |
37 | # ------------------------------------- END OF TRAINING, BEGINNING OF TESTING -----------------------------------
38 |
39 | X = []
40 | final_errors = []
41 | clf = joblib.load(u'../data/bayes.pkl')
42 | test_file = u"data/eval_" + data + u".txt" # which data to test on?
43 |
44 | for (x, y) in generate_arrays_from_file_map2vec(test_file, looping=False):
45 | X.extend(x[0]) # Load test instances
46 |
47 | print(u"Testing with:", len(X), u"examples.")
48 | conn = sqlite3.connect(u'../data/geonames.db')
49 |
50 | for x, (y, name, context) in zip(clf.predict(X), generate_strings_from_file(test_file)):
51 | p = index_to_coord(REVERSE_MAP_2x2[x], 2)
52 | candidates = get_coordinates(conn.cursor(), name)
53 |
54 | if len(candidates) == 0:
55 | print(u"Don't have an entry for", name, u"in GeoNames")
56 | raise Exception(u"Check your database, buddy :-)")
57 |
58 | # candidates = [candidates[0]] # Uncomment for population heuristic.
59 | # THE ABOVE IS THE POPULATION ONLY BASELINE IMPLEMENTATION
60 |
61 | best_candidate = []
62 | max_pop = candidates[0][2]
63 | bias = 0.9 # bias parameter, see
64 | for candidate in candidates:
65 | err = great_circle(p, (float(candidate[0]), float(candidate[1]))).km
66 | best_candidate.append((err - (err * max(1, candidate[2]) / max(1, max_pop)) * bias, (float(candidate[0]), float(candidate[1]))))
67 | best_candidate = sorted(best_candidate, key=lambda (a, b): a)[0]
68 | final_errors.append(great_circle(best_candidate[1], y).km)
69 |
70 | print_stats(final_errors)
71 | print(u"Done testing:", test_file)
72 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Which Melbourne? Augmenting Geocoding with Maps
2 |
3 | ### Resources accompanying the ACL 2018 long paper, presented in Melbourne, Australia.
4 |
5 | *The accepted pdf manuscript is also included in this directory (as is the .PPTX from the Melbourne presentation). The video recording of the Melbourne presentation can be found here (https://vimeo.com/285803462).*
6 |
7 | ##### Abstract
8 | The purpose of text geolocation is to associate geographic information contained
9 | in a document with a set (or sets) of coordinates, either implicitly by using linguistic
10 | features and/or explicitly by using geographic metadata combined with
11 | heuristics. We introduce a geocoder (location mention disambiguator) that achieves
12 | state-of-the-art (SOTA) results on three diverse datasets by exploiting the implicit
13 | lexical clues. Moreover, we propose a new method for systematic encoding of
14 | geographic metadata to generate two distinct views of the same text. To that end,
15 | we introduce the Map Vector (MapVec), a sparse representation obtained by plotting
16 | prior geographic probabilities, derived from population figures, on a World
17 | Map. We then integrate the implicit (language) and explicit (map) features to significantly
18 | improve a range of metrics. We also introduce an open-source dataset for
19 | geoparsing of news events covering global disease outbreaks and epidemics to help
20 | future evaluation in geoparsing.
21 |
22 | ##### Resources
23 |
24 | This repository contains the accompanying data and source code for CamCoder (toponym resolver) described in the paper. Additional data is required as the files are too large for GitHub, please download files from **https://www.repository.cam.ac.uk/handle/1810/277772**.
25 |
26 | #### Dependencies
27 | * Keras 2.2.0 https://keras.io/#installation
28 | * Tensorflow 1.8 https://www.tensorflow.org/install/
29 | * Spacy 2.0 (also download a model https://spacy.io/usage/models)
30 | * Python 2.7+ and a recent version of sqlite, matplotlib, cpickle and geopy
31 | * The rest should be installed alongside the three major libraries
32 | * Next time I'll use Docker, too late now, sorry about that.
33 |
34 | ### Instructions
35 | * Download the `weights.zip` and `geonames.db.zip` files as a **minimum** (optional files available from *https://www.repository.cam.ac.uk/handle/1810/277772*).
36 | * Read the `README.txt` in the repository to learn about the contents.
37 | * Create a **data** folder *outside the root directory* to store the large files. N.B. There is already a data folder **inside** the root directory! This holds the small files.
38 | * Unzip the files into that directory, this will take up a few GBs of space.
39 | * For replication, use `test.py` and see further instructions in the code. That should run out of the box if you followed the previous instructions. If not, get in touch!
40 | * To tweak the model, use `train.py`, see comments inside the script for more info.
41 |
42 | Use a GPU, if you can, a CPU epoch takes such a looooooong time, it's only worth it for small jobs. Contact me on :envelope: *mg711 at cam dot ac dot uk* :envelope: if you need any help with reproduction or some other aspect of this work at any time. After graduation, find me on Twitter/milangritta or raise an issue/ticket.
43 |
44 | ### Tools
45 | I included a couple of 'tools' for applied scientists and tinkerers in case you want to parse your own text and/or want to compare system performance with your research.
46 | #### text2mapVec.py
47 | This is a simple function `buildMapVec(text)` that turns text into a **Map Vector** i.e. extracts locations/toponyms with **Spacy NER** and creates the 'bag of locations' or the Map Vector as an additional feature vector to be used in a downstream task.
48 |
49 | *NOTE: The speed of execution won't be a record breaker, this is research code, I'm really busy trying to finish the PhD, sorry, I don't have time to rewrite it from scratch using proper software engineering principles. I hope you understand. Feel free to fork and edit.*
50 | #### geoparse.py
51 | Unline most (maybe all) geoparsers, CamCoder can perform *geotagging* (NER) and *geocoding* separately. Use (1.) for the full pipeline and (2.) for toponym resolution only.
52 | 1. To geocode with NER: Use `geoparse(text)`, instructions in the code.
53 | 2. To geocode with Oracle: This will be slightly more laborious as you will need the `generate_evaluation_data(corpus, file_name)` function in `preprocessing.py`. First, save your evaluation dataset in the format of `data/lgl.txt` (name,,name,,lat,,lon,,start,end) then you don't have to modify any code. I think it's the best option. Once you have generated machine-readable data with that function, you're ready to `test.py` the performance.
54 |
55 | *NOTE: CamCoder uses **Spacy NER** for Named Entity Recognition. The reported F-Scores for each model can be found here https://spacy.io/models/en, not that great and will certainly affect performance. Use **Oracle NER** for a scientifically adequate comparison. Oracle means you extract the entities separately with perfect fidelity, then evaluate toponym recognition in isolation. Also feel free to plug in a custom **NER tagger**, the code is extendable and should be well documented. Famous last words :-)*
56 |
--------------------------------------------------------------------------------
/context2vec.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import codecs
3 | import numpy as np
4 | import cPickle
5 | from keras import Input
6 | from keras.callbacks import ModelCheckpoint, EarlyStopping
7 | from keras.engine import Model
8 | from keras.layers.merge import concatenate
9 | from keras.layers import Embedding, Dense, Dropout, LSTM
10 | from preprocessing import BATCH_SIZE, EMBEDDING_DIMENSION, CONTEXT_LENGTH, UNKNOWN, TARGET_LENGTH
11 | from preprocessing import generate_arrays_from_file_lstm, ENCODING_MAP_2x2, ENCODING_MAP_1x1
12 | from subprocess import check_output
13 |
14 | print(u"Embedding Dimension:", EMBEDDING_DIMENSION)
15 | print(u"Input length (each side):", CONTEXT_LENGTH)
16 | word_to_index = cPickle.load(open(u"data/words2index.pkl"))
17 | print(u"Vocabulary Size:", len(word_to_index))
18 |
19 | vectors = {UNKNOWN: np.ones(EMBEDDING_DIMENSION), u'0': np.ones(EMBEDDING_DIMENSION)}
20 | for line in codecs.open(u"../data/glove.twitter." + str(EMBEDDING_DIMENSION) + u"d.txt", encoding=u"utf-8"):
21 | if line.strip() == "":
22 | continue
23 | t = line.split()
24 | vectors[t[0]] = [float(x) for x in t[1:]]
25 | print(u'Vectors...', len(vectors))
26 |
27 | emb_weights = np.zeros((len(word_to_index), EMBEDDING_DIMENSION))
28 | oov = 0
29 | for w in word_to_index:
30 | if w in vectors:
31 | emb_weights[word_to_index[w]] = vectors[w]
32 | else:
33 | emb_weights[word_to_index[w]] = np.random.normal(size=(EMBEDDING_DIMENSION,), scale=0.3)
34 | oov += 1
35 |
36 | emb_weights = np.array([emb_weights])
37 | print(u'Done preparing vectors...')
38 | print(u"OOV (no vectors):", oov)
39 | # --------------------------------------------------------------------------------------------------------------------
40 | print(u'Building model...')
41 | embeddings = Embedding(len(word_to_index), EMBEDDING_DIMENSION, input_length=CONTEXT_LENGTH, weights=emb_weights)
42 | # shared embeddings between all language input layers
43 |
44 | forward = Input(shape=(CONTEXT_LENGTH,))
45 | cwf = embeddings(forward)
46 | cwf = LSTM(300)(cwf)
47 | cwf = Dense(300)(cwf)
48 | cwf = Dropout(0.5)(cwf)
49 |
50 | backward = Input(shape=(CONTEXT_LENGTH,))
51 | cwb = embeddings(backward)
52 | cwb = LSTM(300, go_backwards=True)(cwb)
53 | cwb = Dense(300)(cwb)
54 | cwb = Dropout(0.5)(cwb)
55 |
56 | # Uncomment this block for MAPVEC + CONTEXT2VEC model, also uncomment 2 lines further down, thanks!
57 | # You also need to uncomment a few lines in preprocessing.py, generate_arrays_from_file_lstm() function
58 | # mapvec = Input(shape=(len(ENCODING_MAP_1x1),))
59 | # l2v = Dense(5000, activation='relu', input_dim=len(ENCODING_MAP_1x1))(mapvec)
60 | # l2v = Dense(1000, activation='relu')(l2v)
61 | # l2v = Dropout(0.5)(l2v)
62 |
63 | target_string = Input(shape=(TARGET_LENGTH,))
64 | ts = Embedding(len(word_to_index), EMBEDDING_DIMENSION, input_length=TARGET_LENGTH, weights=emb_weights)(target_string)
65 | ts = LSTM(50)(ts)
66 | ts = Dense(50)(ts)
67 | ts = Dropout(0.5)(ts)
68 |
69 | inp = concatenate([cwf, cwb, ts])
70 | # inp = concatenate([cwf, cwb, mapvec, ts]) # Uncomment for MAPVEC + CONTEXT2VEC
71 | inp = Dense(units=len(ENCODING_MAP_2x2), activation=u'softmax')(inp)
72 | model = Model(inputs=[forward, backward, target_string], outputs=[inp])
73 | # model = Model(inputs=[forward, backward, mapvec, target_string], outputs=[inp]) # Uncomment for MAPVEC + CONTEXT2VEC
74 | model.compile(loss=u'categorical_crossentropy', optimizer=u'rmsprop', metrics=[u'accuracy'])
75 |
76 | print(u'Finished building model...')
77 | # --------------------------------------------------------------------------------------------------------------------
78 | checkpoint = ModelCheckpoint(filepath=u"../data/weights.{epoch:02d}-{acc:.2f}.hdf5", verbose=0)
79 | early_stop = EarlyStopping(monitor=u'acc', patience=5)
80 | file_name = u"../data/train_wiki_uniform.txt"
81 | model.fit_generator(generate_arrays_from_file_lstm(file_name, word_to_index),
82 | steps_per_epoch=int(check_output(["wc", file_name]).split()[0]) / BATCH_SIZE,
83 | epochs=250, callbacks=[checkpoint, early_stop])
84 |
--------------------------------------------------------------------------------
/data/eval_wiki_gold.txt.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milangritta/Geocoding-with-Map-Vector/69e6e590c56930ed80d346f6c2da6d58056182e3/data/eval_wiki_gold.txt.zip
--------------------------------------------------------------------------------
/data/geovirus.txt:
--------------------------------------------------------------------------------
1 |
2 | Sudan,,Sudan,,15,,32,,994,,999||
3 |
4 | Texas,,Texas,,31,,-100,,86,,91||Africa,,Africa,,7.18,,21.09,,441,,447||
5 | Nigeria,,Nigeria,,8,,10,,423,,430||
6 | London,,London,,51.50,,-0.12,,28,,34||Sierra Leone,,Sierra Leone,,8.5,,-11.5,,342,,354||
7 |
8 | Taiwan,,Taiwan,,25.03,,121.63,,46,,52||Taoyuan,,Taoyuan,,24.98,,121.31,,96,,103||Taiwan,,Taiwan,,25.03,,121.63,,253,,259||
9 |
10 | Crawford County,,Crawford County,,41.68,,-80.11,,222,,237||Pennsylvania,,Pennsylvania,,41,,-77.5,,249,,261||Pennsylvania,,Pennsylvania,,41,,-77.5,,347,,359||Asia,,Asia,,29.84,,89.29,,505,,509||Europe,,Europe,,51,,17.5,,511,,517||Africa,,Africa,,7.18,,21.09,,522,,528||Pennsylvania,,Pennsylvania,,41,,-77.5,,934,,946||
11 |
12 | Sweden,,Sweden,,63,,16,,100,,106||Baltic Sea,,Baltic Sea,,58,,20,,669,,679||
13 | Egypt,,Egypt,,26,,30,,383,,388||Cairo,,Cairo,,30.04,,31.23,,398,,403||
14 | United Kingdom,,United Kingdom,,55,,-3,,22,,36||Suffolk,,Suffolk,,52.16,,1,,256,,263||Norfolk,,Norfolk,,52.66,,1,,596,,603||
15 | Hong Kong,,Hong Kong,,22.3,,114.2,,357,,366||Indonesia,,Indonesia,,-5,,120,,433,,442||
16 | Jakarta,,Jakarta,,-6.2,,106.81,,298,,305||
17 | England,,England,,51.5,,-0.11,,669,,676||
18 |
19 | Russia,,Russia,,60,,90,,83,,89||Romania,,Romania,,46,,25,,91,,98||Macedonia,,Macedonia,,41.6,,21.7,,104,,113||China,,China,,35,,103,,202,,207||Hohhot,,Hohhot,,40.81,,111.65,,273,,279||Russia,,Russia,,60,,90,,368,,374||Moscow,,Moscow,,55.75,,37.61,,470,,476||Russia,,Russia,,60,,90,,587,,593||Macedonia,,Macedonia,,41.6,,21.7,,623,,632||Danube Delta,,Danube Delta,,45.33,,29.5,,790,,802||
20 | Alaska,,Alaska,,64,,-150,,334,,340||Asia,,Asia,,29.84,,89.29,,379,,383||Europe,,Europe,,51,,17.5,,437,,443||Africa,,Africa,,7.18,,21.09,,448,,454||North America,,North America,,54.77,,-105.64,,553,,566||
21 | Europe,,Europe,,51,,17.5,,20,,26||Greece,,Greece,,39,,22,,277,,283||Bulgaria,,Bulgaria,,42.75,,25.5,,285,,293||Italy,,Italy,,43,,12,,295,,300||Austria,,Austria,,47.33,,13.33,,302,,309||Germany,,Germany,,51,,9,,314,,321||Slovenia,,Slovenia,,46.11,,14.81,,430,,438||Croatia,,Croatia,,45.16,,15.5,,440,,447||Denmark,,Denmark,,56,,10,,452,,459||Africa,,Africa,,7.18,,21.09,,526,,532||Europe,,Europe,,51,,17.5,,536,,542||Russia,,Russia,,60,,90,,640,,646||
22 | Egypt,,Egypt,,26,,30,,12,,17||Egypt,,Egypt,,26,,30,,159,,164||
23 | Pyongyang,,Pyongyang,,39.01,,125.73,,94,,103||North Korea,,North Korea,,40,,127,,449,,460||
24 | India,,India,,21,,78,,95,,100||
25 | Iraq,,Iraq,,33,,44,,32,,36||United States,,United States,,40,,-100,,160,,173||Cairo,,Cairo,,30.04,,31.23,,197,,202||Iraq,,Iraq,,33,,44,,587,,591||Turkey,,Turkey,,39,,35,,636,,642||
26 |
27 | Poland,,Poland,,52,,20,,18,,24||Pulawy,,Pulawy,,51.41,,21.96,,481,,487||
28 | France,,France,,47,,2,,157,,163||France,,France,,47,,2,,165,,171||Austria,,Austria,,47.33,,13.33,,249,,256||Germany,,Germany,,51,,9,,258,,265||Greece,,Greece,,39,,22,,287,,293||Italy,,Italy,,43,,12,,298,,303||Croatia,,Croatia,,45.16,,15.5,,332,,339||Denmark,,Denmark,,56,,10,,344,,351||Europe,,Europe,,51,,17.5,,504,,510||France,,France,,47,,2,,816,,822||
29 | United Kingdom,,United Kingdom,,55,,-3,,25,,39||Cellardyke,,Cellardyke,,56.21,,-2.7,,387,,397||Suffolk,,Suffolk,,52.16,,1,,473,,480||
30 | Medan,,Medan,,3.58,,98.66,,371,,376||
31 | China,,China,,35,,103,,53,,58||
32 | Germany,,Germany,,51,,9,,95,,102||France,,France,,47,,2,,171,,177||France,,France,,47,,2,,421,,427||Europe,,Europe,,51,,17.5,,774,,780||
33 | Romania,,Romania,,46,,25,,92,,99||Ciocile,,Ciocile,,44.81,,27.23,,277,,284||Russia,,Russia,,60,,90,,993,,999||
34 | Michigan,,Michigan,,44,,-85,,99,,107||Lake Erie,,Lake Erie,,42.2,,-81.2,,124,,133||Monroe County,,Monroe County,,41.92,,-83.5,,171,,184||North America,,North America,,54.77,,-105.64,,575,,588||Asia,,Asia,,29.84,,89.29,,676,,680||Michigan,,Michigan,,44,,-85,,922,,930||
35 |
36 | Dogubayazit,,Dogubayazit,,39.54,,44.08,,62,,73||
37 | Illinois,,Illinois,,40,,-89,,889,,897||Asia,,Asia,,29.84,,89.29,,500,,504||Europe,,Europe,,51,,17.5,,506,,512||Africa,,Africa,,7.18,,21.09,,517,,523||
38 | United States,,United States,,40,,-100,,35,,48||
39 | Mexico,,Mexico,,23,,-102,,14,,20||United States,,United States,,40,,-100,,381,,394||New Zealand,,New Zealand,,-42,,174,,993,,1004||
40 |
41 | Israel,,Israel,,31,,35,,278,,284||Gaza,,Gaza,,31.41,,34.33,,303,,307||Egypt,,Egypt,,26,,30,,313,,318||Gaza,,Gaza,,31.41,,34.33,,462,,466||
42 | Kenya,,Kenya,,1,,38,,79,,84||Kenya,,Kenya,,1,,38,,145,,150||Kisumu,,Kisumu,,-0.1,,34.75,,266,,272||India,,India,,21,,78,,376,,381||Britain,,Britain,,55,,-3,,810,,817||London,,London,,51.50,,-0.12,,872,,878||Kenya,,Kenya,,1,,38,,1436,,1441||
43 | United States,,United States,,40,,-100,,30,,43||Norway,,Norway,,61,,8,,48,,54||Norway,,Norway,,61,,8,,298,,304||North Carolina,,North Carolina,,35.5,,-80,,578,,592||Mexico,,Mexico,,23,,-102,,1404,,1410||China,,China,,35,,103,,1412,,1417||Japan,,Japan,,35,,136,,1419,,1424||Brazil,,Brazil,,-10,,-52,,1438,,1444||
44 | India,,India,,21,,78,,327,,332||Sudan,,Sudan,,15,,32,,337,,342||Morocco,,Morocco,,32,,-6,,365,,372||Nigeria,,Nigeria,,8,,10,,392,,399||Egypt,,Egypt,,26,,30,,1214,,1219||Cairo,,Cairo,,30.04,,31.23,,1261,,1266||Africa,,Africa,,7.18,,21.09,,1397,,1403||Saudi Arabia,,Saudi Arabia,,24,,45,,1452,,1464||Iran,,Iran,,32,,53,,1479,,1483||
45 |
46 | United States,,United States,,40,,-100,,1158,,1171||
47 | New York,,New York,,43,,-75,,313,,321||
48 |
49 |
50 | Argentina,,Argentina,,-34,,-64,,36,,45||Buenos Aires,,Buenos Aires,,-34.60,,-58.38,,254,,266||Argentina,,Argentina,,-34,,-64,,386,,395||Argentina,,Argentina,,-34,,-64,,655,,664||South America,,South America,,-14.60,,-57.65,,716,,729||Argentina,,Argentina,,-34,,-64,,893,,902||
51 | United Kingdom,,United Kingdom,,55,,-3,,298,,312||Kenya,,Kenya,,1,,38,,1100,,1105||Kenya,,Kenya,,1,,38,,1196,,1201||
52 | Africa,,Africa,,7.18,,21.09,,105,,111||Zimbabwe,,Zimbabwe,,-20,,30,,203,,211||Angola,,Angola,,-12.5,,18.5,,873,,879||
53 | Ethiopia,,Ethiopia,,8,,38,,202,,210||Sudan,,Sudan,,15,,32,,215,,220||Africa,,Africa,,7.18,,21.09,,411,,417||
54 | Egypt,,Egypt,,26,,30,,110,,115||United States,,United States,,40,,-100,,803,,816||
55 | Asia,,Asia,,29.84,,89.29,,88,,92||Afghanistan,,Afghanistan,,33,,65,,459,,470||India,,India,,21,,78,,472,,477||Pakistan,,Pakistan,,30,,70,,483,,491||Asia,,Asia,,29.84,,89.29,,624,,628||
56 | Peru,,Peru,,-10,,-76,,25,,29||Peru,,Peru,,-10,,-76,,516,,520||
57 | South Africa,,South Africa,,-30,,25,,28,,40||Johannesburg,,Johannesburg,,-26.20,,28.04,,763,,775||Mozambique,,Mozambique,,-18.25,,35,,940,,950||United States,,United States,,40,,-100,,1344,,1357||
58 | Dallas County,,Dallas County,,32.77,,-96.78,,409,,422||
59 | Libya,,Libya,,27,,17,,1,,6||Bulgaria,,Bulgaria,,42.75,,25.5,,265,,273||Libya,,Libya,,27,,17,,648,,653||Libya,,Libya,,27,,17,,800,,805||Libya,,Libya,,27,,17,,912,,917||Libya,,Libya,,27,,17,,993,,998||Libya,,Libya,,27,,17,,1276,,1281||Libya,,Libya,,27,,17,,1369,,1374||Libya,,Libya,,27,,17,,1395,,1400||France,,France,,47,,2,,1558,,1564||France,,France,,47,,2,,1614,,1620||Libya,,Libya,,27,,17,,1635,,1640||Libya,,Libya,,27,,17,,1670,,1675||Europe,,Europe,,51,,17.5,,1770,,1776||Paris,,Paris,,48.85,,2.35,,1875,,1880||Bulgaria,,Bulgaria,,42.75,,25.5,,2175,,2183||
60 | France,,France,,47,,2,,878,,884||
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 | United States,,United States,,40,,-100,,196,,209||Canada,,Canada,,60,,-95,,214,,220||Honduras,,Honduras,,15,,-86.5,,341,,349||United States,,United States,,40,,-100,,504,,517||United States,,United States,,40,,-100,,583,,596||Canada,,Canada,,60,,-95,,624,,630||United States,,United States,,40,,-100,,750,,763||Arizona,,Arizona,,34,,-112,,801,,808||California,,California,,37,,-120,,810,,820||Colorado,,Colorado,,39,,-105.5,,822,,830||Georgia,,Georgia,,33,,-83.5,,832,,839||Illinois,,Illinois,,40,,-89,,841,,849||Missouri,,Missouri,,38.5,,-92.5,,851,,859||New Jersey,,New Jersey,,40,,-74.5,,861,,871||New Mexico,,New Mexico,,34,,-106,,873,,883||New York,,New York,,43,,-75,,885,,893||Ohio,,Ohio,,40.5,,-82.5,,895,,899||Oklahoma,,Oklahoma,,35.5,,-98,,901,,909||Oregon,,Oregon,,44,,-120.5,,911,,917||Tennessee,,Tennessee,,36,,-86,,919,,928||Utah,,Utah,,39,,-111,,930,,934||Washington,,Washington,,47.5,,-120.5,,936,,946||Wisconsin,,Wisconsin,,44.5,,-89.5,,951,,960||Canada,,Canada,,60,,-95,,975,,981||Alberta,,Alberta,,55,,-115,,1012,,1019||Manitoba,,Manitoba,,55,,-97,,1021,,1029||Ontario,,Ontario,,50,,-85,,1031,,1038||Honduras,,Honduras,,15,,-86.5,,1629,,1637||United States,,United States,,40,,-100,,1651,,1664||Honduras,,Honduras,,15,,-86.5,,1722,,1730||Honduras,,Honduras,,15,,-86.5,,1910,,1918||
139 | United States,,United States,,40,,-100,,112,,125||Canada,,Canada,,60,,-95,,130,,136||Canada,,Canada,,60,,-95,,280,,286||
140 | United States,,United States,,40,,-100,,181,,194||Georgia,,Georgia,,33,,-83.5,,903,,910||United States,,United States,,40,,-100,,933,,946||
141 | Belgium,,Belgium,,50.83,,4,,225,,232||Belgium,,Belgium,,50.83,,4,,837,,844||Belgium,,Belgium,,50.83,,4,,1083,,1090||Belgium,,Belgium,,50.83,,4,,1199,,1206||New Zealand,,New Zealand,,-42,,174,,1601,,1612||
142 | South Africa,,South Africa,,-30,,25,,79,,91||Johannesburg,,Johannesburg,,-26.20,,28.04,,946,,958||
143 |
144 | Wisconsin,,Wisconsin,,44.5,,-89.5,,119,,128||Michigan,,Michigan,,44,,-85,,229,,237||Oregon,,Oregon,,44,,-120.5,,239,,245||New Mexico,,New Mexico,,34,,-106,,247,,257||New York,,New York,,43,,-75,,259,,267||Indiana,,Indiana,,40,,-86,,269,,276||Ohio,,Ohio,,40.5,,-82.5,,278,,282||Wisconsin,,Wisconsin,,44.5,,-89.5,,284,,293||Idaho,,Idaho,,45,,-114,,295,,300||Connecticut,,Connecticut,,41.6,,-72.7,,302,,313||Kentucky,,Kentucky,,37.5,,-85,,315,,323||Washington,,Washington,,47.5,,-120.5,,534,,544||Pennsylvania,,Pennsylvania,,41,,-77.5,,546,,558||California,,California,,37,,-120,,563,,573||Wisconsin,,Wisconsin,,44.5,,-89.5,,1903,,1912||Wisconsin,,Wisconsin,,44.5,,-89.5,,1933,,1942||California,,California,,37,,-120,,2633,,2643||
145 | United States,,United States,,40,,-100,,85,,98||Canada,,Canada,,60,,-95,,103,,109||California,,California,,37,,-120,,310,,320||
146 | Pennsylvania,,Pennsylvania,,41,,-77.5,,381,,393||New Jersey,,New Jersey,,40,,-74.5,,399,,409||Canada,,Canada,,60,,-95,,513,,519||Canada,,Canada,,60,,-95,,655,,661||Canada,,Canada,,60,,-95,,736,,742||Canada,,Canada,,60,,-95,,928,,934||Pennsylvania,,Pennsylvania,,41,,-77.5,,1316,,1328||New York,,New York,,43,,-75,,1516,,1524||Canada,,Canada,,60,,-95,,1658,,1664||Texas,,Texas,,31,,-100,,1821,,1826||
147 | Dominican Republic,,Dominican Republic,,19,,-70.66,,219,,237||Jamaica,,Jamaica,,18,,-77,,242,,249||Dominican Republic,,Dominican Republic,,19,,-70.66,,1044,,1062||Jamaica,,Jamaica,,18,,-77,,1066,,1073||Dominican Republic,,Dominican Republic,,19,,-70.66,,1666,,1684||Haiti,,Haiti,,19,,-72.41,,1888,,1893||
148 |
149 |
150 | Uganda,,Uganda,,1,,32,,798,,804||
151 | Ontario,,Ontario,,50,,-85,,680,,687||Ontario,,Ontario,,50,,-85,,767,,774||New York,,New York,,43,,-75,,1360,,1368||United States,,United States,,40,,-100,,1376,,1389||Ontario,,Ontario,,50,,-85,,1439,,1446||
152 |
153 | North America,,North America,,54.77,,-105.64,,3144,,3157||United States,,United States,,40,,-100,,3200,,3213||United States,,United States,,40,,-100,,3543,,3556||Italy,,Italy,,43,,12,,5203,,5208||Rome,,Rome,,41.9,,12.5,,5691,,5695||Singapore,,Singapore,,1.3,,103.8,,7140,,7149||Santa Maria,,Santa Maria,,6.55,,125.46,,7275,,7286||Pung-Pang,,Pongpong,,6.49,,125.46,,7527,,7535||
154 | India,,India,,21,,78,,186,,191||
155 | Singapore,,Singapore,,1.3,,103.8,,152,,161||Hong Kong,,Hong Kong,,22.3,,114.2,,466,,475||
156 |
157 | New South Wales,,New South Wales,,-32.16,,147.01,,87,,102||Sydney,,Sydney,,-33.86,,151.20,,772,,778||Sydney,,Sydney,,-33.86,,151.20,,1067,,1073||Melbourne,,Melbourne,,-37.81,,144.96,,1078,,1087||
158 | Africa,,Africa,,7.18,,21.09,,336,,342||France,,France,,47,,2,,409,,415||Germany,,Germany,,51,,9,,420,,427||France,,France,,47,,2,,567,,573||Germany,,Germany,,51,,9,,578,,585||
159 | Angola,,Angola,,-12.5,,18.5,,83,,89||London,,London,,51.50,,-0.12,,793,,799||Munich,,Munich,,48.13,,11.56,,804,,810||Angola,,Angola,,-12.5,,18.5,,1314,,1320||
160 | Zimbabwe,,Zimbabwe,,-20,,30,,46,,54||Botswana,,Botswana,,-24.65,,25.90,,1186,,1194||Mozambique,,Mozambique,,-18.25,,35,,1196,,1206||Zimbabwe,,Zimbabwe,,-20,,30,,1237,,1245||South Africa,,South Africa,,-30,,25,,1212,,1224||Zimbabwe,,Zimbabwe,,-20,,30,,1519,,1527||Zimbabwe,,Zimbabwe,,-20,,30,,1602,,1610||
161 |
162 | London,,London,,51.50,,-0.12,,929,,935||Italy,,Italy,,43,,12,,1053,,1058||France,,France,,47,,2,,1218,,1224||
163 | United States,,United States,,40,,-100,,41,,54||Canada,,Canada,,60,,-95,,82,,88||Alberta,,Alberta,,55,,-115,,895,,902||Manitoba,,Manitoba,,55,,-97,,918,,926||Calgary,,Calgary,,51.05,,-114.06,,1381,,1388||
164 | India,,India,,21,,78,,591,,596||Malaysia,,Malaysia,,2.5,,112.5,,645,,653||Myanmar,,Myanmar,,22,,96,,655,,662||Bangladesh,,Bangladesh,,23.8,,90.3,,664,,674||Tanzania,,Tanzania,,-6.30,,34.85,,699,,707||Kenya,,Kenya,,1,,38,,712,,717||
165 | Angola,,Angola,,-12.5,,18.5,,37,,43||Congo,,Zaire,,-2.88,,23.65,,714,,719||Uige,,Uige,,-7.61,,15.05,,1055,,1059||Uige,,Uige,,-7.61,,15.05,,1677,,1681||Angola,,Angola,,-12.5,,18.5,,1748,,1754||Mozambique,,Mozambique,,-18.25,,35,,1794,,1804||Angola,,Angola,,-12.5,,18.5,,2236,,2242||Angola,,Angola,,-12.5,,18.5,,2455,,2461||
166 | Indonesia,,Indonesia,,-5,,120,,1353,,1362||
167 | Zimbabwe,,Zimbabwe,,-20,,30,,96,,104||Africa,,Africa,,7.18,,21.09,,188,,194||Zimbabwe,,Zimbabwe,,-20,,30,,529,,537||Mozambique,,Mozambique,,-18.25,,35,,769,,779||South Africa,,South Africa,,-30,,25,,781,,793||
168 | Sydney,,Sydney,,-33.86,,151.20,,85,,91||Melbourne,,Melbourne,,-37.81,,144.96,,1546,,1555||
169 | Canada,,Canada,,60,,-95,,1022,,1028||Nicaragua,,Nicaragua,,13.09,,-86.00,,1598,,1607||Haiti,,Haiti,,19,,-72.41,,1657,,1662||Dominican Republic,,Dominican Republic,,19,,-70.66,,1671,,1689||
170 | Chad,,Chad,,15,,19,,511,,515||Guinea,,Guinea,,11,,-10,,517,,523||Mali,,Mali,,17,,-4,,534,,538||Mauritania,,Mauritania,,20,,-12,,540,,550||Senegal,,Senegal,,14,,-14,,552,,559||Benin,,Benin,,6.46,,2.6,,640,,645||Cape Verde,,Cape Verde,,15.11,,-23.61,,647,,657||Ghana,,Ghana,,7.81,,-1.05,,708,,713||Niger,,Niger,,16,,8,,730,,735||Nigeria,,Nigeria,,8,,10,,737,,744||
171 | United States,,United States,,40,,-100,,877,,890||Canada,,Canada,,60,,-95,,1309,,1315||Georgia,,Georgia,,33,,-83.5,,1464,,1471||Oklahoma,,Oklahoma,,35.5,,-98,,1473,,1481||Pennsylvania,,Pennsylvania,,41,,-77.5,,1483,,1495||Wisconsin,,Wisconsin,,44.5,,-89.5,,1497,,1506||California,,California,,37,,-120,,1511,,1521||California,,California,,37,,-120,,1700,,1710||
172 |
173 | Sweden,,Sweden,,63,,16,,82,,88||Stockholm,,Stockholm,,59.32,,18.06,,140,,149||United Kingdom,,United Kingdom,,55,,-3,,636,,650||Sweden,,Sweden,,63,,16,,753,,759||Sweden,,Sweden,,63,,16,,1094,,1100||
174 | United Kingdom,,United Kingdom,,55,,-3,,690,,704||
175 | Germany,,Germany,,51,,9,,90,,97||Belgium,,Belgium,,50.83,,4,,926,,933||France,,France,,47,,2,,935,,941||
176 | Pakistan,,Pakistan,,30,,70,,231,,239||Pakistan,,Pakistan,,30,,70,,1089,,1097||Australia,,Australia,,-25,,133,,1180,,1189||France,,France,,47,,2,,1191,,1197||Japan,,Japan,,35,,136,,1199,,1204||China,,China,,35,,103,,1214,,1219||Russia,,Russia,,60,,90,,1221,,1227||Iran,,Iran,,32,,53,,1229,,1233||Syria,,Syria,,35,,38,,1235,,1240||
177 | Mexico,,Mexico,,23,,-102,,174,,180||United States,,United States,,40,,-100,,189,,202||China,,China,,35,,103,,286,,291||Japan,,Japan,,35,,136,,293,,298||United Kingdom,,United Kingdom,,55,,-3,,308,,322||
178 | Ceres,,Ceres,,37.60,,-120.95,,82,,87||California,,California,,37,,-120,,89,,99||United States,,United States,,40,,-100,,107,,120||United States,,United States,,40,,-100,,722,,735||Mississauga,,Mississauga,,43.6,,-79.65,,1835,,1846||Ontario,,Ontario,,50,,-85,,1848,,1855||Canada,,Canada,,60,,-95,,1859,,1865||China,,China,,35,,103,,2106,,2111||
179 | Georgia,,Georgia,,33,,-83.5,,41,,48||Angola,,Angola,,-12.5,,18.5,,406,,412||Uganda,,Uganda,,1,,32,,448,,454||
180 | Kenya,,Kenya,,1,,38,,105,,110||Kenya,,Kenya,,1,,38,,268,,273||Kenya,,Kenya,,1,,38,,473,,478||Indian Ocean,,Indian Ocean,,-20,,80,,554,,566||
181 | Santa Ana,,Santa Ana,,33.74,,-117.88,,229,,238||Orange County,,Orange County,,33.67,,-117.78,,1640,,1653||Santa Ana,,Santa Ana,,33.74,,-117.88,,4722,,4731||Santa Ana,,Santa Ana,,33.74,,-117.88,,5238,,5247||Santa Ana,,Santa Ana,,33.74,,-117.88,,5581,,5590||Santa Ana,,Santa Ana,,33.74,,-117.88,,6149,,6158||Santa Ana,,Santa Ana,,33.74,,-117.88,,6377,,6386||Newport Beach,,Newport Beach,,33.61,,-117.89,,7056,,7069||
182 | Papua New Guinea,,Papua New Guinea,,-6,,147,,200,,216||Malaysia,,Malaysia,,2.5,,112.5,,432,,440||Vietnam,,Vietnam,,16.16,,107.83,,442,,449||
183 | Mayotte,,Mayotte,,-12.84,,45.13,,636,,643||
184 | Africa,,Africa,,7.18,,21.09,,146,,152||United States,,United States,,40,,-100,,868,,881||France,,France,,47,,2,,883,,889||Belgium,,Belgium,,50.83,,4,,891,,898||Australia,,Australia,,-25,,133,,900,,909||Denmark,,Denmark,,56,,10,,948,,955||Africa,,Africa,,7.18,,21.09,,2103,,2109||Africa,,Africa,,7.18,,21.09,,2142,,2148||
185 | California,,California,,37,,-120,,434,,444||California,,California,,37,,-120,,678,,688||California,,California,,37,,-120,,904,,914||
186 | Zimbabwe,,Zimbabwe,,-20,,30,,1242,,1250||
187 | Midrand,,Midrand,,-25.99,,28.12,,1307,,1314||Johannesburg,,Johannesburg,,-26.20,,28.04,,1346,,1358||China,,China,,35,,103,,2390,,2395||China,,China,,35,,103,,2777,,2782||China,,China,,35,,103,,2792,,2797||South Africa,,South Africa,,-30,,25,,3030,,3042||
188 | United States,,United States,,40,,-100,,270,,283||Egypt,,Egypt,,26,,30,,354,,359||Bulgaria,,Bulgaria,,42.75,,25.5,,361,,369||Nicaragua,,Nicaragua,,13.09,,-86.00,,375,,384||Lebanon,,Lebanon,,33.83,,35.83,,423,,430||Australia,,Australia,,-25,,133,,1218,,1227||Australia,,Australia,,-25,,133,,1592,,1601||Singapore,,Singapore,,1.3,,103.8,,2279,,2288||Singapore,,Singapore,,1.3,,103.8,,2455,,2464||Rio de Janeiro,,Rio de Janeiro,,-22.90,,-43.19,,2941,,2955||Santa Catarina,,Santa Catarina,,-27.25,,-50.33,,2965,,2979||Canada,,Canada,,60,,-95,,3536,,3542||Chile,,Chile,,-30,,-71,,3760,,3765||Chile,,Chile,,-30,,-71,,4070,,4075||New York,,New York,,40.71,,-74.00,,5100,,5108||Japan,,Japan,,35,,136,,5506,,5511||Spain,,Spain,,40,,-4,,5516,,5521||United States,,United States,,40,,-100,,5904,,5917||Iraq,,Iraq,,33,,44,,5921,,5925||Turkey,,Turkey,,39,,35,,5958,,5964||New York,,New York,,40.71,,-74.00,,6069,,6077||Toronto,,Toronto,,43.7,,-79.4,,6082,,6089||Istanbul,,Istanbul,,41.01,,28.95,,6345,,6353||United Kingdom,,United Kingdom,,55,,-3,,6425,,6439||England,,England,,51.5,,-0.11,,6457,,6464||Scotland,,Scotland,,56,,-4,,6805,,6813||United States,,United States,,40,,-100,,7443,,7456||Wisconsin,,Wisconsin,,44.5,,-89.5,,7726,,7735||United States,,United States,,40,,-100,,8046,,8059||
189 | Panama,,Panama,,9,,-80,,259,,265||Australia,,Australia,,-25,,133,,1122,,1131||Asia,,Asia,,29.84,,89.29,,1136,,1140||
190 | Australia,,Australia,,-25,,133,,119,,128||
191 | Cellardyke,,Cellardyke,,56.21,,-2.7,,83,,93||Scotland,,Scotland,,56,,-4,,103,,111||Scotland,,Scotland,,56,,-4,,222,,230||Scotland,,Scotland,,56,,-4,,3119,,3127||
192 | Mexico,,Mexico,,23,,-102,,758,,764||United States,,United States,,40,,-100,,773,,786||Canada,,Canada,,60,,-95,,1004,,1010||Nova Scotia,,Nova Scotia,,45,,-63,,1079,,1090||Ontario,,Ontario,,50,,-85,,1102,,1109||Alberta,,Alberta,,55,,-115,,1120,,1127||New Brunswick,,New Brunswick,,46,,-66,,1136,,1149||Quebec,,Quebec,,53,,-70,,1162,,1168||Alberta,,Alberta,,55,,-115,,1192,,1199||Mexico,,Mexico,,23,,-102,,1324,,1330||Mexico,,Mexico,,23,,-102,,1864,,1870||Egypt,,Egypt,,26,,30,,1910,,1915||Mexico,,Mexico,,23,,-102,,2123,,2129||Germany,,Germany,,51,,9,,2162,,2169||Mexico,,Mexico,,23,,-102,,2250,,2256||Spain,,Spain,,40,,-4,,2299,,2304||Mexico,,Mexico,,23,,-102,,2405,,2411||Mexico,,Mexico,,23,,-102,,2528,,2534||Hong Kong,,Hong Kong,,22.3,,114.2,,2413,,2422||Hong Kong,,Hong Kong,,22.3,,114.2,,3011,,3020||China,,China,,35,,103,,3263,,3268||Mexico,,Mexico,,23,,-102,,3292,,3298||Mexico,,Mexico,,23,,-102,,3721,,3727||New Zealand,,New Zealand,,-42,,174,,5241,,5252||North America,,North America,,54.77,,-105.64,,5533,,5546||Nigeria,,Nigeria,,8,,10,,6044,,6051||Nigeria,,Nigeria,,8,,10,,6138,,6145||Delaware,,Delaware,,39,,-75.5,,6547,,6555||Illinois,,Illinois,,40,,-89,,6557,,6565||Tennessee,,Tennessee,,36,,-86,,6597,,6606||Texas,,Texas,,31,,-100,,6859,,6864||Alabama,,Alabama,,32.7,,-86.7,,6885,,6892||Mexico,,Mexico,,23,,-102,,7214,,7220||Mexico,,Mexico,,23,,-102,,7366,,7372||
193 | Pakistan,,Pakistan,,30,,70,,38,,46||Pakistan,,Pakistan,,30,,70,,675,,683||Pakistan,,Pakistan,,30,,70,,1014,,1022||Pakistan,,Pakistan,,30,,70,,1873,,1881||Malaysia,,Malaysia,,2.5,,112.5,,2926,,2934||Pakistan,,Pakistan,,30,,70,,3012,,3020||Britain,,Britain,,55,,-3,,3026,,3033||
194 | Rwanda,,Rwanda,,-1.94,,29.87,,3241,,3247||
195 | Kenya,,Kenya,,1,,38,,919,,924||Kenya,,Kenya,,1,,38,,1026,,1031||Kenya,,Kenya,,1,,38,,1487,,1492||Uganda,,Uganda,,1,,32,,1770,,1776||
196 |
197 | United States,,United States,,40,,-100,,27,,40||United States,,United States,,40,,-100,,294,,307||Iraq,,Iraq,,33,,44,,439,,443||Afghanistan,,Afghanistan,,33,,65,,445,,456||North Korea,,North Korea,,40,,127,,458,,469||Iran,,Iran,,32,,53,,559,,563||Mexico,,Mexico,,23,,-102,,923,,929||
198 | Indonesia,,Indonesia,,-5,,120,,1392,,1401||
199 | Mexico,,Mexico,,23,,-102,,48,,54||Australia,,Australia,,-25,,133,,253,,262||Brazil,,Brazil,,-10,,-52,,264,,270||France,,France,,47,,2,,272,,278||Italy,,Italy,,43,,12,,280,,285||New Zealand,,New Zealand,,-42,,174,,287,,298||Norway,,Norway,,61,,8,,300,,306||Switzerland,,Switzerland,,46.83,,8.33,,308,,319||Brazil,,Brazil,,-10,,-52,,799,,805||Brazil,,Brazil,,-10,,-52,,1092,,1098||United States,,United States,,40,,-100,,1117,,1130||Argentina,,Argentina,,-34,,-64,,1218,,1227||China,,China,,35,,103,,1346,,1351||China,,China,,35,,103,,1913,,1918||China,,China,,35,,103,,2208,,2213||India,,India,,21,,78,,2723,,2728||Kenya,,Kenya,,1,,38,,3616,,3621||Mexico,,Mexico,,23,,-102,,4500,,4506||United Kingdom,,United Kingdom,,55,,-3,,5041,,5055||Britain,,Britain,,55,,-3,,6139,,6146||United States,,United States,,40,,-100,,6836,,6849||Vietnam,,Vietnam,,16.16,,107.83,,7067,,7074||
200 | Uganda,,Uganda,,1,,32,,136,,142||Uganda,,Uganda,,1,,32,,471,,477||Uganda,,Uganda,,1,,32,,542,,548||Uganda,,Uganda,,1,,32,,591,,597||
201 |
202 | China,,China,,35,,103,,398,,403||
203 | Northern Ireland,,Northern Ireland,,54.5,,-6.5,,38,,54||Northern Ireland,,Northern Ireland,,54.5,,-6.5,,243,,259||Spain,,Spain,,40,,-4,,353,,358||England,,England,,51.5,,-0.11,,385,,392||Northern Ireland,,Northern Ireland,,54.5,,-6.5,,461,,477||
204 | Denmark,,Denmark,,56,,10,,257,,264||
205 | Las Vegas,,Las Vegas,,36.17,,-115.13,,309,,318||
206 |
207 | Acapulco,,Acapulco,,16.86,,-99.88,,153,,161||Mexico,,Mexico,,23,,-102,,1597,,1603||Mexico,,Mexico,,23,,-102,,2109,,2115||Mexico City,,Mexico City,,19.43,,-99.13,,2151,,2162||South America,,South America,,-14.60,,-57.65,,2222,,2235||United States,,United States,,40,,-100,,2244,,2257||Mexico,,Mexico,,23,,-102,,2412,,2418||
208 | New Orleans,,New Orleans,,29.95,,-90.06,,22,,33||New Orleans,,New Orleans,,29.95,,-90.06,,1128,,1139||
209 |
210 | India,,India,,21,,78,,105,,110||
211 | Australia,,Australia,,-25,,133,,60,,69||Australia,,Australia,,-25,,133,,161,,170||Australia,,Australia,,-25,,133,,521,,530||Australia,,Australia,,-25,,133,,643,,652||Australia,,Australia,,-25,,133,,1066,,1075||Indonesia,,Indonesia,,-5,,120,,2296,,2305||
212 | Angola,,Angola,,-12.5,,18.5,,311,,317||Angola,,Angola,,-12.5,,18.5,,376,,382||Angola,,Angola,,-12.5,,18.5,,2079,,2085||Angola,,Angola,,-12.5,,18.5,,2157,,2163||
213 | China,,China,,35,,103,,67,,72||United Kingdom,,United Kingdom,,55,,-3,,673,,687||China,,China,,35,,103,,1729,,1734||China,,China,,35,,103,,1792,,1797||United States,,United States,,40,,-100,,2186,,2199||
214 | Iraq,,Iraq,,33,,44,,141,,145||Iraq,,Iraq,,33,,44,,454,,458||Kuwait,,Kuwait,,29.5,,45.75,,468,,474||
215 |
216 | Birmingham,,Birmingham,,33.52,,-86.81,,891,,901||
217 |
218 | Bradford,,Bradford,,44.11,,-79.56,,870,,878||Ontario,,Ontario,,50,,-85,,880,,887||
219 | Peru,,Peru,,-10,,-76,,132,,136||Bolivia,,Bolivia,,-16.71,,-64.66,,154,,161||Massachusetts,,Massachusetts,,42.3,,-71.8,,1475,,1488||London,,London,,51.50,,-0.12,,2065,,2071||
220 |
221 | Australia,,Australia,,-25,,133,,37,,46||
222 | Britain,,Britain,,55,,-3,,85,,92||Chechnya,,Chechnya,,43.4,,45.71,,632,,640||Moscow,,Moscow,,55.75,,37.61,,662,,668||Muswell Hill,,Muswell Hill,,51.59,,-0.14,,1949,,1961||Moscow,,Moscow,,55.75,,37.61,,2479,,2485||
223 | China,,China,,35,,103,,113,,118||
224 | United Kingdom,,United Kingdom,,55,,-3,,415,,429||Baghdad,,Baghdad,,33.33,,44.38,,1614,,1621||
225 | Georgia,,Georgia,,42,,43.5,,1,,8||Georgia,,Georgia,,42,,43.5,,464,,471||Georgia,,Georgia,,42,,43.5,,1432,,1439||
226 | Las Vegas,,Las Vegas,,36.17,,-115.13,,936,,945||
227 | Camborne,,Camborne,,50.21,,-5.3,,275,,283||
228 | Denver,,Denver,,39.76,,-104.88,,166,,172||Peru,,Peru,,-10,,-76,,249,,253||San Juan,,San Juan,,-7.29,,-78.49,,442,,450||Peru,,Peru,,-10,,-76,,1408,,1412||Indonesia,,Indonesia,,-5,,120,,2644,,2653||United States,,United States,,40,,-100,,2758,,2771||
229 | United States,,United States,,40,,-100,,78,,91||Florida,,Florida,,28.1,,-81.6,,1327,,1334||Utah,,Utah,,39,,-111,,1387,,1391||United States,,United States,,40,,-100,,1711,,1724||United States,,United States,,40,,-100,,2574,,2587||
230 |
--------------------------------------------------------------------------------
/data/iaa_answers.txt:
--------------------------------------------------------------------------------
1 | https://en.wikipedia.org/wiki/Dorset
2 | 96
3 | Dorset
4 | https://en.wikipedia.org/wiki/England
5 | 104
6 | England
7 | https://en.wikipedia.org/wiki/United_Kingdom
8 | 390
9 | United Kingdom
10 | https://en.wikipedia.org/wiki/Michigan
11 | 98
12 | Michigan
13 | https://en.wikipedia.org/wiki/Lake_Erie
14 | 123
15 | Lake Erie
16 | https://en.wikipedia.org/wiki/Pointe_Mouillee_State_Game_Area
17 | 142
18 | Mouillee
19 | https://en.wikipedia.org/wiki/Monroe_County,_Michigan
20 | 170
21 | Monroe County
22 | https://en.wikipedia.org/wiki/Michigan
23 | 262
24 | Michigan
25 | https://en.wikipedia.org/wiki/Ames,_Iowa
26 | 397
27 | Ames
28 | https://en.wikipedia.org/wiki/Iowa
29 | 403
30 | Iowa
31 | https://en.wikipedia.org/wiki/North_America
32 | 574
33 | North America
34 | https://en.wikipedia.org/wiki/Asia
35 | 675
36 | Asia
37 | https://en.wikipedia.org/wiki/Michigan
38 | 921
39 | Michigan
40 | https://en.wikipedia.org/wiki/United_States
41 | 956
42 | United States
43 | https://en.wikipedia.org/wiki/Buckinghamshire
44 | 85
45 | Buckinghamshire
46 | https://en.wikipedia.org/wiki/England
47 | 102
48 | England
49 | https://en.wikipedia.org/wiki/Milton_Keynes
50 | 333
51 | Milton Keynes
52 | https://en.wikipedia.org/wiki/Peru
53 | 24
54 | Peru
55 | https://en.wikipedia.org/wiki/Peru
56 | 174
57 | Peru
58 | https://en.wikipedia.org/wiki/Peru
59 | 338
60 | Peru
61 | https://en.wikipedia.org/wiki/Peru
62 | 515
63 | Peru
64 | https://en.wikipedia.org/wiki/Libya
65 | 0
66 | Libya
67 | https://en.wikipedia.org/wiki/Sofia
68 | 223
69 | Sofia
70 | https://en.wikipedia.org/wiki/Bulgaria
71 | 230
72 | Bulgaria
73 | https://en.wikipedia.org/wiki/Bulgaria
74 | 264
75 | Bulgaria
76 | https://en.wikipedia.org/wiki/Benghazi
77 | 547
78 | Benghazi
79 | https://en.wikipedia.org/wiki/Libya
80 | 647
81 | Libya
82 | https://en.wikipedia.org/wiki/Libya
83 | 799
84 | Libya
85 | https://en.wikipedia.org/wiki/Libya
86 | 911
87 | Libya
88 | https://en.wikipedia.org/wiki/Qatar
89 | 930
90 | Qatar
91 | https://en.wikipedia.org/wiki/Libya
92 | 992
93 | Libya
94 | https://en.wikipedia.org/wiki/Benghazi
95 | 1135
96 | Benghazi
97 | https://en.wikipedia.org/wiki/Libya
98 | 1275
99 | Libya
100 | https://en.wikipedia.org/wiki/Libya
101 | 1368
102 | Libya
103 | https://en.wikipedia.org/wiki/Libya
104 | 1394
105 | Libya
106 | https://en.wikipedia.org/wiki/France
107 | 1557
108 | France
109 | https://en.wikipedia.org/wiki/France
110 | 1613
111 | France
112 | https://en.wikipedia.org/wiki/Libya
113 | 1634
114 | Libya
115 | https://en.wikipedia.org/wiki/Libya
116 | 1669
117 | Libya
118 | https://en.wikipedia.org/wiki/France
119 | 1780
120 | France
121 | https://en.wikipedia.org/wiki/Libya
122 | 1837
123 | Libya
124 | https://en.wikipedia.org/wiki/Paris
125 | 1874
126 | Paris
127 | https://en.wikipedia.org/wiki/Bulgaria
128 | 2174
129 | Bulgaria
130 | https://en.wikipedia.org/wiki/London
131 | 80
132 | London
133 | https://en.wikipedia.org/wiki/United_Kingdom
134 | 612
135 | UK
136 | https://en.wikipedia.org/wiki/United_Kingdom
137 | 738
138 | UK
139 | https://en.wikipedia.org/wiki/United_States
140 | 163
141 | U.S.
142 | https://en.wikipedia.org/wiki/Central_Plateau_(Haiti)
143 | 710
144 | Central Plateau
145 | https://en.wikipedia.org/wiki/Artibonite_(department)
146 | 730
147 | Artibonite
148 | https://en.wikipedia.org/wiki/Port-au-Prince
149 | 803
150 | Port-Au-Prince
151 | https://en.wikipedia.org/wiki/Java
152 | 80
153 | Java
154 | https://en.wikipedia.org/wiki/Java
155 | 340
156 | Java
157 | https://en.wikipedia.org/wiki/Pangandaran
158 | 935
159 | Pangandaran
160 | https://en.wikipedia.org/wiki/Indonesia
161 | 1226
162 | Indonesia
163 | https://en.wikipedia.org/wiki/Hong_Kong
164 | 54
165 | Hong Kong
166 | https://en.wikipedia.org/wiki/Kitaakita
167 | 89
168 | Kitaakita
169 | https://en.wikipedia.org/wiki/Akita_Prefecture
170 | 114
171 | Akita Prefecture
172 | https://en.wikipedia.org/wiki/Japan
173 | 143
174 | Japan
175 | https://en.wikipedia.org/wiki/United_States
176 | 224
177 | United States
178 | https://en.wikipedia.org/wiki/New_York_City
179 | 1201
180 | New York City
181 | https://en.wikipedia.org/wiki/New_York_City
182 | 1313
183 | New York
184 | https://en.wikipedia.org/wiki/California
185 | 1571
186 | California
187 | https://en.wikipedia.org/wiki/Kansas
188 | 1633
189 | Kansas
190 | https://en.wikipedia.org/wiki/Texas
191 | 1644
192 | Texas
193 | https://en.wikipedia.org/wiki/United_States
194 | 2089
195 | U.S.
196 | https://en.wikipedia.org/wiki/Kabanjahe
197 | 71
198 | Kabanjahe
199 | https://en.wikipedia.org/wiki/Sumatra
200 | 93
201 | Sumatra
202 | https://en.wikipedia.org/wiki/Indonesia
203 | 104
204 | Indonesia
205 | https://en.wikipedia.org/wiki/Kabanjahe
206 | 307
207 | Kabanjahe
208 | https://en.wikipedia.org/wiki/Indonesia
209 | 350
210 | Indonesia
211 | https://en.wikipedia.org/wiki/Atlanta
212 | 500
213 | Atlanta
214 | https://en.wikipedia.org/wiki/Georgia_(U.S._state)
215 | 509
216 | Georgia
217 | https://en.wikipedia.org/wiki/Atlanta
218 | 669
219 | Atlanta
220 | https://en.wikipedia.org/wiki/China
221 | 84
222 | China
223 | https://en.wikipedia.org/wiki/Beijing
224 | 120
225 | Beijing
226 | https://en.wikipedia.org/wiki/China
227 | 400
228 | China
229 | https://en.wikipedia.org/wiki/Hebei
230 | 657
231 | Hebei
232 | https://en.wikipedia.org/wiki/Hubei
233 | 786
234 | Hubei
235 | https://en.wikipedia.org/wiki/China
236 | 870
237 | People's Republic of China
238 | https://en.wikipedia.org/wiki/China
239 | 990
240 | China
241 | https://en.wikipedia.org/wiki/Anhui
242 | 1143
243 | Anhui
244 | https://en.wikipedia.org/wiki/Fuyang
245 | 1276
246 | Fuyang
247 | https://en.wikipedia.org/wiki/Anhui
248 | 1286
249 | Anhui
250 | https://en.wikipedia.org/wiki/Beijing
251 | 1531
252 | Beijing
253 | https://en.wikipedia.org/wiki/Anhui
254 | 1581
255 | Anhui
256 | https://en.wikipedia.org/wiki/Guangdong
257 | 1588
258 | Guangdong
259 | https://en.wikipedia.org/wiki/Guangxi
260 | 1599
261 | Guangxi
262 | https://en.wikipedia.org/wiki/Hainan
263 | 1608
264 | Hainan
265 | https://en.wikipedia.org/wiki/Hunan
266 | 1616
267 | Hunan
268 | https://en.wikipedia.org/wiki/Zhejiang
269 | 1623
270 | Zhejiang
271 | https://en.wikipedia.org/wiki/Beijing
272 | 1633
273 | Beijing
274 | https://en.wikipedia.org/wiki/Hubei
275 | 1645
276 | Hubei
277 | https://en.wikipedia.org/wiki/Beijing
278 | 2195
279 | Beijing
280 | https://en.wikipedia.org/wiki/China
281 | 2393
282 | China
283 | https://en.wikipedia.org/wiki/Asia
284 | 80
285 | Asia
286 | https://en.wikipedia.org/wiki/India
287 | 112
288 | India
289 | https://en.wikipedia.org/wiki/Nepal
290 | 119
291 | Nepal
292 | https://en.wikipedia.org/wiki/Bangladesh
293 | 130
294 | Bangladesh
295 | https://en.wikipedia.org/wiki/Bihar
296 | 461
297 | Bihar
298 | https://en.wikipedia.org/wiki/Uttar_Pradesh
299 | 471
300 | Uttar Pradesh
301 | https://en.wikipedia.org/wiki/Bihar
302 | 585
303 | Bihar
304 | https://en.wikipedia.org/wiki/India
305 | 794
306 | India
307 | None
308 | 1112
309 | Gondra
310 | https://en.wikipedia.org/wiki/Uttar_Pradesh
311 | 1131
312 | Uttar Pradesh
313 | https://en.wikipedia.org/wiki/Greenlane
314 | 76
315 | Greenlane
316 | https://en.wikipedia.org/wiki/Auckland
317 | 87
318 | Auckland
319 | https://en.wikipedia.org/wiki/New_Zealand
320 | 97
321 | New Zealand
322 | https://en.wikipedia.org/wiki/Auckland
323 | 252
324 | Auckland
325 | https://en.wikipedia.org/wiki/Greenlane
326 | 1569
327 | Greenlane
328 | https://en.wikipedia.org/wiki/Auckland
329 | 1580
330 | Auckland
331 | https://en.wikipedia.org/wiki/Auckland
332 | 1679
333 | Auckland
334 | https://en.wikipedia.org/wiki/Zimbabwe
335 | 45
336 | Zimbabwe
337 | https://en.wikipedia.org/wiki/Zimbabwe
338 | 293
339 | Zimbabwe
340 | https://en.wikipedia.org/wiki/Zimbabwe
341 | 387
342 | Zimbabwe
343 | https://en.wikipedia.org/wiki/Zimbabwe
344 | 711
345 | Zimbabwe
346 | https://en.wikipedia.org/wiki/Harare
347 | 787
348 | Harare
349 | https://en.wikipedia.org/wiki/Mabvuku
350 | 897
351 | Mabvuku
352 | https://en.wikipedia.org/wiki/Harare
353 | 931
354 | Harare
355 | https://en.wikipedia.org/wiki/Botswana
356 | 1185
357 | Botswana
358 | https://en.wikipedia.org/wiki/Mozambique
359 | 1195
360 | Mozambique
361 | https://en.wikipedia.org/wiki/South_Africa
362 | 1211
363 | South Africa
364 | https://en.wikipedia.org/wiki/Zimbabwe
365 | 1236
366 | Zimbabwe
367 | https://en.wikipedia.org/wiki/Zimbabwe
368 | 1518
369 | Zimbabwe
370 | https://en.wikipedia.org/wiki/Zimbabwe
371 | 1601
372 | Zimbabwe
373 | https://en.wikipedia.org/wiki/Zimbabwe
374 | 3
375 | Zimbabwe
376 | https://en.wikipedia.org/wiki/Wedza_District
377 | 54
378 | Wedza
379 | https://en.wikipedia.org/wiki/Mashonaland_East_Province
380 | 70
381 | Mashonaland East
382 | https://en.wikipedia.org/wiki/Midlands_Province
383 | 549
384 | Midlands
385 | https://en.wikipedia.org/wiki/Zimbabwe
386 | 1241
387 | Zimbabwe
388 | https://en.wikipedia.org/wiki/United_States
389 | 26
390 | United States
391 | https://en.wikipedia.org/wiki/United_States
392 | 293
393 | United States
394 | https://en.wikipedia.org/wiki/Iraq
395 | 438
396 | Iraq
397 | https://en.wikipedia.org/wiki/Afghanistan
398 | 444
399 | Afghanistan
400 | https://en.wikipedia.org/wiki/North_Korea
401 | 457
402 | North Korea
403 | https://en.wikipedia.org/wiki/Iran
404 | 558
405 | Iran
406 | https://en.wikipedia.org/wiki/United_States
407 | 915
408 | U.S.
409 | https://en.wikipedia.org/wiki/Mexico
410 | 922
411 | Mexico
412 | https://en.wikipedia.org/wiki/China
413 | 169
414 | China
415 | https://en.wikipedia.org/wiki/Indonesia
416 | 176
417 | Indonesia
418 | https://en.wikipedia.org/wiki/Africa
419 | 208
420 | Africa
421 | https://en.wikipedia.org/wiki/China
422 | 492
423 | China
424 | https://en.wikipedia.org/wiki/Indonesia
425 | 502
426 | Indonesia
427 | https://en.wikipedia.org/wiki/Africa
428 | 516
429 | Africa
430 | https://en.wikipedia.org/wiki/Rome
431 | 719
432 | Rome
433 | https://en.wikipedia.org/wiki/Italy
434 | 725
435 | Italy
436 | https://en.wikipedia.org/wiki/Africa
437 | 1117
438 | Africa
439 | https://en.wikipedia.org/wiki/Indonesia
440 | 1391
441 | Indonesia
442 | https://en.wikipedia.org/wiki/Java
443 | 1715
444 | Java
445 | https://en.wikipedia.org/wiki/China
446 | 1813
447 | China
448 | https://en.wikipedia.org/wiki/China
449 | 1858
450 | China
451 | https://en.wikipedia.org/wiki/Mexico
452 | 47
453 | Mexico
454 | https://en.wikipedia.org/wiki/Australia
455 | 252
456 | Australia
457 | https://en.wikipedia.org/wiki/Brazil
458 | 263
459 | Brazil
460 | https://en.wikipedia.org/wiki/France
461 | 271
462 | France
463 | https://en.wikipedia.org/wiki/Italy
464 | 279
465 | Italy
466 | https://en.wikipedia.org/wiki/New_Zealand
467 | 286
468 | New Zealand
469 | https://en.wikipedia.org/wiki/Norway
470 | 299
471 | Norway
472 | https://en.wikipedia.org/wiki/Switzerland
473 | 307
474 | Switzerland
475 | https://en.wikipedia.org/wiki/United_Kingdom
476 | 324
477 | UK
478 | https://en.wikipedia.org/wiki/United_States
479 | 336
480 | US
481 | https://en.wikipedia.org/wiki/United_States
482 | 656
483 | US
484 | https://en.wikipedia.org/wiki/Brazil
485 | 798
486 | Brazil
487 | https://en.wikipedia.org/wiki/Sao_Paulo
488 | 921
489 | Sao Paulo
490 | https://en.wikipedia.org/wiki/Rio_de_Janeiro
491 | 956
492 | Rio de Janeiro
493 | https://en.wikipedia.org/wiki/Brazil
494 | 1091
495 | Brazil
496 | https://en.wikipedia.org/wiki/United_States
497 | 1116
498 | United States
499 | https://en.wikipedia.org/wiki/Brazil
500 | 1228
501 | Brazil
502 | https://en.wikipedia.org/wiki/China
503 | 1345
504 | China
505 | https://en.wikipedia.org/wiki/China
506 | 1709
507 | China
508 | https://en.wikipedia.org/wiki/China
509 | 1912
510 | China
511 | https://en.wikipedia.org/wiki/China
512 | 1978
513 | China
514 | https://en.wikipedia.org/wiki/China
515 | 2207
516 | China
517 | https://en.wikipedia.org/wiki/France
518 | 2228
519 | France
520 | https://en.wikipedia.org/wiki/Kenya
521 | 3615
522 | Kenya
523 | https://en.wikipedia.org/wiki/Kenya
524 | 4276
525 | Kenya
526 | https://en.wikipedia.org/wiki/Nairobi
527 | 4292
528 | Nairobi
529 | https://en.wikipedia.org/wiki/Kisumu
530 | 4401
531 | Kisumu
532 | https://en.wikipedia.org/wiki/Rift_Valley_Province
533 | 4412
534 | Rift Valley
535 | https://en.wikipedia.org/wiki/Mexico
536 | 4499
537 | Mexico
538 | https://en.wikipedia.org/wiki/Mexico
539 | 4784
540 | Mexico
541 | https://en.wikipedia.org/wiki/United_Kingdom
542 | 5040
543 | United Kingdom
544 | https://en.wikipedia.org/wiki/United_Kingdom
545 | 5989
546 | UK
547 | https://en.wikipedia.org/wiki/United_States
548 | 6423
549 | US
550 | https://en.wikipedia.org/wiki/United_States
551 | 6835
552 | United States
553 | https://en.wikipedia.org/wiki/Vietnam
554 | 7066
555 | Vietnam
556 | None
557 | 80
558 | Carancas
559 | https://en.wikipedia.org/wiki/Lake_Titicaca
560 | 95
561 | Lake Titicaca
562 | https://en.wikipedia.org/wiki/Puno_Region
563 | 116
564 | Puno
565 | https://en.wikipedia.org/wiki/Peru
566 | 131
567 | Peru
568 | https://en.wikipedia.org/wiki/Bolivia
569 | 153
570 | Bolivia
571 | https://en.wikipedia.org/wiki/Desaguadero,_Bolivia-Peru
572 | 653
573 | Desaguadero
574 | https://en.wikipedia.org/wiki/Massachusetts
575 | 1474
576 | Massachusetts
577 | https://en.wikipedia.org/wiki/London
578 | 2064
579 | London
580 | https://en.wikipedia.org/wiki/Baghdad
581 | 25
582 | Baghdad
583 | https://en.wikipedia.org/wiki/Iraq
584 | 34
585 | Iraq
586 | https://en.wikipedia.org/wiki/Amman
587 | 321
588 | Amman
589 | https://en.wikipedia.org/wiki/Jordan
590 | 328
591 | Jordan
592 | https://en.wikipedia.org/wiki/United_Kingdom
593 | 414
594 | United Kingdom
595 | https://en.wikipedia.org/wiki/Adhamiyah
596 | 1247
597 | Adhamiya
598 | https://en.wikipedia.org/wiki/Adhamiyah
599 | 1591
600 | Adhamiyah
601 | https://en.wikipedia.org/wiki/Baghdad
602 | 1613
603 | Baghdad
604 |
--------------------------------------------------------------------------------
/data/iaa_check.txt:
--------------------------------------------------------------------------------
1 | https://en.wikipedia.org/wiki/Dorset
2 | 97
3 | Dorset
4 | https://en.wikipedia.org/wiki/England
5 | 105
6 | England
7 | https://en.wikipedia.org/wiki/United_Kingdom
8 | 391
9 | United Kingdom
10 | https://en.wikipedia.org/wiki/Michigan
11 | 99
12 | Michigan
13 | https://en.wikipedia.org/wiki/Lake_Erie
14 | 124
15 | Lake Erie
16 | https://en.wikipedia.org/wiki/Pointe_Mouillee_State_Game_Area
17 | 143
18 | Mouillee
19 | https://en.wikipedia.org/wiki/Monroe_County,_Michigan
20 | 171
21 | Monroe County
22 | https://en.wikipedia.org/wiki/Ames,_Iowa
23 | 398
24 | Ames
25 | https://en.wikipedia.org/wiki/Iowa
26 | 404
27 | Iowa
28 | https://en.wikipedia.org/wiki/North_America
29 | 575
30 | North America
31 | https://en.wikipedia.org/wiki/Asia
32 | 676
33 | Asia
34 | https://en.wikipedia.org/wiki/Michigan
35 | 922
36 | Michigan
37 | https://en.wikipedia.org/wiki/Buckinghamshire
38 | 86
39 | Buckinghamshire
40 | https://en.wikipedia.org/wiki/England
41 | 103
42 | England
43 | https://en.wikipedia.org/wiki/Milton_Keynes
44 | 334
45 | Milton Keynes
46 | https://en.wikipedia.org/wiki/Peru
47 | 25
48 | Peru
49 | https://en.wikipedia.org/wiki/Peru
50 | 175
51 | Peru
52 | https://en.wikipedia.org/wiki/Peru
53 | 339
54 | Peru
55 | https://en.wikipedia.org/wiki/Peru
56 | 516
57 | Peru
58 | https://en.wikipedia.org/wiki/Libya
59 | 1
60 | Libya
61 | https://en.wikipedia.org/wiki/Sofia
62 | 224
63 | Sofia
64 | https://en.wikipedia.org/wiki/Bulgaria
65 | 231
66 | Bulgaria
67 | https://en.wikipedia.org/wiki/Bulgaria
68 | 265
69 | Bulgaria
70 | https://en.wikipedia.org/wiki/Benghazi
71 | 548
72 | Benghazi
73 | https://en.wikipedia.org/wiki/Libya
74 | 648
75 | Libya
76 | https://en.wikipedia.org/wiki/Libya
77 | 800
78 | Libya
79 | https://en.wikipedia.org/wiki/Libya
80 | 912
81 | Libya
82 | https://en.wikipedia.org/wiki/Libya
83 | 993
84 | Libya
85 | https://en.wikipedia.org/wiki/Qatar
86 | 931
87 | Qatar
88 | https://en.wikipedia.org/wiki/Benghazi
89 | 1136
90 | Benghazi
91 | https://en.wikipedia.org/wiki/Libya
92 | 1276
93 | Libya
94 | https://en.wikipedia.org/wiki/Libya
95 | 1369
96 | Libya
97 | https://en.wikipedia.org/wiki/Libya
98 | 1395
99 | Libya
100 | https://en.wikipedia.org/wiki/France
101 | 1558
102 | France
103 | https://en.wikipedia.org/wiki/France
104 | 1614
105 | France
106 | https://en.wikipedia.org/wiki/Libya
107 | 1635
108 | Libya
109 | https://en.wikipedia.org/wiki/Libya
110 | 1670
111 | Libya
112 | https://en.wikipedia.org/wiki/Tripoli
113 | 1697
114 | Tripoli
115 | https://en.wikipedia.org/wiki/Europe
116 | 1770
117 | Europe
118 | https://en.wikipedia.org/wiki/Paris
119 | 1875
120 | Paris
121 | https://en.wikipedia.org/wiki/Bulgaria
122 | 2175
123 | Bulgaria
124 | https://en.wikipedia.org/wiki/London
125 | 81
126 | London
127 | https://en.wikipedia.org/wiki/Liverpool
128 | 178
129 | Liverpool
130 | https://en.wikipedia.org/wiki/United_Kingdom
131 | 613
132 | UK
133 | https://en.wikipedia.org/wiki/United_Kingdom
134 | 739
135 | UK
136 | https://en.wikipedia.org/wiki/Haiti
137 | 424
138 | Haiti
139 | https://en.wikipedia.org/wiki/Central_Plateau_(Haiti)
140 | 711
141 | Central Plateau
142 | https://en.wikipedia.org/wiki/Artibonite_(department)
143 | 731
144 | Artibonite
145 | https://en.wikipedia.org/wiki/Port-au-Prince
146 | 804
147 | Port-Au-Prince
148 | https://en.wikipedia.org/wiki/M%C3%B4le-Saint-Nicolas
149 | 970
150 | St. Nicolas
151 | https://en.wikipedia.org/wiki/Saint-Marc
152 | 1030
153 | St. Marc
154 | https://en.wikipedia.org/wiki/Java
155 | 81
156 | Java
157 | https://en.wikipedia.org/wiki/Java
158 | 341
159 | Java
160 | https://en.wikipedia.org/wiki/Pangandaran
161 | 936
162 | Pangandaran
163 | https://en.wikipedia.org/wiki/Indonesia
164 | 1227
165 | Indonesia
166 | https://en.wikipedia.org/wiki/Pangandaran
167 | 1282
168 | Pangandaran
169 | https://en.wikipedia.org/wiki/United_States
170 | 1519
171 | US
172 | https://en.wikipedia.org/wiki/Kitaakita
173 | 90
174 | Kitaakita
175 | https://en.wikipedia.org/wiki/Akita_Prefecture
176 | 115
177 | Akita Prefecture
178 | https://en.wikipedia.org/wiki/Japan
179 | 144
180 | Japan
181 | https://en.wikipedia.org/wiki/United_States
182 | 92
183 | U.S.
184 | https://en.wikipedia.org/wiki/United_States
185 | 225
186 | United States
187 | https://en.wikipedia.org/wiki/United_States
188 | 288
189 | United States
190 | https://en.wikipedia.org/wiki/New_York_City
191 | 1202
192 | New York City
193 | https://en.wikipedia.org/wiki/Queens
194 | 1306
195 | Queens
196 | https://en.wikipedia.org/wiki/New_York_City
197 | 1314
198 | New York
199 | https://en.wikipedia.org/wiki/Ohio
200 | 1495
201 | Ohio
202 | https://en.wikipedia.org/wiki/California
203 | 1572
204 | California
205 | https://en.wikipedia.org/wiki/Kansas
206 | 1634
207 | Kansas
208 | https://en.wikipedia.org/wiki/Texas
209 | 1645
210 | Texas
211 | https://en.wikipedia.org/wiki/United_States
212 | 1923
213 | U.S.
214 | https://en.wikipedia.org/wiki/United_States
215 | 2090
216 | U.S.
217 | https://en.wikipedia.org/wiki/Kabanjahe
218 | 72
219 | Kabanjahe
220 | https://en.wikipedia.org/wiki/Sumatra
221 | 94
222 | Sumatra
223 | https://en.wikipedia.org/wiki/Indonesia
224 | 105
225 | Indonesia
226 | https://en.wikipedia.org/wiki/Kabanjahe
227 | 308
228 | Kabanjahe
229 | https://en.wikipedia.org/wiki/Indonesia
230 | 351
231 | Indonesia
232 | https://en.wikipedia.org/wiki/Atlanta
233 | 501
234 | Atlanta
235 | https://en.wikipedia.org/wiki/Georgia_(U.S._state)
236 | 510
237 | Georgia
238 | https://en.wikipedia.org/wiki/Atlanta
239 | 670
240 | Atlanta
241 | https://en.wikipedia.org/wiki/United_States
242 | 704
243 | U.S.
244 | https://en.wikipedia.org/wiki/China
245 | 85
246 | China
247 | https://en.wikipedia.org/wiki/Beijing
248 | 121
249 | Beijing
250 | https://en.wikipedia.org/wiki/China
251 | 401
252 | China
253 | https://en.wikipedia.org/wiki/Hebei
254 | 658
255 | Hebei
256 | https://en.wikipedia.org/wiki/Hubei
257 | 787
258 | Hubei
259 | https://en.wikipedia.org/wiki/China
260 | 871
261 | People's Republic of China
262 | https://en.wikipedia.org/wiki/China
263 | 991
264 | China
265 | https://en.wikipedia.org/wiki/Anhui
266 | 1144
267 | Anhui
268 | https://en.wikipedia.org/wiki/Fuyang
269 | 1277
270 | Fuyang
271 | https://en.wikipedia.org/wiki/Anhui
272 | 1287
273 | Anhui
274 | https://en.wikipedia.org/wiki/Beijing
275 | 1532
276 | Beijing
277 | https://en.wikipedia.org/wiki/Guangdong
278 | 1589
279 | Guangdong
280 | https://en.wikipedia.org/wiki/Guangxi
281 | 1600
282 | Guangxi
283 | https://en.wikipedia.org/wiki/Hainan
284 | 1609
285 | Hainan
286 | https://en.wikipedia.org/wiki/Hunan
287 | 1617
288 | Hunan
289 | https://en.wikipedia.org/wiki/Zhejiang
290 | 1624
291 | Zhejiang
292 | https://en.wikipedia.org/wiki/Hubei
293 | 1646
294 | Hubei
295 | https://en.wikipedia.org/wiki/China
296 | 1853
297 | China
298 | https://en.wikipedia.org/wiki/China
299 | 1982
300 | China
301 | https://en.wikipedia.org/wiki/Beijing
302 | 2196
303 | Beijing
304 | https://en.wikipedia.org/wiki/China
305 | 2302
306 | China
307 | https://en.wikipedia.org/wiki/China
308 | 2394
309 | China
310 | https://en.wikipedia.org/wiki/China
311 | 2458
312 | China
313 | https://en.wikipedia.org/wiki/Asia
314 | 81
315 | Asia
316 | https://en.wikipedia.org/wiki/India
317 | 113
318 | India
319 | https://en.wikipedia.org/wiki/Nepal
320 | 120
321 | Nepal
322 | https://en.wikipedia.org/wiki/Bangladesh
323 | 131
324 | Bangladesh
325 | https://en.wikipedia.org/wiki/Bihar
326 | 462
327 | Bihar
328 | https://en.wikipedia.org/wiki/Uttar_Pradesh
329 | 472
330 | Uttar Pradesh
331 | https://en.wikipedia.org/wiki/Bihar
332 | 586
333 | Bihar
334 | https://en.wikipedia.org/wiki/India
335 | 795
336 | India
337 | None
338 | 1113
339 | Gondra
340 | https://en.wikipedia.org/wiki/Uttar_Pradesh
341 | 1132
342 | Uttar Pradesh
343 | https://en.wikipedia.org/wiki/Indore
344 | 1280
345 | Indore
346 | https://en.wikipedia.org/wiki/Greenlane
347 | 77
348 | Greenlane
349 | https://en.wikipedia.org/wiki/Auckland
350 | 88
351 | Auckland
352 | https://en.wikipedia.org/wiki/New_Zealand
353 | 98
354 | New Zealand
355 | https://en.wikipedia.org/wiki/Auckland
356 | 253
357 | Auckland
358 | https://en.wikipedia.org/wiki/Greenlane
359 | 1570
360 | Greenlane
361 | https://en.wikipedia.org/wiki/Auckland
362 | 1581
363 | Auckland
364 | https://en.wikipedia.org/wiki/Auckland
365 | 1680
366 | Auckland
367 | https://en.wikipedia.org/wiki/Zimbabwe
368 | 46
369 | Zimbabwe
370 | https://en.wikipedia.org/wiki/Zimbabwe
371 | 294
372 | Zimbabwe
373 | https://en.wikipedia.org/wiki/Zimbabwe
374 | 388
375 | Zimbabwe
376 | https://en.wikipedia.org/wiki/Zimbabwe
377 | 712
378 | Zimbabwe
379 | https://en.wikipedia.org/wiki/Harare
380 | 788
381 | Harare
382 | https://en.wikipedia.org/wiki/Mabvuku
383 | 898
384 | Mabvuku
385 | https://en.wikipedia.org/wiki/Harare
386 | 932
387 | Harare
388 | https://en.wikipedia.org/wiki/Botswana
389 | 1186
390 | Botswana
391 | https://en.wikipedia.org/wiki/Mozambique
392 | 1196
393 | Mozambique
394 | https://en.wikipedia.org/wiki/Zimbabwe
395 | 1237
396 | Zimbabwe
397 | https://en.wikipedia.org/wiki/South_Africa
398 | 1212
399 | South Africa
400 | https://en.wikipedia.org/wiki/Zimbabwe
401 | 1519
402 | Zimbabwe
403 | https://en.wikipedia.org/wiki/Zimbabwe
404 | 1602
405 | Zimbabwe
406 | https://en.wikipedia.org/wiki/Zimbabwe
407 | 4
408 | Zimbabwe
409 | https://en.wikipedia.org/wiki/Wedza_District
410 | 55
411 | Wedza
412 | https://en.wikipedia.org/wiki/Mashonaland_East_Province
413 | 71
414 | Mashonaland East
415 | https://en.wikipedia.org/wiki/Midlands_Province
416 | 550
417 | Midlands
418 | https://en.wikipedia.org/wiki/Zimbabwe
419 | 1242
420 | Zimbabwe
421 | https://en.wikipedia.org/wiki/United_States
422 | 27
423 | United States
424 | https://en.wikipedia.org/wiki/United_States
425 | 294
426 | United States
427 | https://en.wikipedia.org/wiki/Iraq
428 | 439
429 | Iraq
430 | https://en.wikipedia.org/wiki/Afghanistan
431 | 445
432 | Afghanistan
433 | https://en.wikipedia.org/wiki/North_Korea
434 | 458
435 | North Korea
436 | https://en.wikipedia.org/wiki/Iran
437 | 559
438 | Iran
439 | https://en.wikipedia.org/wiki/United_States
440 | 916
441 | U.S.
442 | https://en.wikipedia.org/wiki/Mexico
443 | 923
444 | Mexico
445 | https://en.wikipedia.org/wiki/China
446 | 170
447 | China
448 | https://en.wikipedia.org/wiki/Indonesia
449 | 177
450 | Indonesia
451 | https://en.wikipedia.org/wiki/Africa
452 | 209
453 | Africa
454 | https://en.wikipedia.org/wiki/China
455 | 493
456 | China
457 | https://en.wikipedia.org/wiki/Indonesia
458 | 503
459 | Indonesia
460 | https://en.wikipedia.org/wiki/Africa
461 | 517
462 | Africa
463 | https://en.wikipedia.org/wiki/Rome
464 | 720
465 | Rome
466 | https://en.wikipedia.org/wiki/Italy
467 | 726
468 | Italy
469 | https://en.wikipedia.org/wiki/Africa
470 | 1118
471 | Africa
472 | https://en.wikipedia.org/wiki/Indonesia
473 | 1392
474 | Indonesia
475 | https://en.wikipedia.org/wiki/Java
476 | 1716
477 | Java
478 | https://en.wikipedia.org/wiki/China
479 | 1814
480 | China
481 | https://en.wikipedia.org/wiki/China
482 | 1859
483 | China
484 | https://en.wikipedia.org/wiki/Mexico
485 | 48
486 | Mexico
487 | https://en.wikipedia.org/wiki/Australia
488 | 253
489 | Australia
490 | https://en.wikipedia.org/wiki/Brazil
491 | 264
492 | Brazil
493 | https://en.wikipedia.org/wiki/France
494 | 272
495 | France
496 | https://en.wikipedia.org/wiki/Italy
497 | 280
498 | Italy
499 | https://en.wikipedia.org/wiki/New_Zealand
500 | 287
501 | New Zealand
502 | https://en.wikipedia.org/wiki/Norway
503 | 300
504 | Norway
505 | https://en.wikipedia.org/wiki/Switzerland
506 | 308
507 | Switzerland
508 | https://en.wikipedia.org/wiki/United_Kingdom
509 | 325
510 | UK
511 | https://en.wikipedia.org/wiki/United_States
512 | 337
513 | US
514 | https://en.wikipedia.org/wiki/United_States
515 | 657
516 | US
517 | https://en.wikipedia.org/wiki/Brazil
518 | 799
519 | Brazil
520 | https://en.wikipedia.org/wiki/Sao_Paulo
521 | 922
522 | Sao Paulo
523 | https://en.wikipedia.org/wiki/Rio_de_Janeiro
524 | 957
525 | Rio de Janeiro
526 | https://en.wikipedia.org/wiki/Brazil
527 | 1092
528 | Brazil
529 | https://en.wikipedia.org/wiki/United_States
530 | 1117
531 | United States
532 | https://en.wikipedia.org/wiki/Argentina
533 | 1218
534 | Argentina
535 | https://en.wikipedia.org/wiki/Brazil
536 | 1229
537 | Brazil
538 | https://en.wikipedia.org/wiki/China
539 | 1346
540 | China
541 | https://en.wikipedia.org/wiki/China
542 | 1710
543 | China
544 | https://en.wikipedia.org/wiki/China
545 | 1913
546 | China
547 | https://en.wikipedia.org/wiki/China
548 | 1979
549 | China
550 | https://en.wikipedia.org/wiki/China
551 | 2208
552 | China
553 | https://en.wikipedia.org/wiki/France
554 | 2229
555 | France
556 | https://en.wikipedia.org/wiki/India
557 | 2723
558 | India
559 | https://en.wikipedia.org/wiki/India
560 | 2856
561 | India
562 | https://en.wikipedia.org/wiki/Kenya
563 | 3616
564 | Kenya
565 | https://en.wikipedia.org/wiki/Kenya
566 | 4277
567 | Kenya
568 | https://en.wikipedia.org/wiki/Nairobi
569 | 4293
570 | Nairobi
571 | https://en.wikipedia.org/wiki/Kisumu
572 | 4402
573 | Kisumu
574 | https://en.wikipedia.org/wiki/Rift_Valley_Province
575 | 4413
576 | Rift Valley
577 | https://en.wikipedia.org/wiki/Mexico
578 | 4500
579 | Mexico
580 | https://en.wikipedia.org/wiki/Mexico
581 | 4785
582 | Mexico
583 | https://en.wikipedia.org/wiki/United_Kingdom
584 | 5041
585 | United Kingdom
586 | https://en.wikipedia.org/wiki/United_Kingdom
587 | 5990
588 | UK
589 | https://en.wikipedia.org/wiki/United_Kingdom
590 | 6139
591 | Britain
592 | https://en.wikipedia.org/wiki/United_States
593 | 6424
594 | US
595 | https://en.wikipedia.org/wiki/United_States
596 | 6836
597 | United States
598 | https://en.wikipedia.org/wiki/United_States
599 | 7021
600 | US
601 | https://en.wikipedia.org/wiki/Vietnam
602 | 7067
603 | Vietnam
604 | https://en.wikipedia.org/wiki/Lake_Titicaca
605 | 96
606 | Lake Titicaca
607 | https://en.wikipedia.org/wiki/Puno_Region
608 | 117
609 | Puno
610 | https://en.wikipedia.org/wiki/Peru
611 | 132
612 | Peru
613 | https://en.wikipedia.org/wiki/Bolivia
614 | 154
615 | Bolivia
616 | https://en.wikipedia.org/wiki/Desaguadero,_Bolivia-Peru
617 | 654
618 | Desaguadero
619 | https://en.wikipedia.org/wiki/Massachusetts
620 | 1475
621 | Massachusetts
622 | https://en.wikipedia.org/wiki/London
623 | 2065
624 | London
625 | https://en.wikipedia.org/wiki/Baghdad
626 | 26
627 | Baghdad
628 | https://en.wikipedia.org/wiki/Iraq
629 | 35
630 | Iraq
631 | https://en.wikipedia.org/wiki/Amman
632 | 322
633 | Amman
634 | https://en.wikipedia.org/wiki/Jordan
635 | 329
636 | Jordan
637 | https://en.wikipedia.org/wiki/United_Kingdom
638 | 415
639 | United Kingdom
640 | https://en.wikipedia.org/wiki/Adhamiyah
641 | 1248
642 | Adhamiya
643 | https://en.wikipedia.org/wiki/Adhamiyah
644 | 1592
645 | Adhamiyah
646 | https://en.wikipedia.org/wiki/Baghdad
647 | 1614
648 | Baghdad
649 |
--------------------------------------------------------------------------------
/data/iaa_test.txt:
--------------------------------------------------------------------------------
1 | -------------NEW ARTICLE-----------------
2 | The H5N1 Avian Flu virus has been found in a dead wild Canadian Goose in Abbotsbury Swannery in Dorset, England. This is the eleventh case of the virus turning up in wild birds. The goose was discovered on February 25, 2008. "The finding of more cases in wild birds is not unexpected ... We are currently considering whether any additional restrictions are necessary in the area," said the United Kingdom's Health Ministry in a statement to the media. As a result of the finding, poultry movement has now been restricted by the Department for the Environment, Food and Rural Affairs (DEFRA) in the areas surrounding the swannery. The removal of all birds, dead or alive from any property now requires a license. DEFRA says the restrictions will expire no earlier than 31 days.
3 | -------------NEW ARTICLE-----------------
4 | Scientists have discovered the possible presence of the H5N1 Bird Flu virus in wild mute swans in Michigan on the coast of Lake Erie near the Mouillee state game area in Monroe County. The swans were sampled on August 8, 2006 and the initial testing was done at Michigan State University's Diagnostic Center for Population and Animal Health and at the National Veterinary Services laboratories in Ames, Iowa. White House Press Secretary Tony Snow says that "They (the scientists) believe it is a strain of low pathogenicity, similar to strains that have been seen before in North America." Snow also added that "this [case] is not what we're accustomed to hearing about from Asia." "Test results thus far indicate this is low pathogenicity avian influenza, which poses no threat to human health. Routine surveillance has indicated the presence of H5 and N1 avian influenza subtypes in samples from two wild mute swans in Michigan," said a statement on the United States Department of Agriculture's (USDA) website. The statement also went on to say that the swans "did not show signs of sickness" and that the swans were infected with "two separate" strains of Avian Flu. "It is possible that these birds were not infected with an H5N1 strain, but instead with two separate avian influenza viruses, one containing H5 and the other containing N1," said the statement. "This is not the highly pathogenic avian influenza virus that has spread through much of other parts of the world. We do not believe this virus represents a risk to human health," said USDA's Animal and Plant Health inspector, Ron DeHaven. Health officials are remaining "remaining vigilant and prepared," said Department of Health and Human Services science advisor, Dr. William Raub. Further tests will be done to confirm that there is in fact a virus there and what type and are expected sometime today.
5 | -------------NEW ARTICLE-----------------
6 | A five-year-old boy has been suspected to have died from the H1N1 swine flu virus in Buckinghamshire, England. The boy came from Emberton School, which now has just 29 pupils attending. Health tests are currently being carried out to determine whether or not the child did indeed die from the virus. He was admitted to a hospital in Milton Keynes, but later died in the early hours of Sunday morning. At present, the individual remains unidentified. Steve Dunning is the principal in the school. Speaking to BBC Three Counties Radio, Dunning said: "The staff of Emberton School are very saddened to learn of the death of one of their pupils who was a confident, delightful and happy student and will be missed greatly. At this time we are focusing on supporting the children and parents in our small village community. I have spoken directly with the mother and passed on the condolences of all the staff and governors at the school."
7 | -------------NEW ARTICLE-----------------
8 | At least four people in Peru have contracted HIV, the virus that causes AIDS after receiving blood transfusions that were infected with the deadly virus. As a result, all of Peru's 240 blood banks have been closed pending further investigation and an emergency has been declared by the government. "This situation cannot continue. All of Peru's blood banks are being reviewed. We do not want people to panic, what we have to do is be more careful, strengthen our care," said Carlos Vallejos, the Health Minister of Peru. The country's government made its decision when Judith Rivera, 44 and mother of four children, went public with claims that during an operation, she was infected with HIV when doctors gave her a transfusion. Soon after the government admitted that at least three other individuals, one being an infant child only 11 months old, another a 17 year-old boy, contracted the virus through blood transfusions and all received care from the same hospitals. Vallejos also stated that all of the individuals infected will receive whatever care is necessary to treat their conditions.
9 | -------------NEW ARTICLE-----------------
10 | Libya has freed six foreign medical personnel who were convicted of infecting hundreds of Libyan children with HIV and sentenced to death. In jail since 1999, the five Bulgarian nurses and one Palestinian doctor arrived in Sofia, Bulgaria, today. The president of Bulgaria, Georgi Parvanov, promptly pardoned them. All six have maintained their innocence throughout. They have also claimed that they suffered torture to extract confessions. International HIV experts testified at the trials that the infections began before the six arrived at the Benghazi hospital. They said the infections were more likely the result of poor hygiene. Last week, Libya lifted the death sentences following a US$460 million financial settlement, which works out to US$1 million to each HIV victim's family. However, Libya insisted on further concessions on relations with the European Union and aid. A deal between the E.U. and Libya, mediated by Qatar, ended the diplomatic standoff. The foreign minister of Libya, Abdel Rahman Shalgham, said the E.U. promised to provide "life-long treatment" to the infected children, as well as aid to "improve the Benghazi hospital" where the children were infected. Further, he claimed that deal will allow for "full cooperation and partnership between Libya and the European Union." "We hope to go on further [in] normalising our relations with Libya. Our relations with Libya were to a large extent blocked by the non-settlement of this medics issue," said José Manuel Barroso, President of the European Commission. The president of France, Nicolas Sarkozy, said that neither the E.U. nor France paid money to Libya. He also said he would visit Libya on Wednesday to help Tripoli's reintegration. "I can quite simply confirm to you that neither Europe nor France have made the slightest financial contribution to Libya," said Sarkozy to reporters in Paris. "I have had the opportunity to thank the Qatari authorities very warmly for their mediation and their humanitarian intervention." Benita Ferrero-Waldner, the European Commissioner for External Relations, said: "I share the joy of their families and friends and of the government and people of Bulgaria. For over eight years, we have never forgotten the suffering of the medical staff who have shown such dignity and fortitude during their long ordeal." "Now I still can't believe that I am standing on Bulgarian soil. We were told the news at four o'clock in the morning and we left the jail at quarter to six to board the plane. Now I will try to get my previous life back," said Kristiyana Vulcheva, 48, upon her release at the airport.
11 | -------------NEW ARTICLE-----------------
12 | Mr Justice Saunders today imprisoned a man for eight years at the Old Bailey in London after an FBI sting in which he tried to buy ricin on the Dark Web. Mohammed Ali, 31, from Liverpool, was convicted at trial of attempting to possess a chemical weapon. He told the jury he was "curious" about the Dark Web, which is a largely hidden and difficult to police section of the Internet. Ali said he didn't realise he had done anything illegal. Ali was prosecuted under the Chemical Weapons Act 1996 after sending an undercover agent a message reading "Hi, would you be able to make me some ricin and send it to the UK?" He bought 500mg, which has the potential to kill about 1,400, but was sent a dummy package. Counter-terror police in the UK liaised with the FBI. The powder, which Ali paid for in BitCoin, was actually harmless. Hidden inside a toy car, the package was treated with markers and his face glowed under ultraviolet light, indicating he had handled it. The judge said today there was "real risk" involved. Ali told his trial he had discovered drugs and guns for sale. Computer analysis showed he had looked up ricin and other poisons; he said he went for ricin simply because it had appeared in Breaking Bad. He also searched for small animals after being advised to test it on a rodent; a to-do list on his computer included "paid ricin guy" and "get pet to murder".
13 | -------------NEW ARTICLE-----------------
14 | Nearly 200 people are confirmed dead and approximately 2600 are ill in a central Haitian cholera outbreak, according to the Centers for Disease Control (CDC), the U.S. Agency for International Development (USAID) and United Nations (UN). Haitian officials place the death toll at 194 deaths with 2,364 people being infected. According to CDC officials Dr. Rob Quick and Dr. Carleene Dei an eleven man team is being sent to Haiti to investigate and determine the best course of action for the country. The USAID has said that they will provide supplies to set up treatment centers and have already provided 300,000 oral re-hydration kits and water purification kits. A majority of the reported cases are in the Central Plateau and Artibonite regions located just north of the earthquake ravaged capital, Port-Au-Prince. Officials fear that the disease could spread to the capital city if not brought under control. It has been reported that many people are flooding the St. Nicolas hospital, which is the main medical facility in St. Marc, for treatment, causing pandemonium outside the gate. An aid worker who visited the hospital called it a "horror scene", while another worker, David Darg, of Operation Blessing International wrote "The courtyard was lined with patients hooked up to intravenous drips. It had just rained and there were people lying on the ground on soggy sheets, half-soaked with feces."
15 | -------------NEW ARTICLE-----------------
16 | More than 650 people have now died after a tsunami hit the Indonesian island of Java on Monday afternoon. In the past few days, around 100 dead bodies have been recovered, and it is estimated that over 300 people are still missing. An underwater earthquake with a magnitude of 7.7 triggered the deadly wave which ravaged a 200km stretch of Java's southern coast. Thousands of people are continuing to camp in the hills. They are too apprehensive to return home due to fears of another tsunami, but according to Reuters, health officials are worried about the threat of disease among those who are still in refuge. "The risk of catching diseases is there because they live in an open area with limited tents and water," said Rustan Pakaya, from the health ministry's crisis centre. He added that people were being given injections to protect them from diseases like measles, tetanus and cholera. Areas worst hit, like the small town of Pangandaran, are beginning to return to normal, and many businesses there have begun to open up again. "The market and many shops are already open today and although they are not operating fully, things are slowly returning to normal," district spokesman Wasdi bin Umri told AFP. Yesterday, Indonesia's President, Susilo Bambang Yudhoyono toured Pangandaran and met people who were staying in a temporary camp. The Indonesian government has been criticised for failing to inform residents living on the coast that a tsunami was looming. After the underwater earthquake was detected, US and Japanese agencies issued warning notices, but the government has admitted it was unable to transmit the bulletins to coastal areas. Speaking yesterday, Mr Yudhoyono vowed to hasten efforts to build an early warning system planned after the 2004 Asian tsunami. "We want to expedite efforts to get infrastructure for the tsunami warning system in place," AP quoted him as saying. "I will work with parliament to get the budget".
17 | -------------NEW ARTICLE-----------------
18 | Six people have died after becoming infected with the Hong Kong Flu virus in the city of Kitaakita located in the Akita Prefecture of northern Japan. Among the dead were four men and two women, aged 60 to 90 years old. All of them died between Monday November 1, and Friday November 5, while in a local hospital. Dozens more are suspected to be ill with the virus while another 30 others, mostly doctors and other hospital personnel, are being tested for the virus. Preliminary tests on the patients showed a positive result for the infection while further laboratory tests confirmed the presence of it. The virus killed nearly 1,000,000 people around the globe in 1968 and 1969. It was a form of the H3N2 strain of influenza type A. So far there are no reports of anyone infected outside hospital grounds.
19 | -------------NEW ARTICLE-----------------
20 | Homeland Security Secretary Janet Napolitano announced today at a news conference that the U.S. has declared a public health emergency in light of the swine flu outbreak. The total number of confirmed swine flu cases in the United States stands at 20. Secretary Napolitano said that the United States' declaration follows suit with the "standard operating procedure" of such an outbreak to make more government resources available to combat the disease. One direct result of the declaration is the government's mobilization of approximately 12 million doses of Tamiflu to locations where the states can quickly access their share of the medication if needed. Secretary Napolitano urged residents not to panic saying that the government is issuing a "declaration of emergency preparedness." Secretary Napolitano added, "Really that's what we're doing right now. We're preparing in an environment where we really don't know ultimately what the size of seriousness of this outbreak is going to be." John Brennan, a Homeland Security assistant, added that "at this point, a top priority is to ensure that communication is robust and that medical surveillance efforts are fully activated." This afternoon, New York City Mayor Michael Bloomberg reported that 8 students from the St. Francis Prepatory School in Queens, New York have contracted the swine flu. All in all, more than 100 students from that high school were absent last week with flu-like symptoms. Meanwhile, public health officials in Ohio today announced one confirmed case of swine flu in the state. Thus far, California has reported 7 confirmed cases of swine flu, while Kansas and Texas have each reported two confirmed cases. At the same news conference Dr. Richard Besser, the acting director from the Centers for Disease Control and Prevention (CDC), said to expect additional cases of swine flu to be reported in the short term. Dr. Besser added that the U.S. could also start seeing cases of the disease where the effects are more dramatic: "We're going to see more severe disease in this country". So far, no one in the U.S. has died from swine flu.
21 | -------------NEW ARTICLE-----------------
22 | Preliminary tests performed on samples taken from six villagers in the Kabanjahe district of Sumatra in Indonesia have tested negative for the deadly H5N1 Avian Flu virus. "Investigations by the ministry of health lab and Namru, too, on August 2 and 3 on all specimens collected from the suspected cases in Kabanjahe district came up negative," said Indonesia's health minister, Siti Fadilah Supari. Final test results are expected in at least seven days from the Center for Disease Control (CDC) in Atlanta, Georgia. "The World Health Organization (WHO) requires human samples to be sent to one of WHO's six collaborative centres. So, we only need to send them to CDC Atlanta as it has worked with the U.S. NAMRU-2 lab here," added Supari. Supari also stated that all individuals are suffering from the "common flu."
23 | -------------NEW ARTICLE-----------------
24 | Over 40 children have died in an outbreak of hand, foot and mouth disease (HFMD) in China, and the country's capital of Beijing reported its first death due to the disease on Wednesday. According to Xinhua News Agency, Beijing Health Bureau spokeswoman Deng Xiaohong said that the 13-month-old boy died Sunday while en route to the hospital. Health authorities state that 24,934 children in mainland China are afflicted with the disease, and 42 children have died from it. The cause of the disease has been identified as Enterovirus 71 (EV-71). HFMD can also be caused by Coxsackievirus. Another child infected with the virus died Monday, but as he died in Hebei province his death was counted there. Xinhua News Agency also reported that a 21-month-old boy died Monday of the virus in Hubei province. After an order was given last week by the Ministry of Health of the People's Republic of China that all cases must be reported, the count of those infected has increased markedly. Eastern China saw a large number of cases in early March, but this information was not made public until late April. In March, Children under age six in eastern Anhui province began being admitted to hospitals with symptoms of the virus, and the outbreak spread quickly after that. The city of Fuyang in Anhui province was especially hard-hit by the outbreak. "The majority of patients who were in critical condition have recovered," said a Health Ministry official in a statement on Monday. As of Monday, 3,606 HFMD infections had been reported in Beijing. Deaths have occurred in the provinces of Anhui, Guangdong, Guangxi, Hainan, Hunan, Zhejiang, Beijing and Hubei. "What I know is the death rate has gone down drastically since early May. There are very, very few cases with complications — 99 percent of these are mild cases," said World Health Organization (WHO) China representative Hans Troedsson in a statement on Wednesday. Incidents of the disease are expected to peak in June and July. China is also dealing with a magnitude-7.9 earthquake which hit the country Monday and has killed almost 15,000. The outbreak is a concern to the government, as the country prepares for the 2008 Summer Olympics in Beijing this August. "We are confident the potential outbreak will not affect the Beijing Olympic Games," China's Health Ministry spokesman Mao Qunan stated. And at a joint press conference held by China's Ministry of Health and the WHO, he further noted that, "China is confident that it can control the spread of the disease with effective prevention methods."
25 | -------------NEW ARTICLE-----------------
26 | Torrential monsoon rains for the past 11 days have inundated parts of southeast Asia, heavily flooding areas of India, Nepal, and Bangladesh and affecting over 20 million people. An estimated 1,400 have been killed across the region, as waterborne diseases have proliferated and become highly virulent in the humid and wet conditions. The United Nations Children's Fund, UNICEF, is currently providing relief to affected areas. In the Northern Indian states of Bihar and Uttar Pradesh, as many as 12.5 million people have been displaced or affected by flooding. Clashes with police in Bihar have left 20 villagers injured and one man dead, since many are staging protests after being forced from their homes. UNICEF estimates as many as 1,103 may have died in 138 districts throughout northern India. Hospitals are reaching dangerous volumes as disease is sickening thousands. Many are ill from dehydration, exposure and dysentery. Aid workers warn that malaria is a serious risk. The Indian Air Force began dropping aid packages containing medical supplies and food yesterday. Santosh Mishra, a villager in the Gondra district of Uttar Pradesh remarked, "I have not seen such flooding in the last 24 years." Bodies of two students of the IIM Indore swept in the flash floods in Indore were recovered.
27 | -------------NEW ARTICLE-----------------
28 | McDonald's is asking everyone who ate at a McDonald's restaurant located in Greenlane, Auckland, New Zealand, in December 15, 2006, to go to their doctor after a worker tested positive for Hepatitis A. Doctor Greg Simmons, medical officer of health in Auckland, said that it is possible for the food handler worker to have passed on the disease during 7:00 p.m. (NZDT) and 2:00 a.m. as he would have been in the most infectious stage of Hepatitis A and was not wearing gloves. According to a spokeswoman from McDonald's, Joanna Redfern-Hardisty, food handlers are not required to wear gloves but are required to have thoroughly washed their hands with antimicrobial soap. However Dr Simmons says that the infected worker usually wore gloves. The shift the worker worked was the only one the worker handled food when he was infectious with Hepatitis A. It is unknown how many people could have come into contact with food that the infected worker had prepared as Friday night is usually a busy night, according to Ms Redfern-Hardisty. Dr Simmons says that if someone has been infected with Hepatitis A then they will currently be showing early symptoms. Those symptoms include being tired, no appetite, nausea and skin and eyes will show a yellowish colour. Ms Redfern-Hardisty, spokeswoman for McDonald's, confirmed that no more risk is being posed to customers. She said that it is currently unknown where the worker caught Hepatitis A but has stated that it was from an external source. The worker has been suspended from work. If you ate at the McDonalds located in Greenlane, Auckland, on late December 15, early December 16, then please either visit your doctor or ring the Auckland Regional Public Health Service on 096234600.
29 | -------------NEW ARTICLE-----------------
30 | A cholera outbreak in the African country of Zimbabwe has killed almost 500 people since August, according to the World Health Organization (WHO). The WHO said that the outbreak affected most areas of the country, and that some remote areas had seen fatality rates increase by as much as 30%. Zimbabwe's Ministry of Health reported 484 deaths from 11,735 cases since the outbreak began. Zimbabwe has had annual outbreaks of cholera for nearly a decade, but this one was the most far-reaching. A report by the WHO stated that the last large outbreak was in 1992, with 3,000 cases recorded. Cholera is frequently spread by contaminated, untreated water. The spread of the disease was expedited by the collapse of Zimbabwe's health and sanitation systems; state media reported that most of Harare has been left without water after the city ran out of chemicals for its treatment plant. A resident of Mabvuku, a suburb located east of Harare, told APTV that electricity is not available most of the time, so water is consumed without being boiled first. The medical charity Médecins Sans Frontières (Doctors Without Borders) said that there have been cases of cholera reported in areas of Botswana, Mozambique, and South Africa that border Zimbabwe, indicating the sub-regional threat of the outbreak. The South African ministry of health confirmed that they had 160 incidents of cholera reported, as well as three deaths. The European Commission said that it was providing €9 million (US$11.4 million) in funds to assist Zimbabwe with the crisis. "I'm shocked at the deteriorating humanitarian crisis in Zimbabwe and call upon the authorities there to respond quickly to this cholera outbreak by allowing full assistance from international humanitarians and regional partners," said the commissioner responsible for the European Union's humanitarian aid, Louis Michel. Other agencies providing aid to the country include the United Nations Children's Fund, the WHO, and Doctors Without Borders.
31 | -------------NEW ARTICLE-----------------
32 | As Zimbabwe's rainy season approaches, farmers in the Wedza district, Mashonaland East province, are worried that again this year they won't be able to locate or afford the seed, fertilizer, and other inputs needed to get a maize crop in the ground. Aiming to relieve such shortages of inputs, Christian Care is among the non-governmental organizations working with the United Nations Food and Agriculture Organization and the European Union to implement an agricultural inputs support scheme. Christian Care said it is now providing farmers in the Midlands with fertilizer and seeds. Experts said most farmers are struggling to obtain inputs because the government has cut back on programs to finance planting, instead urging farmers to borrow from banks. But banks insist on land as collateral, though all farmland has been nationalized. Even farmers resettled under land reform since 2000 have only so-called offer letters granting them working rights, but banks will accept neither these nor livestock as collateral. Christian Care Director Forbes Matonga reported that his is one of seven organizations reaching out to small farmers under the FAO program. As the rainy season begins, cholera is also now a growing concern. Residents of Zimbabwe, fearing a repeat of the 2008 epidemic that killed thousands, are struggling to complete precautionary measures.
33 | -------------NEW ARTICLE-----------------
34 | After 100 days in office, United States president Barack Obama gave a speech on Wednesday, speaking about the swine influenza outbreak and the struggling economy, both described by the Los Angles Times as "two wars." He used a prime time television slot to showcase his message throughout the United States. During his speech, he said, "If you could tell me right now when I walked into this office... that all you had to worry about was Iraq, Afghanistan, North Korea, getting healthcare passed, figuring out how to deal with energy independence, deal with Iran and a pandemic flu, I would take that deal. I would love a nice, lean portfolio to deal with, but that's not the hand that's been dealt us." Obama also said the economy was not the only problem. There are threats to the country including "...terrorism to nuclear proliferation to pandemic flu." Regarding the swine influenza outbreak, he said that the U.S. / Mexico border will not be closed because closing the border does not fix any problems, claiming that this method did not work in the past. Instead, he said that the best method for preventing the spread of the flu is hand washing, covering one's mouth while coughing, and staying home when one feels sick. The Los Angeles Times described Obama "more like school nurse in chief than commander in chief." On the topic of waterboarding, Obama said, "I do believe that it is torture."
35 | -------------NEW ARTICLE-----------------
36 | The World Organization for Animal Health (OIE) and the Food and Agriculture Organization, both part of the United Nations, have stated that some countries, particularly China, Indonesia and some countries in Africa are "under-reporting" the number of human cases of the deadly H5N1 Avian Flu (Bird Flu) virus, but also said that the countries are not hiding them "deliberately." "We know that some countries might be under-reporting ... most do not do it deliberately. We are concerned about China and Indonesia and Africa because the virus seems to be so widespread that we could not get all the information. It is difficult to know about each individual outbreak in a back yard," said Doctor Christianne Bruschke, in Rome, Italy on Wednesday and who is head of the OIE's Bird Flu taskforce. Bruschke also said that farmers lack the education they need on the virus and need to be reimbursed financially for any education they need citing that the "richer nations" should help fund the education they need and that lack of veterinary clinics, distance to them, and time are also to blame for the under-reporting. In Africa, "farmers will probably not report sick animals," said Bruschke. "Their veterinary services are very weak and many countries do not have laboratory facilities - we have all the ingredients there that could lead to under-reporting," she added. Bruschke also said that Indonesia may not be reporting all human or animal cases also stating that the virus is "permanently infecting poultry" in the country which makes it increasingly difficult for anyone to report outbreaks. "I think it could be the case because in certain regions the virus is getting more or less endemic, so in regions like Java, they might not report every single outbreak anymore," said Bruschke. According to Bruschke, China is cooperating but she also said that "China is a very big country" and that there are cases of infections in wild birds. "We sometimes see the outbreaks in wild animals - they will not always detect them. There is also not a very good compensation scheme in place so we feel there might be under-reporting," said Bruschke.
37 | -------------NEW ARTICLE-----------------
38 | The H1N1 outbreak of swine flu, which began in Mexico this April, has now spread across the globe. There have been at least 3,330 deaths from the swine flu since the virus started spreading, out of almost 316,000 total reported cases. Nine countries — Australia, Brazil, France, Italy, New Zealand, Norway, Switzerland, the UK, and the US — have promised to send ten percent of their antiviral vaccine supply to other countries, should the latter be in need of it. The plan was agreed to "in recognition that diseases know no borders and that the health of the American people is inseparable from the health of people around the world," a statement by the US government read. In an in-depth report, Wikinews takes a look at how the disease has affected countries around the world. As of Wednesday, Brazil has registered 899 deaths from the swine flu, making it the hardest-hit country in terms of fatalities. The city of Sao Paulo reported 327 deaths, and Rio de Janeiro 84. However, the country's health ministry also said that the rate of serious cases "fell for the fifth straight week." Brazil had surpassed the United States, which has 593 deaths, in number of total fatalities from the outbreak late in August. Argentina, Brazil's neighbour to the south, has 512 deaths from the H1N1 virus. 10,000 cases of swine flu were confirmed across China since the outbreak began. The number of infections seems to be increasing quickly. Communications director for the World Health Organisation Vivian Tan said that "in the last week or so, the increase has been quite quick," attributing the rise to a small decrease in temperatures as fall sets in, as well as students returning to school after summer breaks. China's official news agency Xinhua reported that 1,118 new cases of the influenza were reported in a two-day period earlier in the week, adding that a vast majority of the cases had been transmitted in China, not by persons entering the country from abroad. All 31 of China's provinces have reported instances of the flu. The disease initially seemed to be limited to large cities, but recently has started moving into more rural areas. No casualties from the swine flu have yet been confirmed in China. The office of France's president Nicolas Sarkozy said that the country would pledge up to one tenth or nine million of its 94 million antiviral vaccine doses to the World Health Organisation, to be distributed to countries with fewer vaccine supplies if needed. International solidarity "will be a determining factor in reducing the health, economic and social impact of the pandemic," according to a statement released by the government. On Wednesday, eleven people had been reported dead from the virus in India, taking the country's death toll up to 212 people. The number of people infected with the influenza is now estimated at 6,800. India's health ministry on Tuesday said that the Tamiflu drug would be on sale in the open market within seven days, allowing for a "restricted sale" of the drug. An unnamed official said that "it is expected that within the next five to seven days, both the drugs would be available in the retail market through identified chemists against proper medical prescriptions. "Taking into account the current spread of the influenza A(H1N1) in the country, the health ministry has decided that retail sale of Tamiflu and Zanamivir should be allowed in the country but in a regulated manner," he said. Previously, distribution of Tamiflu was prohibited by the government, and access to it was only available through public health institutions. At least 70 people in Kenya have the swine flu, according to local health official. In the latest outbreak, twenty high school students came down with the virus and had to be quarantined on Thursday. "A majority of the affected students who are in Forms One and Two were treated and advised to remain under bed rest to minimise further spread of the disease among the student community," said the director of Public Health, Dr. Shanaaz Shariff. However, he said that the students' illness was "not too serious to warrant hospitalisation." Security guards were placed around the school the students were isolated in, with orders only to allow medical personnel to enter the premises. Kenya's capital Nairobi has been the worst hit by the flu, having reported forty cases. Other cities affected by the flu are Kisumu and Rift Valley, who have reported eighteen and ten cases of the H1N1 virus, respectively. Mexico, the country in which the outbreak initially started, has 25,214 reported cases and 217 fatalities from the virus. Some recent cases have forced schools to close down. Jose Angel Cordova, the Mexican health secretary, said that the virus could infect as many as five million of Mexico's 107 million people, and, in a worst-case scenario, cause up to 2,000 deaths. His estimate is higher than his previous prediction of 1 million cases and 1,000 deaths, made last month. About five thousand new cases of swine flu were reported in the United Kingdom in recent weeks, reversing a declining trend in the number of new infections. Health officials have suggested this could lead up to a second outbreak of the virus. "We don't know whether this is the start of the next big wave that we were expecting this autumn but it is certainly something that's giving us concern. It will probably be a week or two before we see whether this increase is sustained." said Liam Donaldson, the Chief Medical Officer. Health authorities have said that at least 25 cases appear to have been resistant to the Tamiflu drug prescribed to treat the illness. Donaldson said that "the positive side of it is that so far these have not been strains that have then gone on and affected other patients, they have stayed with the patient in which they were isolated. What would worry us is if we got a resistant strain that then started infecting people like the rest of the cases of flu that have occurred." The UK is one of several countries that have pledged up to one tenth of their vaccine stock to to other countries if they are in need of more supplies. "Britain recognizes that H1N1 is a global pandemic which requires a global response," the International Development Secretary, Douglas Alexander, said. "Solidarity with other nations is vital, particularly the poorest who may be most vulnerable and have least capacity to respond." The US government recently bought 195 million doses of swine flu vaccine. Health Care Secretary Kathleen Sebelius said that free shots will be given out early in October. The vaccination is to be voluntary, but priority will be given to certain groups, such as toddlers and children, adults over the age of 65, and pregnant women, who are considered especially vulnerable to the virus. "We remain confident that the United States will have sufficient doses of the vaccine to ensure that every American who wants a vaccine is able to receive one," a White House statement said. As of September 16, the US had 593 deaths from the flu. 144 people in Vietnam were diagnosed with the swine flu on Wednesday, bringing the total number of infected people in the country to 5,648. This week, the number of affected people has increased by 1104 infections or 6.3%. Nguyen Tran Hien, the director of the Central Institute of Hygiene Epidemiology, predicted that the swine flu would peak at the end of 2009 and the beginning 2010. The Vietnamese Ministry of Health called for more research into a swine flu vaccine, and urged the the National Steering Board on Flu Prevention in Humans to give out more doses of the drug Tamiflu to areas hardest hit by the flu.
39 | -------------NEW ARTICLE-----------------
40 | On Saturday local villagers claimed a meteorite slammed into a field outside of Carancas, near Lake Titicaca in the Puno region of Peru on the border of Bolivia. It emitted a sweet but noxious odor. It has now been blamed for a mass illness affecting roughly 200 villagers with "nausea, vomiting, digestive problems and general sickness," according to a local health department official, Jorge López. "Boiling water started coming out of the crater and particles of rock and cinders were found nearby. Residents are very concerned," said López. Police officers who went to investigate the meteorite are among those who have fallen ill and been taken to Desaguadero hospital. The impact of the meteorite left a crater 18 feet deep and 30 yards across in the Andean territory that is home to less than 1,000 people. Originally, the villagers thought a plane had crashed. Under consideration is the declaration of a state of emergency. Peruvian Nuclear Energy Institute engineer Renan Ramirez said scientists who went to investigate the crater found no indication of radiation, although, the fumes from the crater were so pungent that one scientist said his throat and nose were irritated despite his use of a mask. Villagers are said to be avoiding the local water out of fear of contamination. Sulfur, arsenic and other elements common in meteorites can react with ground water to produce fumes. Ursula Marvin, a meteor expert at the Smithsonian Astrophysical Observatory in Massachusetts, said a meteorite "wouldn't get much gas out of the earth" and that a more likely explanation for the health problems was the dust cloud caused when the rock hit the Earth. Other explanations abound. Don Yeomans, head of the Near Earth Object Program at NASA's Jet Propulsion Laboratory, said "Statistically, it's far more likely to have come from below than from above," noting that meteorites do not give off smells and it is likely the result of hydrothermal activity, such as a local gas explosion. Dr Caroline Smith, a meteorite expert with the Natural History Museum in London, thought more likely the villagers saw a common fireball and in the process of investigating it, did not find a 'crater' but "a lake of sedimentary deposit, which may be full of smelly, methane rich organic matter." And one science blogger, David Syzdek, theorized that in fact the crater is a mud volcano "that is producing toxic gasses [sic] such as methane, water, and perhaps other hydrocarbons. Many hydrocarbons can cause illness."
41 | -------------NEW ARTICLE-----------------
42 | At least two children in Baghdad, Iraq have died after eating cake poisoned with thallium and at least nine others remain ill. The cake was given to people at an Iraqi sports club near the capital. The Secretary of the Iraqi Air Force and his daughter are also among the victims. All are currently receiving treatment in Amman, Jordan as the antidote for the deadly poison is not available in Iraqi hospitals. The United Kingdom has flown in the antidotes and treatments for the victims, several of which are seriously ill. "This is a disturbing incident," said a police spokesman. Thallium is used in poisons to kill rats and insects and is also considered the assassin's drug or "The Poisoner's Poison" because it is tasteless. Former Iraqi dictator Saddam Hussein used the poison against many of his enemies, and it has not been used since his rule of the country. So far, it is not known how the cakes were poisoned, but the Air force Secretary says that the cakes were seemingly delivered to the club as a "goodwill gesture." Two officials at the club then took the cake home, where members of the families ate it. He now believes someone conspired to kill him and his family. "The use of thallium in this way appears to show that someone in Adhamiya is reviving the techniques of the mukhabarat [Saddam's secret police]. What happens if al-Qaida gets the know-how? We are urgently trying to discover how much thallium is out there and who would know how to utilize it," added the spokesman. An investigation is ongoing, but police say that the cakes were made at a local bakery in the Adhamiyah district of Baghdad. Police also say that the bakery has recently been a host for Sunni militants.
--------------------------------------------------------------------------------
/data/words2index.pkl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milangritta/Geocoding-with-Map-Vector/69e6e590c56930ed80d346f6c2da6d58056182e3/data/words2index.pkl
--------------------------------------------------------------------------------
/geoparse.py:
--------------------------------------------------------------------------------
1 | import cPickle
2 | import codecs
3 | import sqlite3
4 | from genericpath import isfile
5 | from os import listdir
6 | import spacy
7 | import numpy as np
8 | from geopy.distance import great_circle
9 | from keras.models import load_model
10 | from preprocessing import index_to_coord, ENCODING_MAP_1x1, OUTLIERS_MAP_1x1, get_coordinates
11 | from preprocessing import CONTEXT_LENGTH, pad_list, TARGET_LENGTH, UNKNOWN, REVERSE_MAP_2x2
12 | from text2mapVec import text2mapvec
13 |
14 | model = load_model("../data/weights") # weights to be downloaded from Cambridge Uni repo, see GitHub.
15 | nlp = spacy.load(u'en_core_web_lg') # or spacy.load(u'en') depending on your Spacy Download (simple or full)
16 | conn = sqlite3.connect(u'../data/geonames.db').cursor() # this DB can be downloaded using the GitHub link
17 | padding = nlp(u"0")[0] # Do I need to explain? :-)
18 | word_to_index = cPickle.load(open(u"data/words2index.pkl")) # This is the vocabulary file
19 |
20 | for word in nlp.Defaults.stop_words: # This is only necessary if you use the full Spacy English model
21 | lex = nlp.vocab[word] # so if you use spacy.load(u'en'), you can comment this out.
22 | lex.is_stop = True
23 |
24 |
25 | def geoparse(text):
26 | """
27 | This function allows one to geoparse text i.e. extract toponyms (place names) and disambiguate to coordinates.
28 | :param text: to be parsed
29 | :return: currently only prints results to the screen, feel free to modify to your task
30 | """
31 | doc = nlp(text) # NER with Spacy NER
32 | for entity in doc.ents:
33 | if entity.label_ in [u"GPE", u"FACILITY", u"LOC", u"FAC", u"LOCATION"]:
34 | name = entity.text if not entity.text.startswith('the') else entity.text[4:].strip()
35 | start = entity.start_char if not entity.text.startswith('the') else entity.start_char + 4
36 | end = entity.end_char
37 | near_inp = pad_list(CONTEXT_LENGTH / 2, [x for x in doc[max(0, entity.start - CONTEXT_LENGTH / 2):entity.start]], True, padding) + \
38 | pad_list(CONTEXT_LENGTH / 2, [x for x in doc[entity.end: entity.end + CONTEXT_LENGTH / 2]], False, padding)
39 | far_inp = pad_list(CONTEXT_LENGTH / 2, [x for x in doc[max(0, entity.start - CONTEXT_LENGTH):max(0, entity.start - CONTEXT_LENGTH / 2)]], True, padding) + \
40 | pad_list(CONTEXT_LENGTH / 2, [x for x in doc[entity.end + CONTEXT_LENGTH / 2: entity.end + CONTEXT_LENGTH]], False, padding)
41 | map_vector = text2mapvec(doc=near_inp + far_inp, mapping=ENCODING_MAP_1x1, outliers=OUTLIERS_MAP_1x1, polygon_size=1, db=conn, exclude=name)
42 |
43 | context_words, entities_strings = [], []
44 | target_string = pad_list(TARGET_LENGTH, [x.text.lower() for x in entity], True, u'0')
45 | target_string = [word_to_index[x] if x in word_to_index else word_to_index[UNKNOWN] for x in target_string]
46 | for words in [near_inp, far_inp]:
47 | for word in words:
48 | if word.text.lower() in word_to_index:
49 | vec = word_to_index[word.text.lower()]
50 | else:
51 | vec = word_to_index[UNKNOWN]
52 | if word.ent_type_ in [u"GPE", u"FACILITY", u"LOC", u"FAC", u"LOCATION"]:
53 | entities_strings.append(vec)
54 | context_words.append(word_to_index[u'0'])
55 | elif word.is_alpha and not word.is_stop:
56 | context_words.append(vec)
57 | entities_strings.append(word_to_index[u'0'])
58 | else:
59 | context_words.append(word_to_index[u'0'])
60 | entities_strings.append(word_to_index[u'0'])
61 |
62 | prediction = model.predict([np.array([context_words]), np.array([context_words]), np.array([entities_strings]),
63 | np.array([entities_strings]), np.array([map_vector]), np.array([target_string])])
64 | prediction = index_to_coord(REVERSE_MAP_2x2[np.argmax(prediction[0])], 2)
65 | candidates = get_coordinates(conn, name)
66 |
67 | if len(candidates) == 0:
68 | print(u"Don't have an entry for", name, u"in GeoNames")
69 | continue
70 |
71 | max_pop = candidates[0][2]
72 | best_candidate = []
73 | bias = 0.905 # Tweak the parameter depending on the domain you're working with.
74 | # Less than 0.9 suitable for ambiguous text, more than 0.9 suitable for less ambiguous locations, see paper
75 | for candidate in candidates:
76 | err = great_circle(prediction, (float(candidate[0]), float(candidate[1]))).km
77 | best_candidate.append((err - (err * max(1, candidate[2]) / max(1, max_pop)) * bias, (float(candidate[0]), float(candidate[1]))))
78 | best_candidate = sorted(best_candidate, key=lambda (a, b): a)[0]
79 |
80 | # England,, England,, 51.5,, -0.11,, 669,, 676 || - use evaluation script to test correctness
81 | print name, start, end
82 | print u"Coordinates:", best_candidate[1]
83 |
84 |
85 | # Example usage of the geoparse function below reading from a directory and parsing all files.
86 | directory = u"/Users/milangritta/PycharmProjects/data/lgl/"
87 | files = [f for f in listdir(directory) if isfile(directory + f)]
88 | for f in files:
89 | for line in codecs.open(directory + f, encoding="utf-8"):
90 | print line
91 | geoparse(line)
92 |
--------------------------------------------------------------------------------
/geovirus.py:
--------------------------------------------------------------------------------
1 | import codecs
2 | import random
3 | import sqlite3
4 | import xml.etree.ElementTree as ET
5 | from collections import Counter
6 | import numpy
7 | from geopy.distance import great_circle
8 | from preprocessing import get_coordinates
9 |
10 | # -------------------------------------------- ERROR CHECKING ----------------------------------------------
11 |
12 | if False:
13 | """
14 | Check for XML formatting, duplicate articles, URLs, coordinate distances to Geonames database,
15 | correct indexing of location names i.e. start and end character positions.
16 | """
17 | tree = ET.parse(u'data/GeoVirus.xml')
18 | conn = sqlite3.connect(u'../data/geonames.db')
19 | c = conn.cursor()
20 | root = tree.getroot()
21 | duplicates = set()
22 | for article in root:
23 | text = article.find('text').text
24 | if text in duplicates:
25 | raise Exception(u'Duplicate titles/sources!')
26 | else:
27 | duplicates.add(text)
28 | for location in article.find('locations'):
29 | start = location.find('start').text
30 | end = location.find('end').text
31 | name = location.find('name').text
32 | url = location.find('page')
33 | if url.text != u"N/A":
34 | if url is None or not url.text.startswith(u"https://en.wikipedia.org/wiki/"):
35 | raise Exception(u"URL corrupted!")
36 | chunk = text[int(start) - 1: int(end) - 1]
37 | if chunk != name:
38 | raise Exception(chunk + ", " + name)
39 | if location.find('altName') is not None:
40 | name = location.find('altName').text
41 | lat = location.find('lat').text
42 | lon = location.find('lon').text
43 | coords = get_coordinates(c, name)
44 | dist = 10000.0
45 | for coord in coords:
46 | gap = great_circle((float(lat), float(lon)), (coord[0], coord[1])).km
47 | if gap < dist:
48 | dist = gap
49 | if dist > 1000:
50 | print u"Distance is large, please check if this is normal.", name, url, dist, lat, lon
51 |
52 | # -------------------------------------------------- NUMBERS -------------------------------------------------------
53 |
54 | if False:
55 | """
56 | Generate essential stats describing the nature of the dataset. Reported in the publication.
57 | """
58 | tree = ET.parse('data/GeoVirus.xml')
59 | root = tree.getroot()
60 | counter, continents, words, articles = [], 0, [], 0
61 | for article in root:
62 | articles += 1
63 | text = article.find("text").text
64 | words.extend(text.split())
65 | for location in article.findall("locations/location"):
66 | name = location.find("name")
67 | cont = location.find("continent")
68 | if cont is not None:
69 | continents += 1
70 | counter.append(name.text)
71 | print "Total Locations:", len(counter)
72 | counter = Counter(counter)
73 | print "Unique Locations:", len(counter)
74 | print "Most Common:", counter.most_common()
75 | print "Continents", continents
76 | counter = [j for (i, j) in counter.most_common()]
77 | print "Mean:", numpy.mean(counter)
78 | print "Median:", numpy.median(counter)
79 | print "Articles:", articles
80 | print "Total words:", len(words)
81 |
82 |
83 | # ---------------------------------------------- GENERATION ------------------------------------------------
84 |
85 | if False:
86 | """
87 | Before running the function, please create a directory called "geovirus" outside of the loc2vec directory.
88 | This function is used to convert the XML file into (1.) a directory of files where each file contains the
89 | text of each article i.e. 229 files will be created. (2.) a file "geovirus_gold.txt" containing the gold answers
90 | for each article. These two outputs will be used to generate evaluation files in preprocessing.py
91 | """
92 | tree = ET.parse(u"data/GeoVirus.xml")
93 | root = tree.getroot()
94 | f = codecs.open(u"data/geovirus_gold.txt", "w", "utf-8")
95 | c = 0
96 | counter = []
97 | for child in root:
98 | text = child.find('text').text
99 | gold_tops = []
100 | for location in child.findall('./locations/location'):
101 | start = location.find("start")
102 | end = location.find("end")
103 | name = location.find("name")
104 | if location.find('altName') is not None:
105 | alt_name = location.find('altName')
106 | else:
107 | alt_name = name
108 | counter.append(name.text)
109 | lat = location.find("lat")
110 | lon = location.find("lon")
111 | gold_tops.append(alt_name.text + ",," + name.text + ",," + lat.text + ",," + lon.text + ",," + start.text + ",," + end.text)
112 | for t in gold_tops:
113 | f.write(t + "||")
114 | f.write("\n")
115 | f_out = codecs.open(u"../data/geovirus/" + str(c), 'w', "utf-8") # Files saved by numbers
116 | f_out.write(text)
117 | f_out.close()
118 | c += 1
119 | f.close()
120 | counter = Counter(counter)
121 | print counter.most_common()
122 |
123 | # --------------------------------------SUBSAMPLING FOR INTER-ANNOTATOR AGREEMENT--------------------------------------
124 |
125 | if False:
126 | """
127 | Generate a 10% random sample for the Inter Annotator Agreement figures.
128 | """
129 | iaa_check = codecs.open(u"data/iaa_check.txt", "w", "utf-8")
130 | iaa_test = codecs.open(u"data/iaa_test.txt", "w", "utf-8")
131 | tree = ET.parse(u'data/GeoVirus.xml')
132 | root = tree.getroot()
133 |
134 | for article in root:
135 | if random.randint(1, 10) > 9:
136 | text = article.find("text").text
137 | iaa_test.write("-------------NEW ARTICLE-----------------\n")
138 | iaa_test.write(text + "\n")
139 | print_count = 0
140 | for loc in article.findall("./locations/location"):
141 | print_count += 1
142 | start = int(loc.find("start").text)
143 | iaa_check.write(loc.find("page").text + "\n")
144 | iaa_check.write(loc.find("start").text + "\n")
145 | iaa_check.write(loc.find("name").text + "\n")
146 | if print_count <= 3:
147 | iaa_test.write("-----------\n")
148 | iaa_test.write("LOCATION NAME -> Asia\n")
149 | iaa_test.write("LINK -> https://en.wikipedia.org/wiki/Asia\n")
150 | iaa_test.write("START CHARACTER -> 100\n")
151 |
152 | # -----------------------------------------COMPUTING INTER-ANNOTATOR AGREEMENT---------------------------------------
153 |
154 | if False:
155 | """
156 | Compute IAA, print out overlaps and disagreements, then calculate IAA figures manually.
157 | """
158 | iaa_answers = []
159 | for index, line in enumerate(codecs.open(u"data/iaa_answers.txt", "r", "utf-8"), start=1):
160 | if index % 3 == 0:
161 | iaa_answers.append((url, start, line.strip()))
162 | elif index % 3 == 1:
163 | url = line.strip()
164 | else:
165 | start = int(line) + 1
166 |
167 | iaa_check = []
168 | for index, line in enumerate(codecs.open(u"data/iaa_check.txt", "r", "utf-8"), start=1):
169 | if index % 3 == 0:
170 | iaa_check.append((url, start, line.strip()))
171 | elif index % 3 == 1:
172 | url = line.strip()
173 | else:
174 | start = int(line)
175 |
176 | intersection = Counter(iaa_check) & Counter(iaa_answers)
177 | print len(intersection)
178 | check = Counter(iaa_check) - intersection
179 | answers = Counter(iaa_answers) - intersection
180 | iaa_check = list(check.elements())
181 | iaa_answers = list(answers.elements())
182 | print iaa_check
183 | print iaa_answers
184 |
185 | # ----------------------------------------- END -------------------------------------------
186 |
--------------------------------------------------------------------------------
/melbourne-augmenting-geocoding.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milangritta/Geocoding-with-Map-Vector/69e6e590c56930ed80d346f6c2da6d58056182e3/melbourne-augmenting-geocoding.pdf
--------------------------------------------------------------------------------
/preprocessing.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import codecs
3 | import cPickle
4 | from collections import Counter
5 | import matplotlib.pyplot as plt
6 | import spacy
7 | import numpy as np
8 | import sqlite3
9 | from geopy.distance import great_circle
10 | from matplotlib import pyplot, colors
11 |
12 |
13 | # -------- GLOBAL CONSTANTS AND VARIABLES -------- #
14 | BATCH_SIZE = 64
15 | CONTEXT_LENGTH = 200 # each side of target entity
16 | UNKNOWN = u""
17 | EMBEDDING_DIMENSION = 50
18 | TARGET_LENGTH = 15
19 | ENCODING_MAP_1x1 = cPickle.load(open(u"data/1x1_encode_map.pkl")) # We need these maps
20 | ENCODING_MAP_2x2 = cPickle.load(open(u"data/2x2_encode_map.pkl")) # and the reverse ones
21 | REVERSE_MAP_1x1 = cPickle.load(open(u"data/1x1_reverse_map.pkl")) # to handle the used and
22 | REVERSE_MAP_2x2 = cPickle.load(open(u"data/2x2_reverse_map.pkl")) # unused map_vector polygons.
23 | OUTLIERS_MAP_1x1 = cPickle.load(open(u"data/1x1_outliers_map.pkl")) # Outliers are redundant polygons that
24 | OUTLIERS_MAP_2x2 = cPickle.load(open(u"data/2x2_outliers_map.pkl")) # have been removed but must also be handled.
25 | # -------- GLOBAL CONSTANTS AND VARIABLES -------- #
26 |
27 |
28 | def print_stats(accuracy):
29 | """
30 | Prints Mean, Median, AUC and acc@161km for the list.
31 | :param accuracy: a list of geocoding errors
32 | """
33 | print("==============================================================================================")
34 | print(u"Median error:", np.median(sorted(accuracy)))
35 | print(u"Mean error:", np.mean(accuracy))
36 | accuracy = np.log(np.array(accuracy) + 1)
37 | k = np.log(161)
38 | print u"Accuracy to 161 km: ", sum([1.0 for dist in accuracy if dist < k]) / len(accuracy)
39 | print u"AUC = ", np.trapz(accuracy) / (np.log(20039) * (len(accuracy) - 1)) # Trapezoidal rule.
40 | print("==============================================================================================")
41 |
42 |
43 | def pad_list(size, a_list, from_left, padding):
44 | """
45 | Utility function that pads a list with any given padding.
46 | :param size: the final length of the list i.e. pad up to size
47 | :param a_list: the list to pad
48 | :param from_left: True to pad from the left, False to pad from the right
49 | :param padding: whatever you want to use for padding, example "0"
50 | :return: the padded list
51 | """
52 | while len(a_list) < size:
53 | if from_left:
54 | a_list = [padding] + a_list
55 | else:
56 | a_list += [padding]
57 | return a_list
58 |
59 |
60 | def coord_to_index(coordinates, polygon_size):
61 | """
62 | Convert coordinates into an array (world representation) index. Use that to modify map_vector polygon value.
63 | :param coordinates: (latitude, longitude) to convert to the map vector index
64 | :param polygon_size: integer size of the polygon? i.e. the resolution of the world
65 | :return: index pointing into map_vector array
66 | """
67 | latitude = float(coordinates[0]) - 90 if float(coordinates[0]) != -90 else -179.99 # The two edge cases must
68 | longitude = float(coordinates[1]) + 180 if float(coordinates[1]) != 180 else 359.99 # get handled differently!
69 | if longitude < 0:
70 | longitude = -longitude
71 | if latitude < 0:
72 | latitude = -latitude
73 | x = int(360 / polygon_size) * int(latitude / polygon_size)
74 | y = int(longitude / polygon_size)
75 | return x + y if 0 <= x + y <= int(360 / polygon_size) * int(180 / polygon_size) else Exception(u"Shock horror!!")
76 |
77 |
78 | def index_to_coord(index, polygon_size):
79 | """
80 | Convert index (output of the prediction model) back to coordinates.
81 | :param index: of the polygon/tile in map_vector array (given by model prediction)
82 | :param polygon_size: size of each polygon/tile i.e. resolution of the world
83 | :return: pair of (latitude, longitude)
84 | """
85 | x = int(index / (360 / polygon_size))
86 | y = index % int(360 / polygon_size)
87 | if x > int(90 / polygon_size):
88 | x = -int((x - (90 / polygon_size)) * polygon_size)
89 | else:
90 | x = int(((90 / polygon_size) - x) * polygon_size)
91 | if y < int(180 / polygon_size):
92 | y = -int(((180 / polygon_size) - y) * polygon_size)
93 | else:
94 | y = int((y - (180 / polygon_size)) * polygon_size)
95 | return x, y
96 |
97 |
98 | def get_coordinates(con, loc_name):
99 | """
100 | Access the database to retrieve coordinates and other data from DB.
101 | :param con: sqlite3 database cursor i.e. DB connection
102 | :param loc_name: name of the place
103 | :return: a list of tuples [(latitude, longitude, population, feature_code), ...]
104 | """
105 | result = con.execute(u"SELECT METADATA FROM GEO WHERE NAME = ?", (loc_name.lower(),)).fetchone()
106 | if result:
107 | result = eval(result[0]) # Do not remove the sorting, the function below assumes sorted results!
108 | return sorted(result, key=lambda (a, b, c, d): c, reverse=True)
109 | else:
110 | return []
111 |
112 |
113 | def construct_map_vector(a_list, polygon_size, mapping, outliers):
114 | """
115 | Build the map_vector vector representation from a_list of location data.
116 | :param a_list: of tuples [(latitude, longitude, population, feature_code), ...]
117 | :param polygon_size: what's the resolution? size of each polygon in degrees.
118 | :param mapping: one of the transformation maps 1x1 or 2x2
119 | :param outliers: the outlier map, 1x1 or 2x2 (must match resolution or mapping above)
120 | :return: map_vector representation
121 | """
122 | map_vector = np.zeros(len(mapping), )
123 | if len(a_list) == 0:
124 | return map_vector
125 | max_pop = a_list[0][2] if a_list[0][2] > 0 else 1
126 | for s in a_list:
127 | index = coord_to_index((s[0], s[1]), polygon_size)
128 | if index in mapping:
129 | index = mapping[index]
130 | else:
131 | index = mapping[outliers[index]]
132 | map_vector[index] += float(max(s[2], 1)) / max_pop
133 | return map_vector / map_vector.max() if map_vector.max() > 0.0 else map_vector
134 |
135 |
136 | def construct_map_vector_full_scale(a_list, polygon_size):
137 | """
138 | This function is similar to the above BUT it builds map_vector WITHOUT removing redundant polygons.
139 | :param a_list: of tuples [(latitude, longitude, population, feature_code), ...]
140 | :param polygon_size: size of each polygon in degrees i.e 1x1 or 2x2
141 | :return: map_vector (full scale) i.e. without removing redundant polygons, used for visualisation in 2D
142 | """
143 | map_vector = np.zeros(int(360 / polygon_size) * int(180 / polygon_size))
144 | if len(a_list) == 0:
145 | return map_vector
146 | max_pop = a_list[0][2] if a_list[0][2] > 0 else 1
147 | for s in a_list:
148 | index = coord_to_index((s[0], s[1]), polygon_size)
149 | map_vector[index] += float(max(s[2], 1)) / max_pop
150 | return map_vector / map_vector.max() if map_vector.max() > 0.0 else map_vector
151 |
152 |
153 | def merge_lists(lists):
154 | """
155 | Utility function to merge multiple lists.
156 | :param lists: a list of lists to be merged
157 | :return: one single list with all items from above list of lists
158 | """
159 | out = []
160 | for l in lists:
161 | out.extend(l)
162 | return out
163 |
164 |
165 | def populate_sql():
166 | """
167 | Create and populate the sqlite3 database with GeoNames data. Requires Geonames dump.
168 | No need to run this function, I share the database as a separate dump on GitHub (see link).
169 | """
170 | geo_names = {}
171 | p_map = {"PPLC": 100000, "PCLI": 100000, "PCL": 100000, "PCLS": 10000, "PCLF": 10000, "CONT": 100000, "RGN": 100000}
172 |
173 | for line in codecs.open(u"../data/allCountries.txt", u"r", encoding=u"utf-8"):
174 | line = line.split("\t")
175 | feat_code = line[7]
176 | class_code = line[6]
177 | pop = int(line[14])
178 | for name in [line[1], line[2]] + line[3].split(","):
179 | name = name.lower()
180 | if len(name) != 0:
181 | if name in geo_names:
182 | already_have_entry = False
183 | for item in geo_names[name]:
184 | if great_circle((float(line[4]), float(line[5])), (item[0], item[1])).km < 100:
185 | if item[2] >= pop:
186 | already_have_entry = True
187 | if not already_have_entry:
188 | pop = get_population(class_code, feat_code, p_map, pop)
189 | geo_names[name].add((float(line[4]), float(line[5]), pop, feat_code))
190 | else:
191 | pop = get_population(class_code, feat_code, p_map, pop)
192 | geo_names[name] = {(float(line[4]), float(line[5]), pop, feat_code)}
193 |
194 | conn = sqlite3.connect(u'../data/geonames.db')
195 | c = conn.cursor()
196 | # c.execute("CREATE TABLE GEO (NAME VARCHAR(100) PRIMARY KEY NOT NULL, METADATA VARCHAR(5000) NOT NULL);")
197 | c.execute(u"DELETE FROM GEO") # alternatively, delete the database file.
198 | conn.commit()
199 |
200 | for gn in geo_names:
201 | c.execute(u"INSERT INTO GEO VALUES (?, ?)", (gn, str(list(geo_names[gn]))))
202 | print(u"Entries saved:", len(geo_names))
203 | conn.commit()
204 | conn.close()
205 |
206 |
207 | def get_population(class_code, feat_code, p_map, pop):
208 | """
209 | Utility function to eliminate code duplication. Nothing of much interest, methinks.
210 | :param class_code: Geonames code for the class of location
211 | :param feat_code: Geonames code for the feature type of an database entry
212 | :param p_map: dictionary mapping feature codes to estimated population
213 | :param pop: population count
214 | :return: population (modified if class code is one of A, P or L.
215 | """
216 | if pop == 0 and class_code in ["A", "P", "L"]:
217 | pop = p_map.get(feat_code, 0)
218 | return pop
219 |
220 |
221 | def generate_training_data():
222 | """
223 | Prepare Wikipedia training data. Please download the required files from GitHub.
224 | Files: geonames.db and geowiki.txt both inside the data folder (see README)
225 | Alternatively, create your own with http://medialab.di.unipi.it/wiki/Wikipedia_Extractor
226 | """
227 | conn = sqlite3.connect(u'../data/geonames.db')
228 | c = conn.cursor()
229 | nlp = spacy.load(u'en') # or spacy.load(u'en_core_web_lg') depending on your Spacy Download (simple, full)
230 | padding = nlp(u"0")[0]
231 | inp = codecs.open(u"../data/geowiki.txt", u"r", encoding=u"utf-8")
232 | o = codecs.open(u"../data/train_wiki.txt", u"w", encoding=u"utf-8")
233 | lat, lon = u"", u""
234 | target, string = u"", u""
235 | skipped = 0
236 |
237 | for line in inp:
238 | if len(line.strip()) == 0:
239 | continue
240 | limit = 0
241 | if line.startswith(u"NEW ARTICLE::"):
242 | if len(string.strip()) > 0 and len(target) != 0:
243 | locations_near, locations_far = [], []
244 | doc = nlp(string)
245 | for d in doc:
246 | if d.text == target[0]:
247 | if u" ".join(target) == u" ".join([t.text for t in doc[d.i:d.i + len(target)]]):
248 | near_inp = pad_list(CONTEXT_LENGTH / 2, [x for x in doc[max(0, d.i - CONTEXT_LENGTH / 2):d.i]], True, padding) \
249 | + pad_list(CONTEXT_LENGTH / 2, [x for x in doc[d.i + len(target): d.i + len(target) + CONTEXT_LENGTH / 2]], False, padding)
250 | far_inp = pad_list(CONTEXT_LENGTH / 2, [x for x in doc[max(0, d.i - CONTEXT_LENGTH):max(0, d.i - CONTEXT_LENGTH / 2)]], True, padding) \
251 | + pad_list(CONTEXT_LENGTH / 2, [x for x in doc[d.i + len(target) + CONTEXT_LENGTH / 2: d.i + len(target) + CONTEXT_LENGTH]], False, padding)
252 | near_out, far_out = [], []
253 | location = u""
254 | for (out_list, in_list, is_near) in [(near_out, near_inp, True), (far_out, far_inp, False)]:
255 | for index, item in enumerate(in_list):
256 | if item.ent_type_ in [u"GPE", u"FACILITY", u"LOC", u"FAC", u"LOCATION"]:
257 | if item.ent_iob_ == u"B" and item.text.lower() == u"the":
258 | out_list.append(item.text.lower())
259 | else:
260 | location += item.text + u" "
261 | out_list.append(u"**LOC**" + item.text.lower())
262 | elif item.ent_type_ in [u"PERSON", u"DATE", u"TIME", u"PERCENT", u"MONEY",
263 | u"QUANTITY", u"CARDINAL", u"ORDINAL"]:
264 | out_list.append(u'0')
265 | elif item.is_punct:
266 | out_list.append(u'0')
267 | elif item.is_digit or item.like_num:
268 | out_list.append(u'0')
269 | elif item.like_email:
270 | out_list.append(u'0')
271 | elif item.like_url:
272 | out_list.append(u'0')
273 | elif item.is_stop:
274 | out_list.append(u'0')
275 | else:
276 | out_list.append(item.lemma_)
277 | if location.strip() != u"" and (item.ent_type == 0 or index == len(in_list) - 1):
278 | location = location.strip()
279 | coords = get_coordinates(c, location)
280 | if len(coords) > 0 and location != u" ".join(target):
281 | if is_near:
282 | locations_near.append(coords)
283 | else:
284 | locations_far.append(coords)
285 | else:
286 | offset = 1 if index == len(in_list) - 1 else 0
287 | for i in range(index - len(location.split()), index):
288 | out_list[i + offset] = in_list[i + offset].lemma_ \
289 | if in_list[i + offset].is_alpha and location != u" ".join(target) else u'0'
290 | location = u""
291 | target_grid = get_coordinates(c, u" ".join(target))
292 | if len(target_grid) == 0:
293 | skipped += 1
294 | break
295 | entities_near = merge_lists(locations_near)
296 | entities_far = merge_lists(locations_far)
297 | locations_near, locations_far = [], []
298 | o.write(lat + u"\t" + lon + u"\t" + str(near_out) + u"\t" + str(far_out) + u"\t")
299 | o.write(str(target_grid) + u"\t" + str([t.lower() for t in target][:TARGET_LENGTH]))
300 | o.write(u"\t" + str(entities_near) + u"\t" + str(entities_far) + u"\n")
301 | limit += 1
302 | if limit > 29:
303 | break
304 | line = line.strip().split("\t")
305 | if u"(" in line[1]:
306 | line[1] = line[1].split(u"(")[0].strip()
307 | if line[1].strip().startswith(u"Geography of "):
308 | target = line[1].replace(u"Geography of ", u"").split()
309 | elif u"," in line[1]:
310 | target = line[1].split(u",")[0].strip().split()
311 | else:
312 | target = line[1].split()
313 | lat = line[2]
314 | lon = line[3]
315 | string = ""
316 | print(u"Processed", limit, u"Skipped:", skipped, u"Name:", u" ".join(target))
317 | else:
318 | string += line
319 | o.close()
320 |
321 |
322 | def generate_evaluation_data(corpus, file_name):
323 | """
324 | Create evaluation data from text files. See README for formatting and download instructions.
325 | :param corpus: name of the dataset such as LGL, GEOVIRUS or WIKTOR
326 | :param file_name: an affix, in case you're creating several versions of the same dataset
327 | """
328 | conn = sqlite3.connect(u'../data/geonames.db')
329 | c = conn.cursor()
330 | nlp = spacy.load(u'en') # or spacy.load(u'en_core_web_lg'), it depends on your choice of model
331 | padding = nlp(u"0")[0]
332 | directory = u"../data/" + corpus + u"/"
333 | o = codecs.open(u"data/eval_" + corpus + file_name + u".txt", u"w", encoding=u"utf-8")
334 | line_no = 0 if corpus == u"lgl" else -1
335 |
336 | for line in codecs.open(u"data/" + corpus + file_name + u".txt", u"r", encoding=u"utf-8"):
337 | line_no += 1
338 | if len(line.strip()) == 0:
339 | continue
340 | for toponym in line.split(u"||")[:-1]:
341 | captured = False
342 | doc = nlp(codecs.open(directory + str(line_no), u"r", encoding=u"utf-8").read())
343 | locations_near, locations_far = [], []
344 | toponym = toponym.split(u",,")
345 | target = [t.text for t in nlp(toponym[1])]
346 | ent_length = len(u" ".join(target))
347 | lat, lon = toponym[2], toponym[3]
348 | start, end = int(toponym[4]), int(toponym[5])
349 | for d in doc:
350 | if d.text == target[0]:
351 | if u" ".join(target) == u" ".join([t.text for t in doc[d.i:d.i + len(target)]]):
352 | if abs(d.idx - start) > 4 or abs(d.idx + ent_length - end) > 4:
353 | continue
354 | captured = True
355 | near_inp = pad_list(CONTEXT_LENGTH / 2, [x for x in doc[max(0, d.i - CONTEXT_LENGTH / 2):d.i]], True, padding) \
356 | + pad_list(CONTEXT_LENGTH / 2, [x for x in doc[d.i + len(target): d.i + len(target) + CONTEXT_LENGTH / 2]], False, padding)
357 | far_inp = pad_list(CONTEXT_LENGTH / 2, [x for x in doc[max(0, d.i - CONTEXT_LENGTH):max(0, d.i - CONTEXT_LENGTH / 2)]], True, padding) \
358 | + pad_list(CONTEXT_LENGTH / 2, [x for x in doc[d.i + len(target) + CONTEXT_LENGTH / 2: d.i + len(target) + CONTEXT_LENGTH]], False, padding)
359 | near_out, far_out = [], []
360 | location = u""
361 | for (out_list, in_list, is_near) in [(near_out, near_inp, True), (far_out, far_inp, False)]:
362 | for index, item in enumerate(in_list):
363 | if item.ent_type_ in [u"GPE", u"FACILITY", u"LOC", u"FAC", u"LOCATION"]:
364 | if item.ent_iob_ == u"B" and item.text.lower() == u"the":
365 | out_list.append(item.text.lower())
366 | else:
367 | location += item.text + u" "
368 | out_list.append(u"**LOC**" + item.text.lower())
369 | elif item.ent_type_ in [u"PERSON", u"DATE", u"TIME", u"PERCENT", u"MONEY",
370 | u"QUANTITY", u"CARDINAL", u"ORDINAL"]:
371 | out_list.append(u'0')
372 | elif item.is_punct:
373 | out_list.append(u'0')
374 | elif item.is_digit or item.like_num:
375 | out_list.append(u'0')
376 | elif item.like_email:
377 | out_list.append(u'0')
378 | elif item.like_url:
379 | out_list.append(u'0')
380 | elif item.is_stop:
381 | out_list.append(u'0')
382 | else:
383 | out_list.append(item.lemma_)
384 | if location.strip() != u"" and (item.ent_type == 0 or index == len(in_list) - 1):
385 | location = location.strip()
386 | coords = get_coordinates(c, location)
387 | if len(coords) > 0 and location != u" ".join(target):
388 | if is_near:
389 | locations_near.append(coords)
390 | else:
391 | locations_far.append(coords)
392 | else:
393 | offset = 1 if index == len(in_list) - 1 else 0
394 | for i in range(index - len(location.split()), index):
395 | out_list[i + offset] = in_list[i + offset].lemma_ \
396 | if in_list[i + offset].is_alpha and location != u" ".join(target) else u'0'
397 | location = u""
398 |
399 | lookup = toponym[0] if corpus != u"wiki" else toponym[1]
400 | target_grid = get_coordinates(c, lookup)
401 | if len(target_grid) == 0:
402 | raise Exception(u"No entry in the database!", lookup)
403 | entities_near = merge_lists(locations_near)
404 | entities_far = merge_lists(locations_far)
405 | locations_near, locations_far = [], []
406 | o.write(lat + u"\t" + lon + u"\t" + str(near_out) + u"\t" + str(far_out) + u"\t")
407 | o.write(str(target_grid) + u"\t" + str([t.lower() for t in lookup.split()][:TARGET_LENGTH]))
408 | o.write(u"\t" + str(entities_near) + u"\t" + str(entities_far) + u"\n")
409 | if not captured:
410 | print line_no, line, target, start, end
411 | o.close()
412 |
413 |
414 | def visualise_2D_grid(x, title, log=False):
415 | """
416 | Display 2D array data with a title. Optional: log for better visualisation of small values.
417 | :param x: 2D numpy array you want to visualise
418 | :param title: of the chart because it's nice to have one :-)
419 | :param log: True in order to log the values and make for better visualisation, False for raw numbers
420 | """
421 | if log:
422 | x = np.log10(x)
423 | cmap = colors.LinearSegmentedColormap.from_list('my_colormap', ['lightgrey', 'darkgrey', 'dimgrey', 'black'])
424 | cmap.set_bad(color='white')
425 | img = pyplot.imshow(x, cmap=cmap, interpolation='nearest')
426 | pyplot.colorbar(img, cmap=cmap)
427 | plt.title(title)
428 | # plt.savefig(title + u".png", dpi=200, transparent=True) # Uncomment to save to file
429 | plt.show()
430 |
431 |
432 | def generate_vocabulary(path, min_words, min_entities):
433 | """
434 | Prepare the vocabulary for training/testing. This function is to be called on generated data only, not plain text.
435 | :param path: to the file from which to build
436 | :param min_words: occurrence for inclusion in the vocabulary
437 | :param min_entities: occurrence for inclusion in the vocabulary
438 | """
439 | vocab_words, vocab_locations = {UNKNOWN, u'0'}, {UNKNOWN, u'0'}
440 | words, locations = [], []
441 | for f in [path]: # You can also build the vocabulary from several files, just add to the list.
442 | training_file = codecs.open(f, u"r", encoding=u"utf-8")
443 | for line in training_file:
444 | line = line.strip().split("\t")
445 | words.extend([w for w in eval(line[2]) if u"**LOC**" not in w]) # NEAR WORDS
446 | words.extend([w for w in eval(line[3]) if u"**LOC**" not in w]) # FAR WORDS
447 | locations.extend([w for w in eval(line[2]) if u"**LOC**" in w]) # NEAR ENTITIES
448 | locations.extend([w for w in eval(line[3]) if u"**LOC**" in w]) # FAR ENTITIES
449 |
450 | words = Counter(words)
451 | for word in words:
452 | if words[word] > min_words:
453 | vocab_words.add(word)
454 | print(u"Words saved:", len(vocab_words))
455 |
456 | locations = Counter(locations)
457 | for location in locations:
458 | if locations[location] > min_entities:
459 | vocab_locations.add(location.replace(u"**LOC**", u""))
460 | print(u"Locations saved:", len(vocab_locations))
461 |
462 | vocabulary = vocab_words.union(vocab_locations)
463 | word_to_index = dict([(w, i) for i, w in enumerate(vocabulary)])
464 | cPickle.dump(word_to_index, open(u"data/words2index.pkl", "w"))
465 |
466 |
467 | def generate_arrays_from_file(path, words_to_index, train=True):
468 | """
469 | Generator function for the FULL (SOTA) CNN + map_vector model in the paper. Uses all available data inputs.
470 | :param path: to the training file (see training data generation functions)
471 | :param words_to_index: the vocabulary set
472 | :param train: True is generating training data, false for test data
473 | """
474 | while True:
475 | training_file = codecs.open(path, "r", encoding="utf-8")
476 | counter = 0
477 | context_words, entities_strings, labels = [], [], []
478 | map_vector, target_string = [], []
479 | for line in training_file:
480 | counter += 1
481 | line = line.strip().split("\t")
482 | labels.append(construct_map_vector([(float(line[0]), float(line[1]), 0)], 2, ENCODING_MAP_2x2, OUTLIERS_MAP_2x2))
483 |
484 | near = [w if u"**LOC**" not in w else u'0' for w in eval(line[2])]
485 | far = [w if u"**LOC**" not in w else u'0' for w in eval(line[3])]
486 | context_words.append(far[:CONTEXT_LENGTH / 2] + near + far[CONTEXT_LENGTH / 2:])
487 |
488 | near = [w.replace(u"**LOC**", u"") if u"**LOC**" in w else u'0' for w in eval(line[2])]
489 | far = [w.replace(u"**LOC**", u"") if u"**LOC**" in w else u'0' for w in eval(line[3])]
490 | entities_strings.append(far[:CONTEXT_LENGTH / 2] + near + far[CONTEXT_LENGTH / 2:])
491 |
492 | # map_vector.append(construct_map_vector(sorted(eval(line[4]) + eval(line[6]) + eval(line[7]),
493 | # key=lambda (a, b, c, d): c, reverse=True), 1, ENCODING_MAP_1x1, OUTLIERS_MAP_1x1))
494 | # paper version above versus small experimental setup below, map_vector is fully modular, remember? Try both!
495 | map_vector.append(construct_map_vector(eval(line[4]) + eval(line[6]) + eval(line[7]), 1, ENCODING_MAP_1x1, OUTLIERS_MAP_1x1))
496 | target_string.append(pad_list(TARGET_LENGTH, eval(line[5]), True, u'0'))
497 |
498 | if counter % BATCH_SIZE == 0:
499 | for collection in [context_words, entities_strings, target_string]:
500 | for x in collection:
501 | for i, w in enumerate(x):
502 | if w in words_to_index:
503 | x[i] = words_to_index[w]
504 | else:
505 | x[i] = words_to_index[UNKNOWN]
506 | if train:
507 | yield ([np.asarray(context_words), np.asarray(context_words), np.asarray(entities_strings),
508 | np.asarray(entities_strings), np.asarray(map_vector), np.asarray(target_string)], np.asarray(labels))
509 | else:
510 | yield ([np.asarray(context_words), np.asarray(context_words), np.asarray(entities_strings),
511 | np.asarray(entities_strings), np.asarray(map_vector), np.asarray(target_string)])
512 |
513 | context_words, entities_strings, labels = [], [], []
514 | map_vector, target_string = [], []
515 |
516 | if len(labels) > 0: # This block is only ever entered at the end to yield the final few samples. (< BATCH_SIZE)
517 | for collection in [context_words, entities_strings, target_string]:
518 | for x in collection:
519 | for i, w in enumerate(x):
520 | if w in words_to_index:
521 | x[i] = words_to_index[w]
522 | else:
523 | x[i] = words_to_index[UNKNOWN]
524 | if train:
525 | yield ([np.asarray(context_words), np.asarray(context_words), np.asarray(entities_strings),
526 | np.asarray(entities_strings), np.asarray(map_vector), np.asarray(target_string)], np.asarray(labels))
527 | else:
528 | yield ([np.asarray(context_words), np.asarray(context_words), np.asarray(entities_strings),
529 | np.asarray(entities_strings), np.asarray(map_vector), np.asarray(target_string)])
530 |
531 |
532 | def generate_arrays_from_file_lstm(path, words_to_index, train=True):
533 | """
534 | Generator for the context2vec model. Uses only lexical features.
535 | To replicate the map_vector + CONTEXT2VEC model from the paper, uncomment a few sections below
536 | and in the context2vec.py file. I hope it's clear enough :-) Email me if it isn't!
537 | :param path: to the training file (see training data generation functions)
538 | :param words_to_index: the vocabulary set
539 | :param train: True for training stage, False for testing stage
540 | """
541 | while True:
542 | training_file = codecs.open(path, "r", encoding="utf-8")
543 | counter = 0
544 | left, right, map_vector = [], [], []
545 | target_string, labels = [], []
546 | for line in training_file:
547 | counter += 1
548 | line = line.strip().split("\t")
549 | labels.append(construct_map_vector([(float(line[0]), float(line[1]), 0)], 2, ENCODING_MAP_2x2, OUTLIERS_MAP_2x2))
550 |
551 | near = [w.replace(u"**LOC**", u"") for w in eval(line[2])]
552 | far = [w.replace(u"**LOC**", u"") for w in eval(line[3])]
553 | left.append(far[:CONTEXT_LENGTH / 2] + near[:CONTEXT_LENGTH / 2])
554 | right.append(near[CONTEXT_LENGTH / 2:] + far[CONTEXT_LENGTH / 2:])
555 |
556 | target_string.append(pad_list(TARGET_LENGTH, eval(line[5]), True, u'0'))
557 |
558 | # map_vector.append(construct_map_vector(eval(line[4]) + eval(line[6]) + eval(line[7]), 1, ENCODING_MAP_1x1, OUTLIERS_MAP_1x1))
559 |
560 | if counter % BATCH_SIZE == 0:
561 | for collection in [left, right, target_string]:
562 | for x in collection:
563 | for i, w in enumerate(x):
564 | if w in words_to_index:
565 | x[i] = words_to_index[w]
566 | else:
567 | x[i] = words_to_index[UNKNOWN]
568 | if train:
569 | yield ([np.asarray(left), np.asarray(right), np.asarray(target_string)], np.asarray(labels))
570 | # yield ([np.asarray(left), np.asarray(right), np.asarray(map_vector), np.asarray(target_string)], np.asarray(labels))
571 | else:
572 | yield ([np.asarray(left), np.asarray(right), np.asarray(target_string)])
573 | # yield ([np.asarray(left), np.asarray(right), np.asarray(map_vector), np.asarray(target_string)])
574 |
575 | left, right, map_vector = [], [], []
576 | target_string, labels = [], []
577 |
578 | if len(labels) > 0: # This block is only ever entered at the end to yield the final few samples. (< BATCH_SIZE)
579 | for collection in [left, right, target_string]:
580 | for x in collection:
581 | for i, w in enumerate(x):
582 | if w in words_to_index:
583 | x[i] = words_to_index[w]
584 | else:
585 | x[i] = words_to_index[UNKNOWN]
586 | if train:
587 | yield ([np.asarray(left), np.asarray(right), np.asarray(target_string)], np.asarray(labels))
588 | # yield ([np.asarray(left), np.asarray(right), np.asarray(map_vector), np.asarray(target_string)], np.asarray(labels))
589 | else:
590 | yield ([np.asarray(left), np.asarray(right), np.asarray(target_string)])
591 | # yield ([np.asarray(left), np.asarray(right), np.asarray(map_vector), np.asarray(target_string)])
592 |
593 |
594 | def generate_strings_from_file(path):
595 | """
596 | Generator of labels, location names and context. Used for training and testing.
597 | :param path: to the training file (see training data generation functions)
598 | :return: Yields a list of tuples [(label, location name, context), ...]
599 | """
600 | while True:
601 | for line in codecs.open(path, "r", encoding="utf-8"):
602 | line = line.strip().split("\t")
603 | context = u" ".join(eval(line[2])) + u"*E*" + u" ".join(eval(line[5])) + u"*E*" + u" ".join(eval(line[3]))
604 | yield ((float(line[0]), float(line[1])), u" ".join(eval(line[5])).strip(), context)
605 |
606 |
607 | def generate_arrays_from_file_map_vector(path, train=True, looping=True):
608 | """
609 | Generator for the plain map_vector model, works for MLP, Naive Bayes or Random Forest. Table 2 in the paper.
610 | :param path: to the training file (see training data generation functions)
611 | :param train: True for training phase, False for testing phase
612 | :param looping: True for continuous generation, False for one iteration.
613 | """
614 | while True:
615 | training_file = codecs.open(path, "r", encoding="utf-8")
616 | counter = 0
617 | labels, target_coord = [], []
618 | for line in training_file:
619 | counter += 1
620 | line = line.strip().split("\t")
621 | labels.append(construct_map_vector([(float(line[0]), float(line[1]), 0, u'')], 2, ENCODING_MAP_2x2, OUTLIERS_MAP_2x2))
622 | target_coord.append(construct_map_vector(eval(line[4]) + eval(line[6]) + eval(line[7]), 1, ENCODING_MAP_1x1, OUTLIERS_MAP_1x1))
623 |
624 | if counter % BATCH_SIZE == 0:
625 | if train:
626 | yield ([np.asarray(target_coord)], np.asarray(labels))
627 | else:
628 | yield ([np.asarray(target_coord)])
629 |
630 | labels = []
631 | target_coord = []
632 |
633 | if len(labels) > 0:
634 | # This block is only ever entered at the end to yield the final few samples. (< BATCH_SIZE)
635 | if train:
636 | yield ([np.asarray(target_coord)], np.asarray(labels))
637 | else:
638 | yield ([np.asarray(target_coord)])
639 | if not looping:
640 | break
641 |
642 |
643 | def shrink_map_vector(polygon_size):
644 | """
645 | Remove polygons that only cover oceans. Dumps a dictionary of DB entries.
646 | :param polygon_size: the size of each polygon such as 1x1 or 2x2 or 3x3 degrees (integer)
647 | """
648 | map_vector = np.zeros((180 / polygon_size) * (360 / polygon_size),)
649 | for line in codecs.open(u"../data/allCountries.txt", u"r", encoding=u"utf-8"):
650 | line = line.split("\t")
651 | lat, lon = float(line[4]), float(line[5])
652 | index = coord_to_index((lat, lon), polygon_size=polygon_size)
653 | map_vector[index] += 1.0
654 | cPickle.dump(map_vector, open(u"mapvec_shrink.pkl", "w"))
655 |
656 |
657 | def oracle(path):
658 | """
659 | Calculate the Oracle (best possible given your database) performance for a given dataset.
660 | Prints the Oracle scores including mean, median, AUC and acc@161.
661 | :param path: file path to evaluate
662 | """
663 | final_errors = []
664 | conn = sqlite3.connect(u'../data/geonames.db')
665 | for line in codecs.open(path, "r", encoding="utf-8"):
666 | line = line.strip().split("\t")
667 | coordinates = (float(line[0]), float(line[1]))
668 | best_candidate = []
669 | for candidate in get_coordinates(conn.cursor(), u" ".join(eval(line[5])).strip()):
670 | best_candidate.append(great_circle(coordinates, (float(candidate[0]), float(candidate[1]))).km)
671 | final_errors.append(sorted(best_candidate)[0])
672 | print_stats(final_errors)
673 |
674 |
675 | # --------------------------------------------- INVOKE FUNCTIONS ---------------------------------------------------
676 | # prepare_geocorpora()
677 | # print get_coordinates(sqlite3.connect('../data/geonames.db').cursor(), u"dublin")
678 | # generate_training_data()
679 | # generate_evaluation_data(corpus="geovirus", file_name="")
680 | # generate_vocabulary(path=u"../data/train_wiki.txt", min_words=9, min_entities=1)
681 | # shrink_map_vector(2)
682 | # oracle(u"data/eval_geovirus_gold.txt")
683 | # conn = sqlite3.connect('../data/geonames.db')
684 | # c = conn.cursor()
685 | # c.execute("INSERT INTO GEO VALUES (?, ?)", (u"darfur", u"[(13.5, 23.5, 0), (44.05135, -94.83804, 106)]"))
686 | # c.execute("DELETE FROM GEO WHERE name = 'darfur'")
687 | # conn.commit()
688 | # print index_to_coord(8177, 2)
689 | # populate_sql()
690 |
691 | # -------- CREATE MAPS (mapping from 64,000/16,200 polygons to 23,002, 7,821) ------------
692 | # map_vector = list(cPickle.load(open(u"data/1x1_geonames.pkl")))
693 | # zeros = dict([(i, v) for i, v in enumerate(map_vector) if v > 0]) # isolate the non zero values
694 | # zeros = dict([(i, v) for i, v in enumerate(zeros)]) # replace counts with indices
695 | # zeros = dict([(v, i) for (i, v) in zeros.iteritems()]) # reverse keys and values
696 | # cPickle.dump(zeros, open(u"data/1x1_encode_map.pkl", "w"))
697 |
698 | # ------- VISUALISE THE WHOLE DATABASE ----------
699 | # map_vector = np.reshape(map_vector, newshape=((180 / 1), (360 / 1)))
700 | # visualise_2D_grid(map_vector, "Geonames Database", True)
701 |
702 | # -------- CREATE OUTLIERS (polygons outside of map_vector) MAP --------
703 | # filtered = [i for i, v in enumerate(map_vector) if v > 0]
704 | # the_rest = [i for i, v in enumerate(map_vector) if v == 0]
705 | # poly_size = 2
706 | # dict_rest = dict()
707 | #
708 | # for poly_rest in the_rest:
709 | # best_index = 100000
710 | # best_dist = 100000
711 | # for poly_filtered in filtered:
712 | # dist = great_circle(index_to_coord(poly_rest, poly_size), index_to_coord(poly_filtered, poly_size)).km
713 | # if dist < best_dist:
714 | # best_index = poly_filtered
715 | # best_dist = dist
716 | # dict_rest[poly_rest] = best_index
717 | #
718 | # cPickle.dump(dict_rest, open(u"data/2x2_outliers_map.pkl", "w"))
719 |
720 | # ------ PROFILING SETUP -----------
721 | # import cProfile, pstats, StringIO
722 | # pr = cProfile.Profile()
723 | # pr.enable()
724 | # CODE HERE
725 | # pr.disable()
726 | # s = StringIO.StringIO()
727 | # sortby = 'cumulative'
728 | # ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
729 | # ps.print_stats()
730 | # print s.getvalue()
731 |
732 | # ----------- VISUALISATION OF DIFFERENT LOCATIONS -------------
733 | # print len(get_coordinates(sqlite3.connect('../data/geonames.db').cursor(), u"Melbourne"))
734 | # coord = get_coordinates(sqlite3.connect('../data/geonames.db').cursor(), u"Giza")
735 | # print coord
736 | # coord.extend(get_coordinates(sqlite3.connect('../data/geonames.db').cursor(), u"Giza Plateau"))
737 | # coord.extend(get_coordinates(sqlite3.connect('../data/geonames.db').cursor(), u"Cairo"))
738 | # coord.extend(get_coordinates(sqlite3.connect('../data/geonames.db').cursor(), u"Egypt"))
739 | # coord = sorted(coord, key=lambda (a, b, c, d): c, reverse=True)
740 | # x = construct_map_vector_full_scale(coord, polygon_size=2)
741 | # x = np.reshape(x, newshape=((180 / 2), (360 / 2)))
742 | # visualise_2D_grid(x, "Giza, Giza Plateau, Egypt, Cairo", True)
743 |
744 | # ---------- DUMP DATABASE ------
745 | # import sqlite3
746 | #
747 | # con = sqlite3.connect('../data/geonames.db')
748 | # with codecs.open('dump.sql', 'w', 'utf-8') as f:
749 | # for line in con.iterdump():
750 | # f.write('%s\n' % line)
751 | # -------------------------------
752 |
--------------------------------------------------------------------------------
/subsample.py:
--------------------------------------------------------------------------------
1 | import codecs
2 | import sqlite3
3 | from geopy.distance import great_circle
4 | from preprocessing import get_coordinates
5 |
6 | counter = 0 # keeps track of current line number
7 | start = 0 # where do you want to start sampling from?
8 | finish = 800000 # where do you want to end the uniform sampling?
9 | frequency = 2 # 1 means take EVERY sample, 2 means take every SECOND sample, etc...
10 | output_file = u"../data/train_wiki_uniform.txt" # This file is used in train.py
11 | input_file = u"../data/train_wiki.txt" # This dataset contains around 1.4M lines of train examples
12 |
13 | filtering = True # Do you want to filter samples with coordinate errors? Probably yes.
14 | filtered_count = 0 # Keeping track of how many get filtered out? Good idea.
15 | saved_count = 0 # Keeping track of how many samples were saved? That, too.
16 | max_distance = 999 # The maximum size of the coordinate error, this depends on the database. 999 is good.
17 | conn = sqlite3.connect(u'../data/geonames.db') # Download this file from GitHub (milangritta)
18 | c = conn.cursor() # Initialise database connection
19 |
20 | out = codecs.open(output_file, u"w", encoding=u"utf-8")
21 | for line in codecs.open(input_file, u"r", encoding=u"utf-8"):
22 | counter += 1
23 | if counter < start:
24 | continue
25 | if counter > finish:
26 | break
27 | if counter % frequency == 0:
28 | if not filtering:
29 | out.write(line)
30 | saved_count += 1
31 | else:
32 | split = line.split(u"\t")
33 | wiki_coordinates = (float(split[0]), float(split[1]))
34 | name = u" ".join(eval(split[5])).strip()
35 | db_coordinates = get_coordinates(c, name)
36 | distance = []
37 | for candidate in db_coordinates:
38 | distance.append(great_circle(wiki_coordinates, (float(candidate[0]), float(candidate[1]))).kilometers)
39 | distance = sorted(distance)
40 | if distance[0] > max_distance:
41 | print(name, distance[0])
42 | filtered_count += 1
43 | else:
44 | out.write(line)
45 | saved_count += 1
46 |
47 | print(u"Saved", saved_count, u"samples.")
48 | if filtering:
49 | print(u"Filtered:", filtered_count, u"samples.")
50 |
--------------------------------------------------------------------------------
/test.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import numpy as np
3 | import cPickle
4 | import sqlite3
5 | import sys
6 | from geopy.distance import great_circle
7 | from keras.models import load_model
8 | from subprocess import check_output
9 | from preprocessing import get_coordinates, print_stats, index_to_coord, generate_strings_from_file
10 | from preprocessing import BATCH_SIZE, REVERSE_MAP_2x2
11 | from preprocessing import generate_arrays_from_file
12 |
13 | # For command line use, type: python test.py
14 | # For example: python test.py lgl_gold
15 | if len(sys.argv) > 1:
16 | test_data = sys.argv[1]
17 | else:
18 | test_data = u"geovirus" # or edit this line if running inside an IDE editor
19 |
20 | saved_model_file = u"../data/weights"
21 | print(u"Testing:", test_data, u"with weights:", saved_model_file)
22 | word_to_index = cPickle.load(open(u"data/words2index.pkl")) # This is the vocabulary file
23 | # --------------------------------------------------------------------------------------------------------------------
24 | print(u'Loading model...')
25 | model = load_model(saved_model_file)
26 | print(u'Finished loading model...')
27 | # --------------------------------------------------------------------------------------------------------------------
28 | print(u'Crunching numbers, sit tight...')
29 | # errors = codecs.open(u"errors.tsv", u"w", encoding=u"utf-8")
30 | # Uncomment the above line for error diagnostics, also the section below.
31 | conn = sqlite3.connect(u'../data/geonames.db')
32 | file_name = u"data/eval_" + test_data + u".txt"
33 | final_errors = []
34 | for prediction, (y, name, context) in zip(model.predict_generator(generate_arrays_from_file(file_name, word_to_index, train=False),
35 | steps=int(check_output([u"wc", file_name]).split()[0]) / BATCH_SIZE, verbose=True), generate_strings_from_file(file_name)):
36 | prediction = index_to_coord(REVERSE_MAP_2x2[np.argmax(prediction)], 2)
37 | candidates = get_coordinates(conn.cursor(), name)
38 |
39 | if len(candidates) == 0:
40 | print(u"Don't have an entry for", name, u"in GeoNames")
41 | raise Exception(u"Check your database, buddy :-)")
42 |
43 | # candidates = [candidates[0]] # Uncomment for population heuristic.
44 | # THE ABOVE IS THE POPULATION ONLY BASELINE IMPLEMENTATION
45 |
46 | best_candidate = []
47 | max_pop = candidates[0][2]
48 | bias = 0.905 # the Bias parameter in the paper
49 | for candidate in candidates:
50 | err = great_circle(prediction, (float(candidate[0]), float(candidate[1]))).km
51 | best_candidate.append((err - (err * max(1, candidate[2]) / max(1, max_pop)) * bias, (float(candidate[0]), float(candidate[1]))))
52 | best_candidate = sorted(best_candidate, key=lambda (a, b): a)[0]
53 | final_errors.append(great_circle(best_candidate[1], y).km)
54 |
55 | # ---------------- ERROR DIAGNOSTICS --------------------
56 | # dist_p, dist_y, index_p, index_y = 100000, 100000, 0, 0
57 | # for index, candidate in enumerate(candidates):
58 | # if great_circle(best_candidate[1], (candidate[0], candidate[1])).km < dist_p:
59 | # dist_p = great_circle(best_candidate[1], (candidate[0], candidate[1])).km
60 | # index_p = index
61 | # if great_circle(y, (candidate[0], candidate[1])).km < dist_y:
62 | # dist_y = great_circle(y, (candidate[0], candidate[1])).km
63 | # index_y = index
64 | #
65 | # errors.write(name + u"\t" + unicode(y) + u"\t" + unicode(p) + "\t" + unicode(best_candidate[1])
66 | # + u"\t" + unicode(index_y) + u"\t" + unicode(index_p) + u"\t" + unicode(final_errors[-1]) + u"\t" +
67 | # unicode(best_candidate[0]) + u"\t" + unicode(len(candidates)) + u"\t" + context.replace(u"\n", u"") + u"\n")
68 | # ------------------ END OF DIAGNOSTICS -----------------
69 |
70 | print_stats(final_errors)
71 | print(u"Processed file", file_name)
72 |
73 | # ------------------------ VISUALISATION ------------------------------
74 | # import matplotlib.pyplot as plt
75 | # plt.plot(range(len(final_errors)), np.log(1 + np.asarray(sorted(final_errors))))
76 | # plt.xlabel(u"Predictions")
77 | # plt.ylabel(u'Error Size')
78 | # plt.title(u"Some Chart")
79 | # plt.savefig(u'test.png', transparent=True)
80 | # plt.show()
81 | # ----------------------------------------------------------------------
82 |
--------------------------------------------------------------------------------
/text2mapVec.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import sqlite3
3 | import cPickle
4 | import numpy as np
5 | import spacy
6 |
7 | #######################################################################################
8 | # #
9 | # If you're only interested the Map Vector generation, I extracted the relevant #
10 | # code into this python script for quick and dirty use. You still need at least the #
11 | # encoding map files (see ENCODING_MAP below). You also need a database 'geonames.db' #
12 | # #
13 | #######################################################################################
14 |
15 |
16 | def text2mapvec(doc, mapping, outliers, polygon_size, db, exclude):
17 | """
18 | Parse text, extract entities, create and return the MAP VECTOR.
19 | :param exclude: Exclude the TARGET entity from the MAP VECTOR to avoid self-bias
20 | :param db: database cursor to use for retrieval
21 | :param doc: the paragraph to turn into a Map Vector
22 | :param mapping: the map resolution file, determines the size of MAP VECTOR
23 | :param outliers: must be the same size/resolution as MAPPING
24 | :param polygon_size: the tile size must also match i.e. all three either 1x1 or 2x2, etc.
25 | :return: the map vector for this paragraph of text
26 | """
27 | location = u""
28 | entities = []
29 | for index, item in enumerate(doc):
30 | if item.ent_type_ in [u"GPE", u"FACILITY", u"LOC", u"FAC", u"LOCATION"]:
31 | if not (item.ent_iob_ == u"B" and item.text.lower() == u"the"):
32 | location += item.text + u" "
33 |
34 | if location.strip() != u"" and (item.ent_type == 0 or index == len(doc) - 1):
35 | location = location.strip()
36 | if exclude is not None:
37 | if location == exclude:
38 | location = u""
39 | continue
40 | coords = get_coordinates(db, location)
41 | if len(coords) > 0:
42 | entities.extend(coords)
43 | location = u""
44 |
45 | entities = sorted(entities, key=lambda (a, b, c, d): c, reverse=True)
46 | mapvec = np.zeros(len(mapping), )
47 |
48 | if len(entities) == 0:
49 | return mapvec # No locations? Return an empty vector.
50 | max_pop = entities[0][2] if entities[0][2] > 0 else 1
51 | for s in entities:
52 | index = coord_to_index((s[0], s[1]), polygon_size)
53 | if index in mapping:
54 | index = mapping[index]
55 | else:
56 | index = mapping[outliers[index]]
57 | mapvec[index] += float(max(s[2], 1)) / max_pop
58 | return mapvec / mapvec.max() if mapvec.max() > 0.0 else mapvec
59 |
60 |
61 | def coord_to_index(coordinates, polygon_size):
62 | """
63 | Convert coordinates into an array index. Use that to modify mapvec polygon value.
64 | :param coordinates: (latitude, longitude) to compute
65 | :param polygon_size: integer size of the polygon? i.e. the resolution of the world
66 | :return: index pointing into mapvec array
67 | """
68 | latitude = float(coordinates[0]) - 90 if float(coordinates[0]) != -90 else -179.99 # The two edge cases must
69 | longitude = float(coordinates[1]) + 180 if float(coordinates[1]) != 180 else 359.99 # get handled differently!
70 | if longitude < 0:
71 | longitude = -longitude
72 | if latitude < 0:
73 | latitude = -latitude
74 | x = int(360 / polygon_size) * int(latitude / polygon_size)
75 | y = int(longitude / polygon_size)
76 | return x + y if 0 <= x + y <= int(360 / polygon_size) * int(180 / polygon_size) else Exception(u"Shock horror!!")
77 |
78 |
79 | def get_coordinates(con, loc_name):
80 | """
81 | Access the database to retrieve coordinates and other data from DB.
82 | :param con: sqlite3 database cursor i.e. DB connection
83 | :param loc_name: name of the place
84 | :return: a list of tuples [(latitude, longitude, population, feature_code), ...]
85 | """
86 | result = con.execute(u"SELECT METADATA FROM GEO WHERE NAME = ?", (loc_name.lower(),)).fetchone()
87 | if result:
88 | result = eval(result[0]) # Do not remove the sorting, the function below assumes sorted results!
89 | return sorted(result, key=lambda (a, b, c, d): c, reverse=True)
90 | else:
91 | return []
92 |
93 |
94 | def buildMapVec(text):
95 | """
96 | An example wrapper function for text2mapVec(), reads in necessary collections and then runs text2mapVec().
97 | Feel free to modify to your preference and task objective.
98 | :param text: to create the Map Vector from encoded as unicode.
99 | :return: currently only prints the vector, add 'return map_vector' or whatever you prefer.
100 | """
101 | ENCODING_MAP = cPickle.load(open(u"data/1x1_encode_map.pkl")) # the resolution of the map
102 | OUTLIERS_MAP = cPickle.load(open(u"data/1x1_outliers_map.pkl")) # dimensions must match the above
103 | nlp = spacy.load(u'en_core_web_lg') # or spacy.load(u'en') depending on your Spacy Download (simple or full)
104 | conn = sqlite3.connect(u'../data/geonames.db').cursor() # this DB can be downloaded using the GitHub link
105 | map_vector = text2mapvec(doc=nlp(text), mapping=ENCODING_MAP, outliers=OUTLIERS_MAP, polygon_size=1, db=conn, exclude=u"Cairo")
106 | print(map_vector)
107 |
108 |
109 | # text = u"The Giza pyramid complex is an archaeological site on the Giza Plateau, on the outskirts of Cairo, Egypt."
110 | # buildMapVec(text)
111 |
--------------------------------------------------------------------------------
/train.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import codecs
3 | import numpy as np
4 | import cPickle
5 | from keras import Input
6 | from keras.callbacks import ModelCheckpoint, EarlyStopping
7 | from keras.engine import Model
8 | from keras.layers.merge import concatenate
9 | from keras.layers import Embedding, Dense, Dropout, Conv1D, GlobalMaxPooling1D
10 | from preprocessing import BATCH_SIZE, EMBEDDING_DIMENSION, CONTEXT_LENGTH, UNKNOWN
11 | from preprocessing import TARGET_LENGTH, generate_arrays_from_file, ENCODING_MAP_2x2, ENCODING_MAP_1x1
12 | from subprocess import check_output
13 |
14 | print(u"Embedding Dimension:", EMBEDDING_DIMENSION)
15 | print(u"Input length (each side):", CONTEXT_LENGTH)
16 | word_to_index = cPickle.load(open(u"data/words2index.pkl"))
17 | print(u"Vocabulary Size:", len(word_to_index))
18 |
19 | vectors = {UNKNOWN: np.ones(EMBEDDING_DIMENSION), u'0': np.ones(EMBEDDING_DIMENSION)}
20 | for line in codecs.open(u"../data/glove.twitter." + str(EMBEDDING_DIMENSION) + u"d.txt", encoding=u"utf-8"):
21 | if line.strip() == "":
22 | continue
23 | t = line.split()
24 | vectors[t[0]] = [float(x) for x in t[1:]]
25 | print(u'Vectors...', len(vectors))
26 |
27 | emb_weights = np.zeros((len(word_to_index), EMBEDDING_DIMENSION))
28 | oov = 0
29 | for w in word_to_index:
30 | if w in vectors:
31 | emb_weights[word_to_index[w]] = vectors[w]
32 | else:
33 | emb_weights[word_to_index[w]] = np.random.normal(size=(EMBEDDING_DIMENSION,), scale=0.3)
34 | oov += 1
35 |
36 | emb_weights = np.array([emb_weights])
37 | print(u'Done preparing vectors...')
38 | print(u"OOV (no vectors):", oov)
39 | # --------------------------------------------------------------------------------------------------------------------
40 | print(u'Building model...')
41 | embeddings = Embedding(len(word_to_index), EMBEDDING_DIMENSION, input_length=CONTEXT_LENGTH * 2, weights=emb_weights)
42 | # shared embeddings between all language input layers
43 |
44 | context_words_pair = Input(shape=(CONTEXT_LENGTH * 2,))
45 | cwp = embeddings(context_words_pair)
46 | cwp = Conv1D(1000, 2, activation='relu', strides=1)(cwp)
47 | cwp = GlobalMaxPooling1D()(cwp)
48 | cwp = Dense(250)(cwp)
49 | cwp = Dropout(0.5)(cwp)
50 |
51 | context_words_single = Input(shape=(CONTEXT_LENGTH * 2,))
52 | cws = embeddings(context_words_single)
53 | cws = Conv1D(1000, 1, activation='relu', strides=1)(cws)
54 | cws = GlobalMaxPooling1D()(cws)
55 | cws = Dense(250)(cws)
56 | cws = Dropout(0.5)(cws)
57 |
58 | entities_strings_pair = Input(shape=(CONTEXT_LENGTH * 2,))
59 | esp = embeddings(entities_strings_pair)
60 | esp = Conv1D(1000, 2, activation='relu', strides=1)(esp)
61 | esp = GlobalMaxPooling1D()(esp)
62 | esp = Dense(250)(esp)
63 | esp = Dropout(0.5)(esp)
64 |
65 | entities_strings_single = Input(shape=(CONTEXT_LENGTH * 2,))
66 | ess = embeddings(entities_strings_single)
67 | ess = Conv1D(1000, 1, activation='relu', strides=1)(ess)
68 | ess = GlobalMaxPooling1D()(ess)
69 | ess = Dense(250)(ess)
70 | ess = Dropout(0.5)(ess)
71 |
72 | mapvec = Input(shape=(len(ENCODING_MAP_1x1),))
73 | l2v = Dense(5000, activation='relu', input_dim=len(ENCODING_MAP_1x1))(mapvec)
74 | l2v = Dense(1000, activation='relu')(l2v)
75 | l2v = Dropout(0.5)(l2v)
76 |
77 | target_string = Input(shape=(TARGET_LENGTH,))
78 | ts = Embedding(len(word_to_index), EMBEDDING_DIMENSION, input_length=TARGET_LENGTH, weights=emb_weights)(target_string)
79 | ts = Conv1D(1000, 3, activation='relu')(ts)
80 | ts = GlobalMaxPooling1D()(ts)
81 | ts = Dropout(0.5)(ts)
82 |
83 | inp = concatenate([cwp, cws, esp, ess, l2v, ts])
84 | inp = Dense(units=len(ENCODING_MAP_2x2), activation=u'softmax')(inp)
85 | model = Model(inputs=[context_words_pair, context_words_single, entities_strings_pair, entities_strings_single,
86 | mapvec, target_string], outputs=[inp])
87 | model.compile(loss=u'categorical_crossentropy', optimizer=u'rmsprop', metrics=[u'accuracy'])
88 |
89 | print(u'Finished building model...')
90 | # --------------------------------------------------------------------------------------------------------------------
91 | checkpoint = ModelCheckpoint(filepath=u"../data/weights.{epoch:02d}-{acc:.2f}.hdf5", verbose=0)
92 | early_stop = EarlyStopping(monitor=u'acc', patience=5)
93 | file_name = u"../data/train_wiki_uniform.txt"
94 | model.fit_generator(generate_arrays_from_file(file_name, word_to_index),
95 | steps_per_epoch=int(check_output(["wc", file_name]).split()[0]) / BATCH_SIZE,
96 | epochs=250, callbacks=[checkpoint, early_stop])
97 |
--------------------------------------------------------------------------------