Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added accentuation.make_varia #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ __pycache__
dist
.coverage
htmlcov
.idea/
venv/
.ipynb_checkpoints
*/.ipynb_checkpoints/*
*.ipynb
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ see [docs.rst](https://github.com/jtauber/greek-accentuation/blob/master/docs.rs

## Change Log

### Changed in 1.2.1

* added `accentuation.make_varia`, that changes acute in oxytona to grave

### Changed in 1.2.0

* `on_penult` will now return an oxytone rather than None if input only has one syllable
Expand Down
19 changes: 17 additions & 2 deletions docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ provided):
>>> get_accent_type('ψυχή') == OXYTONE
True

>>> get_accent_type('ψυχὴ') == VARIA
True

>>> get_accent_type('ἀγαθοῦ') == PERISPOMENON
True

Expand Down Expand Up @@ -467,6 +470,9 @@ If you want to display the type of accent you can use ``display_accent_type``:
>>> syllable_add_accent('ος', ACUTE)
'ός'

>>> syllable_add_accent('κος', GRAVE)
'κὸς'

>>> syllable_add_accent('ου', CIRCUMFLEX)
'οῦ'

Expand All @@ -477,6 +483,15 @@ If you want to display the type of accent you can use ``display_accent_type``:
>>> make_oxytone('θεος')
'θεός'

>>> make_varia('θεος')
'θεὸς'

>>> make_varia('θεός')
'θεὸς'

>>> make_varia('λόγος')
'λόγος'

This is the same as:

>>> add_accent(syllabify('θεος'), OXYTONE)
Expand Down Expand Up @@ -613,7 +628,7 @@ If the word only has one syllable, it will fall back to an oxytone:
'δός'


The ``persistent`` function will try to persist the accent from the given form:
The ``persistent`` function will try to keep an accent from a given form:

>>> persistent('ἀνθρωπος', 'ἄνθρωπος')
'ἄνθρωπος'
Expand All @@ -622,4 +637,4 @@ The ``persistent`` function will try to persist the accent from the given form:
'ἀνθρώπου'

>>> persistent('καταβαινον', 'καταβαίνων')
'καταβαῖνον'
'καταβαῖνον'
Binary file added greek_accentuation/__init__.pyc
Binary file not shown.
43 changes: 32 additions & 11 deletions greek_accentuation/accentuation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .characters import add_diacritic
from .characters import ACUTE, CIRCUMFLEX, SHORT, LONG, SMOOTH, ROUGH
from .characters import add_diacritic, remove_diacritic
from .characters import ACUTE, CIRCUMFLEX, SHORT, LONG, SMOOTH, ROUGH, GRAVE
from .syllabify import onset_nucleus_coda, syllabify, UNKNOWN, syllable_length
from .syllabify import syllable_accent, ultima, penult, antepenult

Expand All @@ -18,6 +18,7 @@ def add_accent(s, accent_type):
return "".join(s[:-pos] + [syllable_add_accent(s[-pos], accent)] + final)


VARIA = 1, GRAVE
OXYTONE = 1, ACUTE
PERISPOMENON = 1, CIRCUMFLEX
PAROXYTONE = 2, ACUTE
Expand All @@ -27,6 +28,7 @@ def add_accent(s, accent_type):

def display_accent_type(accent_type):
return {
VARIA: "varia",
OXYTONE: "oxytone",
PERISPOMENON: "perispomenon",
PAROXYTONE: "paroxytone",
Expand Down Expand Up @@ -62,21 +64,36 @@ def make_properispomenon(w):
else:
return add_accent(s, PAROXYTONE)

def make_varia(w):
s = syllabify(w)
if get_accent_type(w) == OXYTONE:
s[-1] = remove_diacritic(ACUTE)(s[-1])
return add_accent(s, VARIA)
elif get_accent_type(w) in [PAROXYTONE, PROPAROXYTONE, PERISPOMENON, PROPERISPOMENON]:
return w
else:
return add_accent(s, VARIA)

def get_accent_type(w):
u = syllable_accent(ultima(w))
if u == ACUTE:
return OXYTONE
elif u == CIRCUMFLEX:
return PERISPOMENON
p = syllable_accent(penult(w))
if p == ACUTE:
return PAROXYTONE
elif p == CIRCUMFLEX:
return PROPERISPOMENON
a = syllable_accent(antepenult(w))
if a == ACUTE:
return PROPAROXYTONE
elif u == GRAVE:
return VARIA
if len(syllabify(w)) > 1:
p = syllable_accent(penult(w))
if p == ACUTE:
return PAROXYTONE
elif p == CIRCUMFLEX:
return PROPERISPOMENON
if len(syllabify(w)) > 2:
a = syllable_accent(antepenult(w))
if a == ACUTE:
return PROPAROXYTONE
else:
return None


def possible_accentuations(
Expand Down Expand Up @@ -139,8 +156,9 @@ def on_penult(w, default_short=False):


def persistent(w, lemma, default_short=False):
w = w.replace("|", "")

w = w.replace("|", "")
get_accent_type(lemma)
place, accent = get_accent_type(lemma)
s = syllabify(w)
possible = list(possible_accentuations(s, default_short=default_short))
Expand All @@ -157,3 +175,6 @@ def persistent(w, lemma, default_short=False):
accent_type = (place2 - i, ACUTE)
break
return add_accent(s, accent_type)



Binary file added greek_accentuation/accentuation.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions greek_accentuation/characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _(text):
return _



PSILI = SMOOTH = "\u0313"
DASIA = ROUGH = "\u0314"

Expand Down
Binary file added greek_accentuation/characters.pyc
Binary file not shown.