- Notifications
You must be signed in to change notification settings - Fork7
A JavaScript library for Greek language with utilities such as replacement of accented and other diacritics characters, conversion from Greek to phonetic, transliterated or greeklish Latin and more.
License
vbarzokas/greek-utils
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A JavaScript library for Greek language with utilities such as replacement of accented and other diacritics characters,conversion from Greek to phonetic, transliterated orgreeklish Latin and more, like Greek stopwords removal.
npminstall--savegreek-utils
vargreekUtils=require('greek-utils');
Convert all diacritics symbols to their simple equivalent
Example 1 (modern Greek):
varsanitized=greekUtils.sanitizeDiacritics('Αρνάκι άσπρο και παχύ');console.log(sanitized);//Αρνακι ασπρο και παχυ
Example 2 (ancient Greek):
varsanitized=greekUtils.sanitizeDiacritics('Ἐξ οὗ καὶ δῆλον ὅτι οὐδεμία τῶν ἠθικῶν ἀρετῶν φύσει ἡμῖν ἐγγίνεται');console.log(sanitized);//Εξ ου και δηλον οτι ουδεμια των ηθικων αρετων φυσει ημιν εγγινεται
Convert a Latin character text to its modern Greek equivalent
Example:
vargreek=greekUtils.toGreek('kalhmera, pws eiste?');console.log(greek);//καλημερα, πως ειστε;
Convert a modern Greek character text to itsgreeklish equivalent
Example:
vargreeklish=greekUtils.toGreeklish('Εύηχο: αυτό που ακούγεται ωραία.');console.log(greeklish);//Euhxo: auto pou akougetai wraia.
Convert a modern Greek character text to its phonetically equivalent Latin (sound mapping).
Example:
varphoneticLatin=greekUtils.toPhoneticLatin('Εύηχο: αυτό που ακούγεται ωραία.');console.log(phoneticLatin);//Évikho: aftó pou akoúyete oréa.
Convert a modern Greek character text to its transliterated equivalent Latin (letter mapping).
Example:
vartransliteratedLatin=greekUtils.toTransliteratedLatin('Εύηχο: αυτό που ακούγεται ωραία.');console.log(transliteratedLatin);//Eúēkho: autó pou akoúgetai ōraía.
All of the above functions accept an optional second parameter as a string with characters you don't wish to be converted.
Example:
vargreeklish=greekUtils.toGreeklish('καλημερα, πως ειστε;','ε');console.log(greeklish);//kalhmεra, pws εistε?
Remove all stop words from the given text, for both ancient and modern Greek. Also accepts an optional flag, which when set totrue
will remove the multiple whitespaces that probably have occurred in the text after removing the stop words.
Note: The default value for that flag isfalse
, so multiple whitespaces are expected to be returned.
Examples:
Without stripping the extra white spaces:
varwithPreservedWhitespace=greekUtils.removeStopWords('Αυτή είναι μια απλή πρόταση, που δείχνει την αφαίρεση όλων των stopwords της αρχαίας και νέας Ελληνικής γλώσσας και επιστρέφει το καθαρό κείμενο.',false);console.log(withPreservedWhitespace);//μια απλή πρόταση, δείχνει αφαίρεση όλων stopwords αρχαίας νέας Ελληνικής γλώσσας επιστρέφει καθαρό κείμενο.
With stripping the extra white spaces:
varwithoutPreservedWhitespace=greekUtils.removeStopWords('Αυτή είναι μια απλή πρόταση, που δείχνει την αφαίρεση όλων των stopwords της αρχαίας και νέας Ελληνικής γλώσσας και επιστρέφει το καθαρό κείμενο.',true);console.log(withoutPreservedWhitespace);//μια απλή πρόταση, δείχνει αφαίρεση όλων stopwords αρχαίας νέας Ελληνικής γλώσσας επιστρέφει καθαρό κείμενο.
About
A JavaScript library for Greek language with utilities such as replacement of accented and other diacritics characters, conversion from Greek to phonetic, transliterated or greeklish Latin and more.