Created
November 30, 2011 13:48
-
-
Save vzarytovskii/1409120 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Stemmer = function ( word ) { | |
var _re = /^(разо|надо|недо|подо|пред|предо|без|бес|взо|изо|над|обо|ото|под|пра|про|до|за|на|вы|во|ко|об|не|от|па|по|су|в|о)?(.*?)(ствова|ичес|льник|льщик|льщиц|итель|тельн|анин|еват|оват|енск|инск|овит|ский|ость|янин|ение|еств|есть|тель|нича|изм|ниц|изн|ник|ист|ени|ниe|ств|чик|чиц|щик|ошк|ушк|ёшк|ышк|юшк|аст|овый|енн|онн|лив|ейш|айш|жды|учи|ючи|чив|чат|ева|ова|ыва|ива|еет|ин|то|ец|ун|ан|ян|ач|иц|их|ия|лк|ик|ни|ал|ит|ат|ев|ов|ив|ен|уч|юч|яч|шн|от|нн|ил|к|а|c|ы|и(^иб))(.*)?$/gi; | |
this.wordForm = word.toLowerCase(); | |
this.Type = function () { return typeof this.wordForm } | |
this.getRoot = function () { return this.wordForm.match("/a-z0-9/i") ? this.wordForm : this.wordForm.replace(_re,"$2"); } | |
} | |
var res = new Stemmer('турист'); | |
alert(res.getRoot()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment