Skip to content

Commit

Permalink
Phonetic descriptions improved for a better code (#817)
Browse files Browse the repository at this point in the history
* Merge branch 'upstream-master' of C:\Users\clement_besnier\PycharmProjects\cltk_clemsciences with conflicts.

* before and after must be lists

* before and after must be lists

* Major use of Enum with the auto name function

* utils.py update applied to Old Norse

* Improved a little Old Swedish docs for phonetic transcription

* Phonetic transcriptions updated

* Old Norse, Old Swedish, Gothic phonetic transcriptions updated

* before and after do not have to be lists, for now

* Update .gitignore

* Revert "Update .gitignore"

This reverts commit b445368

* Revert: Major use of Enum with the auto name function

* Code updated

* Uncommented tests

* Uncommented tests

* before and after must be lists

* Major use of Enum with the auto name function

* utils.py update applied to Old Norse

* Improved a little Old Swedish docs for phonetic transcription

* Phonetic transcriptions updated

* Old Norse, Old Swedish, Gothic phonetic transcriptions updated

* before and after do not have to be lists, for now

* Update .gitignore

* Revert "Update .gitignore"

This reverts commit b445368

* Revert: Major use of Enum with the auto name function

* Code updated

* Uncommented tests

* Uncommented tests

* re-commits things already committed
  • Loading branch information
clemsciences authored and kylepjohnson committed Aug 8, 2018
1 parent a447fb1 commit 3fb1fb5
Show file tree
Hide file tree
Showing 5 changed files with 341 additions and 296 deletions.
114 changes: 57 additions & 57 deletions cltk/phonology/gothic/transcription.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,49 +37,49 @@

__author__ = ["Clément Besnier <clemsciences@gmail.com>"]

a = Vowel("open", "front", False, "short", "a")
a = Vowel(Height.open, Backness.front, False, Length.short, "a")
long_a = a.lengthen()
ee = Vowel("open-mid", "front", False, "short", "ɛ")
ee = Vowel(Height.open_mid, Backness.front, False, Length.short, "ɛ")
long_ee = ee.lengthen()
e = Vowel("close-mid", "front", False, "short", "e")
e = Vowel(Height.close_mid, Backness.front, False, Length.short, "e")
long_e = e.lengthen()
i = Vowel("close", "front", False, "short", "i")
i = Vowel(Height.close, Backness.front, False, Length.short, "i")
long_i = i.lengthen()
y = Vowel("close", "front", True, "short", "y")
oo = Vowel("open-mid", "back", True, "short", "ɔ")
y = Vowel(Height.close, Backness.front, True, Length.short, "y")
oo = Vowel(Height.open_mid, Backness.back, True, Length.short, "ɔ")
long_oo = oo.lengthen()
o = Vowel("close-mid", "back", True, "short", "o")
o = Vowel(Height.close_mid, Backness.back, True, Length.short, "o")
long_o = o.lengthen()
u = Vowel("close", "back", True, "short", "u")
u = Vowel(Height.close, Backness.back, True, Length.short, "u")
long_u = u.lengthen()

b = Consonant("bilabial", "stop", True, "b", False)
bh = Consonant("bilabial", "frictative", True, "β", False)
d = Consonant("alveolar", "stop", True, "d", False)
f = Consonant("labio-dental", "frictative", False, "f", False)
g = Consonant("velar", "stop", True, "g", False)
gh = Consonant("velar", "frictative", True, "Ɣ", False)
h = Consonant("glottal", "frictative", False, "h", False)
j = Consonant("palatal", "frictative", True, "j", False)
k = Consonant("velar", "stop", False, "k", False)
kh = Consonant("velar", "frictative", False, "", False)
l = Consonant("alveolar", "lateral", True, "l", False)
m = Consonant("bilabial", "nasal", True, "m", False)
n = Consonant("labio-dental", "nasal", True, "n", False)
ng = Consonant("velar", "nasal", True, "ŋ", False)
p = Consonant("bilabial", "stop", False, "p", False)
ph = Consonant("bilabial", "frictative", False, "ɸ", False)
r = Consonant("alveolar", "trill", False, "r", False)
s = Consonant("alveolar", "frictative", False, "s", False)
t = Consonant("alveolar", "stop", False, "t", False)
v = Consonant("labio-dental", "frictative", True, "v", False)
w = Consonant("bilabial", "spirant", True, "w", False)
b = Consonant(Place.bilabial, Manner.stop, True, "b", False)
bh = Consonant(Place.bilabial, Manner.fricative, True, "β", False)
d = Consonant(Place.alveolar, Manner.stop, True, "d", False)
f = Consonant(Place.labio_dental, Manner.fricative, False, "f", False)
g = Consonant(Place.velar, Manner.stop, True, "g", False)
gh = Consonant(Place.velar, Manner.fricative, True, "Ɣ", False)
h = Consonant(Place.glottal, Manner.fricative, False, "h", False)
j = Consonant(Place.palatal, Manner.fricative, True, "j", False)
k = Consonant(Place.velar, Manner.stop, False, "k", False)
kh = Consonant(Place.velar, Manner.fricative, False, "x", False)
l = Consonant(Place.alveolar, Manner.lateral, True, "l", False)
m = Consonant(Place.bilabial, Manner.nasal, True, "m", False)
n = Consonant(Place.labio_dental, Manner.nasal, True, "n", False)
ng = Consonant(Place.velar, Manner.nasal, True, "ŋ", False)
p = Consonant(Place.bilabial, Manner.stop, False, "p", False)
ph = Consonant(Place.bilabial, Manner.fricative, False, "ɸ", False)
r = Consonant(Place.alveolar, Manner.trill, False, "r", False)
s = Consonant(Place.alveolar, Manner.fricative, False, "s", False)
t = Consonant(Place.alveolar, Manner.stop, False, "t", False)
v = Consonant(Place.labio_dental, Manner.fricative, True, "v", False)
w = Consonant(Place.bilabial, Manner.spirant, True, "w", False)
x = k + s
z = Consonant("alveolar", "frictative", True, "z", False)
# θ = Consonant("dental", "frictative", False, "θ")
th = Consonant("dental", "frictative", False, "θ", False)
# ð = Consonant("dental", "frictative", True, "ð")
dh = Consonant("dental", "frictative", True, "ð", False)
z = Consonant(Place.alveolar, Manner.fricative, True, "z", False)
# θ = Consonant(Place.dental, Manner.frictative, False, "θ")
th = Consonant(Place.dental, Manner.fricative, False, "θ", False)
# ð = Consonant(Place.dental, Manner.frictative, True, "ð")
dh = Consonant(Place.dental, Manner.fricative, True, "ð", False)

GOTHIC_PHONOLOGY = [
a, ee, e, i, y, oo, u, long_a, long_e, long_ee, long_i, long_oo, long_o, long_u,
Expand All @@ -96,7 +96,7 @@
}
# Wrong diphthongs implementation but not that bad for now
DIPHTHONGS_IPA_class = {
"iu": Vowel("open", "front", True, "short", "iu"),
"iu": Vowel(Height.open, Backness.front, True, Length.short, "iu"),
"ai": ee,
"ei": i.lengthen(),
"au": oo
Expand Down Expand Up @@ -229,46 +229,46 @@
gothic_rules = []

gothic_rules_i = [
Rule(AbstractPosition("first", None, [AbstractVowel()]), i, j),
Rule(AbstractPosition(Rank.first, None, [AbstractVowel()]), i, j),
]


gothic_rules_b = [
Rule(AbstractPosition("first", None, []), b, b),
Rule(AbstractPosition("inner", [n.to_abstract(), m.to_abstract()], []), b, b),
Rule(AbstractPosition("inner", [r.to_abstract(), l.to_abstract()], []), b, b),
Rule(AbstractPosition("inner", [AbstractVowel()], [AbstractVowel()]), b, bh),
Rule(AbstractPosition("last", [], None), b, ph)
Rule(AbstractPosition(Rank.first, None, []), b, b),
Rule(AbstractPosition(Rank.inner, [n.to_abstract(), m.to_abstract()], []), b, b),
Rule(AbstractPosition(Rank.inner, [r.to_abstract(), l.to_abstract()], []), b, b),
Rule(AbstractPosition(Rank.inner, [AbstractVowel()], [AbstractVowel()]), b, bh),
Rule(AbstractPosition(Rank.last, [], None), b, ph)
]

gothic_rules_d = [
Rule(AbstractPosition("first", None, []), d, d),
Rule(AbstractPosition("inner", [n.to_abstract(), m.to_abstract()], []), d, d),
Rule(AbstractPosition("inner", [r.to_abstract(), l.to_abstract()], []), d, d),
Rule(AbstractPosition("inner", [AbstractVowel()], [AbstractVowel()]), d, dh),
Rule(AbstractPosition("last", [], None), b, th)
Rule(AbstractPosition(Rank.first, None, []), d, d),
Rule(AbstractPosition(Rank.inner, [n.to_abstract(), m.to_abstract()], []), d, d),
Rule(AbstractPosition(Rank.inner, [r.to_abstract(), l.to_abstract()], []), d, d),
Rule(AbstractPosition(Rank.inner, [AbstractVowel()], [AbstractVowel()]), d, dh),
Rule(AbstractPosition(Rank.last, [], None), b, th)
]

gothic_rules_g = [
Rule(AbstractPosition("first", None, None), g, g),
Rule(AbstractPosition("inner", [n.to_abstract(), m.to_abstract()], None), g, g),
Rule(AbstractPosition("inner", [r.to_abstract(), l.to_abstract()], None), g, g),
Rule(AbstractPosition("inner", [AbstractVowel()], [AbstractVowel()]), g, gh),
Rule(AbstractPosition("last", [], None), b, kh)
Rule(AbstractPosition(Rank.first, None, None), g, g),
Rule(AbstractPosition(Rank.inner, [n.to_abstract(), m.to_abstract()], None), g, g),
Rule(AbstractPosition(Rank.inner, [r.to_abstract(), l.to_abstract()], None), g, g),
Rule(AbstractPosition(Rank.inner, [AbstractVowel()], [AbstractVowel()]), g, gh),
Rule(AbstractPosition(Rank.last, [], None), b, kh)
]
gothic_rules_s = [
Rule(AbstractPosition("first", None, None), s, z),
Rule(AbstractPosition(Rank.first, None, None), s, z),
]
gothic_rules_ks = [
Rule(AbstractPosition("first", None, [AbstractConsonant()]), x, k),
Rule(AbstractPosition("inner", [], [AbstractConsonant()]), x, k),
Rule(AbstractPosition(Rank.first, None, [AbstractConsonant()]), x, k),
Rule(AbstractPosition(Rank.inner, [], [AbstractConsonant()]), x, k),
]


gothic_rules_h = [
Rule(AbstractPosition("first", None, [AbstractVowel()]), h, h),
Rule(AbstractPosition("first", None, [AbstractConsonant()]), h, kh),
Rule(AbstractPosition("inner", [], [s.to_abstract(), t.to_abstract()]), h, h),
Rule(AbstractPosition(Rank.first, None, [AbstractVowel()]), h, h),
Rule(AbstractPosition(Rank.first, None, [AbstractConsonant()]), h, kh),
Rule(AbstractPosition(Rank.inner, [], [s.to_abstract(), t.to_abstract()]), h, h),

]

Expand Down
100 changes: 50 additions & 50 deletions cltk/phonology/old_norse/transcription.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,38 @@
__author__ = ["Clément Besnier <clemsciences@gmail.com>"]


a = Vowel("open", "front", False, "short", "a")
ee = Vowel("open-mid", "front", False, "short", "ɛ")
e = Vowel("close-mid", "front", False, "short", "e")
oee = Vowel("close-mid", "front", True, "short", "ø")
oe = Vowel("open-mid", "front", True, "short", "œ")
i = Vowel("close", "front", False, "short", "i")
y = Vowel("close", "front", True, "short", "y")
ao = Vowel("open", "back", True, "short", "ɒ")
oo = Vowel("open-mid", "back", True, "short", "ɔ")
o = Vowel("close-mid", "back", True, "short", "o")
u = Vowel("close", "back", True, "short", "u")
a = Vowel(Height.open, Backness.front, False, Length.short, "a")
ee = Vowel(Height.open_mid, Backness.front, False, Length.short, "ɛ")
e = Vowel(Height.close_mid, Backness.front, False, Length.short, "e")
oee = Vowel(Height.close_mid, Backness.front, True, Length.short, "ø")
oe = Vowel(Height.open_mid, Backness.front, True, Length.short, "œ")
i = Vowel(Height.close, Backness.front, False, Length.short, "i")
y = Vowel(Height.close, Backness.front, True, Length.short, "y")
ao = Vowel(Height.open, Backness.back, True, Length.short, "ɒ")
oo = Vowel(Height.open_mid, Backness.back, True, Length.short, "ɔ")
o = Vowel(Height.close_mid, Backness.back, True, Length.short, "o")
u = Vowel(Height.close, Backness.back, True, Length.short, "u")

b = Consonant("bilabial", "stop", True, "b", False)
d = Consonant("alveolar", "stop", True, "d", False)
f = Consonant("labio-dental", "frictative", False, "f", False)
g = Consonant("velar", "stop", True, "g", False)
gh = Consonant("velar", "frictative", True, "ɣ", False)
h = Consonant("glottal", "frictative", False, "h", False)
j = Consonant("palatal", "frictative", True, "j", False)
k = Consonant("velar", "stop", False, "k", False)
l = Consonant("alveolar", "lateral", True, "l", False)
m = Consonant("bilabial", "nasal", True, "m", False)
n = Consonant("labio-dental", "nasal", True, "n", False)
p = Consonant("bilabial", "stop", False, "p", False)
r = Consonant("alveolar", "trill", True, "r", False)
s = Consonant("alveolar", "frictative", False, "s", False)
t = Consonant("alveolar", "stop", False, "t", False)
v = Consonant("labio-dental", "frictative", True, "v", False)
# θ = Consonant("dental", "frictative", False, "θ")
th = Consonant("dental", "frictative", False, "θ", False)
# ð = Consonant("dental", "frictative", True, "ð")
dh = Consonant("dental", "frictative", True, "ð", False)
b = Consonant(Place.bilabial, Manner.stop, True, "b", False)
d = Consonant(Place.alveolar, Manner.stop, True, "d", False)
f = Consonant(Place.labio_dental, Manner.fricative, False, "f", False)
g = Consonant(Place.velar, Manner.stop, True, "g", False)
gh = Consonant(Place.velar, Manner.fricative, True, "ɣ", False)
h = Consonant(Place.glottal, Manner.fricative, False, "h", False)
j = Consonant(Place.palatal, Manner.fricative, True, "j", False)
k = Consonant(Place.velar, Manner.stop, False, "k", False)
l = Consonant(Place.alveolar, Manner.lateral, True, "l", False)
m = Consonant(Place.bilabial, Manner.nasal, True, "m", False)
n = Consonant(Place.labio_dental, Manner.nasal, True, "n", False)
p = Consonant(Place.bilabial, Manner.stop, False, "p", False)
r = Consonant(Place.alveolar, Manner.trill, True, "r", False)
s = Consonant(Place.alveolar, Manner.fricative, False, "s", False)
t = Consonant(Place.alveolar, Manner.stop, False, "t", False)
v = Consonant(Place.labio_dental, Manner.fricative, True, "v", False)
# θ = Consonant(Place.dental, Manner.frictative, False, "θ")
th = Consonant(Place.dental, Manner.fricative, False, "θ", False)
# ð = Consonant(Place.dental, Manner.frictative, True, "ð")
dh = Consonant(Place.dental, Manner.fricative, True, "ð", False)

OLD_NORSE8_PHONOLOGY = [
a, ee, e, oe, i, y, ao, oo, u, a.lengthen(),
Expand All @@ -57,10 +57,10 @@
}
# Wrong diphthongs implementation but not that bad for now
DIPHTHONGS_IPA_class = {
"ey": Vowel("open", "front", True, "short", "ɐy"),
"au": Vowel("open", "back", True, "short", "ɒu"),
"øy": Vowel("open", "front", True, "short", "ɐy"),
"ei": Vowel("open", "front", True, "short", "ɛi"),
"ey": Vowel(Height.open, Backness.front, True, Length.short, "ɐy"),
"au": Vowel(Height.open, Backness.back, True, Length.short, "ɒu"),
"øy": Vowel(Height.open, Backness.front, True, Length.short, "ɐy"),
"ei": Vowel(Height.open, Backness.front, True, Length.short, "ɛi"),
}
IPA = {
"a": "a", # Short vowels
Expand Down Expand Up @@ -156,23 +156,23 @@

# Some Old Norse rules
# The first rule which matches is retained
rule_th = [Rule(AbstractPosition("first", None, []), th, th),
Rule(AbstractPosition("inner", [], [AbstractConsonant(voiced=True)]), th, th),
Rule(AbstractPosition("inner", [AbstractConsonant(voiced=True)], []), th, th),
Rule(AbstractPosition("inner", [], []), th, dh),
Rule(AbstractPosition("last", [], None), th, dh)]
rule_th = [Rule(AbstractPosition(Rank.first, None, []), th, th),
Rule(AbstractPosition(Rank.inner, [], [AbstractConsonant(voiced=True)]), th, th),
Rule(AbstractPosition(Rank.inner, [AbstractConsonant(voiced=True)], []), th, th),
Rule(AbstractPosition(Rank.inner, [], []), th, dh),
Rule(AbstractPosition(Rank.last, [], None), th, dh)]

rule_f = [Rule(AbstractPosition("first", None, []), f, f),
Rule(AbstractPosition("inner", [], [AbstractConsonant(voiced=False)]), f, f),
Rule(AbstractPosition("inner", [AbstractConsonant(voiced=False)], []), f, f),
Rule(AbstractPosition("inner", [], []), f, v),
Rule(AbstractPosition("last", [], None), f, v)]
rule_f = [Rule(AbstractPosition(Rank.first, None, []), f, f),
Rule(AbstractPosition(Rank.inner, [], [AbstractConsonant(voiced=False)]), f, f),
Rule(AbstractPosition(Rank.inner, [AbstractConsonant(voiced=False)], []), f, f),
Rule(AbstractPosition(Rank.inner, [], []), f, v),
Rule(AbstractPosition(Rank.last, [], None), f, v)]

rule_g = [Rule(AbstractPosition("first", None, None), g, g),
Rule(AbstractPosition("inner", [n.to_abstract()], None), g, g),
Rule(AbstractPosition("inner", None, [AbstractConsonant(voiced=False)]), g, k),
Rule(AbstractPosition("inner", [], []), g, gh),
Rule(AbstractPosition("last", [], None), g, gh)]
rule_g = [Rule(AbstractPosition(Rank.first, None, None), g, g),
Rule(AbstractPosition(Rank.inner, [n.to_abstract()], None), g, g),
Rule(AbstractPosition(Rank.inner, None, [AbstractConsonant(voiced=False)]), g, k),
Rule(AbstractPosition(Rank.inner, [], []), g, gh),
Rule(AbstractPosition(Rank.last, [], None), g, gh)]

old_norse_rules = []
old_norse_rules.extend(rule_f)
Expand Down

0 comments on commit 3fb1fb5

Please sign in to comment.