├── lib ├── morph-1.5.jar ├── english-1.5.jar └── russian-1.5.jar ├── .gitignore ├── src ├── test │ └── resources │ │ ├── log4j.properties │ │ └── rest-api-spec │ │ └── test │ │ └── analysis-morphology │ │ ├── 10_analyze.yml │ │ └── 5_plugin_version.yml └── main │ ├── assemblies │ └── plugin.xml │ ├── java │ └── org │ │ └── elasticsearch │ │ └── plugin │ │ └── analysis │ │ └── morphology │ │ ├── MorphologyAnalyzerProvider.java │ │ ├── MorphologyTokenFilterFactory.java │ │ └── AnalysisMorphologyPlugin.java │ └── resources │ └── plugin-descriptor.properties ├── .travis.yml ├── Dockerfile ├── README.md ├── pom.xml └── LICENSE.txt /lib/morph-1.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickyat/elasticsearch-analysis-morphology/HEAD/lib/morph-1.5.jar -------------------------------------------------------------------------------- /lib/english-1.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickyat/elasticsearch-analysis-morphology/HEAD/lib/english-1.5.jar -------------------------------------------------------------------------------- /lib/russian-1.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickyat/elasticsearch-analysis-morphology/HEAD/lib/russian-1.5.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /data 2 | /work 3 | /logs 4 | /.idea 5 | /target 6 | .DS_Store 7 | *.iml 8 | /.project 9 | /.settings 10 | /.classpath 11 | /*.ipr 12 | /*.iws 13 | -------------------------------------------------------------------------------- /src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO, out 2 | 3 | log4j.appender.out=org.apache.log4j.ConsoleAppender 4 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.out.layout.conversionPattern=[%d{ISO8601}][%-5p][%-25c] %m%n 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | jdk: 3 | - oraclejdk8 4 | install: true 5 | script: 6 | - sudo apt-get update && sudo apt-get install oracle-java8-installer 7 | - java -version 8 | - mvn clean package -Dmaven.test.skip=true 9 | language: java 10 | 11 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.elastic.co/elasticsearch/elasticsearch:8.4.1 2 | COPY /target/releases/elasticsearch-analysis-morphology-8.4.1.zip /tmp/elasticsearch-analysis-morphology-8.4.1.zip 3 | RUN bin/elasticsearch-plugin install file:/tmp/elasticsearch-analysis-morphology-8.4.1.zip 4 | -------------------------------------------------------------------------------- /src/test/resources/rest-api-spec/test/analysis-morphology/10_analyze.yml: -------------------------------------------------------------------------------- 1 | # Basic integration tests for the morphology analysis plugin 2 | # 3 | --- 4 | "Russian analyzer and filter": 5 | - do: 6 | indices.analyze: 7 | body: 8 | tokenizer: standard 9 | filter: ["lowercase", "russian_morphology"] 10 | text: Японские автомобили 11 | - length: { tokens: 2 } 12 | - match: { tokens.0.token: японский } 13 | - match: { tokens.1.token: автомобиль } 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/rest-api-spec/test/analysis-morphology/5_plugin_version.yml: -------------------------------------------------------------------------------- 1 | # Basic integration tests for the morphology analysis plugin 2 | # 3 | --- 4 | "Russian analyzer and filter": 5 | - do: 6 | cluster.state: {} 7 | 8 | # Get master node id 9 | - set: { master_node: master } 10 | 11 | - do: 12 | nodes.info: 13 | metric: [ plugins ] 14 | 15 | - match : { nodes.$master.plugins.0.name: "analysis-morphology" } 16 | - match : 17 | nodes.$master.plugins.0.version: | 18 | /^\d+\.\d+\.\d+(\.\d+)?$/ 19 | -------------------------------------------------------------------------------- /src/main/assemblies/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | plugin 4 | 5 | zip 6 | 7 | false 8 | 9 | 10 | ${project.basedir}/src/main/resources/plugin-descriptor.properties 11 | 12 | true 13 | 14 | 15 | 16 | 17 | / 18 | true 19 | true 20 | 21 | org.elasticsearch:elasticsearch 22 | 23 | 24 | 25 | / 26 | true 27 | true 28 | 29 | org.apache.lucene:lucene-russian 30 | 31 | 32 | 33 | 34 | 35 | ${basedir}/lib/ 36 | / 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/java/org/elasticsearch/plugin/analysis/morphology/MorphologyAnalyzerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Igor Motov 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.elasticsearch.plugin.analysis.morphology; 18 | 19 | import org.apache.lucene.morphology.LuceneMorphology; 20 | import org.apache.lucene.morphology.analyzer.MorphologyAnalyzer; 21 | import org.elasticsearch.common.settings.Settings; 22 | import org.elasticsearch.env.Environment; 23 | import org.elasticsearch.index.IndexSettings; 24 | import org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider; 25 | 26 | /** 27 | * Provider for russian/english morphology analyzer 28 | */ 29 | public class MorphologyAnalyzerProvider extends AbstractIndexAnalyzerProvider { 30 | 31 | private final MorphologyAnalyzer analyzer; 32 | 33 | public MorphologyAnalyzerProvider(Environment environment, String name, 34 | Settings settings, LuceneMorphology luceneMorphology) { 35 | super(name, settings); 36 | analyzer = new MorphologyAnalyzer(luceneMorphology); 37 | } 38 | 39 | @Override 40 | public MorphologyAnalyzer get() { 41 | return this.analyzer; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/elasticsearch/plugin/analysis/morphology/MorphologyTokenFilterFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Igor Motov 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.elasticsearch.plugin.analysis.morphology; 18 | 19 | import org.apache.lucene.analysis.TokenStream; 20 | import org.apache.lucene.morphology.LuceneMorphology; 21 | import org.apache.lucene.morphology.analyzer.MorphologyFilter; 22 | import org.elasticsearch.common.settings.Settings; 23 | import org.elasticsearch.env.Environment; 24 | import org.elasticsearch.index.IndexSettings; 25 | import org.elasticsearch.index.analysis.AbstractTokenFilterFactory; 26 | 27 | /** 28 | * Russian/english morphology token filter factory 29 | */ 30 | public class MorphologyTokenFilterFactory extends AbstractTokenFilterFactory { 31 | 32 | private final LuceneMorphology luceneMorph; 33 | 34 | public MorphologyTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, 35 | Settings settings, LuceneMorphology englishLuceneMorphology) { 36 | super(name, settings); 37 | luceneMorph = englishLuceneMorphology; 38 | } 39 | 40 | @Override 41 | public TokenStream create(TokenStream tokenStream) { 42 | return new MorphologyFilter(tokenStream, luceneMorph); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/resources/plugin-descriptor.properties: -------------------------------------------------------------------------------- 1 | # Elasticsearch plugin descriptor file 2 | # This file must exist as 'plugin-descriptor.properties' at 3 | # the root directory of all plugins. 4 | # 5 | # A plugin can be 'site', 'jvm', or both. 6 | # 7 | ### example site plugin for "foo": 8 | # 9 | # foo.zip <-- zip file for the plugin, with this structure: 10 | # _site/ <-- the contents that will be served 11 | # plugin-descriptor.properties <-- example contents below: 12 | # 13 | # site=true 14 | # description=My cool plugin 15 | # version=1.0 16 | # 17 | ### example jvm plugin for "foo" 18 | # 19 | # foo.zip <-- zip file for the plugin, with this structure: 20 | # .jar <-- classes, resources, dependencies 21 | # .jar <-- any number of jars 22 | # plugin-descriptor.properties <-- example contents below: 23 | # 24 | # jvm=true 25 | # classname=foo.bar.BazPlugin 26 | # description=My cool plugin 27 | # version=2.0.0-rc1 28 | # elasticsearch.version=2.0 29 | # java.version=1.7 30 | # 31 | ### mandatory elements for all plugins: 32 | # 33 | # 'description': simple summary of the plugin 34 | description=${project.description} 35 | # 36 | # 'version': plugin's version 37 | version=${project.version} 38 | # 39 | # 'name': the plugin name 40 | name=${elasticsearch.plugin.name} 41 | 42 | # 43 | # 'classname': the name of the class to load, fully-qualified. 44 | classname=${elasticsearch.plugin.classname} 45 | # 46 | # 'java.version' version of java the code is built against 47 | # use the system property java.specification.version 48 | # version string must be a sequence of nonnegative decimal integers 49 | # separated by "."'s and may have leading zeros 50 | java.version=${maven.compiler.target} 51 | # 52 | # 'elasticsearch.version' version of elasticsearch compiled against 53 | # You will have to release a new version of the plugin for each new 54 | # elasticsearch release. This version is checked when the plugin 55 | # is loaded so Elasticsearch will refuse to start in the presence of 56 | # plugins with the incorrect elasticsearch.version. 57 | elasticsearch.version=${elasticsearch.version} 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # elasticsearch-analysis-morphology 2 | Плагин для ElasticSearch (8.4.1) реализующий анализатор для русского и английского языка, используются словари проекта http://aot.ru 3 | Оригинальный плагин взят отсюда https://github.com/imotov/elasticsearch-analysis-morphology который в свою очередь использует 4 | russian_morphology и english_morphology от проекта Russian Morphology for Apache Lucene https://github.com/AKuznetsov/russianmorphology 5 | Плагин добавляет два analyzers и token filter: "russian_morphology" и "english_morphology" 6 | 7 | # Elasticsearch 8 | 9 | При создании индекса указываем настройки с указанием анализатора и создаем на основе настроек маппинг. 10 | Пример 11 | ``` 12 | PUT /products 13 | { 14 | "settings": { 15 | "index": { 16 | "analysis": { 17 | "analyzer": { 18 | "product_name_analyzer": { 19 | "type": "custom", 20 | "tokenizer": "standard", 21 | "filter": [ 22 | "lowercase", 23 | "search_synonym", 24 | "russian_morphology", 25 | "english_morphology", 26 | "ru_stopwords" 27 | ] 28 | } 29 | }, 30 | "filter": { 31 | "search_synonym": { 32 | "ignore_case": "true", 33 | "type": "synonym", 34 | "synonyms": [ 35 | "bosch,бош" 36 | ] 37 | }, 38 | "ru_stopwords": { 39 | "type": "stop", 40 | "stopwords": "а,без,более,бы,был,была,были,было,быть,в,вам,вас,весь,во,вот,все,всего,всех,вы,где,да,даже,для,до,его,ее,если,есть,еще,же,за,здесь,и,из,или,им,их,к,как,ко,когда,кто,ли,либо,мне,может,мы,на,надо,наш,не,него,нее,нет,ни,них,но,ну,о,об,однако,он,она,они,оно,от,очень,по,под,при,с,со,так,также,такой,там,те,тем,то,того,тоже,той,только,том,ты,у,уже,хотя,чего,чей,чем,что,чтобы,чье,чья,эта,эти,это,я,a,an,and,are,as,at,be,but,by,for,if,in,into,is,it,no,not,of,on,or,such,that,the,their,then,there,these,they,this,to,was,will,with" 41 | } 42 | } 43 | } 44 | } 45 | }, 46 | "mappings": { 47 | "properties": { 48 | "name": { 49 | "type": "text", 50 | "analyzer": "product_name_analyzer" 51 | }, 52 | "code": { 53 | "type": "keyword" 54 | }, 55 | "description": { 56 | "type": "text", 57 | "analyzer": "product_name_analyzer" 58 | }, 59 | "brand": { 60 | "type": "keyword" 61 | } 62 | } 63 | } 64 | } 65 | ``` 66 | # Dockerfile 67 | Образ оригинального elasticsearch 8.4.1 с шагом установки плагина analysis-morphology 68 | 69 | # Maven 70 | тесты не реализованы, собирать 71 | ```mvn clean package -Dmaven.test.skip=true``` 72 | и далее копировать полученный /target/releases/elasticsearch-analysis-morphology-8.4.1.zip в существующий кластер и устанавливать через bin/elasticsearch-plugin install file:elasticsearch-analysis-morphology-8.4.1.zip 73 | 74 | -------------------------------------------------------------------------------- /src/main/java/org/elasticsearch/plugin/analysis/morphology/AnalysisMorphologyPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Igor Motov 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.elasticsearch.plugin.analysis.morphology; 18 | 19 | import org.apache.lucene.analysis.Analyzer; 20 | import org.apache.lucene.morphology.english.EnglishLuceneMorphology; 21 | import org.apache.lucene.morphology.russian.RussianLuceneMorphology; 22 | import org.elasticsearch.index.analysis.AnalyzerProvider; 23 | import org.elasticsearch.index.analysis.TokenFilterFactory; 24 | import org.elasticsearch.indices.analysis.AnalysisModule; 25 | import org.elasticsearch.plugins.AnalysisPlugin; 26 | import org.elasticsearch.plugins.Plugin; 27 | 28 | import java.io.IOException; 29 | import java.util.HashMap; 30 | import java.util.Map; 31 | 32 | /** 33 | * Plugin for russian/english morphology analyzer 34 | */ 35 | public class AnalysisMorphologyPlugin extends Plugin implements AnalysisPlugin { 36 | 37 | private final RussianLuceneMorphology russianLuceneMorphology; 38 | private final EnglishLuceneMorphology englishLuceneMorphology; 39 | 40 | public AnalysisMorphologyPlugin() { 41 | super(); 42 | try { 43 | russianLuceneMorphology = new RussianLuceneMorphology(); 44 | } catch (IOException ex) { 45 | throw new IllegalStateException("unable to load russian morphology info", ex); 46 | } 47 | try { 48 | englishLuceneMorphology = new EnglishLuceneMorphology(); 49 | } catch (IOException ex) { 50 | throw new IllegalStateException("unable to load english morphology info", ex); 51 | } 52 | } 53 | 54 | @Override 55 | public Map> getTokenFilters() { 56 | Map> extra = new HashMap<>(); 57 | extra.put("russian_morphology", (indexSettings, environment, name, settings) -> 58 | new MorphologyTokenFilterFactory(indexSettings, environment, name, settings, russianLuceneMorphology)); 59 | extra.put("english_morphology", (indexSettings, environment, name, settings) -> 60 | new MorphologyTokenFilterFactory(indexSettings, environment, name, settings, englishLuceneMorphology)); 61 | return extra; 62 | } 63 | 64 | @Override 65 | public Map>> getAnalyzers() { 66 | Map>> extra = new HashMap<>(); 67 | extra.put("russian_morphology", (indexSettings, environment, name, settings) -> 68 | new MorphologyAnalyzerProvider(environment, name, settings, russianLuceneMorphology)); 69 | extra.put("english_morphology", (indexSettings, environment, name, settings) -> 70 | new MorphologyAnalyzerProvider(environment, name, settings, englishLuceneMorphology)); 71 | return extra; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | elasticsearch-analysis-morphology 6 | 4.0.0 7 | org.elasticsearch 8 | elasticsearch-analysis-morphology 9 | 8.9.1 10 | jar 11 | Russian and English Morphology Analysis for Elasticsearch 12 | 13 | 14 | 15 | 8.9.1 16 | 17 17 | ${project.basedir}/src/main/assemblies/plugin.xml 18 | analysis-morphology 19 | org.elasticsearch.plugin.analysis.morphology.AnalysisMorphologyPlugin 20 | true 21 | false 22 | true 23 | 24 | 25 | 26 | 27 | 28 | The Apache Software License, Version 2.0 29 | http://www.apache.org/licenses/LICENSE-2.0.txt 30 | repo 31 | 32 | 33 | 34 | 35 | 36 | Medcl 37 | medcl@elastic.co 38 | elastic 39 | http://www.elastic.co 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.sonatype.oss 47 | oss-parent 48 | 9 49 | 50 | 51 | 52 | 53 | oss.sonatype.org 54 | https://oss.sonatype.org/content/repositories/snapshots 55 | 56 | 57 | oss.sonatype.org 58 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 59 | 60 | 61 | 62 | 63 | 64 | oss.sonatype.org 65 | OSS Sonatype 66 | 67 | true 68 | 69 | 70 | true 71 | 72 | https://oss.sonatype.org/content/repositories/releases/ 73 | 74 | 75 | 76 | 77 | 78 | org.apache.lucene.morphology 79 | morph 80 | 1.5 81 | ${basedir}/lib/morph-1.5.jar 82 | system 83 | 84 | 85 | org.apache.lucene.morphology 86 | russian-morphology 87 | 1.5 88 | ${basedir}/lib/russian-1.5.jar 89 | system 90 | 91 | 92 | org.apache.lucene.morphology 93 | english-morphology 94 | 1.5 95 | ${basedir}/lib/english-1.5.jar 96 | system 97 | 98 | 99 | 100 | org.elasticsearch 101 | elasticsearch 102 | ${elasticsearch.version} 103 | compile 104 | 105 | 106 | 107 | org.apache.logging.log4j 108 | log4j-api 109 | 2.17.2 110 | 111 | 112 | 113 | 114 | 115 | 116 | org.apache.maven.plugins 117 | maven-compiler-plugin 118 | 3.5.1 119 | 120 | ${maven.compiler.target} 121 | ${maven.compiler.target} 122 | 123 | 124 | 125 | org.apache.maven.plugins 126 | maven-surefire-plugin 127 | 2.19.1 128 | 129 | 130 | org.apache.maven.plugins 131 | maven-source-plugin 132 | 2.1.2 133 | 134 | 135 | attach-sources 136 | 137 | jar 138 | 139 | 140 | 141 | 142 | 143 | maven-assembly-plugin 144 | 2.3 145 | 146 | false 147 | ${project.build.directory}/releases/ 148 | 149 | ${basedir}/src/main/assemblies/plugin.xml 150 | 151 | 152 | 153 | 154 | package 155 | 156 | single 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | disable-java8-doclint 167 | 168 | [1.8,) 169 | 170 | 171 | -Xdoclint:none 172 | 173 | 174 | 175 | release 176 | 177 | 178 | 179 | org.sonatype.plugins 180 | nexus-staging-maven-plugin 181 | 1.6.3 182 | true 183 | 184 | oss 185 | https://oss.sonatype.org/ 186 | true 187 | 188 | 189 | 190 | org.apache.maven.plugins 191 | maven-release-plugin 192 | 2.1 193 | 194 | true 195 | false 196 | release 197 | deploy 198 | 199 | 200 | 201 | org.apache.maven.plugins 202 | maven-compiler-plugin 203 | 3.5.1 204 | 205 | ${maven.compiler.target} 206 | ${maven.compiler.target} 207 | 208 | 209 | 210 | org.apache.maven.plugins 211 | maven-gpg-plugin 212 | 1.5 213 | 214 | 215 | sign-artifacts 216 | verify 217 | 218 | sign 219 | 220 | 221 | 222 | 223 | 224 | org.apache.maven.plugins 225 | maven-source-plugin 226 | 2.2.1 227 | 228 | 229 | attach-sources 230 | 231 | jar-no-fork 232 | 233 | 234 | 235 | 236 | 237 | org.apache.maven.plugins 238 | maven-javadoc-plugin 239 | 2.9 240 | 241 | 242 | attach-javadocs 243 | 244 | jar 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. --------------------------------------------------------------------------------