├── .classpath ├── .gitattributes ├── .gitignore ├── .project ├── .settings ├── org.eclipse.jdt.core.prefs └── org.eclipse.m2e.core.prefs ├── LICENSE ├── README.md ├── build-osx.sh ├── build-win.bat ├── lib ├── apiguardian │ └── LICENSE └── junit5 │ ├── LICENSE.md │ ├── junit-jupiter-api │ └── LICENSE.md │ ├── junit-jupiter-engine │ └── LICENSE.md │ └── junit-platform-console-standalone │ └── LICENSE.md ├── pom.xml ├── src └── com │ └── sperske │ └── jason │ └── flashtext │ ├── KeywordProcessor.java │ ├── KeywordProcessorFactory.java │ └── KeywordTrieNode.java ├── target ├── .gitignore └── test-classes │ ├── com │ └── sperske │ │ └── jason │ │ └── flashtext │ │ └── sentance.txt │ ├── keywords_format_one.txt │ └── keywords_format_two.txt └── test ├── com └── sperske │ └── jason │ └── flashtext │ ├── KeywordProcessorFactoryTests.java │ └── KeywordReplacerTests.java ├── keywords_format_one.txt └── keywords_format_two.txt /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | build/ 4 | package/ 5 | 6 | # Log file 7 | *.log 8 | 9 | # BlueJ files 10 | *.ctxt 11 | 12 | # Mobile Tools for Java (J2ME) 13 | .mtj.tmp/ 14 | 15 | # Package Files # 16 | *.jar 17 | *.war 18 | *.nar 19 | *.ear 20 | *.zip 21 | *.tar.gz 22 | *.rar 23 | 24 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 25 | hs_err_pid* 26 | 27 | sources.txt 28 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | FlashTextJava 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.m2e.core.maven2Nature 21 | org.eclipse.jdt.core.javanature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 12 | org.eclipse.jdt.core.compiler.release=disabled 13 | org.eclipse.jdt.core.compiler.source=1.8 14 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Jason Sperske 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FlashTextJava 2 | 3 | A idiomatic port of [flashtext.py](https://github.com/vi3k6i5/flashtext) into Java (utilizing Streams) -------------------------------------------------------------------------------- /build-osx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p build 3 | find . -name "*.java" > sources.txt 4 | javac -classpath lib/junit-jupiter-api-5.0.0.jar:lib/apiguardian-api-1.0.0.jar -d build @sources.txt 5 | mkdir -p package 6 | jar cf package/FlashText.jar -C build . 7 | java -jar lib/junit-platform-console-standalone-1.0.0.jar -classpath lib/junit-jupiter-api-5.0.0.jar:lib/apiguardian-api-1.0.0.jar:lib/junit-jupiter-engine-5.0.0.jar:package/FlashText.jar --scan-class-path 8 | -------------------------------------------------------------------------------- /build-win.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | MKDIR build > nul 2> nul 3 | DIR /S /B *.java > sources.txt 4 | javac -classpath lib\junit-jupiter-api-5.0.0.jar;lib\apiguardian-api-1.0.0.jar -d build @sources.txt 5 | MKDIR package > nul 2> nul 6 | jar cf package\FlashText.jar -C build . 7 | java -jar lib\junit-platform-console-standalone-1.0.0.jar -classpath lib\junit-jupiter-api-5.0.0.jar;lib\apiguardian-api-1.0.0.jar;lib\junit-jupiter-engine-5.0.0.jar;package\FlashText.jar --scan-class-path 8 | -------------------------------------------------------------------------------- /lib/apiguardian/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /lib/junit5/LICENSE.md: -------------------------------------------------------------------------------- 1 | Open Source Licenses 2 | ==================== 3 | 4 | The individual JUnit modules/artifacts use different open source licenses: 5 | 6 | - `junit-platform-surefire-provider` uses [Apache License v2.0](junit-platform-surefire-provider/LICENSE.md) 7 | - All other modules use [Eclipse Public License v2.0](junit-jupiter-api/LICENSE.md). 8 | 9 | Please see the `LICENSE.md` files in the subfolders for details. 10 | -------------------------------------------------------------------------------- /lib/junit5/junit-jupiter-api/LICENSE.md: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 2.0 2 | ============================== 3 | 4 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 5 | 6 | ### 1. Definitions 7 | 8 | “Contribution” means: 9 | * **a)** in the case of the initial Contributor, the initial content Distributed under this Agreement, and 10 | * **b)** in the case of each subsequent Contributor: 11 | * **i)** changes to the Program, and 12 | * **ii)** additions to the Program; 13 | where such changes and/or additions to the Program originate from and are Distributed by that particular Contributor. A Contribution “originates” from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include changes or additions to the Program that are not Modified Works. 14 | 15 | “Contributor” means any person or entity that Distributes the Program. 16 | 17 | “Licensed Patents” mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. 18 | 19 | “Program” means the Contributions Distributed in accordance with this Agreement. 20 | 21 | “Recipient” means anyone who receives the Program under this Agreement or any Secondary License (as applicable), including Contributors. 22 | 23 | “Derivative Works” shall mean any work, whether in Source Code or other form, that is based on (or derived from) the Program and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. 24 | 25 | “Modified Works” shall mean any work in Source Code or other form that results from an addition to, deletion from, or modification of the contents of the Program, including, for purposes of clarity any new file in Source Code form that contains any contents of the Program. Modified Works shall not include works that contain only declarations, interfaces, types, classes, structures, or files of the Program solely in each case in order to link to, bind by name, or subclass the Program or Modified Works thereof. 26 | 27 | “Distribute” means the acts of **a)** distributing or **b)** making available in any manner that enables the transfer of a copy. 28 | 29 | “Source Code” means the form of a Program preferred for making modifications, including but not limited to software source code, documentation source, and configuration files. 30 | 31 | “Secondary License” means either the GNU General Public License, Version 2.0, or any later versions of that license, including any exceptions or additional permissions as identified by the initial Contributor. 32 | 33 | ### 2. Grant of Rights 34 | 35 | **a)** Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, Distribute and sublicense the Contribution of such Contributor, if any, and such Derivative Works. 36 | 37 | **b)** Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in Source Code or other form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. 38 | 39 | **c)** Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to Distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. 40 | 41 | **d)** Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 42 | 43 | **e)** Notwithstanding the terms of any Secondary License, no Contributor makes additional grants to any Recipient (other than those set forth in this Agreement) as a result of such Recipient's receipt of the Program under the terms of a Secondary License (if permitted under the terms of Section 3). 44 | 45 | ### 3. Requirements 46 | 47 | **3.1** If a Contributor Distributes the Program in any form, then: 48 | 49 | * **a)** the Program must also be made available as Source Code, in accordance with section 3.2, and the Contributor must accompany the Program with a statement that the Source Code for the Program is available under this Agreement, and informs Recipients how to obtain it in a reasonable manner on or through a medium customarily used for software exchange; and 50 | 51 | * **b)** the Contributor may Distribute the Program under a license different than this Agreement, provided that such license: 52 | * **i)** effectively disclaims on behalf of all other Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; 53 | * **ii)** effectively excludes on behalf of all other Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; 54 | * **iii)** does not attempt to limit or alter the recipients' rights in the Source Code under section 3.2; and 55 | * **iv)** requires any subsequent distribution of the Program by any party to be under a license that satisfies the requirements of this section 3. 56 | 57 | **3.2** When the Program is Distributed as Source Code: 58 | 59 | * **a)** it must be made available under this Agreement, or if the Program **(i)** is combined with other material in a separate file or files made available under a Secondary License, and **(ii)** the initial Contributor attached to the Source Code the notice described in Exhibit A of this Agreement, then the Program may be made available under the terms of such Secondary Licenses, and 60 | * **b)** a copy of this Agreement must be included with each copy of the Program. 61 | 62 | **3.3** Contributors may not remove or alter any copyright, patent, trademark, attribution notices, disclaimers of warranty, or limitations of liability (“notices”) contained within the Program from any copy of the Program which they Distribute, provided that Contributors may add their own appropriate notices. 63 | 64 | ### 4. Commercial Distribution 65 | 66 | Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor (“Commercial Contributor”) hereby agrees to defend and indemnify every other Contributor (“Indemnified Contributor”) against any losses, damages and costs (collectively “Losses”) arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: **a)** promptly notify the Commercial Contributor in writing of such claim, and **b)** allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. 67 | 68 | For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 69 | 70 | ### 5. No Warranty 71 | 72 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 73 | 74 | ### 6. Disclaimer of Liability 75 | 76 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 77 | 78 | ### 7. General 79 | 80 | If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 81 | 82 | If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. 83 | 84 | All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. 85 | 86 | Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be Distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to Distribute the Program (including its Contributions) under the new version. 87 | 88 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. Nothing in this Agreement is intended to be enforceable by any entity that is not a Contributor or Recipient. No third-party beneficiary rights are created under this Agreement. 89 | 90 | #### Exhibit A - Form of Secondary Licenses Notice 91 | 92 | > “This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), version(s), and exceptions or additional permissions here}.” 93 | 94 | Simply including a copy of this Agreement, including this Exhibit A is not sufficient to license the Source Code under Secondary Licenses. 95 | 96 | If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. 97 | 98 | You may add additional accurate notices of copyright ownership. 99 | -------------------------------------------------------------------------------- /lib/junit5/junit-jupiter-engine/LICENSE.md: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 2.0 2 | ============================== 3 | 4 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 5 | 6 | ### 1. Definitions 7 | 8 | “Contribution” means: 9 | * **a)** in the case of the initial Contributor, the initial content Distributed under this Agreement, and 10 | * **b)** in the case of each subsequent Contributor: 11 | * **i)** changes to the Program, and 12 | * **ii)** additions to the Program; 13 | where such changes and/or additions to the Program originate from and are Distributed by that particular Contributor. A Contribution “originates” from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include changes or additions to the Program that are not Modified Works. 14 | 15 | “Contributor” means any person or entity that Distributes the Program. 16 | 17 | “Licensed Patents” mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. 18 | 19 | “Program” means the Contributions Distributed in accordance with this Agreement. 20 | 21 | “Recipient” means anyone who receives the Program under this Agreement or any Secondary License (as applicable), including Contributors. 22 | 23 | “Derivative Works” shall mean any work, whether in Source Code or other form, that is based on (or derived from) the Program and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. 24 | 25 | “Modified Works” shall mean any work in Source Code or other form that results from an addition to, deletion from, or modification of the contents of the Program, including, for purposes of clarity any new file in Source Code form that contains any contents of the Program. Modified Works shall not include works that contain only declarations, interfaces, types, classes, structures, or files of the Program solely in each case in order to link to, bind by name, or subclass the Program or Modified Works thereof. 26 | 27 | “Distribute” means the acts of **a)** distributing or **b)** making available in any manner that enables the transfer of a copy. 28 | 29 | “Source Code” means the form of a Program preferred for making modifications, including but not limited to software source code, documentation source, and configuration files. 30 | 31 | “Secondary License” means either the GNU General Public License, Version 2.0, or any later versions of that license, including any exceptions or additional permissions as identified by the initial Contributor. 32 | 33 | ### 2. Grant of Rights 34 | 35 | **a)** Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, Distribute and sublicense the Contribution of such Contributor, if any, and such Derivative Works. 36 | 37 | **b)** Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in Source Code or other form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. 38 | 39 | **c)** Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to Distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. 40 | 41 | **d)** Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 42 | 43 | **e)** Notwithstanding the terms of any Secondary License, no Contributor makes additional grants to any Recipient (other than those set forth in this Agreement) as a result of such Recipient's receipt of the Program under the terms of a Secondary License (if permitted under the terms of Section 3). 44 | 45 | ### 3. Requirements 46 | 47 | **3.1** If a Contributor Distributes the Program in any form, then: 48 | 49 | * **a)** the Program must also be made available as Source Code, in accordance with section 3.2, and the Contributor must accompany the Program with a statement that the Source Code for the Program is available under this Agreement, and informs Recipients how to obtain it in a reasonable manner on or through a medium customarily used for software exchange; and 50 | 51 | * **b)** the Contributor may Distribute the Program under a license different than this Agreement, provided that such license: 52 | * **i)** effectively disclaims on behalf of all other Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; 53 | * **ii)** effectively excludes on behalf of all other Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; 54 | * **iii)** does not attempt to limit or alter the recipients' rights in the Source Code under section 3.2; and 55 | * **iv)** requires any subsequent distribution of the Program by any party to be under a license that satisfies the requirements of this section 3. 56 | 57 | **3.2** When the Program is Distributed as Source Code: 58 | 59 | * **a)** it must be made available under this Agreement, or if the Program **(i)** is combined with other material in a separate file or files made available under a Secondary License, and **(ii)** the initial Contributor attached to the Source Code the notice described in Exhibit A of this Agreement, then the Program may be made available under the terms of such Secondary Licenses, and 60 | * **b)** a copy of this Agreement must be included with each copy of the Program. 61 | 62 | **3.3** Contributors may not remove or alter any copyright, patent, trademark, attribution notices, disclaimers of warranty, or limitations of liability (“notices”) contained within the Program from any copy of the Program which they Distribute, provided that Contributors may add their own appropriate notices. 63 | 64 | ### 4. Commercial Distribution 65 | 66 | Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor (“Commercial Contributor”) hereby agrees to defend and indemnify every other Contributor (“Indemnified Contributor”) against any losses, damages and costs (collectively “Losses”) arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: **a)** promptly notify the Commercial Contributor in writing of such claim, and **b)** allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. 67 | 68 | For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 69 | 70 | ### 5. No Warranty 71 | 72 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 73 | 74 | ### 6. Disclaimer of Liability 75 | 76 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 77 | 78 | ### 7. General 79 | 80 | If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 81 | 82 | If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. 83 | 84 | All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. 85 | 86 | Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be Distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to Distribute the Program (including its Contributions) under the new version. 87 | 88 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. Nothing in this Agreement is intended to be enforceable by any entity that is not a Contributor or Recipient. No third-party beneficiary rights are created under this Agreement. 89 | 90 | #### Exhibit A - Form of Secondary Licenses Notice 91 | 92 | > “This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), version(s), and exceptions or additional permissions here}.” 93 | 94 | Simply including a copy of this Agreement, including this Exhibit A is not sufficient to license the Source Code under Secondary Licenses. 95 | 96 | If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. 97 | 98 | You may add additional accurate notices of copyright ownership. 99 | -------------------------------------------------------------------------------- /lib/junit5/junit-platform-console-standalone/LICENSE.md: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 2.0 2 | ============================== 3 | 4 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 5 | 6 | ### 1. Definitions 7 | 8 | “Contribution” means: 9 | * **a)** in the case of the initial Contributor, the initial content Distributed under this Agreement, and 10 | * **b)** in the case of each subsequent Contributor: 11 | * **i)** changes to the Program, and 12 | * **ii)** additions to the Program; 13 | where such changes and/or additions to the Program originate from and are Distributed by that particular Contributor. A Contribution “originates” from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include changes or additions to the Program that are not Modified Works. 14 | 15 | “Contributor” means any person or entity that Distributes the Program. 16 | 17 | “Licensed Patents” mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. 18 | 19 | “Program” means the Contributions Distributed in accordance with this Agreement. 20 | 21 | “Recipient” means anyone who receives the Program under this Agreement or any Secondary License (as applicable), including Contributors. 22 | 23 | “Derivative Works” shall mean any work, whether in Source Code or other form, that is based on (or derived from) the Program and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. 24 | 25 | “Modified Works” shall mean any work in Source Code or other form that results from an addition to, deletion from, or modification of the contents of the Program, including, for purposes of clarity any new file in Source Code form that contains any contents of the Program. Modified Works shall not include works that contain only declarations, interfaces, types, classes, structures, or files of the Program solely in each case in order to link to, bind by name, or subclass the Program or Modified Works thereof. 26 | 27 | “Distribute” means the acts of **a)** distributing or **b)** making available in any manner that enables the transfer of a copy. 28 | 29 | “Source Code” means the form of a Program preferred for making modifications, including but not limited to software source code, documentation source, and configuration files. 30 | 31 | “Secondary License” means either the GNU General Public License, Version 2.0, or any later versions of that license, including any exceptions or additional permissions as identified by the initial Contributor. 32 | 33 | ### 2. Grant of Rights 34 | 35 | **a)** Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, Distribute and sublicense the Contribution of such Contributor, if any, and such Derivative Works. 36 | 37 | **b)** Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in Source Code or other form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. 38 | 39 | **c)** Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to Distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. 40 | 41 | **d)** Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 42 | 43 | **e)** Notwithstanding the terms of any Secondary License, no Contributor makes additional grants to any Recipient (other than those set forth in this Agreement) as a result of such Recipient's receipt of the Program under the terms of a Secondary License (if permitted under the terms of Section 3). 44 | 45 | ### 3. Requirements 46 | 47 | **3.1** If a Contributor Distributes the Program in any form, then: 48 | 49 | * **a)** the Program must also be made available as Source Code, in accordance with section 3.2, and the Contributor must accompany the Program with a statement that the Source Code for the Program is available under this Agreement, and informs Recipients how to obtain it in a reasonable manner on or through a medium customarily used for software exchange; and 50 | 51 | * **b)** the Contributor may Distribute the Program under a license different than this Agreement, provided that such license: 52 | * **i)** effectively disclaims on behalf of all other Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; 53 | * **ii)** effectively excludes on behalf of all other Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; 54 | * **iii)** does not attempt to limit or alter the recipients' rights in the Source Code under section 3.2; and 55 | * **iv)** requires any subsequent distribution of the Program by any party to be under a license that satisfies the requirements of this section 3. 56 | 57 | **3.2** When the Program is Distributed as Source Code: 58 | 59 | * **a)** it must be made available under this Agreement, or if the Program **(i)** is combined with other material in a separate file or files made available under a Secondary License, and **(ii)** the initial Contributor attached to the Source Code the notice described in Exhibit A of this Agreement, then the Program may be made available under the terms of such Secondary Licenses, and 60 | * **b)** a copy of this Agreement must be included with each copy of the Program. 61 | 62 | **3.3** Contributors may not remove or alter any copyright, patent, trademark, attribution notices, disclaimers of warranty, or limitations of liability (“notices”) contained within the Program from any copy of the Program which they Distribute, provided that Contributors may add their own appropriate notices. 63 | 64 | ### 4. Commercial Distribution 65 | 66 | Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor (“Commercial Contributor”) hereby agrees to defend and indemnify every other Contributor (“Indemnified Contributor”) against any losses, damages and costs (collectively “Losses”) arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: **a)** promptly notify the Commercial Contributor in writing of such claim, and **b)** allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. 67 | 68 | For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 69 | 70 | ### 5. No Warranty 71 | 72 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 73 | 74 | ### 6. Disclaimer of Liability 75 | 76 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 77 | 78 | ### 7. General 79 | 80 | If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 81 | 82 | If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. 83 | 84 | All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. 85 | 86 | Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be Distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to Distribute the Program (including its Contributions) under the new version. 87 | 88 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. Nothing in this Agreement is intended to be enforceable by any entity that is not a Contributor or Recipient. No third-party beneficiary rights are created under this Agreement. 89 | 90 | #### Exhibit A - Form of Secondary Licenses Notice 91 | 92 | > “This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), version(s), and exceptions or additional permissions here}.” 93 | 94 | Simply including a copy of this Agreement, including this Exhibit A is not sufficient to license the Source Code under Secondary Licenses. 95 | 96 | If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. 97 | 98 | You may add additional accurate notices of copyright ownership. 99 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | com.sperske.jason.flashtext 4 | FlashTextJava 5 | 0.0.1 6 | FlashTextJava 7 | A idiomatic port of FlashText.py in Java 8 | 9 | src 10 | test 11 | 12 | 13 | maven-compiler-plugin 14 | 3.7.0 15 | 16 | 1.8 17 | 1.8 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.junit.jupiter 25 | junit-jupiter-api 26 | 5.11.1 27 | test 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/com/sperske/jason/flashtext/KeywordProcessor.java: -------------------------------------------------------------------------------- 1 | package com.sperske.jason.flashtext; 2 | 3 | import java.util.Collections; 4 | import java.util.HashSet; 5 | import java.util.LinkedList; 6 | import java.util.Set; 7 | import java.util.function.BiConsumer; 8 | import java.util.function.BinaryOperator; 9 | import java.util.function.Function; 10 | import java.util.function.Supplier; 11 | import java.util.stream.Collector; 12 | import java.util.stream.Collectors; 13 | import java.util.stream.Stream; 14 | 15 | /* 16 | * FlashTextJava - An idiomatic Java port of the Python library FlashText by Vikash Singh 17 | * Original Python source can be found at https://github.com/vi3k6i5/flashtext 18 | * Based on the Aho-Corasick algorithm (https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm) 19 | * Java Version written by Jason Sperske 20 | */ 21 | public class KeywordProcessor { 22 | // immutable properties once KeywordProcessor is instantiated 23 | private final boolean CASE_SENSITIVE; 24 | 25 | // dynamic properties while KeywordProcessor is being built up 26 | private int _terms_in_trie = 0; 27 | private KeywordTrieNode rootNode; 28 | 29 | public KeywordProcessor() { 30 | this(false); 31 | } 32 | 33 | public KeywordProcessor(boolean case_sensitive) { 34 | this.CASE_SENSITIVE = case_sensitive; 35 | this.rootNode = new KeywordTrieNode(); 36 | } 37 | 38 | public int length() { 39 | return this._terms_in_trie; 40 | } 41 | 42 | public boolean contains(String word) { 43 | KeywordTrieNode current_keyword_trie_node = this.rootNode; 44 | int chars_traveled = 0; 45 | 46 | if (!this.CASE_SENSITIVE) { 47 | word = word.toLowerCase(); 48 | } 49 | for (Character c : word.toCharArray()) { 50 | if (current_keyword_trie_node.contains(c)) { 51 | current_keyword_trie_node = current_keyword_trie_node.children.get(c); 52 | chars_traveled += 1; 53 | } else { 54 | return false; 55 | } 56 | } 57 | 58 | return chars_traveled == word.length() && current_keyword_trie_node.contains(word); 59 | } 60 | 61 | public String get(String word) { 62 | KeywordTrieNode current_keyword_trie_node = this.rootNode; 63 | int chars_traveled = 0; 64 | 65 | if (!this.CASE_SENSITIVE) { 66 | word = word.toLowerCase(); 67 | } 68 | for(Character c : word.toCharArray()) { 69 | if (current_keyword_trie_node.contains(c)) { 70 | current_keyword_trie_node = current_keyword_trie_node.children.get(c); 71 | chars_traveled += 1; 72 | } else { 73 | return null; 74 | } 75 | } 76 | 77 | if (chars_traveled == word.length()) { 78 | return current_keyword_trie_node.get(); 79 | } else { 80 | return null; 81 | } 82 | } 83 | 84 | public void addKeyword(String word) { 85 | // Clean Name is set to word when not defined 86 | addKeyword(word, word); 87 | } 88 | 89 | public void addKeyword(String word, String clean_name) { 90 | if (!this.CASE_SENSITIVE) { 91 | word = word.toLowerCase(); 92 | } 93 | LinkedList characters = word.chars().mapToObj(c -> (char)c).collect(Collectors.toCollection(LinkedList::new)); 94 | 95 | this.rootNode.add(characters, word, clean_name); 96 | this._terms_in_trie += 1; 97 | } 98 | 99 | public Set extractKeywords(String sentance) { 100 | return extractKeywords(sentance.chars().mapToObj(c -> (char) c)); 101 | } 102 | public Set extractKeywords(Stream chars) { 103 | return chars.collect(new Extractor(this.rootNode, this.CASE_SENSITIVE)); 104 | } 105 | 106 | class Extractor implements Collector, Set> { 107 | private KeywordTrieNode currentNode; 108 | private final KeywordTrieNode rootNode; 109 | private final boolean CASE_SENSITIVE; 110 | private Set keywords; 111 | 112 | public Extractor(KeywordTrieNode rootNode, boolean caseSensitive) { 113 | this.rootNode = rootNode; 114 | this.currentNode = rootNode; 115 | this.CASE_SENSITIVE = caseSensitive; 116 | this.keywords = new HashSet<>(); 117 | } 118 | 119 | @Override 120 | public BiConsumer, Character> accumulator() { 121 | return (keywords, c) -> { 122 | if (!this.CASE_SENSITIVE) { 123 | c = Character.toLowerCase(c); 124 | } 125 | KeywordTrieNode node = currentNode.get(c); 126 | if (node == null) { 127 | currentNode = this.rootNode; 128 | } else { 129 | currentNode = node; 130 | String keyword = currentNode.get(); 131 | if (keyword != null) { 132 | keywords.add(keyword); 133 | } 134 | } 135 | }; 136 | } 137 | 138 | @Override 139 | public Set characteristics() { 140 | return Collections.emptySet(); 141 | } 142 | 143 | @Override 144 | public BinaryOperator> combiner() { 145 | return (a, b) -> a; 146 | } 147 | 148 | @Override 149 | public Function, Set> finisher() { 150 | return (keywords) -> keywords; 151 | } 152 | 153 | @Override 154 | public Supplier> supplier() { 155 | return () -> this.keywords; 156 | } 157 | 158 | } 159 | 160 | public String replace(String sentance) { 161 | return replace(sentance.chars().mapToObj(c -> (char) c)); 162 | } 163 | private String replace(Stream chars) { 164 | return chars.collect(new Replacer(this.rootNode, this.CASE_SENSITIVE)); 165 | } 166 | 167 | // Design adapted from https://codereview.stackexchange.com/a/199677/9162 168 | class Replacer implements Collector { 169 | private StringBuffer out; 170 | private StringBuffer buffer; 171 | private KeywordTrieNode currentNode; 172 | private final KeywordTrieNode rootNode; 173 | private final boolean CASE_SENSITIVE; 174 | 175 | public Replacer(KeywordTrieNode rootNode, boolean caseSensitive) { 176 | this.rootNode = rootNode; 177 | this.currentNode = rootNode; 178 | this.out = new StringBuffer(); 179 | this.buffer = new StringBuffer(); 180 | this.CASE_SENSITIVE = caseSensitive; 181 | } 182 | 183 | @Override 184 | public BiConsumer accumulator() { 185 | return (out, c) -> { 186 | char match_c = c; 187 | if (!this.CASE_SENSITIVE) { 188 | match_c = Character.toLowerCase(c); 189 | } 190 | KeywordTrieNode node = currentNode.get(match_c); 191 | if (node != null) { 192 | buffer.append(c); 193 | currentNode = node; 194 | return; 195 | } 196 | 197 | String keyword = currentNode.get(); 198 | out.append(keyword != null ? keyword : buffer); 199 | buffer = new StringBuffer(); 200 | currentNode = this.rootNode; 201 | 202 | // re-match root node 203 | node = this.rootNode.get(match_c); 204 | if (node != null) { 205 | buffer.append(c); 206 | currentNode = node; 207 | } else { 208 | out.append(c); 209 | } 210 | }; 211 | } 212 | 213 | @Override 214 | public Set characteristics() { 215 | return Collections.emptySet(); 216 | } 217 | 218 | @Override 219 | public BinaryOperator combiner() { 220 | return (a, b) -> a; 221 | } 222 | 223 | @Override 224 | public Function finisher() { 225 | return (out) -> { 226 | String keyword = currentNode.get(); 227 | if (keyword == null) { 228 | out.append(buffer); 229 | } else { 230 | out.append(keyword); 231 | } 232 | return out.toString(); 233 | }; 234 | } 235 | 236 | @Override 237 | public Supplier supplier() { 238 | return () -> this.out; 239 | } 240 | } 241 | 242 | public String toString() { 243 | return this.rootNode.toString(); 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /src/com/sperske/jason/flashtext/KeywordProcessorFactory.java: -------------------------------------------------------------------------------- 1 | package com.sperske.jason.flashtext; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Files; 5 | import java.nio.file.Paths; 6 | import java.util.stream.Stream; 7 | 8 | public class KeywordProcessorFactory { 9 | /* 10 | * FlashText.py defines a text file format with two types of lines, 11 | * format_one appears as a keyword, followed by '=>' and then a 'clean name' 12 | * format_two is just the keyword. This class implements these formats 13 | * allowing you to reuse a single keyword file. 14 | */ 15 | public static KeywordProcessor fromFlashTextFile(String file) throws IOException { 16 | return fromFlashTextFile(file, false); 17 | } 18 | 19 | public static KeywordProcessor fromFlashTextFile(String file, boolean case_sensitive) throws IOException { 20 | try (Stream stream = Files.lines(Paths.get(file))) { 21 | return fromFlashTextFile(stream, case_sensitive); 22 | } catch (IOException e) { 23 | throw e; 24 | } 25 | } 26 | 27 | public static KeywordProcessor fromFlashTextFile(Stream stream) { 28 | return fromFlashTextFile(stream, false); 29 | } 30 | 31 | public static KeywordProcessor fromFlashTextFile(Stream stream, boolean case_sensitive) { 32 | KeywordProcessor processor = new KeywordProcessor(); 33 | stream.forEach(line -> { 34 | String[] data = line.split("=>"); 35 | if (data.length == 2) { 36 | processor.addKeyword(data[0], data[1]); 37 | } else { 38 | processor.addKeyword(data[0]); 39 | } 40 | }); 41 | return processor; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/com/sperske/jason/flashtext/KeywordTrieNode.java: -------------------------------------------------------------------------------- 1 | package com.sperske.jason.flashtext; 2 | 3 | import java.util.HashMap; 4 | import java.util.LinkedList; 5 | import java.util.Map; 6 | 7 | public class KeywordTrieNode { 8 | private String keyword; 9 | private String clean_name; 10 | 11 | public Map children; 12 | 13 | public KeywordTrieNode() { 14 | // This is a transit node and will need a map to store values 15 | this.children = new HashMap<>(); 16 | } 17 | public KeywordTrieNode(String keyword, String clean_name) { 18 | // This is a value node and will need to store keyword and clean_name 19 | this.keyword = keyword; 20 | this.clean_name = clean_name; 21 | } 22 | 23 | public boolean contains(Character c) { 24 | if (this.children != null) { 25 | return this.children.containsKey(c); 26 | } 27 | return false; 28 | } 29 | 30 | public boolean contains(String word) { 31 | if (this.keyword != null) { 32 | return this.keyword.compareTo(word) == 0; 33 | } 34 | return false; 35 | } 36 | 37 | public boolean isEmpty() { 38 | return this.children == null || this.children.isEmpty(); 39 | } 40 | 41 | public KeywordTrieNode get(Character c) { 42 | if (this.children != null) { 43 | return this.children.get(c); 44 | } else { 45 | return null; 46 | } 47 | } 48 | 49 | public String get() { 50 | if (this.clean_name != null) { 51 | return this.clean_name; 52 | } else { 53 | return this.keyword; 54 | } 55 | } 56 | 57 | public KeywordTrieNode add(LinkedList characters, String word, String clean_name) { 58 | Character c = characters.poll(); 59 | if (c == null) { 60 | this.keyword = word; 61 | this.clean_name = clean_name; 62 | } else { 63 | KeywordTrieNode node = get(c); 64 | if (node == null) { 65 | node = new KeywordTrieNode(); 66 | } 67 | this.children.put(c, node.add(characters, word, clean_name)); 68 | } 69 | return this; 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return toIndentedString(""); 75 | } 76 | 77 | private String toIndentedString(String pad) { 78 | StringBuilder out = new StringBuilder(); 79 | String name = get(); 80 | if (name != null) { 81 | out.append(name); 82 | } 83 | out.append('\n'); 84 | if (this.children != null) { 85 | for(Character c : this.children.keySet()) { 86 | out.append(pad).append(c).append(':').append(this.children.get(c).toIndentedString(pad + " ")); 87 | } 88 | } 89 | 90 | return out.toString(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /target/.gitignore: -------------------------------------------------------------------------------- 1 | /classes/ 2 | -------------------------------------------------------------------------------- /target/test-classes/com/sperske/jason/flashtext/sentance.txt: -------------------------------------------------------------------------------- 1 | I know java_2e and product management techniques -------------------------------------------------------------------------------- /target/test-classes/keywords_format_one.txt: -------------------------------------------------------------------------------- 1 | java_2e=>java 2 | java programing=>java 3 | product management=>product management 4 | product management techniques=>product management -------------------------------------------------------------------------------- /target/test-classes/keywords_format_two.txt: -------------------------------------------------------------------------------- 1 | java 2 | product management -------------------------------------------------------------------------------- /test/com/sperske/jason/flashtext/KeywordProcessorFactoryTests.java: -------------------------------------------------------------------------------- 1 | package com.sperske.jason.flashtext; 2 | 3 | import java.io.IOException; 4 | import java.util.Set; 5 | import static org.junit.jupiter.api.Assertions.*; 6 | import org.junit.jupiter.api.Test; 7 | 8 | class KeywordProcessorFactoryTests { 9 | @Test 10 | void shouldSupportFileFormatOne() throws IOException { 11 | KeywordProcessor processor = KeywordProcessorFactory.fromFlashTextFile("test/keywords_format_one.txt"); 12 | Set keywords = processor.extractKeywords("I know java_2e and product management techniques"); 13 | 14 | assertTrue(keywords.size() == 2); 15 | assertTrue(keywords.contains("java")); 16 | assertTrue(keywords.contains("product management")); 17 | } 18 | 19 | @Test 20 | void shouldSupportFileFormatTwo() throws IOException { 21 | KeywordProcessor processor = KeywordProcessorFactory.fromFlashTextFile("test/keywords_format_two.txt"); 22 | Set keywords = processor.extractKeywords("I know java and product management"); 23 | 24 | assertTrue(keywords.size() == 2); 25 | assertTrue(keywords.contains("java")); 26 | assertTrue(keywords.contains("product management")); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/com/sperske/jason/flashtext/KeywordReplacerTests.java: -------------------------------------------------------------------------------- 1 | package com.sperske.jason.flashtext; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | import java.util.Set; 5 | import org.junit.jupiter.api.Test; 6 | 7 | class KeywordReplacerTests { 8 | @Test 9 | void shouldFindKeywordAtTheEndOfTheSentence() { 10 | KeywordProcessor processor = new KeywordProcessor(); 11 | processor.addKeyword("Python", "python"); 12 | 13 | Set keywords = processor.extractKeywords("I like python"); 14 | assertTrue(keywords.size() == 1); 15 | assertTrue(keywords.contains("python")); 16 | } 17 | @Test 18 | void shouldSkipIncompleteKeywordAtTheEndOfTheSentence() { 19 | KeywordProcessor processor = new KeywordProcessor(); 20 | processor.addKeyword("Pythonizer", "pythonizer"); 21 | 22 | Set keywords = processor.extractKeywords("I like python"); 23 | assertTrue(keywords.size() == 0); 24 | } 25 | @Test 26 | void shouldFindKeywordAtTheBeginningOfTheSentence() { 27 | KeywordProcessor processor = new KeywordProcessor(); 28 | processor.addKeyword("Python", "python"); 29 | 30 | Set keywords = processor.extractKeywords("python I like"); 31 | assertTrue(keywords.size() == 1); 32 | assertTrue(keywords.contains("python")); 33 | } 34 | @Test 35 | void shouldFindKeywordBeforeTheEndOfTheSentence() { 36 | KeywordProcessor processor = new KeywordProcessor(); 37 | processor.addKeyword("Python", "python"); 38 | 39 | Set keywords = processor.extractKeywords("I like python also"); 40 | assertTrue(keywords.size() == 1); 41 | assertTrue(keywords.contains("python")); 42 | } 43 | @Test 44 | void shouldFindMultipleKeywordsInTheEndOfTheSentence() { 45 | KeywordProcessor processor = new KeywordProcessor(); 46 | 47 | processor.addKeyword("Python", "python"); 48 | processor.addKeyword("Java", "java"); 49 | 50 | Set keywords = processor.extractKeywords("I like python java"); 51 | assertTrue(keywords.size() == 2); 52 | assertTrue(keywords.contains("python")); 53 | assertTrue(keywords.contains("java")); 54 | } 55 | @Test 56 | void shouldReplaceIfFirstMatchFails() { 57 | KeywordProcessor processor = new KeywordProcessor(); 58 | processor.addKeyword("ab", "12"); 59 | processor.addKeyword("cd", "34"); 60 | 61 | assertEquals("a34", processor.replace("acd")); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /test/keywords_format_one.txt: -------------------------------------------------------------------------------- 1 | java_2e=>java 2 | java programing=>java 3 | product management=>product management 4 | product management techniques=>product management -------------------------------------------------------------------------------- /test/keywords_format_two.txt: -------------------------------------------------------------------------------- 1 | java 2 | product management --------------------------------------------------------------------------------