├── src └── main │ ├── webapp │ ├── index.html │ ├── img │ │ └── loading.gif │ ├── WEB-INF │ │ ├── appengine-web.xml │ │ ├── logging.properties │ │ └── web.xml │ ├── css │ │ └── style.css │ └── js │ │ └── script.js │ └── java │ └── com │ └── ipeirotis │ └── readability │ ├── enums │ └── MetricType.java │ ├── endpoints │ └── ReadabilityEndpoint.java │ └── engine │ ├── SentenceExtractor.java │ ├── Syllabify.java │ └── Readability.java ├── .gitignore ├── README.md ├── pom.xml └── LICENSE /src/main/webapp/index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipeirotis/ReadabilityMetrics/HEAD/src/main/webapp/index.html -------------------------------------------------------------------------------- /src/main/webapp/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipeirotis/ReadabilityMetrics/HEAD/src/main/webapp/img/loading.gif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .settings 3 | .classpath 4 | target 5 | .idea/ 6 | 7 | *.iml 8 | *.ipr 9 | *.iws 10 | *.launch 11 | *.log 12 | -------------------------------------------------------------------------------- /src/main/java/com/ipeirotis/readability/enums/MetricType.java: -------------------------------------------------------------------------------- 1 | package com.ipeirotis.readability.enums; 2 | 3 | public enum MetricType { 4 | SMOG, FLESCH_READING, FLESCH_KINCAID, ARI, GUNNING_FOG, COLEMAN_LIAU, SMOG_INDEX, CHARACTERS, SYLLABLES, WORDS, COMPLEXWORDS, SENTENCES; 5 | } 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ReadabilityMetrics 2 | ================== 3 | 4 | ## Don't make me think 5 | 6 | * See an [online demo](https://ipeirotis-hrd.appspot.com/) 7 | 8 | ## What is it about? 9 | 10 | 11 | * Well, you can see [the wiki](https://github.com/ipeirotis/ReadabilityMetrics/wiki) 12 | 13 | ## Test and it use via RapidAPI 14 | 15 | * Please see https://rapidapi.com/ipeirotis/api/readability-metrics 16 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/appengine-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ipeirotis-hrd 4 | 1 5 | true 6 | 7 | 8 | 9 | 10 | java8 11 | false 12 | 13 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/logging.properties: -------------------------------------------------------------------------------- 1 | # A default java.util.logging configuration. 2 | # (All App Engine logging is through java.util.logging by default). 3 | # 4 | # To use this configuration, copy it into your application's WEB-INF 5 | # folder and add the following to your appengine-web.xml: 6 | # 7 | # 8 | # 9 | # 10 | # 11 | 12 | # Set the default logging level for all loggers to WARNING 13 | .level = WARNING 14 | com.ipeirotis.level=INFO -------------------------------------------------------------------------------- /src/main/webapp/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #e1ddd9; 3 | font-family: Verdana, Arial, Helvetica, SunSans-Regular, Sans-Serif; 4 | font-size: 11px; 5 | color: #564b47; 6 | padding: 20px; 7 | margin: 5px; 8 | text-align: center; 9 | } 10 | 11 | td { 12 | background-color: #e1ddd9; 13 | font-size: 11px; 14 | } 15 | 16 | textarea { 17 | background-color: #eeeeee; 18 | font-size: 11px; 19 | } 20 | 21 | #inhalt { 22 | text-align: left; 23 | vertical-align: middle; 24 | margin: 5px auto; 25 | padding: 5px; 26 | width: 700px; 27 | background-color: #ffffff; 28 | border: 1px dashed #564b47; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | index.html 10 | 11 | 12 | 13 | EndpointsServlet 14 | 15 | com.google.api.server.spi.EndpointsServlet 16 | 17 | 18 | services 19 | 20 | com.ipeirotis.readability.endpoints.ReadabilityEndpoint 21 | 22 | 23 | 24 | 25 | 26 | EndpointsServlet 27 | /_ah/api/* 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/java/com/ipeirotis/readability/endpoints/ReadabilityEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.ipeirotis.readability.endpoints; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import javax.inject.Named; 8 | 9 | import com.google.api.server.spi.config.Api; 10 | import com.google.api.server.spi.config.ApiMethod; 11 | import com.google.api.server.spi.config.ApiMethod.HttpMethod; 12 | import com.ipeirotis.readability.engine.Readability; 13 | import com.ipeirotis.readability.enums.MetricType; 14 | 15 | @Api(name = "readability", description = "The API for readability metrics", version = "v1") 16 | public class ReadabilityEndpoint { 17 | 18 | @ApiMethod(name = "getReadabilityMetrics", path = "getReadabilityMetrics", httpMethod = HttpMethod.POST) 19 | public Map get(@Named("text") String text) { 20 | Map result = new HashMap(); 21 | Readability r = new Readability(text); 22 | 23 | for (MetricType metricType : MetricType.values()) { 24 | BigDecimal value = new BigDecimal(Double.toString(r.getMetric(metricType))); 25 | value = value.setScale(3, BigDecimal.ROUND_HALF_UP); 26 | result.put(metricType, value); 27 | } 28 | 29 | return result; 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/main/webapp/js/script.js: -------------------------------------------------------------------------------- 1 | var ReadabilityMetricsModule = (function() { 2 | return { 3 | init: function() { 4 | var self = this; 5 | 6 | $('#calculate-button').on('click', function() { 7 | self.getReadabilityMetrics($("#text").val()); 8 | }); 9 | 10 | self.getReadabilityMetrics($("#text").val()); 11 | }, 12 | 13 | getReadabilityMetrics: function(text) { 14 | var self = this; 15 | $('#loading').show(); 16 | 17 | $.ajax({ 18 | type: 'POST', 19 | url: self.getApiUrl() + '?text=' + encodeURIComponent(text), 20 | contentType: "application/json", 21 | dataType: 'json' 22 | }).done(function(metrics) { 23 | for(var id in metrics){ 24 | if(metrics.hasOwnProperty(id)){ 25 | $("#metric-" + id).text(metrics[id]); 26 | } 27 | } 28 | $("td span").fadeIn(); 29 | $('#loading').hide(); 30 | }).fail(function(jqXHR, textStatus, errorThrown) { 31 | console.log(errorThrown); 32 | $('#loading').hide(); 33 | }); 34 | }, 35 | 36 | getApiUrl: function() { 37 | var path = '/_ah/api/readability/v1/getReadabilityMetrics'; 38 | if (/^localhost/.test(window.location.host)) { 39 | return 'http://' + window.location.host + path; 40 | } else { 41 | return 'https://' + window.location.host + path; 42 | } 43 | } 44 | 45 | }; 46 | }()); -------------------------------------------------------------------------------- /src/main/java/com/ipeirotis/readability/engine/SentenceExtractor.java: -------------------------------------------------------------------------------- 1 | package com.ipeirotis.readability.engine; 2 | 3 | import java.util.ArrayList; 4 | 5 | import com.aliasi.sentences.IndoEuropeanSentenceModel; 6 | import com.aliasi.sentences.SentenceModel; 7 | import com.aliasi.tokenizer.IndoEuropeanTokenizerFactory; 8 | import com.aliasi.tokenizer.Tokenizer; 9 | import com.aliasi.tokenizer.TokenizerFactory; 10 | 11 | /** Use SentenceModel to find sentence boundaries in text */ 12 | public class SentenceExtractor { 13 | 14 | final TokenizerFactory TOKENIZER_FACTORY = new IndoEuropeanTokenizerFactory(); 15 | final SentenceModel SENTENCE_MODEL = new IndoEuropeanSentenceModel(); 16 | 17 | public String[] getSentences(String text) { 18 | ArrayList tokenList = new ArrayList(); 19 | ArrayList whiteList = new ArrayList(); 20 | Tokenizer tokenizer = TOKENIZER_FACTORY.tokenizer(text.toCharArray(), 0, text.length()); 21 | tokenizer.tokenize(tokenList, whiteList); 22 | 23 | String[] tokens = new String[tokenList.size()]; 24 | String[] whites = new String[whiteList.size()]; 25 | tokenList.toArray(tokens); 26 | whiteList.toArray(whites); 27 | int[] sentenceBoundaries = SENTENCE_MODEL.boundaryIndices(tokens, whites); 28 | 29 | if (sentenceBoundaries.length < 1) { 30 | return new String[0]; 31 | } 32 | 33 | String[] result = new String[sentenceBoundaries.length]; 34 | 35 | int sentStartTok = 0; 36 | int sentEndTok = 0; 37 | for (int i = 0; i < sentenceBoundaries.length; ++i) { 38 | sentEndTok = sentenceBoundaries[i]; 39 | StringBuffer sb = new StringBuffer(); 40 | for (int j = sentStartTok; j <= sentEndTok; j++) { 41 | sb.append(tokens[j] + whites[j + 1]); 42 | } 43 | result[i] = sb.toString(); 44 | sentStartTok = sentEndTok + 1; 45 | } 46 | return result; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/ipeirotis/readability/engine/Syllabify.java: -------------------------------------------------------------------------------- 1 | package com.ipeirotis.readability.engine; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | /** 6 | * @author Panos Ipeirotis 7 | * @author Steve Ash 8 | * 9 | * Java Code to estimate the number of syllables in a word. 10 | * 11 | * Translation of the Perl code by Greg Fast, found at: 12 | * http://search.cpan.org/author/GREGFAST/Lingua-EN-Syllable-0.251/ 13 | * 14 | * For documentation and comments 15 | * http://search.cpan.org/src/GREGFAST/Lingua 16 | * -EN-Syllable-0.251/Syllable.pm 17 | * 18 | * 2017-01-15 updated to EN-Syllable-0.30 and fixed regex issue 19 | * 20 | */ 21 | public class Syllabify { 22 | 23 | private static final Pattern VOWELS = Pattern.compile("[^aeiouy]+"); 24 | 25 | private static final String[] staticSubMatches = {"cial", "tia", "cius", "cious", "giu", "ion", "iou"}; 26 | private static final Pattern[] regexSubMatches = { 27 | Pattern.compile(".*sia$"), 28 | Pattern.compile(".*.ely$"), 29 | Pattern.compile(".*[^td]ed$") 30 | }; 31 | 32 | private static final String[] staticAddMatches = {"ia", "riet", "dien", "iu", "io", "ii", "microor"}; 33 | private static final Pattern[] regexAddMatches = { 34 | Pattern.compile(".*[aeiouym]bl$"), 35 | Pattern.compile(".*[aeiou]{3}.*"), 36 | Pattern.compile("^mc.*"), 37 | Pattern.compile(".*ism$"), 38 | Pattern.compile(".*isms$"), 39 | Pattern.compile(".*([^aeiouy])\\1l$"), 40 | Pattern.compile(".*[^l]lien.*"), 41 | Pattern.compile("^coa[dglx]..*"), 42 | Pattern.compile(".*[^gq]ua[^auieo].*"), 43 | Pattern.compile(".*dnt$") 44 | }; 45 | 46 | public static int syllable(String word) { 47 | 48 | word = word.toLowerCase(); 49 | if (word.equals("w")) { 50 | return 2; 51 | } 52 | if (word.length() == 1) { 53 | return 1; 54 | } 55 | word = word.replaceAll("'", " "); 56 | 57 | if (word.endsWith("e")) { 58 | word = word.substring(0, word.length() - 1); 59 | } 60 | 61 | String[] phonems = VOWELS.split(word); 62 | 63 | int syl = 0; 64 | for (int i = 0; i < staticSubMatches.length; i++) { 65 | if (word.contains(staticSubMatches[i])) { 66 | syl -= 1; 67 | } 68 | } 69 | for (int i = 0; i < regexSubMatches.length; i++) { 70 | if (regexSubMatches[i].matcher(word).matches()) { 71 | syl -= 1; 72 | } 73 | } 74 | for (int i = 0; i < staticAddMatches.length; i++) { 75 | if (word.contains(staticAddMatches[i])) { 76 | syl += 1; 77 | } 78 | } 79 | for (int i = 0; i < regexAddMatches.length; i++) { 80 | if (regexAddMatches[i].matcher(word).matches()) { 81 | syl += 1; 82 | } 83 | } 84 | 85 | for (int i = 0; i < phonems.length; i++) { 86 | if (phonems[i].length() > 0) { 87 | syl++; 88 | } 89 | } 90 | 91 | if (syl == 0) { 92 | syl = 1; 93 | } 94 | 95 | return syl; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | war 7 | 1.0-SNAPSHOT 8 | 9 | com.ipeirotis 10 | readability-metrics 11 | 12 | 13 | 1 14 | 1.9.57 15 | UTF-8 16 | 17 | 18 | 19 | 20 | 21 | com.google.appengine 22 | appengine-api-1.0-sdk 23 | ${appengine.target.version} 24 | 25 | 26 | com.google.endpoints 27 | endpoints-framework 28 | 2.0.8 29 | 30 | 31 | javax.servlet 32 | servlet-api 33 | 2.5 34 | provided 35 | 36 | 37 | jstl 38 | jstl 39 | 1.2 40 | 41 | 42 | javax.inject 43 | javax.inject 44 | 1 45 | 46 | 47 | com.alias-i 48 | lingpipe 49 | 4.1.0 50 | 51 | 52 | 53 | 54 | junit 55 | junit 56 | 4.10 57 | test 58 | 59 | 60 | org.mockito 61 | mockito-all 62 | 1.9.0 63 | test 64 | 65 | 66 | com.google.appengine 67 | appengine-testing 68 | ${appengine.target.version} 69 | test 70 | 71 | 72 | com.google.appengine 73 | appengine-api-stubs 74 | ${appengine.target.version} 75 | test 76 | 77 | 78 | 79 | 80 | ${project.build.directory}/${project.build.finalName}/WEB-INF/classes 81 | 82 | 83 | org.apache.maven.plugins 84 | 3.7.0 85 | maven-compiler-plugin 86 | 87 | 1.8 88 | 1.8 89 | 90 | 91 | 92 | 93 | org.apache.maven.plugins 94 | maven-war-plugin 95 | 2.3 96 | 97 | true 98 | 99 | 100 | 101 | ${basedir}/src/main/webapp/WEB-INF 102 | true 103 | WEB-INF 104 | 105 | 106 | 107 | 108 | 109 | 110 | com.google.appengine 111 | appengine-maven-plugin 112 | ${appengine.target.version} 113 | 114 | 115 | -Ddatastore.backing_store=${project.basedir}/local_db.bin 116 | 117 | 118 | 119 | 120 | com.google.cloud.tools 121 | endpoints-framework-maven-plugin 122 | 1.0.0 123 | 124 | http://ipeirotis-hrd.appspot.com 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /src/main/java/com/ipeirotis/readability/engine/Readability.java: -------------------------------------------------------------------------------- 1 | package com.ipeirotis.readability.engine; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import com.ipeirotis.readability.enums.MetricType; 6 | 7 | /** 8 | * Implements various readability indexes 9 | * 10 | * @author Panos Ipeirotis 11 | * 12 | */ 13 | public class Readability { 14 | 15 | private static SentenceExtractor se = new SentenceExtractor(); 16 | 17 | Integer sentences; 18 | 19 | Integer complex; 20 | 21 | Integer words; 22 | 23 | Integer syllables; 24 | 25 | Integer characters; 26 | 27 | public double getMetric(MetricType t) throws IllegalArgumentException { 28 | 29 | switch (t) { 30 | case SMOG: 31 | return getSMOG(); 32 | case FLESCH_READING: 33 | return getFleschReadingEase(); 34 | case FLESCH_KINCAID: 35 | return getFleschKincaidGradeLevel(); 36 | case ARI: 37 | return getARI(); 38 | case GUNNING_FOG: 39 | return getGunningFog(); 40 | case COLEMAN_LIAU: 41 | return getColemanLiau(); 42 | case SMOG_INDEX: 43 | return getSMOGIndex(); 44 | case CHARACTERS: 45 | return getCharacters(); 46 | case SYLLABLES: 47 | return getSyllables(); 48 | case WORDS: 49 | return getWords(); 50 | case COMPLEXWORDS: 51 | return getComplex(); 52 | case SENTENCES: 53 | return getSentences(); 54 | 55 | default: 56 | throw new IllegalArgumentException("Readability Metric '" 57 | + t.toString() + "' not supported"); 58 | } 59 | } 60 | 61 | private int getCharacters() { 62 | return characters; 63 | } 64 | 65 | private int getComplex() { 66 | return complex; 67 | } 68 | 69 | private int getSentences() { 70 | return sentences; 71 | } 72 | 73 | private int getSyllables() { 74 | return syllables; 75 | } 76 | 77 | private int getWords() { 78 | return words; 79 | } 80 | 81 | public Readability(String text) { 82 | 83 | // We add the "." for the sentence extractor to pick the last sentence, 84 | // if it does not end with a punctuation mark. 85 | this.sentences = getNumberOfSentences(text + "."); 86 | this.complex = getNumberOfComplexWords(text); 87 | this.words = getNumberOfWords(text); 88 | this.syllables = getNumberOfSyllables(text); 89 | this.characters = getNumberOfCharacters(text); 90 | 91 | } 92 | 93 | /** 94 | * Returns true is the word contains 3 or more syllables 95 | * 96 | * @param w 97 | * @return 98 | */ 99 | private static boolean isComplex(String w) { 100 | int syllables = Syllabify.syllable(w); 101 | return (syllables > 2); 102 | } 103 | 104 | /** 105 | * Returns the number of letter characters in the text 106 | * 107 | * @return 108 | */ 109 | private static int getNumberOfCharacters(String text) { 110 | String cleanText = cleanLine(text); 111 | String[] word = cleanText.split(" "); 112 | 113 | int characters = 0; 114 | for (String w : word) { 115 | characters += w.length(); 116 | } 117 | return characters; 118 | } 119 | 120 | /** 121 | * Returns the number of words with 3 or more syllables 122 | * 123 | * @param text 124 | * @return the number of words in the text with 3 or more syllables 125 | */ 126 | private static int getNumberOfComplexWords(String text) { 127 | String cleanText = cleanLine(text); 128 | String[] words = cleanText.split(" "); 129 | int complex = 0; 130 | for (String w : words) { 131 | if (isComplex(w)) 132 | complex++; 133 | } 134 | return complex; 135 | } 136 | 137 | private static int getNumberOfWords(String text) { 138 | String cleanText = cleanLine(text); 139 | String[] word = cleanText.split(" "); 140 | int words = 0; 141 | for (String w : word) { 142 | if (w.length() > 0) 143 | words++; 144 | } 145 | return words; 146 | } 147 | 148 | /** 149 | * Returns the total number of syllables in the words of the text 150 | * 151 | * @param text 152 | * @return the total number of syllables in the words of the text 153 | */ 154 | private static int getNumberOfSyllables(String text) { 155 | String cleanText = cleanLine(text); 156 | String[] word = cleanText.split(" "); 157 | int syllables = 0; 158 | for (String w : word) { 159 | if (w.length() > 0) { 160 | syllables += Syllabify.syllable(w); 161 | } 162 | } 163 | return syllables; 164 | } 165 | 166 | private static String cleanLine(String line) { 167 | StringBuffer buffer = new StringBuffer(); 168 | for (int i = 0; i < line.length(); i++) { 169 | char c = line.charAt(i); 170 | if (c < 128 && Character.isLetter(c)) { 171 | buffer.append(c); 172 | } else { 173 | buffer.append(' '); 174 | } 175 | } 176 | return buffer.toString().toLowerCase(); 177 | } 178 | 179 | private static int getNumberOfSentences(String text) { 180 | int l = se.getSentences(text).length; 181 | if (l > 0) 182 | return l; 183 | else if (text.length() > 0) 184 | return 1; 185 | else 186 | return 0; 187 | } 188 | 189 | /** 190 | * 191 | * http://en.wikipedia.org/wiki/SMOG_Index 192 | * 193 | * @param text 194 | * @return The SMOG index of the text 195 | */ 196 | private double getSMOGIndex() { 197 | double score = Math.sqrt(complex * (30.0 / sentences)) + 3; 198 | return round(score, 3); 199 | } 200 | 201 | /** 202 | * 203 | * http://en.wikipedia.org/wiki/SMOG 204 | * 205 | * @param text 206 | * @return Retugns the SMOG value for the text 207 | */ 208 | private double getSMOG() { 209 | double score = 1.043 * Math.sqrt(complex * (30.0 / sentences)) + 3.1291; 210 | return round(score, 3); 211 | } 212 | 213 | /** 214 | * 215 | * http://en.wikipedia.org/wiki/Flesch-Kincaid_Readability_Test 216 | * 217 | * @param text 218 | * @return Returns the Flesch_Reading Ease value for the text 219 | */ 220 | private double getFleschReadingEase() { 221 | 222 | double score = 206.835 - 1.015 * words / sentences - 84.6 * syllables 223 | / words; 224 | 225 | return round(score, 3); 226 | } 227 | 228 | /** 229 | * 230 | * http://en.wikipedia.org/wiki/Flesch-Kincaid_Readability_Test 231 | * 232 | * @param text 233 | * @return Returns the Flesch-Kincaid_Readability_Test value for the text 234 | */ 235 | private double getFleschKincaidGradeLevel() { 236 | double score = 0.39 * words / sentences + 11.8 * syllables / words 237 | - 15.59; 238 | return round(score, 3); 239 | } 240 | 241 | /** 242 | * 243 | * http://en.wikipedia.org/wiki/Automated_Readability_Index 244 | * 245 | * @param text 246 | * @return the Automated Readability Index for text 247 | */ 248 | private double getARI() { 249 | double score = 4.71 * characters / words + 0.5 * words / sentences 250 | - 21.43; 251 | return round(score, 3); 252 | } 253 | 254 | /** 255 | * 256 | * http://en.wikipedia.org/wiki/Gunning-Fog_Index 257 | * 258 | * @param text 259 | * @return the Gunning-Fog Index for text 260 | */ 261 | private double getGunningFog() { 262 | double score = 0.4 * (words / sentences + 100 * complex / words); 263 | return round(score, 3); 264 | } 265 | 266 | /** 267 | * 268 | * http://en.wikipedia.org/wiki/Coleman-Liau_Index 269 | * 270 | * @return The Coleman-Liau_Index value for the text 271 | */ 272 | private double getColemanLiau() { 273 | double score = (5.89 * characters / words) - (30 * sentences / words) 274 | - 15.8; 275 | return round(score, 3); 276 | } 277 | 278 | private static Double round(double d, int decimalPlace) { 279 | // see the Javadoc about why we use a String in the constructor 280 | // http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(double) 281 | BigDecimal bd = new BigDecimal(Double.toString(d)); 282 | bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP); 283 | return bd.doubleValue(); 284 | } 285 | } -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------