GithubHelp home page GithubHelp logo

vbarzokas / greek-utils Goto Github PK

View Code? Open in Web Editor NEW
85.0 7.0 7.0 40 KB

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: MIT License

JavaScript 100.00%
greek-language nodejs javascript string-manipulation utilities greeklish

greek-utils's Introduction

Greek Utilities

Build Status

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, like Greek stopwords removal.

NPM

Installation

npm install --save greek-utils

Usage

Node.js

var greekUtils = require('greek-utils');

- sanitizeDiacritics(text, [ignoreCharacters])

Convert all diacritics symbols to their simple equivalent

Example 1 (modern Greek):

var sanitized = greekUtils.sanitizeDiacritics('Αρνάκι άσπρο και παχύ');
console.log(sanitized); //Αρνακι ασπρο και παχυ

Example 2 (ancient Greek):

var sanitized = greekUtils.sanitizeDiacritics('Ἐξ οὗ καὶ δῆλον ὅτι οὐδεμία τῶν ἠθικῶν ἀρετῶν φύσει ἡμῖν ἐγγίνεται');
console.log(sanitized); //Εξ ου και δηλον οτι ουδεμια των ηθικων αρετων φυσει ημιν εγγινεται

- toGreek(text, [ignoreCharacters])

Convert a Latin character text to its modern Greek equivalent

Example:

var greek = greekUtils.toGreek('kalhmera, pws eiste?');
console.log(greek); //καλημερα, πως ειστε;

- toGreeklish(text, [ignoreCharacters])

Convert a modern Greek character text to its greeklish equivalent

Example:

var greeklish = greekUtils.toGreeklish('Εύηχο: αυτό που ακούγεται ωραία.');
console.log(greeklish); //Euhxo: auto pou akougetai wraia.

- toPhoneticLatin(text, [ignoreCharacters])

Convert a modern Greek character text to its phonetically equivalent Latin (sound mapping).

Example:

var phoneticLatin = greekUtils.toPhoneticLatin('Εύηχο: αυτό που ακούγεται ωραία.');
console.log(phoneticLatin); //Évikho: aftó pou akoúyete oréa.

- toTransliteratedLatin(text, [ignoreCharacters])

Convert a modern Greek character text to its transliterated equivalent Latin (letter mapping).

Example:

var transliteratedLatin = greekUtils.toTransliteratedLatin('Εύηχο: αυτό που ακούγεται ωραία.');
console.log(transliteratedLatin); //Eúēkho: autó pou akoúgetai ōraía.
Ignoring characters

All of the above functions accept an optional second parameter as a string with characters you don't wish to be converted.

Example:

var greeklish = greekUtils.toGreeklish('καλημερα, πως ειστε;', 'ε');
console.log(greeklish); //kalhmεra, pws εistε?

- removeStopWords(text, [shouldRemoveMultipleWhiteSpaces])

Remove all stop words from the given text, for both ancient and modern Greek. Also accepts an optional flag, which when set to true will remove the multiple whitespaces that probably have occurred in the text after removing the stop words.

Note: The default value for that flag is false, so multiple whitespaces are expected to be returned.

Examples:

  • Without stripping the extra white spaces:

    var withPreservedWhitespace = greekUtils.removeStopWords('Αυτή είναι μια απλή πρόταση, που δείχνει την αφαίρεση όλων των stopwords της αρχαίας και νέας Ελληνικής γλώσσας και επιστρέφει το καθαρό κείμενο.', false);
    
    console.log(withPreservedWhitespace); //μια απλή πρόταση,  δείχνει  αφαίρεση όλων  stopwords  αρχαίας  νέας Ελληνικής γλώσσας  επιστρέφει  καθαρό κείμενο.
  • With stripping the extra white spaces:

    var withoutPreservedWhitespace = greekUtils.removeStopWords('Αυτή είναι μια απλή πρόταση, που δείχνει την αφαίρεση όλων των stopwords της αρχαίας και νέας Ελληνικής γλώσσας και επιστρέφει το καθαρό κείμενο.', true);
    
    console.log(withoutPreservedWhitespace); //μια απλή πρόταση, δείχνει αφαίρεση όλων stopwords αρχαίας νέας Ελληνικής γλώσσας επιστρέφει καθαρό κείμενο.

greek-utils's People

Contributors

asteriosm avatar kodie avatar sebdesign avatar vagelis-prokopiou avatar vbarzokas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

greek-utils's Issues

Suggestion - ELOT 743

Hello everyone,

I want to suggest a new function based on the Greek Standard, ELOT 743 which is recognised by the EU.

Current Function

var greeklish = greekUtils.toGreeklish('Εύηχο: αυτό που ακούγεται ωραία.');
console.log(greeklish); //Euhxo: auto pou akougetai wraia.

Suggested Function (to Add)

var greeklish = greekUtils.toGreeklishELOT743('Εύηχο: αυτό που ακούγεται ωραία.');
console.log(greeklish); // Evicho: afto pou akougetai oraia.

Goverment App for Translation

Standard Documentation (in greek)


If i understand correctly, the mapping is working based on find/replace objects.
We also need to sanitize the string which is already a function.

I will do my best to provide a greek-to-greeklish-elot743-map.js.

Regards,
Alex

Suggestion

Can you do a greek to English translation method?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.