Skip to content

Greek Language Tools is a set of tools that will help you make easy transformations to Greek words.

License

Notifications You must be signed in to change notification settings

SStelioss/greek-language-tools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Greek Language Tools

Greek Language Tools is a set of tools that will help you make easy transformations to Greek words.

Installation

pip install greek-language-tools

Usage

Import as any other module using the name greeklt

from greeklt import *

  • capitalize(word)

Makes a word all caps without accentuation, adding dieresis when necessary:

word = "γάιδαρος"
>>> word.upper()
ΓΆΙΔΑΡΟΣ

>>> capitalize(word)
ΓΑΪΔΑΡΟΣ
  • remove_accentuation(word, modifier=0)

Removes accentuation but adds dieresis when necessary, without capitalizing:

word = "γάιδαρος"

>>> remove_accentuation(word)
γαϊδαρος

Works exceptionally well when you want to sort a list alphabetically and not based on unicode:

cities = ["Όσλο", "Λευκωσία", "Άκαμπα", "Ζυρίχη", "Ρώμη"]

>>> sorted(cities)
["Άκαμπα", "Όσλο", "Ζυρίχη", "Λευκωσία", "Ρώμη"]

>>> sorted(cities, key=remove_accentuation)
["Άκαμπα", "Ζυρίχη", "Λευκωσία", "Όσλο", "Ρώμη"]

Also contains an option to never add dieresis, enabled by setting modifier to 1:

string = "Αιδόνι"

>>> print(remove_accentuation(string))
Αιδονι
  • convert_final_s(word)

Checks last letter of each word in a string. If it is a σ it is converted into a ς (final σ):

>>> convert_final_s("Φάροσ φάρος ΦΑΡΟΣ")
Φάρος φάρος ΦΑΡΟΣ
  • greek_transliteration(word)

Transliterates a string written with latin characters into it's equivalent Greek (based on the keys of a QWERTY keyboard):

>>> greek_transliteration("fvtia")
φωτια

This can come quite in handy when a user forgets to change the language and the word looks the same both in latin and Greek:

# ANNA written in latin (Anna)
name = "ANNA"

>>> name == greek_transliteration(name)
False

# Both look the same but are different unnicode characters
>>> ANNA == ΑΝΝΑ
False

There's also the abillity to convert a word from latin to it's intended accentuated once in Greek:

>>> greek_transliteration("P;ita soybl;aki")
Πίτα σουβλάκι
>>> greek_transliteration("kaWiki")
καΐκι
>>> greek_transliteration("pro:yp;ouesh")
προϋπόθεση
>>> greek_transliteration("GA:IDAROS")
ΓΑΪΔΑΡΟΣ

Note: The function takes as given that the user intended to write the work in Greek using the correct key sequence but just didn't switch their keyboard to Greek. It doesn't convert from Greeklish!

# Wrong key sequence by user.
# They're supposed to press SHIFT + W and not just w for the ΅ character to appear.
>>> greek_transliteration("kawiki")
καςικι
  • greek_elot_Transliteration(word/sentence)

Transliterates a string according to the ELOT 743 standard, frequently used in formal transcription settings (e.g passports, ID, etc)


name = "Ελευθέριος Βενιζέλος"

>>> latin_name = greek_elot_transliteration(name)
>>> print(latin_name)
Eleftherios Venizelos

About

Greek Language Tools is a set of tools that will help you make easy transformations to Greek words.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Python 100.0%