├── .gitignore ├── LICENSE ├── README.md ├── bower.json ├── bower_components ├── jquery │ ├── .bower.json │ ├── MIT-LICENSE.txt │ ├── bower.json │ ├── dist │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ └── jquery.min.map │ └── src │ │ ├── ajax.js │ │ ├── ajax │ │ ├── jsonp.js │ │ ├── load.js │ │ ├── parseJSON.js │ │ ├── parseXML.js │ │ ├── script.js │ │ ├── var │ │ │ ├── nonce.js │ │ │ └── rquery.js │ │ └── xhr.js │ │ ├── attributes.js │ │ ├── attributes │ │ ├── attr.js │ │ ├── classes.js │ │ ├── prop.js │ │ ├── support.js │ │ └── val.js │ │ ├── callbacks.js │ │ ├── core.js │ │ ├── core │ │ ├── access.js │ │ ├── init.js │ │ ├── parseHTML.js │ │ ├── ready.js │ │ └── var │ │ │ └── rsingleTag.js │ │ ├── css.js │ │ ├── css │ │ ├── addGetHookIf.js │ │ ├── curCSS.js │ │ ├── defaultDisplay.js │ │ ├── hiddenVisibleSelectors.js │ │ ├── support.js │ │ ├── swap.js │ │ └── var │ │ │ ├── cssExpand.js │ │ │ ├── getStyles.js │ │ │ ├── isHidden.js │ │ │ ├── rmargin.js │ │ │ └── rnumnonpx.js │ │ ├── data.js │ │ ├── data │ │ ├── Data.js │ │ ├── accepts.js │ │ └── var │ │ │ ├── data_priv.js │ │ │ └── data_user.js │ │ ├── deferred.js │ │ ├── deprecated.js │ │ ├── dimensions.js │ │ ├── effects.js │ │ ├── effects │ │ ├── Tween.js │ │ └── animatedSelector.js │ │ ├── event.js │ │ ├── event │ │ ├── ajax.js │ │ ├── alias.js │ │ └── support.js │ │ ├── exports │ │ ├── amd.js │ │ └── global.js │ │ ├── intro.js │ │ ├── jquery.js │ │ ├── manipulation.js │ │ ├── manipulation │ │ ├── _evalUrl.js │ │ ├── support.js │ │ └── var │ │ │ └── rcheckableType.js │ │ ├── offset.js │ │ ├── outro.js │ │ ├── queue.js │ │ ├── queue │ │ └── delay.js │ │ ├── selector-native.js │ │ ├── selector-sizzle.js │ │ ├── selector.js │ │ ├── serialize.js │ │ ├── sizzle │ │ └── dist │ │ │ ├── sizzle.js │ │ │ ├── sizzle.min.js │ │ │ └── sizzle.min.map │ │ ├── traversing.js │ │ ├── traversing │ │ ├── findFilter.js │ │ └── var │ │ │ └── rneedsContext.js │ │ ├── var │ │ ├── arr.js │ │ ├── class2type.js │ │ ├── concat.js │ │ ├── hasOwn.js │ │ ├── indexOf.js │ │ ├── pnum.js │ │ ├── push.js │ │ ├── rnotwhite.js │ │ ├── slice.js │ │ ├── strundefined.js │ │ ├── support.js │ │ └── toString.js │ │ └── wrap.js └── underscore │ ├── .bower.json │ ├── .eslintrc │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── bower.json │ ├── component.json │ ├── package.json │ ├── underscore-min.js │ ├── underscore-min.map │ └── underscore.js ├── dict ├── adj.exc.json ├── adv.exc.json ├── index.adj.json ├── index.adv.json ├── index.noun.json ├── index.verb.json ├── noun.exc.json └── verb.exc.json ├── html └── lemmatizer_sample.html ├── js └── lemmatizer.js └── test ├── lemmatizer_qunit.html └── lemmatizer_qunit.js /.gitignore: -------------------------------------------------------------------------------- 1 | /work 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Takafumi Yamano 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | JavaScript Lemmatizer 2 | ==== 3 | 4 | JavaScript Lemmatizer is a lemmatization library for JavaScript to retrieve a base form from an inflected form word in English. 5 | 6 | Inspired by [Ruby Lemmatizer](https://github.com/yohasebe/lemmatizer) but the returned values and the algorithm are different from it. 7 | 8 | ## Requirements 9 | 10 | Depends on Underscore.js. 11 | 12 | - [Underscore.js](http://underscorejs.org/) 13 | 14 | ## Demo 15 | 16 | A sample html is bundled in this library. The sample html code and the demo page are followings. 17 | 18 | - [lemmatizer_sample.html](https://github.com/takafumir/javascript-lemmatizer/blob/master/html/lemmatizer_sample.html) 19 | - [Demo page](http://takafumir.github.io/javascript-lemmatizer/html/lemmatizer_sample.html) 20 | 21 | The sample html code depends on jQuery. 22 | 23 | - [jQuery](http://jquery.com/) 24 | 25 | ## Check 26 | 27 | The operation check is conducted in the following web browsers with Mac OS X. 28 | 29 | - Firefox 35.0 30 | - Google Chrome 40.0 31 | - Safari 6.1.6 32 | - Opera 25.0 33 | 34 | ## Install 35 | ##### 1. Download and unzip JavaScript Lemmatizer, and then put it in your project. 36 | 37 | Directories of dict, js in JavaScript Lemmatizer are must, so you can put it in your project like this. 38 | 39 | ``` 40 | your-project 41 | ├ index.html 42 | ├ javascript-lemmatizer 43 | ├ dict 44 | ├ js 45 | ├ bower_components 46 | ├ jquery 47 | ├ underscore 48 | ``` 49 | 50 | ##### 2. Load Underscore.js and JavaScript Lemmatizer in your HTML like the following code. 51 | 52 | ```html 53 | 54 | 55 | ``` 56 | 57 | Or you can load Underscore.js the way you like. 58 | 59 | As an option, you can load jQuery, if you need it in your project. 60 | 61 | ```html 62 | 63 | 64 | 65 | ``` 66 | 67 | ##### 3. Use JavaScript Lemmatizer in your JavaScript code according to the Usage. 68 | 69 | See also. 70 | - [lemmatizer_sample.html](https://github.com/takafumir/javascript-lemmatizer/blob/master/html/lemmatizer_sample.html) 71 | - [Demo page](http://takafumir.github.io/javascript-lemmatizer/html/lemmatizer_sample.html) 72 | 73 | ## Usage 74 | 75 | You can use `Lemmatizer#lemmas` or `Lemmatizer#only_lemmas` methods like the follwoing sample in your JavaScript code. 76 | 77 | ```javascript 78 | // initialize Lemmatizer. 79 | var lemmatizer = new Lemmatizer(); 80 | 81 | // retrieve a lemma with a part of speech. 82 | // you can assign 'verb' or 'noun' or 'adj' or 'adv' as a part of speech. 83 | lemmatizer.lemmas('desks', 'noun'); // => [ ['desk', 'noun'] ] 84 | lemmatizer.lemmas('talked', 'verb'); // => [ ['talk', 'verb'] ] 85 | lemmatizer.lemmas('coded', 'verb'); // => [ ['code', 'verb'] ] 86 | 87 | // of course, available for irregular iflected form words. 88 | lemmatizer.lemmas('went', 'verb'); // => [ ['go', 'verb'] ] 89 | lemmatizer.lemmas('written', 'verb'); // => [ ['write', 'verb'] ] 90 | lemmatizer.lemmas('better', 'adj'); // => [ ['better', 'adj'], ['good', 'adj'] ] 91 | 92 | // when multiple base forms are found, return all of them. 93 | lemmatizer.lemmas('leaves', 'noun'); // => [ ['leave', 'noun'], ['leaf', 'noun'] ] 94 | 95 | // retrieve a lemma without a part of speech. 96 | lemmatizer.lemmas('sitting'); // => [ ['sit', 'verb'], ['sitting', 'noun'], ['sitting', 'adj'] ] 97 | lemmatizer.lemmas('oxen'); // => [ ['oxen', 'noun'], ['ox', 'noun'] ] 98 | lemmatizer.lemmas('leaves'); // => [ ['leave', 'verb'], ['leave', 'noun'], ['leaf', 'noun'] ] 99 | 100 | // retrieve only lemmas not including part of speeches in the returned value. 101 | lemmatizer.only_lemmas('desks', 'noun'); // => [ 'desk' ] 102 | lemmatizer.only_lemmas('coded', 'verb'); // => [ 'code' ] 103 | lemmatizer.only_lemmas('priorities'); // => [ 'priority' ] 104 | lemmatizer.only_lemmas('leaves'); // => [ 'leave', 'leaf' ] 105 | ``` 106 | 107 | See also. 108 | - [lemmatizer_sample.html](https://github.com/takafumir/javascript-lemmatizer/blob/master/html/lemmatizer_sample.html) 109 | - [Demo page](http://takafumir.github.io/javascript-lemmatizer/html/lemmatizer_sample.html) 110 | 111 | ## Limitations 112 | ```javascript 113 | // Lemmatizer leaves alone a word not included in it's dictionary index. 114 | lemmatizer.lemmas('MacBooks', 'noun'); // => [ ['MacBooks', 'noun'] ] 115 | ``` 116 | 117 | ## Changelog 118 | 119 | ##### v0.0.2 120 | 2015/01/30 121 | With v0.0.2, a returned value includes the input form word, when the input form word is included in the lemma dictionary index like the following. 122 | ```javascript 123 | lemmatizer.lemmas('matter'); // => [ ['matter', 'verb'], ['matter', 'noun'], ['matte', 'adj'], ['matt', 'adj'], ['mat', 'adj'] ] 124 | ``` 125 | 126 | With v0.0.1 127 | ```javascript 128 | lemmatizer.lemmas('matter'); // => [ ['matte', 'adj'], ['matt', 'adj'], ['mat', 'adj'] ] 129 | ``` 130 | 131 | ##### v0.0.1 132 | 2015/01/27 133 | Released JavaScript Lemmatizer v0.0.1 134 | 135 | ## Contribution 136 | 137 | 1. Fork it ( https://github.com/takafumir/javascript-lemmatizer/fork ) 138 | 1. Create your feature branch (git checkout -b my-new-feature) 139 | 1. Commit your changes (git commit -am 'Add some feature') 140 | 1. Push to the branch (git push origin my-new-feature) 141 | 1. Create a new Pull Request 142 | 143 | ## Licence 144 | 145 | [MIT License](https://github.com/takafumir/javascript-lemmatizer/blob/master/LICENSE) 146 | 147 | ## Author 148 | 149 | [Takafumi Yamano](https://github.com/takafumir) 150 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JavaScript Lemmatizer", 3 | "version": "0.0.2", 4 | "homepage": "https://github.com/takafumir/javascript-lemmatizer", 5 | "authors": [ 6 | "Takafumi Yamano" 7 | ], 8 | "description": "JavaScript Lemmatizer is a lemmatization library to retrieve a base form from an inflected form word in English.", 9 | "keywords": [ 10 | "javascript", 11 | "lemmatizer", 12 | "lemmatization" 13 | ], 14 | "license": "MIT", 15 | "ignore": [ 16 | "**/.*", 17 | "node_modules", 18 | "bower_components", 19 | "test", 20 | "tests" 21 | ], 22 | "dependencies": { 23 | "jquery": "~2.1.3", 24 | "underscore": "~1.7.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /bower_components/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "version": "2.1.3", 4 | "main": "dist/jquery.js", 5 | "license": "MIT", 6 | "ignore": [ 7 | "**/.*", 8 | "build", 9 | "speed", 10 | "test", 11 | "*.md", 12 | "AUTHORS.txt", 13 | "Gruntfile.js", 14 | "package.json" 15 | ], 16 | "devDependencies": { 17 | "sizzle": "2.1.1-jquery.2.1.2", 18 | "requirejs": "2.1.10", 19 | "qunit": "1.14.0", 20 | "sinon": "1.8.1" 21 | }, 22 | "keywords": [ 23 | "jquery", 24 | "javascript", 25 | "library" 26 | ], 27 | "homepage": "https://github.com/jquery/jquery", 28 | "_release": "2.1.3", 29 | "_resolution": { 30 | "type": "version", 31 | "tag": "2.1.3", 32 | "commit": "8f2a9d9272d6ed7f32d3a484740ab342c02541e0" 33 | }, 34 | "_source": "git://github.com/jquery/jquery.git", 35 | "_target": "~2.1.3", 36 | "_originalSource": "jquery", 37 | "_direct": true 38 | } -------------------------------------------------------------------------------- /bower_components/jquery/MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014 jQuery Foundation and other contributors 2 | http://jquery.com/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /bower_components/jquery/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "version": "2.1.3", 4 | "main": "dist/jquery.js", 5 | "license": "MIT", 6 | "ignore": [ 7 | "**/.*", 8 | "build", 9 | "speed", 10 | "test", 11 | "*.md", 12 | "AUTHORS.txt", 13 | "Gruntfile.js", 14 | "package.json" 15 | ], 16 | "devDependencies": { 17 | "sizzle": "2.1.1-jquery.2.1.2", 18 | "requirejs": "2.1.10", 19 | "qunit": "1.14.0", 20 | "sinon": "1.8.1" 21 | }, 22 | "keywords": [ 23 | "jquery", 24 | "javascript", 25 | "library" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /bower_components/jquery/src/ajax/jsonp.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "./var/nonce", 4 | "./var/rquery", 5 | "../ajax" 6 | ], function( jQuery, nonce, rquery ) { 7 | 8 | var oldCallbacks = [], 9 | rjsonp = /(=)\?(?=&|$)|\?\?/; 10 | 11 | // Default jsonp settings 12 | jQuery.ajaxSetup({ 13 | jsonp: "callback", 14 | jsonpCallback: function() { 15 | var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); 16 | this[ callback ] = true; 17 | return callback; 18 | } 19 | }); 20 | 21 | // Detect, normalize options and install callbacks for jsonp requests 22 | jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 23 | 24 | var callbackName, overwritten, responseContainer, 25 | jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 26 | "url" : 27 | typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" 28 | ); 29 | 30 | // Handle iff the expected data type is "jsonp" or we have a parameter to set 31 | if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 32 | 33 | // Get callback name, remembering preexisting value associated with it 34 | callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? 35 | s.jsonpCallback() : 36 | s.jsonpCallback; 37 | 38 | // Insert callback into url or form data 39 | if ( jsonProp ) { 40 | s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 41 | } else if ( s.jsonp !== false ) { 42 | s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 43 | } 44 | 45 | // Use data converter to retrieve json after script execution 46 | s.converters["script json"] = function() { 47 | if ( !responseContainer ) { 48 | jQuery.error( callbackName + " was not called" ); 49 | } 50 | return responseContainer[ 0 ]; 51 | }; 52 | 53 | // force json dataType 54 | s.dataTypes[ 0 ] = "json"; 55 | 56 | // Install callback 57 | overwritten = window[ callbackName ]; 58 | window[ callbackName ] = function() { 59 | responseContainer = arguments; 60 | }; 61 | 62 | // Clean-up function (fires after converters) 63 | jqXHR.always(function() { 64 | // Restore preexisting value 65 | window[ callbackName ] = overwritten; 66 | 67 | // Save back as free 68 | if ( s[ callbackName ] ) { 69 | // make sure that re-using the options doesn't screw things around 70 | s.jsonpCallback = originalSettings.jsonpCallback; 71 | 72 | // save the callback name for future use 73 | oldCallbacks.push( callbackName ); 74 | } 75 | 76 | // Call if it was a function and we have a response 77 | if ( responseContainer && jQuery.isFunction( overwritten ) ) { 78 | overwritten( responseContainer[ 0 ] ); 79 | } 80 | 81 | responseContainer = overwritten = undefined; 82 | }); 83 | 84 | // Delegate to script 85 | return "script"; 86 | } 87 | }); 88 | 89 | }); 90 | -------------------------------------------------------------------------------- /bower_components/jquery/src/ajax/load.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../core/parseHTML", 4 | "../ajax", 5 | "../traversing", 6 | "../manipulation", 7 | "../selector", 8 | // Optional event/alias dependency 9 | "../event/alias" 10 | ], function( jQuery ) { 11 | 12 | // Keep a copy of the old load method 13 | var _load = jQuery.fn.load; 14 | 15 | /** 16 | * Load a url into a page 17 | */ 18 | jQuery.fn.load = function( url, params, callback ) { 19 | if ( typeof url !== "string" && _load ) { 20 | return _load.apply( this, arguments ); 21 | } 22 | 23 | var selector, type, response, 24 | self = this, 25 | off = url.indexOf(" "); 26 | 27 | if ( off >= 0 ) { 28 | selector = jQuery.trim( url.slice( off ) ); 29 | url = url.slice( 0, off ); 30 | } 31 | 32 | // If it's a function 33 | if ( jQuery.isFunction( params ) ) { 34 | 35 | // We assume that it's the callback 36 | callback = params; 37 | params = undefined; 38 | 39 | // Otherwise, build a param string 40 | } else if ( params && typeof params === "object" ) { 41 | type = "POST"; 42 | } 43 | 44 | // If we have elements to modify, make the request 45 | if ( self.length > 0 ) { 46 | jQuery.ajax({ 47 | url: url, 48 | 49 | // if "type" variable is undefined, then "GET" method will be used 50 | type: type, 51 | dataType: "html", 52 | data: params 53 | }).done(function( responseText ) { 54 | 55 | // Save response for use in complete callback 56 | response = arguments; 57 | 58 | self.html( selector ? 59 | 60 | // If a selector was specified, locate the right elements in a dummy div 61 | // Exclude scripts to avoid IE 'Permission Denied' errors 62 | jQuery("