├── .gitignore ├── LICENSE ├── README.md ├── lib ├── Indexer.jar ├── commons-io-2.4.jar ├── commons-math3-3.2.jar ├── gs-algo-1.2.jar ├── gs-core-1.2.jar ├── lucene-analyzers-common-4.10.2.jar └── lucene-core-4.10.2.jar ├── parameters.txt ├── screenshot.png ├── src ├── cc │ └── mallet │ │ └── util │ │ └── Util.java └── fr │ └── ericlab │ ├── mabed │ ├── algo │ │ ├── Component1.java │ │ ├── Component2.java │ │ └── MABED.java │ ├── app │ │ ├── Configuration.java │ │ └── Main.java │ └── structure │ │ ├── Corpus.java │ │ ├── Event.java │ │ ├── EventGraph.java │ │ ├── EventList.java │ │ ├── StopWords.java │ │ ├── TimeInterval.java │ │ ├── WeightedTerm.java │ │ └── WeightedTermList.java │ └── util │ └── Util.java └── stopwords.txt /.gitignore: -------------------------------------------------------------------------------- 1 | /nbproject/private/ 2 | manifest.mf 3 | 4 | nbbuild.xml 5 | 6 | nbproject/build-impl.xml 7 | 8 | nbproject/genfiles.properties 9 | 10 | nbproject/project.properties 11 | 12 | nbproject/project.xml 13 | /build/ 14 | /dist/ 15 | dist/lib/commons-io-2.4.jar 16 | -------------------------------------------------------------------------------- /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 | 676 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Nota bene: This Java implementation is not maintained anymore, for an up-to-date implementation, see: https://github.com/AdrienGuille/pyMABED 2 | 3 | MABED 4 | ===== 5 | 6 | Mention-anomaly-based Event Detection and Tracking in Twitter 7 | 8 | Author: Adrien GUILLE 9 | 10 | Details of this program are described in the following papers: 11 | 12 | Adrien Guille and Cécile Favre (2015) 13 | Event detection, tracking, and visualization in Twitter: a mention-anomaly-based approach. 14 | Springer Social Network Analysis and Mining, 15 | vol. 5, iss. 1, art. 18, DOI: 10.1007/s13278-015-0258-0 16 | 17 | Adrien Guille and Cécile Favre (2014) 18 | Mention-Anomaly-Based Event Detection and Tracking in Twitter. 19 | In Proceedings of the 2014 IEEE/ACM International Conference on 20 | Advances in Social Network Mining and Analysis (ASONAM 2014), 21 | pp. 375-382, DOI: 10.1109/ASONAM.2014.6921613 22 | 23 | Please cite one of these papers when using the program. 24 | 25 | Files in the Directory 26 | ---------------------- 27 | 28 | - input/: input files that describe the corpus in which we want to detect events 29 | - MABED.jar: Java program that does the event detection 30 | - README.txt: this file 31 | - parameters.txt: Java properties file in which parameters are set 32 | - stopwords.txt: a list of common stopwords to remove when generating the vocabulary 33 | - lib/: program dependencies 34 | 35 | Input Format 36 | ------------ 37 | 38 | The program expects two sets of files in the "input/" directory: 39 | 40 | 1. .text: content of the messages, one line per message; 41 | 2. .time: timestamp of the messages, each line maps to the message that has the same line number in .text. Timestamps should be formatted according to this format: YYYY-MM-DD HH:mm:ss (e.g. 2009-11-01 00:01:24) 42 | 43 | Time-slices are expected to be numbered starting from 0 and files are expected to be named with 8 digits (e.g. 00000000.text, 00000000.time, 00000001.text, 00000001.time) 44 | 45 | Parameter Setting 46 | ----------------- 47 | 48 | All the parameters are set in the parameters.txt file: 49 | 50 | 1. prepareCorpus (boolean): if you are running MABED for the first time, or if the content of the input directory has been modified, this parameter should be set to 'true', otherwise 'false'. 51 | 2. timeSliceLength (int): length of each time-slice, expressed in minutes (e.g. 30); 52 | 3. numberOfThreads (int): the number of threads used by MABED (if > 1, then the parallelized implementation of MABED is executed) 53 | 4. k (int): desired number of events (e.g. 40); 54 | 5. p (int): maximum number of related words describing each event (e.g. 10); 55 | 6. theta (double): minimum weight of each related word (e.g. 0.7); 56 | 7. sigma (double): merging threshold (e.g. 0.5); 57 | 8. stopwords (String): name of the file that lists the stopwords, one word per line (e.g. stopwords.txt); 58 | 9. minSupport (double): minimum support of words in the vocabulary (e.g. 0) 59 | 10. maxSupport (double): maximum support of words in the vocabulary (e.g. 1) 60 | 61 | Running the program 62 | ------------------- 63 | 64 | - Requirements: JAVA (7+) 65 | - Execute the program MABED.jar with the following command: "java -jar MABED.jar -run". It should process the input and save the output in the "ouput/" directory. 66 | -------------------------------------------------------------------------------- /lib/Indexer.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdrienGuille/MABED/b237855fb4f6ddebfb1ebf50fcbb43e1140b00e0/lib/Indexer.jar -------------------------------------------------------------------------------- /lib/commons-io-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdrienGuille/MABED/b237855fb4f6ddebfb1ebf50fcbb43e1140b00e0/lib/commons-io-2.4.jar -------------------------------------------------------------------------------- /lib/commons-math3-3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdrienGuille/MABED/b237855fb4f6ddebfb1ebf50fcbb43e1140b00e0/lib/commons-math3-3.2.jar -------------------------------------------------------------------------------- /lib/gs-algo-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdrienGuille/MABED/b237855fb4f6ddebfb1ebf50fcbb43e1140b00e0/lib/gs-algo-1.2.jar -------------------------------------------------------------------------------- /lib/gs-core-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdrienGuille/MABED/b237855fb4f6ddebfb1ebf50fcbb43e1140b00e0/lib/gs-core-1.2.jar -------------------------------------------------------------------------------- /lib/lucene-analyzers-common-4.10.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdrienGuille/MABED/b237855fb4f6ddebfb1ebf50fcbb43e1140b00e0/lib/lucene-analyzers-common-4.10.2.jar -------------------------------------------------------------------------------- /lib/lucene-core-4.10.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdrienGuille/MABED/b237855fb4f6ddebfb1ebf50fcbb43e1140b00e0/lib/lucene-core-4.10.2.jar -------------------------------------------------------------------------------- /parameters.txt: -------------------------------------------------------------------------------- 1 | # If you are running MABED for the first time, or if the content of the input directory has been modified, this parameter should be set to 'true', otherwise 'false' 2 | prepareCorpus = true 3 | # The length of each time-slice, expressed in minutes, e.g. 30 4 | timeSliceLength = 30 5 | # Number of threads to use 6 | numberOfThreads = 12 7 | # MABED parameters 8 | k = 40 9 | p = 10 10 | theta = 0.7 11 | sigma = 0.5 12 | # List of stopwords that are removed from the vocabularies 13 | stopwords = stopwords.txt 14 | # Adjust support to speed up the first phase 15 | minSupport = 0.001 16 | maxSupport = 0.01 17 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AdrienGuille/MABED/b237855fb4f6ddebfb1ebf50fcbb43e1140b00e0/screenshot.png -------------------------------------------------------------------------------- /src/cc/mallet/util/Util.java: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2003 Univ. of Massachusetts Amherst, Computer Science Dept. 2 | This file is part of "MALLET" (MAchine Learning for LanguagE Toolkit). 3 | http://www.cs.umass.edu/~mccallum/mallet 4 | This software is provided under the terms of the Common Public License, 5 | version 1.0, as published by http://www.opensource.org. For further 6 | information, see the file `LICENSE' included with this distribution. */ 7 | 8 | package cc.mallet.util; 9 | 10 | /** 11 | * 12 | * 13 | * @author Charles Sutton 14 | * @version $Id: ArrayUtils.java,v 1.1 2007/10/22 21:37:40 mccallum Exp $ 15 | */ 16 | public class Util { 17 | /** 18 | * Returns the Jensen-Shannon divergence. 19 | */ 20 | public static double jensenShannonDivergence(double[] p1, double[] p2) { 21 | assert(p1.length == p2.length); 22 | double[] average = new double[p1.length]; 23 | for (int i = 0; i < p1.length; ++i) { 24 | average[i] += (p1[i] + p2[i])/2; 25 | } 26 | return (klDivergence(p1, average) + klDivergence(p2, average))/2; 27 | } 28 | 29 | 30 | public static final double log2 = Math.log(2); 31 | /** 32 | * Returns the KL divergence, K(p1 || p2). 33 | * 34 | * The log is w.r.t. base 2.

35 | * 36 | * *Note*: If any value in p2 is 0.0 then the KL-divergence 37 | * is infinite. Limin changes it to zero instead of infinite. 38 | * 39 | */ 40 | public static double klDivergence(double[] p1, double[] p2) { 41 | 42 | 43 | double klDiv = 0.0; 44 | 45 | for (int i = 0; i < p1.length; ++i) { 46 | if (p1[i] == 0) { continue; } 47 | if (p2[i] == 0.0) { continue; } // Limin 48 | 49 | klDiv += p1[i] * Math.log( p1[i] / p2[i] ); 50 | } 51 | 52 | return klDiv / log2; // moved this division out of the loop -DM 53 | } 54 | } -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/algo/Component1.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.algo; 19 | 20 | import static fr.ericlab.mabed.algo.MABED._SMOOTH_; 21 | import fr.ericlab.mabed.structure.Corpus; 22 | import fr.ericlab.mabed.structure.Event; 23 | import fr.ericlab.mabed.structure.EventList; 24 | import fr.ericlab.mabed.structure.TimeInterval; 25 | import fr.ericlab.util.Util; 26 | import java.util.ArrayList; 27 | import java.util.LinkedList; 28 | 29 | /** 30 | * 31 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 32 | * @email adrien.guille@univ-lyon2.fr 33 | */ 34 | public class Component1 extends Thread { 35 | public EventList events = new EventList(); 36 | Corpus corpus; 37 | int from; 38 | int to; 39 | int minTermOccur; 40 | int maxTermOccur; 41 | int threadId; 42 | 43 | public Component1(int id, Corpus c, int a, int b, int min, int max){ 44 | corpus = c; 45 | from = a; 46 | to = b; 47 | minTermOccur = min; 48 | maxTermOccur = max; 49 | threadId = id; 50 | } 51 | 52 | float expectation(int timeSlice, float tmf){ 53 | return corpus.distribution[timeSlice]*(tmf/corpus.messageCount); 54 | } 55 | 56 | float anomaly(float expectation, float real){ 57 | return real - expectation; 58 | } 59 | 60 | @Override 61 | public void run() { 62 | int m = corpus.nbTimeSlices; 63 | for(int t = from; t <= to; t++){ 64 | String term = corpus.mentionVocabulary.get(t); 65 | float[] gf, mf; 66 | gf = Util.toFloatArray(corpus.getGlobalFrequency(term)); 67 | mf = Util.toFloatArray(corpus.getMentionFrequency(t)); 68 | int tmf = (int)Util.sum(mf,0,m-1); 69 | int tgf = (int)Util.sum(gf,0,m-1); 70 | if(tgf>minTermOccur && tgf 0){ 73 | mf = Util.smoothArray(mf, _SMOOTH_); 74 | } 75 | float scoreSequence[] = new float[m]; 76 | for(int i = 0; i < m; i++){ 77 | expectation = expectation(i,tmf); 78 | scoreSequence[i] = anomaly(expectation, mf[i]); 79 | } 80 | LinkedList I = new LinkedList<>(); 81 | LinkedList L = new LinkedList<>(); 82 | LinkedList R = new LinkedList<>(); 83 | ArrayList anomaly = new ArrayList<>(); 84 | for(int i = 0; i < m; i++){ 85 | anomaly.add(scoreSequence[i]>0?scoreSequence[i]:0); 86 | if(scoreSequence[i]>0){ 87 | int k = I.size(); 88 | float Lk = 0, Rk = Util.sum(scoreSequence,0,i); 89 | if(i>0){ 90 | Lk = Util.sum(scoreSequence,0,i-1); 91 | } 92 | int j = 0; 93 | boolean foundJ = false; 94 | for(int l=k-1; l>=0 && !foundJ; l--){ 95 | if(L.get(l)0){ 119 | TimeInterval maxI = I.get(0); 120 | for(TimeInterval Ii : I){ 121 | if(Util.sum(scoreSequence,Ii.timeSliceA,Ii.timeSliceB)>Util.sum(scoreSequence,maxI.timeSliceA,maxI.timeSliceB)){ 122 | maxI.timeSliceA = Ii.timeSliceA; 123 | maxI.timeSliceB = Ii.timeSliceB; 124 | } 125 | } 126 | double score = Util.sum(scoreSequence,I.get(0).timeSliceA,I.get(0).timeSliceB); 127 | events.add(new Event(term,maxI,score,anomaly)); 128 | } 129 | } 130 | } 131 | System.out.println(" - number of detected events (thread "+threadId+"): "+events.size()); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/algo/Component2.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.algo; 19 | 20 | import fr.ericlab.mabed.structure.Corpus; 21 | import fr.ericlab.mabed.structure.Event; 22 | import fr.ericlab.mabed.structure.WeightedTerm; 23 | import indexer.Indexer; 24 | import java.util.ArrayList; 25 | 26 | /** 27 | * 28 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 29 | * @email adrien.guille@univ-lyon2.fr 30 | */ 31 | public class Component2 extends Thread { 32 | Corpus corpus; 33 | Event basicEvent; 34 | int candidateWordSetSize; 35 | double theta; 36 | Event refinedEvent; 37 | int threadId; 38 | 39 | public Component2(int id, Corpus c, Event be, int p, double t){ 40 | corpus = c; 41 | basicEvent = be; 42 | candidateWordSetSize = p; 43 | theta = t; 44 | threadId = id; 45 | } 46 | 47 | double getErdemCoefficient(short[] ref, short[] comp, int a, int b){ 48 | double scores1[] = new double[b-a+1], scores2[] = new double[b-a+1]; 49 | for(int i = a; i <= b; i++){ 50 | scores1[i-a] = ref[i]; 51 | scores2[i-a] = comp[i]; 52 | } 53 | double result; 54 | double A12 = 0, A1 = 0, A2 = 0; 55 | for(int i=2;i candidateWords = indexer.getMostFrequentWords(corpus.getMessages(basicEvent),basicEvent.mainTerm,candidateWordSetSize); 71 | short ref[] = corpus.getGlobalFrequency(basicEvent.mainTerm); 72 | short comp[]; 73 | refinedEvent = new Event(basicEvent.mainTerm, basicEvent.I, basicEvent.score, basicEvent.anomaly); 74 | for(String word : candidateWords){ 75 | comp = corpus.getGlobalFrequency(word); 76 | double w = getErdemCoefficient(ref, comp, basicEvent.I.timeSliceA, basicEvent.I.timeSliceB); 77 | if(w >= theta){ 78 | refinedEvent.relatedTerms.add(new WeightedTerm(word,w)); 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/algo/MABED.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.algo; 19 | 20 | import fr.ericlab.mabed.app.Configuration; 21 | import fr.ericlab.mabed.structure.EventList; 22 | import fr.ericlab.mabed.structure.Corpus; 23 | import fr.ericlab.mabed.structure.WeightedTerm; 24 | import fr.ericlab.mabed.structure.Event; 25 | import fr.ericlab.mabed.structure.TimeInterval; 26 | import fr.ericlab.util.Util; 27 | import fr.ericlab.mabed.structure.EventGraph; 28 | import indexer.Indexer; 29 | import java.text.DecimalFormat; 30 | import java.util.ArrayList; 31 | import java.util.LinkedList; 32 | 33 | /** 34 | * 35 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 36 | * @email adrien.guille@univ-lyon2.fr 37 | */ 38 | final public class MABED { 39 | // stopwords 40 | LinkedList stopWords = new LinkedList<>(); 41 | 42 | // dataset 43 | public Corpus corpus; 44 | 45 | // algo 46 | double maximumScore; 47 | static int _SMOOTH_ = 4; 48 | static int _MIN_RELATED_WORDS_ = 2; 49 | public String info; 50 | 51 | // results 52 | public EventList events; 53 | public EventGraph eventGraph; 54 | 55 | public String applyCentralized(Corpus c, Configuration configuration){ 56 | corpus = c; 57 | info = " - minimum support for main terms: "+configuration.minSupport+"
- maximum support for main terms: "+configuration.maxSupport+"
- maximum number of related terms: "+configuration.p+"
- minimum weight for related terms: "+configuration.theta; 58 | String output = " - min suppport = "+configuration.minSupport+", max support = "+configuration.maxSupport+", p = "+configuration.p+", theta = "+configuration.theta+", sigma = "+configuration.sigma+"\n"; 59 | 60 | stopWords = Util.readStopWords(configuration.stopwords); 61 | System.out.println(Util.getDate()+" Loaded stopwords:\n - filename: "+configuration.stopwords+"\n - number of words: "+stopWords.size()); 62 | 63 | // Get basic events 64 | long startP1 = Util.getTime(); 65 | EventList basicEvents = getSimpleEvents((int)(configuration.minSupport*corpus.messageCount), (int)(configuration.maxSupport*corpus.messageCount)); 66 | basicEvents.sort(); 67 | long endP1 = Util.getTime(); 68 | 69 | // Get final events 70 | System.out.println(Util.getDate()+" Selecting related terms ("+configuration.k+" events with at most "+configuration.p+" related terms)"); 71 | int nbFinalEvents = 0; 72 | int i = 0; 73 | long startP2 = Util.getTime(); 74 | if(basicEvents.size() > 0){ 75 | eventGraph = new EventGraph(corpus, basicEvents.get(0).score, configuration.sigma); 76 | System.out.print(" - k: "); 77 | while(nbFinalEvents < configuration.k && i < basicEvents.size()){ 78 | Event event = getRefinedEvent(corpus, basicEvents.get(i), configuration.p, configuration.theta); 79 | if(event.relatedTerms.size() >= _MIN_RELATED_WORDS_){ 80 | int previousNb = nbFinalEvents; 81 | nbFinalEvents += eventGraph.addEvent(event); 82 | if(nbFinalEvents > previousNb){ 83 | System.out.print(" "+nbFinalEvents); 84 | } 85 | } 86 | i++; 87 | } 88 | long endP2 = Util.getTime(); 89 | System.out.println(); 90 | long startP3 = Util.getTime(); 91 | mergeRedundantEvents(eventGraph); 92 | events = eventGraph.toEventList(); 93 | long endP3 = Util.getTime(); 94 | double p1 = (double)(endP1-startP1)/(double)1000, p2 = (double)(endP2-startP2)/(double)1000, p3 = (double)(endP3-startP3)/(double)1000; 95 | DecimalFormat df = new DecimalFormat("#.00"); 96 | System.out.println(Util.getDate()+" Computation time: "+df.format(p1)+"s + "+df.format(p2)+"s + "+df.format(p3)+"s = "+df.format(p1+p2+p3)+"s"); 97 | output += " - computation time: "+df.format(p1)+"s + "+df.format(p2)+"s + "+df.format(p3)+"s = "+df.format(p1+p2+p3)+"s\n"; 98 | } 99 | return output; 100 | } 101 | 102 | public String applyParallelized(Corpus d, Configuration configuration) throws InterruptedException{ 103 | corpus = d; 104 | info = " - minimum support for main terms: "+configuration.minSupport+"
- maximum support for main terms: "+configuration.maxSupport+"
- maximum number of related terms: "+configuration.p+"
- minimum weight for related terms: "+configuration.theta; 105 | String output = " - min suppport = "+configuration.minSupport+", max support = "+configuration.maxSupport+", p = "+configuration.p+", theta = "+configuration.theta+", sigma = "+configuration.sigma+"\n"; 106 | 107 | stopWords = Util.readStopWords(configuration.stopwords); 108 | System.out.println(Util.getDate()+" Loaded stopwords:\n - filename: "+configuration.stopwords+"\n - number of words: "+stopWords.size()); 109 | 110 | // Phase 1 111 | long startP1 = Util.getTime(); 112 | System.out.println(Util.getDate()+" Detecting events based on mention anomaly..."); 113 | LinkedList c1Threads = new LinkedList<>(); 114 | int numberOfWordsPerThread = corpus.mentionVocabulary.size()/configuration.numberOfThreads; 115 | for(int i = 0; i < configuration.numberOfThreads; i++){ 116 | int upperBound = (i==configuration.numberOfThreads-1)?corpus.mentionVocabulary.size()-1:numberOfWordsPerThread*(i+1); 117 | c1Threads.add(new Component1(i,corpus,numberOfWordsPerThread*i+1,upperBound,(int)(configuration.minSupport*corpus.messageCount),(int)(configuration.maxSupport*corpus.messageCount))); 118 | c1Threads.get(i).start(); 119 | } 120 | for(Component1 c1 : c1Threads){ 121 | c1.join(); 122 | } 123 | EventList basicEvents = new EventList(); 124 | for(Component1 c1 : c1Threads){ 125 | basicEvents.addAll(c1.events); 126 | } 127 | basicEvents.sort(); 128 | c1Threads.clear(); 129 | System.out.println(" - number of detected events (total): "+basicEvents.size()); 130 | long endP1 = Util.getTime(); 131 | 132 | // Phase 2 133 | System.out.println(Util.getDate()+" Selecting related terms ("+configuration.k+" events with at most "+configuration.p+" related terms)"); 134 | int nbFinalEvents = 0; 135 | int i = 0; 136 | long startP2 = Util.getTime(); 137 | if(basicEvents.size() > 0){ 138 | eventGraph = new EventGraph(corpus, basicEvents.get(0).score, configuration.sigma); 139 | System.out.print(" - k: "); 140 | while(nbFinalEvents < configuration.k && i < basicEvents.size()-configuration.numberOfThreads){ 141 | int numberOfC2Threads = ((configuration.k - nbFinalEvents)<=configuration.numberOfThreads)?(configuration.k-nbFinalEvents):configuration.numberOfThreads; 142 | Event[] refinedEvents = new Event[numberOfC2Threads]; 143 | LinkedList c2Threads = new LinkedList<>(); 144 | for(int j = 0; j < numberOfC2Threads; j++){ 145 | c2Threads.add(new Component2(j,corpus,basicEvents.get(i+j),configuration.p,configuration.theta)); 146 | c2Threads.get(j).start(); 147 | } 148 | for(Component2 c2 : c2Threads){ 149 | c2.join(); 150 | } 151 | for(Component2 c2 : c2Threads){ 152 | refinedEvents[c2.threadId] = c2.refinedEvent; 153 | } 154 | for(Event refinedEvent : refinedEvents){ 155 | if(refinedEvent.relatedTerms.size() >= _MIN_RELATED_WORDS_){ 156 | int previousNb = nbFinalEvents; 157 | nbFinalEvents += eventGraph.addEvent(refinedEvent); 158 | if(nbFinalEvents > previousNb){ 159 | System.out.print(" "+nbFinalEvents); 160 | } 161 | } 162 | i++; 163 | } 164 | } 165 | long endP2 = Util.getTime(); 166 | System.out.println(); 167 | long startP3 = Util.getTime(); 168 | mergeRedundantEvents(eventGraph); 169 | events = eventGraph.toEventList(); 170 | long endP3 = Util.getTime(); 171 | double p1 = (double)(endP1-startP1)/(double)1000, p2 = (double)(endP2-startP2)/(double)1000, p3 = (double)(endP3-startP3)/(double)1000; 172 | DecimalFormat df = new DecimalFormat("#.00"); 173 | System.out.println(Util.getDate()+" Computation time: "+df.format(p1)+"s + "+df.format(p2)+"s + "+df.format(p3)+"s = "+df.format(p1+p2+p3)+"s"); 174 | output += " - computation time: "+df.format(p1)+"s + "+df.format(p2)+"s + "+df.format(p3)+"s = "+df.format(p1+p2+p3)+"s\n"; 175 | } 176 | return output; 177 | } 178 | 179 | float expectation(int timeSlice, float tmf){ 180 | return corpus.distribution[timeSlice]*(tmf/corpus.messageCount); 181 | } 182 | 183 | float anomaly(float expectation, float real){ 184 | return real - expectation; 185 | } 186 | 187 | double getErdemCoefficient(short[] ref, short[] comp, int a, int b){ 188 | double scores1[] = new double[b-a+1], scores2[] = new double[b-a+1]; 189 | for(int i = a; i <= b; i++){ 190 | scores1[i-a] = ref[i]; 191 | scores2[i-a] = comp[i]; 192 | } 193 | double result; 194 | double A12 = 0, A1 = 0, A2 = 0; 195 | for(int i=2;i candidateWords = indexer.getMostFrequentWords(corpus.getMessages(basicEvent),basicEvent.mainTerm,p); 210 | short ref[] = corpus.getGlobalFrequency(basicEvent.mainTerm); 211 | short comp[]; 212 | refinedEvent = new Event(basicEvent.mainTerm, basicEvent.I, basicEvent.score, basicEvent.anomaly); 213 | for(String word : candidateWords){ 214 | comp = corpus.getGlobalFrequency(word); 215 | double w = getErdemCoefficient(ref, comp, basicEvent.I.timeSliceA, basicEvent.I.timeSliceB); 216 | if(w >= theta){ 217 | refinedEvent.relatedTerms.add(new WeightedTerm(word,w)); 218 | } 219 | } 220 | return refinedEvent; 221 | } 222 | 223 | EventList getSimpleEvents(int minTermOccur, int maxTermOccur){ 224 | System.out.println(Util.getDate()+" Detecting events based on mention anomaly..."); 225 | EventList simpleEvents = new EventList(); 226 | int m = corpus.nbTimeSlices; 227 | for(int t = 0; t < corpus.mentionVocabulary.size(); t++){ 228 | String term = corpus.mentionVocabulary.get(t); 229 | float[] gf, mf; 230 | gf = Util.toFloatArray(corpus.getGlobalFrequency(term)); 231 | mf = Util.toFloatArray(corpus.getMentionFrequency(t)); 232 | int tmf = (int)Util.sum(mf,0,m-1); 233 | int tgf = (int)Util.sum(gf,0,m-1); 234 | if(tgf>minTermOccur && tgf 0){ 237 | mf = Util.smoothArray(mf, _SMOOTH_); 238 | } 239 | float scoreSequence[] = new float[m]; 240 | for(int i = 0; i < m; i++){ 241 | expectation = expectation(i,tmf); 242 | scoreSequence[i] = anomaly(expectation, mf[i]); 243 | } 244 | LinkedList I = new LinkedList<>(); 245 | LinkedList L = new LinkedList<>(); 246 | LinkedList R = new LinkedList<>(); 247 | ArrayList anomaly = new ArrayList<>(); 248 | for(int i = 0; i < m; i++){ 249 | anomaly.add(scoreSequence[i]>0?scoreSequence[i]:0); 250 | if(scoreSequence[i]>0){ 251 | int k = I.size(); 252 | float Lk = 0, Rk = Util.sum(scoreSequence,0,i); 253 | if(i>0){ 254 | Lk = Util.sum(scoreSequence,0,i-1); 255 | } 256 | int j = 0; 257 | boolean foundJ = false; 258 | for(int l=k-1; l>=0 && !foundJ; l--){ 259 | if(L.get(l)0){ 283 | TimeInterval maxI = I.get(0); 284 | for(TimeInterval Ii : I){ 285 | if(Util.sum(scoreSequence,Ii.timeSliceA,Ii.timeSliceB)>Util.sum(scoreSequence,maxI.timeSliceA,maxI.timeSliceB)){ 286 | maxI.timeSliceA = Ii.timeSliceA; 287 | maxI.timeSliceB = Ii.timeSliceB; 288 | } 289 | } 290 | double score = Util.sum(scoreSequence,I.get(0).timeSliceA,I.get(0).timeSliceB); 291 | simpleEvents.add(new Event(term,maxI,score,anomaly)); 292 | } 293 | } 294 | } 295 | System.out.println(" - number of detected events: "+simpleEvents.size()); 296 | simpleEvents.sort(); 297 | return simpleEvents; 298 | } 299 | 300 | void mergeRedundantEvents(EventGraph eventGraph){ 301 | System.out.println(Util.getDate()+" Merging duplicated events..."); 302 | eventGraph.identifyConnectedComponents(); 303 | } 304 | } 305 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/app/Configuration.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.app; 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.IOException; 23 | import java.util.Properties; 24 | 25 | /** 26 | * 27 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 28 | * @email adrien.guille@univ-lyon2.fr 29 | */ 30 | public class Configuration { 31 | 32 | // Parallel 33 | public int numberOfThreads; 34 | 35 | // Corpus 36 | public boolean prepareCorpus; 37 | public int timeSliceLength; 38 | public String stopwords; 39 | 40 | // MABED 41 | public int k; 42 | public int p; 43 | public double theta; 44 | public double sigma; 45 | public double minSupport; 46 | public double maxSupport; 47 | 48 | public Configuration() throws IOException{ 49 | File inputFile = new File("parameters.txt"); 50 | Properties prop = new Properties(); 51 | if(!inputFile.exists()){ 52 | System.out.println("Configuration file not found! See README.txt"); 53 | System.exit(-1); 54 | }else{ 55 | try (FileInputStream inputStream = new FileInputStream(inputFile)) { 56 | prop.load(inputStream); 57 | prepareCorpus = Boolean.parseBoolean(prop.getProperty("prepareCorpus")); 58 | timeSliceLength = Integer.parseInt(prop.getProperty("timeSliceLength")); 59 | k = Integer.parseInt(prop.getProperty("k")); 60 | p = Integer.parseInt(prop.getProperty("p")); 61 | theta = Double.parseDouble(prop.getProperty("theta")); 62 | sigma = Double.parseDouble(prop.getProperty("sigma")); 63 | minSupport = Double.parseDouble(prop.getProperty("minSupport")); 64 | maxSupport = Double.parseDouble(prop.getProperty("maxSupport")); 65 | stopwords = prop.getProperty("stopwords"); 66 | numberOfThreads = Integer.parseInt(prop.getProperty("numberOfThreads")); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/app/Main.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.app; 19 | 20 | import fr.ericlab.mabed.structure.Corpus; 21 | import fr.ericlab.util.Util; 22 | import fr.ericlab.mabed.algo.MABED; 23 | import java.io.File; 24 | import java.io.IOException; 25 | import java.util.Locale; 26 | import java.util.logging.Level; 27 | import java.util.logging.Logger; 28 | import org.apache.commons.io.FileUtils; 29 | 30 | /** 31 | * 32 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 33 | * @email adrien.guille@univ-lyon2.fr 34 | */ 35 | public class Main { 36 | 37 | 38 | public static void main(String[] args) throws IOException { 39 | Locale.setDefault(Locale.US); 40 | Configuration configuration = new Configuration(); 41 | Corpus corpus = new Corpus(configuration); 42 | System.out.println("MABED: Mention-Anomaly-Based Event Detection"); 43 | if(args.length == 0 || args[0].equals("-help")){ 44 | System.out.println("For more information on how to run MABED, see the README.txt file"); 45 | }else{ 46 | if(args[0].equals("-run") ){ 47 | try { 48 | if(configuration.numberOfThreads>1){ 49 | System.out.println("Running the parallelized implementation with "+configuration.numberOfThreads+" threads (this computer has "+ Runtime.getRuntime().availableProcessors()+" available threads)"); 50 | }else{ 51 | System.out.println("Running the centralized implementation"); 52 | } 53 | corpus.loadCorpus(configuration.numberOfThreads>1); 54 | String output = "MABED: Mention-Anomaly-Based Event Detection\n"+corpus.output+"\n"; 55 | System.out.println("-------------------------\n"+Util.getDate()+" MABED is running\n-------------------------"); 56 | output += "-------------------------\n"+Util.getDate()+" MABED is running\n-------------------------\n"; 57 | System.out.println(Util.getDate()+" Reading parameters:\n - k = "+configuration.k+", p = "+configuration.p+", theta = "+configuration.theta+", sigma = "+configuration.sigma); 58 | MABED mabed = new MABED(); 59 | if(configuration.numberOfThreads>1){ 60 | output += mabed.applyParallelized(corpus,configuration); 61 | }else{ 62 | output += mabed.applyCentralized(corpus,configuration); 63 | } 64 | System.out.println("--------------------\n"+Util.getDate()+" MABED ended\n--------------------"); 65 | output += "--------------------\n"+Util.getDate()+" MABED ended\n--------------------\n"; 66 | File outputDir = new File("output"); 67 | if(!outputDir.isDirectory()){ 68 | outputDir.mkdir(); 69 | } 70 | File textFile = new File("output/MABED.tex"); 71 | FileUtils.writeStringToFile(textFile,mabed.events.toLatex(corpus),false); 72 | textFile = new File("output/MABED.log"); 73 | FileUtils.writeStringToFile(textFile,output,false); 74 | mabed.events.printLatex(corpus); 75 | } catch (InterruptedException ex) { 76 | Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); 77 | } 78 | }else{ 79 | System.out.println("Unknown option '"+args[0]+"'\nType 'java -jar MABED.jar -help' for more information on how to run MABED"); 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/structure/Corpus.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.structure; 19 | 20 | import fr.ericlab.mabed.app.Configuration; 21 | import fr.ericlab.util.Util; 22 | import indexer.GlobalIndexer; 23 | import java.io.File; 24 | import java.io.FileInputStream; 25 | import java.io.FileNotFoundException; 26 | import java.io.IOException; 27 | import java.io.ObjectInputStream; 28 | import java.sql.Timestamp; 29 | import java.text.DecimalFormat; 30 | import java.text.NumberFormat; 31 | import java.text.ParseException; 32 | import java.text.SimpleDateFormat; 33 | import java.util.ArrayList; 34 | import java.util.Collections; 35 | import java.util.Date; 36 | import java.util.List; 37 | import java.util.logging.Level; 38 | import java.util.logging.Logger; 39 | import org.apache.commons.io.FileUtils; 40 | import org.apache.commons.io.LineIterator; 41 | 42 | /** 43 | * 44 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 45 | * @email adrien.guille@univ-lyon2.fr 46 | */ 47 | public class Corpus { 48 | public Configuration configuration; 49 | 50 | public String info; 51 | public int messageCount; 52 | public int nbTimeSlices; 53 | public boolean loaded = false; 54 | public Timestamp startTimestamp; 55 | public Timestamp endTimestamp; 56 | public int[] distribution; 57 | public String output; 58 | 59 | // Indexes 60 | short[][] frequencyMatrix; 61 | public ArrayList vocabulary; 62 | short[][] mentionFrequencyMatrix; 63 | public ArrayList mentionVocabulary; 64 | 65 | public Corpus(Configuration conf){ 66 | configuration = conf; 67 | } 68 | 69 | public void prepareCorpus(){ 70 | System.out.println(Util.getDate()+" Preparing corpus..."); 71 | String[] fileArray = new File("input/").list(); 72 | nbTimeSlices = 0; 73 | NumberFormat formatter = new DecimalFormat("00000000"); 74 | ArrayList list = new ArrayList<>(); 75 | for(String filename : fileArray){ 76 | if(filename.endsWith(".text")){ 77 | try { 78 | list.add(formatter.parse(filename.substring(0, 8)).intValue()); 79 | } catch (ParseException ex) { 80 | Logger.getLogger(Corpus.class.getName()).log(Level.SEVERE, null, ex); 81 | } 82 | nbTimeSlices++; 83 | } 84 | } 85 | int a = Collections.min(list), b = Collections.max(list); 86 | LineIterator it = null; 87 | try { 88 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 89 | it = FileUtils.lineIterator(new File("input/"+formatter.format(a)+".time"), "UTF-8"); 90 | if(it.hasNext()) { 91 | Date parsedDate = dateFormat.parse(it.nextLine()); 92 | startTimestamp = new java.sql.Timestamp(parsedDate.getTime()); 93 | } 94 | it = FileUtils.lineIterator(new File("input/"+formatter.format(b)+".time"), "UTF-8"); 95 | String lastLine = ""; 96 | while(it.hasNext()) { 97 | lastLine = it.nextLine(); 98 | } 99 | Date parsedDate = dateFormat.parse(lastLine); 100 | endTimestamp = new java.sql.Timestamp(parsedDate.getTime()); 101 | } catch (IOException | ParseException ex) { 102 | Logger.getLogger(Corpus.class.getName()).log(Level.SEVERE, null, ex); 103 | } finally { 104 | LineIterator.closeQuietly(it); 105 | } 106 | System.out.print(" - Computing word frequencies"); 107 | GlobalIndexer indexer = new GlobalIndexer(configuration.numberOfThreads,false); 108 | try { 109 | indexer.index("input/", configuration.stopwords); 110 | } catch ( InterruptedException | IOException ex) { 111 | Logger.getLogger(Corpus.class.getName()).log(Level.SEVERE, null, ex); 112 | } 113 | indexer = new GlobalIndexer(configuration.numberOfThreads,true); 114 | try { 115 | indexer.index("input/", configuration.stopwords); 116 | } catch ( InterruptedException | IOException ex) { 117 | Logger.getLogger(Corpus.class.getName()).log(Level.SEVERE, null, ex); 118 | } 119 | System.out.println(", 100% done."); 120 | } 121 | 122 | public void loadCorpus(boolean parallelized){ 123 | output = ""; 124 | if(configuration.prepareCorpus){ 125 | prepareCorpus(); 126 | } 127 | String[] fileArray = new File("input/").list(); 128 | nbTimeSlices = 0; 129 | NumberFormat formatter = new DecimalFormat("00000000"); 130 | ArrayList list = new ArrayList<>(); 131 | for(String filename : fileArray){ 132 | if(filename.endsWith(".text")){ 133 | try { 134 | list.add(formatter.parse(filename.substring(0, 8)).intValue()); 135 | } catch (ParseException ex) { 136 | Logger.getLogger(Corpus.class.getName()).log(Level.SEVERE, null, ex); 137 | } 138 | nbTimeSlices++; 139 | } 140 | } 141 | int a = Collections.min(list), b = Collections.max(list); 142 | distribution = new int[nbTimeSlices]; 143 | messageCount = 0; 144 | LineIterator it = null; 145 | try { 146 | it = FileUtils.lineIterator(new File("input/"+formatter.format(a)+".time"), "UTF-8"); 147 | if(it.hasNext()) { 148 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 149 | Date parsedDate = dateFormat.parse(it.nextLine()); 150 | startTimestamp = new java.sql.Timestamp(parsedDate.getTime()); 151 | } 152 | it = FileUtils.lineIterator(new File("input/"+formatter.format(b)+".time"), "UTF-8"); 153 | String timestamp = ""; 154 | while(it.hasNext()) { 155 | timestamp = it.nextLine(); 156 | } 157 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 158 | Date parsedDate = dateFormat.parse(timestamp); 159 | endTimestamp = new java.sql.Timestamp(parsedDate.getTime()); 160 | } catch (IOException | ParseException ex) { 161 | Logger.getLogger(Corpus.class.getName()).log(Level.SEVERE, null, ex); 162 | } finally { 163 | LineIterator.closeQuietly(it); 164 | } 165 | try { 166 | // Global index 167 | FileInputStream fisMatrix = new FileInputStream("input/indexes/frequencyMatrix.dat"); 168 | ObjectInputStream oisMatrix = new ObjectInputStream(fisMatrix); 169 | frequencyMatrix = (short[][]) oisMatrix.readObject(); 170 | FileInputStream fisVocabulary = new FileInputStream("input/indexes/vocabulary.dat"); 171 | ObjectInputStream oisVocabulary = new ObjectInputStream(fisVocabulary); 172 | vocabulary = (ArrayList) oisVocabulary.readObject(); 173 | // Mention index 174 | FileInputStream fisMentionMatrix = new FileInputStream("input/indexes/mentionFrequencyMatrix.dat"); 175 | ObjectInputStream oisMentionMatrix = new ObjectInputStream(fisMentionMatrix); 176 | mentionFrequencyMatrix = (short[][]) oisMentionMatrix.readObject(); 177 | FileInputStream fisMentionVocabulary = new FileInputStream("input/indexes/mentionVocabulary.dat"); 178 | ObjectInputStream oisMentionVocabulary = new ObjectInputStream(fisMentionVocabulary); 179 | mentionVocabulary = (ArrayList) oisMentionVocabulary.readObject(); 180 | // Message count 181 | String messageCountStr = FileUtils.readFileToString(new File("input/indexes/messageCount.txt")); 182 | messageCount = Integer.parseInt(messageCountStr); 183 | // Message count distribution 184 | FileInputStream fisDistribution = new FileInputStream("input/indexes/messageCountDistribution.dat"); 185 | ObjectInputStream oisDistribution = new ObjectInputStream(fisDistribution); 186 | distribution = (int[]) oisDistribution.readObject(); 187 | } catch (FileNotFoundException ex) { 188 | Logger.getLogger(Corpus.class.getName()).log(Level.SEVERE, null, ex); 189 | } catch (IOException | ClassNotFoundException ex) { 190 | Logger.getLogger(Corpus.class.getName()).log(Level.SEVERE, null, ex); 191 | } 192 | DecimalFormat df = new DecimalFormat("#,###"); 193 | System.out.println(Util.getDate()+" Loaded corpus:"); 194 | output += Util.getDate()+" Loaded corpus:\n"; 195 | info =" - time-slices: "+df.format(nbTimeSlices)+" time-slices of "+configuration.timeSliceLength+" minutes each\n"; 196 | info +=" - first message: "+startTimestamp+"\n"; 197 | double datasetLength = (nbTimeSlices*configuration.timeSliceLength)/60/24; 198 | info +=" - last message: "+endTimestamp+" ("+datasetLength+" days)\n"; 199 | info +=" - number of messages: "+df.format(messageCount); 200 | output += info; 201 | System.out.println(info); 202 | } 203 | 204 | public short[] getMentionFrequency(int i){ 205 | return mentionFrequencyMatrix[i]; 206 | } 207 | 208 | public short[] getGlobalFrequency(String term){ 209 | int i = vocabulary.indexOf(term); 210 | if(i == -1){ 211 | return new short[nbTimeSlices]; 212 | }else{ 213 | return frequencyMatrix[i]; 214 | } 215 | } 216 | 217 | public String getMessages(Event event){ 218 | String messages = ""; 219 | NumberFormat formatter = new DecimalFormat("00000000"); 220 | String mainTerm = event.mainTerm; 221 | int count = 0; 222 | for(int i = event.I.timeSliceA; i <= event.I.timeSliceB; i++){ 223 | try { 224 | String filename = "input/"+formatter.format(i)+".text"; 225 | List lines = FileUtils.readLines(new File(filename)); 226 | for(String line : lines){ 227 | if(line.contains(" "+mainTerm+" ")){ 228 | messages += line+"\n"; 229 | count++; 230 | } 231 | } 232 | } catch (IOException ex) { 233 | Logger.getLogger(Corpus.class.getName()).log(Level.SEVERE, null, ex); 234 | } 235 | } 236 | return messages; 237 | } 238 | 239 | public Timestamp toDate(int timeSlice){ 240 | Timestamp date = startTimestamp; 241 | long dateLong = date.getTime() + timeSlice*configuration.timeSliceLength*60*1000L; 242 | return new Timestamp(dateLong); 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/structure/Event.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.structure; 19 | 20 | import java.util.ArrayList; 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | 24 | /** 25 | * 26 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 27 | * @email adrien.guille@univ-lyon2.fr 28 | */ 29 | public class Event implements Comparable { 30 | public String mainTerm; 31 | public WeightedTermList relatedTerms; 32 | public TimeInterval I; 33 | public double score; 34 | public ArrayList anomaly; 35 | 36 | public Event(){ 37 | mainTerm = "noMainTerm"; 38 | score = 0; 39 | relatedTerms = new WeightedTermList(); 40 | anomaly = new ArrayList<>(); 41 | } 42 | 43 | public Event(String t, TimeInterval tI, double s){ 44 | mainTerm = t; 45 | I = tI; 46 | score = s; 47 | relatedTerms = new WeightedTermList(); 48 | anomaly = new ArrayList<>(); 49 | } 50 | 51 | public Event(String t, TimeInterval tI, double s, ArrayList a){ 52 | mainTerm = t; 53 | I = tI; 54 | score = s; 55 | relatedTerms = new WeightedTermList(); 56 | anomaly = a; 57 | } 58 | 59 | public void setMainTerm(String t){ 60 | mainTerm = t; 61 | } 62 | 63 | public Map getMainTermAttributes(){ 64 | HashMap map = new HashMap<>(); 65 | map.put("ui.class","mainTerm"); 66 | map.put("ui.color",1); 67 | map.put("ui.color",1); 68 | map.put("I", I.timeSliceA+":"+I.timeSliceB); 69 | map.put("score",score); 70 | return map; 71 | } 72 | 73 | public Event merge(Event t){ 74 | Event t1 = new Event(this.mainTerm+", "+t.mainTerm, this.I, this.score); 75 | for(WeightedTerm wt : this.relatedTerms.list){ 76 | if(!t1.contains(wt.term)){ 77 | t1.relatedTerms.add(wt); 78 | } 79 | } 80 | for(WeightedTerm wt : t.relatedTerms.list){ 81 | if(!t1.contains(wt.term)){ 82 | t1.relatedTerms.add(wt); 83 | } 84 | } 85 | return t1; 86 | } 87 | 88 | public Event merge(EventList tl){ 89 | Event t1 = new Event("",this.I,this.score,this.anomaly); 90 | String mT = this.mainTerm; 91 | for(Event t : tl.list){ 92 | mT += ", "+t.mainTerm; 93 | } 94 | t1.setMainTerm(mT); 95 | for(Event t : tl.list){ 96 | for(WeightedTerm wt : t.relatedTerms.list){ 97 | if(!t1.contains(wt.term)){ 98 | t1.relatedTerms.add(wt); 99 | } 100 | } 101 | } 102 | for(WeightedTerm wt : this.relatedTerms.list){ 103 | if(!t1.contains(wt.term)){ 104 | t1.relatedTerms.add(wt); 105 | } 106 | } 107 | return t1; 108 | } 109 | 110 | public String toString(boolean printI){ 111 | String str = ""; 112 | if(printI){ 113 | str = "["+I.toString()+"] "; 114 | } 115 | str += mainTerm+"("+score+"): "; 116 | for(WeightedTerm wt : relatedTerms.list){ 117 | str += wt.term+"("+wt.weight+") "; 118 | } 119 | return str; 120 | } 121 | 122 | public String intervalAsString(String lang){ 123 | 124 | return ""; 125 | } 126 | 127 | public boolean contains(String term){ 128 | return this.mainTerm.contains(term) || containsrelatedTerm(term); 129 | } 130 | 131 | public boolean containsrelatedTerm(String term){ 132 | for(WeightedTerm wt : relatedTerms.list){ 133 | if(wt.term.equals(term)){ 134 | return true; 135 | } 136 | } 137 | return false; 138 | } 139 | 140 | public String relatedTermAsList(){ 141 | String st = ""; 142 | for(WeightedTerm wt : relatedTerms.list){ 143 | st += wt.term+" "; 144 | } 145 | return st; 146 | } 147 | 148 | public String anomalyToString(){ 149 | String string = "["; 150 | for(double d : anomaly){ 151 | string += d+","; 152 | } 153 | string = string.substring(0,string.length()); 154 | return string+"]"; 155 | } 156 | 157 | @Override 158 | public int compareTo(Event o) { 159 | if((o.score - this.score) == 0){ 160 | return 0; 161 | }else{ 162 | if(this.score > o.score){ 163 | return -1; 164 | }else{ 165 | return 1; 166 | } 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/structure/EventGraph.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.structure; 19 | 20 | import java.util.ArrayList; 21 | import java.util.Collection; 22 | import java.util.HashMap; 23 | import org.graphstream.algorithm.ConnectedComponents; 24 | import org.graphstream.algorithm.ConnectedComponents.ConnectedComponent; 25 | import org.graphstream.graph.Edge; 26 | import org.graphstream.graph.Graph; 27 | import org.graphstream.graph.Node; 28 | import org.graphstream.graph.implementations.SingleGraph; 29 | 30 | /** 31 | * 32 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 33 | * @email adrien.guille@univ-lyon2.fr 34 | */ 35 | public class EventGraph { 36 | public Graph graph; 37 | public Graph redundancyGraph; 38 | public HashMap duplicatedEvents; 39 | double maximumScore; 40 | double sigma; 41 | Corpus corpus; 42 | 43 | public EventGraph(Corpus d, double ms, Double sig){ 44 | sigma = sig; 45 | graph = new SingleGraph(""); 46 | redundancyGraph = new SingleGraph(""); 47 | maximumScore = ms; 48 | corpus = d; 49 | duplicatedEvents = new HashMap<>(); 50 | } 51 | 52 | public int addEvent(Event event){ 53 | int added = 0; 54 | boolean redundant = false; 55 | if(graph.getNode(event.mainTerm) != null){ 56 | for(WeightedTerm wt : event.relatedTerms.list){ 57 | Node wtNode = graph.getNode(wt.term); 58 | if(wtNode != null){ 59 | if(wtNode.getAttribute("ui.class").equals("mainTerm") && wtNode.hasEdgeFrom((Node)graph.getNode(event.mainTerm))){ 60 | Event event1 = getEvent(wtNode); 61 | double intersection = Math.max(event.I.intersectionProportion(event1.I), event1.I.intersectionProportion(event.I)); 62 | if(intersection > sigma){ 63 | redundant = true; 64 | duplicatedEvents.put(event.mainTerm,event); 65 | duplicatedEvents.put(event1.mainTerm,event1); 66 | // new way of managing redundancy 67 | if(redundancyGraph.getNode(event1.mainTerm) == null){ 68 | redundancyGraph.addNode(event1.mainTerm); 69 | } 70 | if(redundancyGraph.getNode(event.mainTerm) == null){ 71 | redundancyGraph.addNode(event.mainTerm); 72 | } 73 | if(redundancyGraph.getEdge(event.mainTerm+"-"+event1.mainTerm) == null){ 74 | redundancyGraph.addEdge(event.mainTerm+"-"+event1.mainTerm, event.mainTerm, event1.mainTerm, false); 75 | } 76 | } 77 | } 78 | } 79 | } 80 | } 81 | if(!redundant){ 82 | if(event.mainTerm != null){ 83 | if(graph.getNode(event.mainTerm) == null){ 84 | graph.addNode(event.mainTerm); 85 | } 86 | graph.getNode(event.mainTerm).addAttributes(event.getMainTermAttributes()); 87 | graph.getNode(event.mainTerm).setAttribute("ui.size",20+(event.score/maximumScore)*10); 88 | graph.getNode(event.mainTerm).addAttribute("ui.label", "["+corpus.toDate(event.I.timeSliceA)+"::"+corpus.toDate(event.I.timeSliceB)+"]:"+event.mainTerm); 89 | graph.getNode(event.mainTerm).addAttribute("anomaly",event.anomaly); 90 | for(WeightedTerm wt : event.relatedTerms.list){ 91 | if(wt.term != null){ 92 | if(graph.getNode(wt.term)==null){ 93 | graph.addNode(wt.term); 94 | graph.getNode(wt.term).addAttribute("ui.label", wt.term); 95 | graph.getNode(wt.term).setAttribute("ui.class","relatedTerm"); 96 | } 97 | graph.addEdge("["+event.I.timeSliceA+":"+event.I.timeSliceB+"]"+event.mainTerm+"-"+wt.term,wt.term,event.mainTerm,true); 98 | graph.getEdge("["+event.I.timeSliceA+":"+event.I.timeSliceB+"]"+event.mainTerm+"-"+wt.term).addAttribute("weight", wt.weight); 99 | } 100 | } 101 | } 102 | added = 1; 103 | } 104 | return added; 105 | } 106 | 107 | public EventList identifyConnectedComponents(){ 108 | ConnectedComponents ccs = new ConnectedComponents(redundancyGraph); 109 | ccs.setCountAttribute("component"); 110 | System.out.println(" - number of connected component(s): "+ccs.getConnectedComponentsCount()); 111 | int i = 0; 112 | EventList globalEvents = new EventList(); 113 | for (ConnectedComponent cc : ccs) { 114 | EventList ccEvents = new EventList(); 115 | for(Node node : cc.getEachNode()){ 116 | Event event = duplicatedEvents.get(node.getId()); 117 | ccEvents.add(event); 118 | removeEvent(event); 119 | } 120 | ccEvents.sort(); 121 | Event mainEvent = ccEvents.list.pop(); 122 | Event globalEvent = mainEvent.merge(ccEvents); 123 | globalEvents.add(globalEvent); 124 | addEvent(globalEvent); 125 | i++; 126 | } 127 | return globalEvents; 128 | } 129 | 130 | public void removeEvent(Event event){ 131 | Node mainNode = graph.getNode(event.mainTerm); 132 | if(mainNode != null){ 133 | if(mainNode.getAttribute("ui.class").equals("mainTerm")){ 134 | Collection edges = mainNode.getEnteringEdgeSet(); 135 | if(edges != null){ 136 | for(Edge edge : edges){ 137 | if(edge != null){ 138 | // remove obsolete edge 139 | graph.removeEdge(edge); 140 | if(edge.getSourceNode().getDegree() == 0){ 141 | graph.removeNode((Node)edge.getSourceNode()); 142 | } 143 | } 144 | } 145 | } 146 | if(mainNode.getOutDegree() == 0){ 147 | graph.removeNode(mainNode); 148 | }else{ 149 | mainNode.setAttribute("ui.class", "relatedTerm"); 150 | } 151 | } 152 | } 153 | } 154 | 155 | public void replaceEvent(Node nodeT0, Event t1){ 156 | nodeT0.setAttribute("ui.class","relatedTerm"); 157 | Collection edges = nodeT0.getEnteringEdgeSet(); 158 | graph.addNode(t1.mainTerm); 159 | graph.getNode(t1.mainTerm).addAttributes(t1.getMainTermAttributes()); 160 | graph.getNode(t1.mainTerm).setAttribute("ui.size",20+(t1.score/maximumScore)*10); 161 | graph.getNode(t1.mainTerm).addAttribute("ui.label", "["+corpus.toDate(t1.I.timeSliceA)+"::"+corpus.toDate(t1.I.timeSliceB)+"]:"+t1.mainTerm); 162 | graph.getNode(t1.mainTerm).setAttribute("anomaly",t1.anomaly); 163 | if(edges != null){ 164 | for(Edge edge : edges){ 165 | if(edge != null){ 166 | // remove obsolete edge 167 | graph.removeEdge(edge); 168 | // add edge toward the new main term 169 | if(!t1.mainTerm.contains(edge.getSourceNode().getId())){ 170 | String edgeId = "["+t1.I.timeSliceA+":"+t1.I.timeSliceB+"]"+t1.mainTerm+"-"+edge.getSourceNode().getId(); 171 | graph.addEdge(edgeId,edge.getSourceNode().getId(),t1.mainTerm,true); 172 | graph.getEdge(edgeId).addAttribute("weight", edge.getAttribute("weight")); 173 | } 174 | if(edge.getSourceNode().getDegree() == 0){ 175 | graph.removeNode((Node)edge.getSourceNode()); 176 | } 177 | } 178 | } 179 | } 180 | graph.removeNode(nodeT0); 181 | for(WeightedTerm wt : t1.relatedTerms.list){ 182 | if(wt.term != null){ 183 | if(graph.getNode(wt.term)==null){ 184 | graph.addNode(wt.term); 185 | graph.getNode(wt.term).addAttribute("ui.label", wt.term); 186 | graph.getNode(wt.term).setAttribute("ui.class","relatedTerm"); 187 | } 188 | if(graph.getEdge("["+t1.I.timeSliceA+":"+t1.I.timeSliceB+"]"+t1.mainTerm+"-"+wt.term) == null){ 189 | graph.addEdge("["+t1.I.timeSliceA+":"+t1.I.timeSliceB+"]"+t1.mainTerm+"-"+wt.term,wt.term,t1.mainTerm,true); 190 | } 191 | graph.getEdge("["+t1.I.timeSliceA+":"+t1.I.timeSliceB+"]"+t1.mainTerm+"-"+wt.term).addAttribute("weight", wt.weight); 192 | } 193 | } 194 | // if(nodeT0.getDegree() == 0){ 195 | // System.out.println(" - "+nodeT0.getId()+" is a leaf node."); 196 | // graph.removeNode(nodeT0); 197 | // } 198 | } 199 | 200 | public Event getEvent(Node mainNode){ 201 | Event event = new Event(); 202 | if(mainNode.getAttribute("ui.class")!=null && mainNode.getAttribute("ui.class").equals("mainTerm")){ 203 | event = new Event(mainNode.getId(), new TimeInterval((String) mainNode.getAttribute("I")), (double) mainNode.getAttribute("score"), (ArrayList) mainNode.getAttribute("anomaly")); 204 | for(Edge edge : mainNode.getEnteringEdgeSet()){ 205 | event.relatedTerms.add(new WeightedTerm(edge.getSourceNode().getId(), (double) edge.getAttribute("weight"))); 206 | } 207 | } 208 | return event; 209 | } 210 | 211 | public EventList toEventList(){ 212 | EventList events = new EventList(); 213 | for(Node node : graph){ 214 | if(node.getAttribute("ui.class")!=null && node.getAttribute("ui.class").equals("mainTerm")){ 215 | Event event = new Event(node.getId(), new TimeInterval((String) node.getAttribute("I")), (double) node.getAttribute("score"), (ArrayList) node.getAttribute("anomaly")); 216 | for(Edge edge : node.getEnteringEdgeSet()){ 217 | event.relatedTerms.add(new WeightedTerm(edge.getSourceNode().getId(), (double) edge.getAttribute("weight"))); 218 | } 219 | events.add(event); 220 | } 221 | } 222 | events.sort(); 223 | return events; 224 | } 225 | 226 | } 227 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/structure/EventList.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.structure; 19 | 20 | import fr.ericlab.mabed.algo.MABED; 21 | import java.io.File; 22 | import java.io.IOException; 23 | import java.text.DecimalFormat; 24 | import java.text.NumberFormat; 25 | import java.text.SimpleDateFormat; 26 | import java.util.Collections; 27 | import java.util.LinkedList; 28 | import java.util.logging.Level; 29 | import java.util.logging.Logger; 30 | import org.apache.commons.io.FileUtils; 31 | 32 | /** 33 | * 34 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 35 | * @email adrien.guille@univ-lyon2.fr 36 | */ 37 | public class EventList { 38 | public LinkedList list; 39 | 40 | public EventList(){ 41 | list = new LinkedList<>(); 42 | } 43 | 44 | public void writeEventsToFile(Corpus dataset, String filename){ 45 | try { 46 | File textFile = new File("output/"+filename+".txt"); 47 | FileUtils.writeStringToFile(textFile,"",false); 48 | for(Event event : list){ 49 | FileUtils.writeStringToFile(textFile," - ["+new SimpleDateFormat("yyyy-MM-dd hh:mm").format(dataset.toDate(event.I.timeSliceA))+"//"+new SimpleDateFormat("yyyy-MM-dd hh:mm").format(dataset.toDate(event.I.timeSliceB))+ 50 | "] "+event.toString(false)+"\n---------------------------------\n",true); 51 | } 52 | } catch (IOException ex) { 53 | Logger.getLogger(MABED.class.getName()).log(Level.SEVERE, null, ex); 54 | } 55 | } 56 | 57 | public void scoreEvolution(){ 58 | for(int i = 1; i <= list.size(); i++){ 59 | System.out.print(i+","); 60 | } 61 | for(Event event : list){ 62 | System.out.print(event.score+","); 63 | } 64 | } 65 | 66 | public void printLatex(Corpus corpus){ 67 | System.out.println(toLatex(corpus)); 68 | } 69 | 70 | public String toLatex(Corpus corpus){ 71 | int rank = 1; 72 | String string = ""; 73 | for(Event topic : list){ 74 | string += rank+" & "+new SimpleDateFormat("dd/MM HH:mm").format(corpus.toDate(topic.I.timeSliceA))+" -- "+new SimpleDateFormat("dd/MM HH:mm").format(corpus.toDate(topic.I.timeSliceB))+" & "+topic.mainTerm+": "+topic.relatedTerms.toString().replace("related terms:","")+"\\\\ \\hline\n"; 75 | rank++; 76 | } 77 | return string; 78 | } 79 | 80 | public void add(Event t){ 81 | list.add(t); 82 | } 83 | 84 | public void sort(){ 85 | Collections.sort(list); 86 | } 87 | 88 | public int size(){ 89 | return list.size(); 90 | } 91 | 92 | public Event get(int i){ 93 | return list.get(i); 94 | } 95 | 96 | public void addAll(EventList tl){ 97 | list.addAll(tl.list); 98 | } 99 | 100 | public void exportDetailledResults(Corpus corpus){ 101 | File outputDir = new File("output/csv/"); 102 | if(!outputDir.isDirectory()){ 103 | outputDir.mkdir(); 104 | }else{ 105 | for(String filename : outputDir.list()){ 106 | FileUtils.deleteQuietly(new File("output/csv/"+filename)); 107 | } 108 | } 109 | NumberFormat formatter = new DecimalFormat("000"); 110 | for(int i = 0; i < list.size(); i++){ 111 | Event event = list.get(i); 112 | String mainTerm = event.mainTerm.replace(", ", "_"); 113 | File descFile = new File("output/csv/"+formatter.format(i)+"-"+mainTerm+".desc"); 114 | File wordsFile = new File("output/csv/"+formatter.format(i)+"-"+mainTerm+".words"); 115 | File seriesFile = new File("output/csv/"+formatter.format(i)+"-"+mainTerm+".anomaly"); 116 | try { 117 | FileUtils.writeStringToFile(descFile,event.score+"\t"+event.I.timeSliceA+"\t"+event.I.timeSliceB+"\t"+new SimpleDateFormat("YYYY-MM-dd HH:mm").format(corpus.toDate(event.I.timeSliceA))+"\t"+new SimpleDateFormat("YYYY-MM-dd HH:mm").format(corpus.toDate(event.I.timeSliceB))+"\n",true); 118 | } catch (IOException ex) { 119 | Logger.getLogger(EventList.class.getName()).log(Level.SEVERE, null, ex); 120 | } 121 | for(WeightedTerm wt : event.relatedTerms.list){ 122 | try { 123 | FileUtils.writeStringToFile(wordsFile,wt.term+"\t"+wt.weight+"\n",true); 124 | } catch (IOException ex) { 125 | Logger.getLogger(EventList.class.getName()).log(Level.SEVERE, null, ex); 126 | } 127 | } 128 | for(int j = 0; j < event.anomaly.size(); j++){ 129 | try { 130 | FileUtils.writeStringToFile(seriesFile,j+"\t"+event.anomaly.get(j)+"\n",true); 131 | } catch (IOException ex) { 132 | Logger.getLogger(EventList.class.getName()).log(Level.SEVERE, null, ex); 133 | } 134 | } 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/structure/StopWords.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.structure; 19 | 20 | /** 21 | * 22 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 23 | * @email adrien.guille@univ-lyon2.fr 24 | */ 25 | public class StopWords { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/structure/TimeInterval.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.structure; 19 | 20 | import java.util.HashSet; 21 | 22 | /** 23 | * 24 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 25 | * @email adrien.guille@univ-lyon2.fr 26 | */ 27 | public class TimeInterval implements Comparable { 28 | public int timeSliceA; 29 | public int timeSliceB; 30 | 31 | public TimeInterval(int a, int b){ 32 | timeSliceA = a; 33 | timeSliceB = b; 34 | } 35 | 36 | public TimeInterval(String str){ 37 | String[] split = str.split(":"); 38 | timeSliceA = Integer.parseInt(split[0]); 39 | timeSliceB = Integer.parseInt(split[1]); 40 | } 41 | 42 | public String toString(){ 43 | return timeSliceA+":"+timeSliceB; 44 | } 45 | 46 | public double intersection(TimeInterval ti){ 47 | HashSet set1 = new HashSet<>(); 48 | HashSet set2 = new HashSet<>(); 49 | int intersectionSize = 0; 50 | for(int i = this.timeSliceA; i <= this.timeSliceB; i++){ 51 | set1.add(i); 52 | } 53 | for(int j = ti.timeSliceA; j <= ti.timeSliceB; j++){ 54 | set2.add(j); 55 | } 56 | for(int k : set1){ 57 | if(set2.contains(k)){ 58 | intersectionSize++; 59 | } 60 | } 61 | return intersectionSize; 62 | } 63 | 64 | public double intersectionProportion(TimeInterval ti){ 65 | return intersection(ti)/(this.timeSliceB-this.timeSliceA+1); 66 | } 67 | 68 | @Override 69 | public int compareTo(Object o) { 70 | TimeInterval point = (TimeInterval)o; 71 | if(this.timeSliceA > point.timeSliceA){ 72 | return 1; 73 | }else{ 74 | if(this.timeSliceA == point.timeSliceA){ 75 | return 0; 76 | }else{ 77 | return -1; 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/structure/WeightedTerm.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.structure; 19 | 20 | /** 21 | * 22 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 23 | * @email adrien.guille@univ-lyon2.fr 24 | */ 25 | public class WeightedTerm implements Comparable{ 26 | public String term; 27 | public double weight; 28 | 29 | public WeightedTerm(String t){ 30 | term = t; 31 | weight = 0; 32 | } 33 | 34 | public WeightedTerm(String t, double w){ 35 | term = t; 36 | weight = w; 37 | } 38 | 39 | @Override 40 | public int compareTo(WeightedTerm o) { 41 | if(o.weight-this.weight<0){ 42 | return -1; 43 | }else{ 44 | if(o.weight-this.weight>0){ 45 | return 1; 46 | }else{ 47 | return 0; 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/fr/ericlab/mabed/structure/WeightedTermList.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.mabed.structure; 19 | 20 | import java.text.DecimalFormat; 21 | import java.util.Collections; 22 | import java.util.LinkedList; 23 | 24 | /** 25 | * 26 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 27 | * @email adrien.guille@univ-lyon2.fr 28 | */ 29 | public class WeightedTermList { 30 | public LinkedList list; 31 | 32 | public WeightedTermList(){ 33 | list = new LinkedList<>(); 34 | } 35 | 36 | public void add(WeightedTerm t){ 37 | list.add(t); 38 | } 39 | 40 | public void sort(){ 41 | Collections.sort(list); 42 | } 43 | 44 | public int size(){ 45 | return list.size(); 46 | } 47 | 48 | public WeightedTerm get(int i){ 49 | return list.get(i); 50 | } 51 | 52 | public void addAll(WeightedTermList tl){ 53 | list.addAll(tl.list); 54 | } 55 | 56 | public String toString(){ 57 | sort(); 58 | String str = "related terms: "; 59 | DecimalFormat df = new DecimalFormat("0.00"); 60 | for(WeightedTerm t: list){ 61 | str += t.term+" ("+df.format(t.weight)+"), "; 62 | } 63 | return str.substring(0,str.length()-2); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/fr/ericlab/util/Util.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is part of MABED. // 3 | // // 4 | // MABED is free software: you can redistribute it and/or modify // 5 | // it under the terms of the GNU General Public License as published by // 6 | // the Free Software Foundation, either version 3 of the License, or // 7 | // (at your option) any later version. // 8 | // // 9 | // MABED is distributed in the hope that it will be useful, // 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 12 | // GNU General Public License for more details. // 13 | // // 14 | // You should have received a copy of the GNU General Public License // 15 | // along with MABED. If not, see . // 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | package fr.ericlab.util; 19 | 20 | import fr.ericlab.mabed.algo.MABED; 21 | import java.io.File; 22 | import java.io.IOException; 23 | import java.text.DateFormat; 24 | import java.text.SimpleDateFormat; 25 | import java.util.Arrays; 26 | import java.util.Date; 27 | import java.util.LinkedList; 28 | import java.util.logging.Level; 29 | import java.util.logging.Logger; 30 | import org.apache.commons.io.FileUtils; 31 | import org.apache.commons.io.LineIterator; 32 | 33 | /** 34 | * 35 | * @author Adrien GUILLE, ERIC Lab, University of Lyon 2 36 | * @email adrien.guille@univ-lyon2.fr 37 | */ 38 | public class Util { 39 | 40 | static public LinkedList readStopWords(String pathToStopwordsFile){ 41 | LinkedList stopWords = new LinkedList<>(); 42 | if(pathToStopwordsFile != null){ 43 | LineIterator it = null; 44 | try { 45 | it = FileUtils.lineIterator(new File(pathToStopwordsFile), "UTF-8"); 46 | while (it.hasNext()) { 47 | stopWords.add(it.nextLine()); 48 | } 49 | } catch (IOException ex) { 50 | Logger.getLogger(MABED.class.getName()).log(Level.SEVERE, null, ex); 51 | } finally { 52 | LineIterator.closeQuietly(it); 53 | } 54 | } 55 | return stopWords; 56 | } 57 | 58 | static public String getDate(){ 59 | DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); 60 | Date date = new Date(); 61 | String dateString = dateFormat.format(date); 62 | return dateString; 63 | } 64 | 65 | static public long getTime(){ 66 | Date date = new Date(); 67 | return date.getTime(); 68 | } 69 | 70 | static public int sum(short tab[], int a, int b){ 71 | int sum = 0; 72 | for(int i = a; i <= b; i++){ 73 | sum += tab[i]; 74 | } 75 | return sum; 76 | } 77 | 78 | static public float sum(float tab[], int a, int b){ 79 | float sum = 0; 80 | for(int i = a; i <= b; i++){ 81 | sum += tab[i]; 82 | } 83 | return sum; 84 | } 85 | 86 | static public float[] toFloatArray(short[] array){ 87 | float[] newArray = new float[array.length]; 88 | for(int i = 0; i < array.length; i++){ 89 | newArray[i] = array[i]; 90 | } 91 | return newArray; 92 | } 93 | 94 | static public float[] smoothArray(float array[], int windowSize){ 95 | float[] smoothedArray = new float[array.length]; 96 | for(int i = 0; i < array.length-1; i++){ 97 | smoothedArray[i] = centeredMovingAverage(array, i, windowSize); 98 | } 99 | return smoothedArray; 100 | } 101 | 102 | static public float[] smoothArray(short array[], int windowSize){ 103 | float[] smoothedArray = new float[array.length]; 104 | for(int i = 0; i < array.length-1; i++){ 105 | smoothedArray[i] = centeredMovingAverage(array, i, windowSize); 106 | } 107 | return smoothedArray; 108 | } 109 | 110 | static public double getMedian(double array[]){ 111 | Arrays.sort(array); 112 | return array[array.length/2]; 113 | } 114 | 115 | static public float centeredMovingAverage(float[] array, int index, int windowSize){ 116 | int halfWindowSize = windowSize/2; 117 | int possibleLeftWindow = (index >= halfWindowSize)?halfWindowSize:index; 118 | int possibleRightWindow = (index+halfWindowSize < array.length-1)? halfWindowSize:array.length-2-index; 119 | int i1 = index - possibleLeftWindow, i2 = index + possibleRightWindow; 120 | float total = 0; 121 | for(int i = i1; i <= i2; i++){ 122 | total += array[i]; 123 | } 124 | return total/(float)(possibleLeftWindow+possibleRightWindow); 125 | } 126 | 127 | static public float centeredMovingAverage(short[] array, int index, int windowSize){ 128 | int halfWindowSize = windowSize/2; 129 | int possibleLeftWindow = (index >= halfWindowSize)?halfWindowSize:index; 130 | int possibleRightWindow = (index+halfWindowSize < array.length-1)? halfWindowSize:array.length-2-index; 131 | int i1 = index - possibleLeftWindow, i2 = index + possibleRightWindow; 132 | float total = 0; 133 | for(int i = i1; i <= i2; i++){ 134 | total += array[i]; 135 | } 136 | return total/(float)(possibleLeftWindow+possibleRightWindow); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /stopwords.txt: -------------------------------------------------------------------------------- 1 | ... 2 | .... 3 | 0 4 | 1 5 | 2 6 | 3 7 | 4 8 | 5 9 | 6 10 | 7 11 | 8 12 | 9 13 | a 14 | about 15 | above 16 | accordingly 17 | across 18 | after 19 | afterwards 20 | again 21 | against 22 | al 23 | all 24 | allows 25 | almost 26 | alone 27 | along 28 | already 29 | also 30 | although 31 | always 32 | am 33 | among 34 | amongst 35 | an 36 | and 37 | another 38 | any 39 | anybody 40 | anyhow 41 | anyone 42 | anything 43 | anywhere 44 | apart 45 | appear 46 | appropriate 47 | are 48 | around 49 | as 50 | aside 51 | associated 52 | at 53 | available 54 | away 55 | awfully 56 | b 57 | back 58 | be 59 | became 60 | because 61 | become 62 | becomes 63 | becoming 64 | been 65 | before 66 | beforehand 67 | behind 68 | being 69 | below 70 | beside 71 | besides 72 | best 73 | better 74 | between 75 | beyond 76 | both 77 | brief 78 | but 79 | by 80 | c 81 | came 82 | can 83 | cannot 84 | cant 85 | care 86 | cause 87 | causes 88 | certain 89 | changes 90 | co 91 | come 92 | consequently 93 | contain 94 | containing 95 | contains 96 | corresponding 97 | could 98 | currently 99 | d 100 | day 101 | described 102 | did 103 | different 104 | do 105 | does 106 | doesnt 107 | doing 108 | don 109 | done 110 | dont 111 | down 112 | downwards 113 | did 114 | didnt 115 | during 116 | e 117 | each 118 | eg 119 | eight 120 | either 121 | else 122 | elsewhere 123 | enough 124 | eq 125 | et 126 | etc 127 | even 128 | ever 129 | every 130 | everybody 131 | everyone 132 | everything 133 | everywhere 134 | ex 135 | example 136 | except 137 | f 138 | far 139 | few 140 | fifth 141 | first 142 | five 143 | followed 144 | following 145 | for 146 | former 147 | formerly 148 | forth 149 | four 150 | friend 151 | friends 152 | from 153 | further 154 | furthermore 155 | g 156 | get 157 | gets 158 | given 159 | gives 160 | go 161 | goes 162 | going 163 | gonna 164 | gone 165 | good 166 | got 167 | great 168 | h 169 | had 170 | hardly 171 | has 172 | have 173 | having 174 | he 175 | hence 176 | her 177 | hes 178 | here 179 | hereafter 180 | hereby 181 | herein 182 | heres 183 | hereupon 184 | hers 185 | herself 186 | him 187 | himself 188 | his 189 | hither 190 | how 191 | howbeit 192 | however 193 | http 194 | i 195 | ie 196 | if 197 | ignored 198 | ill 199 | im 200 | immediate 201 | in 202 | inasmuch 203 | inc 204 | indeed 205 | indicate 206 | indicated 207 | indicates 208 | inner 209 | insofar 210 | instead 211 | into 212 | inward 213 | is 214 | it 215 | its 216 | itself 217 | ive 218 | j 219 | just 220 | k 221 | keep 222 | kept 223 | know 224 | knows 225 | l 226 | last 227 | latter 228 | latterly 229 | least 230 | less 231 | lest 232 | let 233 | life 234 | like 235 | little 236 | long 237 | love 238 | ltd 239 | m 240 | made 241 | make 242 | man 243 | many 244 | may 245 | me 246 | meanwhile 247 | men 248 | might 249 | more 250 | moreover 251 | most 252 | mostly 253 | mr 254 | much 255 | must 256 | my 257 | myself 258 | n 259 | name 260 | namely 261 | near 262 | necessary 263 | need 264 | needed 265 | neither 266 | never 267 | nevertheless 268 | new 269 | next 270 | nine 271 | no 272 | nobody 273 | none 274 | noone 275 | nor 276 | normally 277 | not 278 | nothing 279 | novel 280 | now 281 | nowhere 282 | o 283 | of 284 | off 285 | often 286 | oh 287 | old 288 | on 289 | once 290 | one 291 | ones 292 | only 293 | onto 294 | or 295 | other 296 | others 297 | otherwise 298 | ought 299 | our 300 | ours 301 | ourselves 302 | out 303 | outside 304 | over 305 | overall 306 | own 307 | p 308 | particular 309 | particularly 310 | people 311 | per 312 | perhaps 313 | placed 314 | please 315 | plus 316 | possible 317 | probably 318 | provides 319 | q 320 | que 321 | quite 322 | r 323 | rather 324 | really 325 | relatively 326 | respectively 327 | right 328 | s 329 | said 330 | same 331 | say 332 | says 333 | second 334 | secondly 335 | see 336 | seem 337 | seemed 338 | seeming 339 | seems 340 | self 341 | selves 342 | sensible 343 | sent 344 | serious 345 | seven 346 | several 347 | shall 348 | she 349 | should 350 | since 351 | six 352 | so 353 | some 354 | somebody 355 | somehow 356 | someone 357 | something 358 | sometime 359 | sometimes 360 | somewhat 361 | somewhere 362 | specified 363 | specify 364 | specifying 365 | state 366 | still 367 | sub 368 | such 369 | sup 370 | sure 371 | t 372 | take 373 | taken 374 | than 375 | thank 376 | thanks 377 | that 378 | thats 379 | the 380 | their 381 | theirs 382 | them 383 | themselves 384 | then 385 | thence 386 | there 387 | thereafter 388 | thereby 389 | therefore 390 | therein 391 | thereupon 392 | these 393 | they 394 | think 395 | thinks 396 | third 397 | this 398 | thorough 399 | thoroughly 400 | those 401 | though 402 | three 403 | through 404 | throughout 405 | thru 406 | thus 407 | time 408 | to 409 | today 410 | together 411 | too 412 | toward 413 | towards 414 | twice 415 | two 416 | u 417 | under 418 | unless 419 | until 420 | unto 421 | up 422 | upon 423 | us 424 | use 425 | used 426 | useful 427 | uses 428 | using 429 | usually 430 | v 431 | value 432 | various 433 | very 434 | via 435 | viz 436 | vs 437 | w 438 | want 439 | was 440 | way 441 | we 442 | well 443 | went 444 | were 445 | what 446 | whatever 447 | when 448 | whence 449 | whenever 450 | where 451 | whereafter 452 | whereas 453 | whereby 454 | wherein 455 | whereupon 456 | wherever 457 | whether 458 | which 459 | while 460 | whither 461 | who 462 | whoever 463 | whole 464 | whom 465 | whose 466 | why 467 | will 468 | with 469 | within 470 | without 471 | work 472 | world 473 | would 474 | x 475 | y 476 | year 477 | years 478 | yes 479 | yet 480 | you 481 | youd 482 | your 483 | youre 484 | yours 485 | yourself 486 | yourselves 487 | z 488 | zero 489 | via 490 | rt 491 | http 492 | html 493 | php 494 | tinyurl.com 495 | tweet 496 | tweets 497 | bit.ly 498 | twitpic.com 499 | ow.ly 500 | im 501 | ive 502 | lol 503 | com 504 | bit 505 | ff 506 | followfriday 507 | follow 508 | retweet 509 | post 510 | list 511 | lists 512 | tcot --------------------------------------------------------------------------------