Skip to content

Commit

Permalink
Merge pull request #192 from neelsmith/dev
Browse files Browse the repository at this point in the history
Fixes a bug in dental phonology
  • Loading branch information
neelsmith authored Aug 18, 2023
2 parents f0dd292 + 89b3b47 commit a886b5b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PolytonicGreek"
uuid = "72b824a7-2b4a-40fa-944c-ac4f345dc63a"
authors = ["Neel Smith <dnsmith.neel@gmail.com>"]
version = "0.21.3"
version = "0.21.4"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Expand Down
7 changes: 4 additions & 3 deletions src/litgreek/lgaccentuate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ $(SIGNATURES)
"""
function accentpenult(wrd::AbstractString, accent::Symbol, ortho::LiteraryGreekOrthography = literaryGreek())
sylls = syllabify(wrd, ortho)
@debug("Accenting penult, sylls $(syll)")
@info("Accenting penult, sylls $(sylls)")
if length(sylls) < 2
@warn("accentpenult: can't accent word with fewer than two syllables $wrd")
nothing
else
pen = penult(wrd,ortho)
@debug("Get the penult: $(pen)")
@info("Get the penult: $(pen)")
sylls[end - 1] = accentsyllable(penult(wrd, ortho), accent)

strcat(ortho, sylls...)
Expand Down Expand Up @@ -223,7 +223,7 @@ additional morphological information beyond the string value of the token.
"""
function accentword(wrd::AbstractString, placement::Symbol, ortho::LiteraryGreekOrthography = literaryGreek())
sylls = syllabify(wrd, ortho)
@debug("Acccent syllabified $(wrd) to $(sylls)")
@info("Acccent syllabified $(wrd) to $(sylls)")
ult = ultima(wrd, ortho)
if placement == :PENULT
if length(sylls) < 2
Expand All @@ -247,6 +247,7 @@ function accentword(wrd::AbstractString, placement::Symbol, ortho::LiteraryGreek
nothing
else
if length(sylls) == 2
@info("2 sylls, so again invoke accentword but now with syll specified as penult")
accentword(wrd, :PENULT)

elseif finallong(ult, ortho)
Expand Down
18 changes: 14 additions & 4 deletions src/litgreek/lgstrcat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function strcat(ortho::LiteraryGreekOrthography, s1::AbstractString,s2::Abstract
@debug("Strcatting $(s1) and $(s2)")
part2 = rmbreathing(s2, ortho)
s1 = elision ? elide(s1, part2, ortho) : s1
@debug("strcat: After elision, s1 is ", s1)
@info("strcat: After elision, s1 is ", s1)

if isempty(s1)
s2
Expand All @@ -23,6 +23,7 @@ function strcat(ortho::LiteraryGreekOrthography, s1::AbstractString,s2::Abstract
lg_appendtolabial(s1,part2) |> nfkc

elseif occursin(r"[τδθ]$", s1)
@info("Cat")
lg_appendtodental(s1,part2) |> nfkc

elseif occursin(r"[κγχ]$", s1)
Expand Down Expand Up @@ -139,12 +140,17 @@ end
$(SIGNATURES)
"""
function lg_appendtodental(s1::AbstractString, s2::AbstractString)
@info("Appending dental $(s1) and $(s2)")

# Aspirate dental if next syllable starts with rough breathing:
if lginitialrough(s2)
indices = collect(eachindex(s1))
quit = indices[end - 1]
@debug("Reducing s1 to ",string(s1[1:quit],"θ"))
string(s1[1:quit],"θ", rmbreathing(s2,literaryGreek()))

# if next syllable starts with σθ, drop σ
# and aspirate dental
elseif startswith(s2, "σθ")
indices1 = collect(eachindex(s1))
quit1 = indices1[end - 1]
Expand All @@ -154,12 +160,16 @@ function lg_appendtodental(s1::AbstractString, s2::AbstractString)

string(s1[1:quit1], aspirate(s1[indices1[end]]), s2[start2:end] )

elseif ! occursin(r"^[τδθ]", s2)
s1 * s2
else
# when an aspirated dental is followed by another dental,
# replace it with ς
elseif endswith(s1, "θ") && occursin(r"^[τδθ]", s2)
indices = collect(eachindex(s1))
quit = indices[end - 1]
string(s1[1:quit],"σ", s2)

# Just cat the two together:
else
s1 * s2
end
end

Expand Down
1 change: 1 addition & 0 deletions test/test_accentuation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@ end
lg = literaryGreek()
@test accentword("ἐν#κελευω", :RECESSIVE, lg) == nfkc("ἐγκελεύω")
@test accentword("νοηματος", :RECESSIVE, lg) == nfkc("νοήματος")
@test accentword("πραττω", :RECESSIVE, lg) == nfkc("πράττω")
end

0 comments on commit a886b5b

Please sign in to comment.