Skip to content

Commit

Permalink
Merge pull request #188 from neelsmith/dev
Browse files Browse the repository at this point in the history
Update for new signature of `strcat`
  • Loading branch information
neelsmith authored Aug 17, 2023
2 parents 8f315b4 + cab5107 commit b6ff652
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 98 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.20.6"
version = "0.21"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Expand Down
8 changes: 4 additions & 4 deletions src/common/abstract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ modifications required by orthography `ortho`.
$(SIGNATURES)
"""
function strcat(ortho::T, s1::AbstractString,slist...) where {T <: GreekOrthography}
function strcat(ortho::T, s1::AbstractString, slist...) where {T <: GreekOrthography}
if isempty(slist)
s1
elseif length(slist) == 1
strcat(s1,slist[1],ortho)
strcat(ortho, s1,slist[1])
else
@debug("s1 is ", s1)
@debug("slist[1] is ", slist[1])
pair1 = strcat(s1, slist[1],ortho)
pair1 = strcat(ortho, s1, slist[1])
@debug("pair 1", pair1)
strcat(ortho, pair1, slist[2:end]...)
end
Expand All @@ -48,7 +48,7 @@ modifications required by orthography `ortho`.
$(SIGNATURES)
"""
function strcat(s1::AbstractString,s2::AbstractString,ortho::T) where {T <: GreekOrthography}
function strcat(ortho::T, s1::AbstractString,s2::AbstractString) where {T <: GreekOrthography}
@warn "Function strcat not defined for orthography $(typeof(ortho))"
nothing
end
Expand Down
1 change: 1 addition & 0 deletions src/litgreek/lgaccentuate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ function accentpenult(wrd::AbstractString, accent::Symbol, ortho::LiteraryGreekO
nothing
else
sylls[end - 1] = accentsyllable(penult(wrd, ortho), accent)
@debug("This is sylls: $(sylls)")
join(sylls,"")
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/litgreek/lgaugment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ function augment(s::AbstractString, ortho::LiteraryGreekOrthography)

if endswith(prepend,"εκ") || endswith(prepend,nfkc("ἐκ"))
prepend = replace(prepend, r"κ$" => "ξ")
strcat(prepend * "#", augpiece, ortho)
strcat(ortho, prepend * "#", augpiece)
else
@debug("Cat $(prepend) and $(augpiece)")
strcat(prepend * "#", augpiece, ortho)
strcat(ortho, prepend * "#", augpiece)
end

else
Expand Down
2 changes: 1 addition & 1 deletion src/litgreek/lgredupe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function reduplicate(s::AbstractString, ortho::LiteraryGreekOrthography)
if length(morphemes) > 1
@debug("More than one morpheme")
dupepiece = applyreduplication(morphemes[end], ortho)
strcat(join(morphemes[1:end-1], "#") * "#", rmbreathing(dupepiece,ortho), ortho)
strcat(ortho, join(morphemes[1:end-1], "#") * "#", rmbreathing(dupepiece,ortho))
else
applyreduplication(s, ortho)
end
Expand Down
24 changes: 11 additions & 13 deletions src/litgreek/lgstrcat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$(SIGNATURES)
"""
function strcat(s1::AbstractString,s2::AbstractString,ortho::LiteraryGreekOrthography; elision = true)
function strcat(ortho::LiteraryGreekOrthography, s1::AbstractString,s2::AbstractString; elision = true)


part2 = rmbreathing(s2, ortho)
Expand Down Expand Up @@ -37,38 +37,36 @@ function strcat(s1::AbstractString,s2::AbstractString,ortho::LiteraryGreekOrthog
end
end



"""Append string `s2` to a string ending in ν, `s1`.
$(SIGNATURES)
"""
function lg_appendtonu(s1::AbstractString, s2::AbstractString)
indices = collect(eachindex(s1))
quit = indices[end - 1]

if ! occursin(r"^[πβφψκγχξμλρ]", s2)
s1 * s2

elseif occursin(r"^[πβφ]", s2)
indices = collect(eachindex(s1))
quit = indices[end - 1]
string(s1[1:quit],"μ", s2)

elseif occursin(r"^[κγχξ]", s2)
indices = collect(eachindex(s1))
quit = indices[end - 1]
elseif occursin(r"^[κγχξ]", s2)
string(s1[1:quit],"γ", s2)

elseif startswith(s2, "μ")
indices = collect(eachindex(s1))
quit = indices[end - 1]
string(s1[1:quit],"μ", s2)

elseif startswith(s2, "λ")
indices = collect(eachindex(s1))
quit = indices[end - 1]
string(s1[1:quit],"λ", s2)

elseif startswith(s2, "ρ")
indices = collect(eachindex(s1))
quit = indices[end - 1]
string(s1[1:quit],"ρ", s2)

elseif occursin(r"^γκχ", s2)
string(s1[1:quit], "γ", s2)

end

end
Expand Down
18 changes: 9 additions & 9 deletions test/test_compounding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
ortho = literaryGreek()

s1 = "ἀπ#ἰεναι" # -> ἀπιέναι
@test strcat(PolytonicGreek.splitmorphemes(s1)..., ortho) == "ἀπιεναι"
@test strcat(ortho, PolytonicGreek.splitmorphemes(s1)...) == nfkc("ἀπιεναι")

s2 = "ἀπο#οἰσω" # -> ἀποίσω
@test strcat(PolytonicGreek.splitmorphemes(s2)..., ortho) == "ἀποισω"
@test strcat(ortho, PolytonicGreek.splitmorphemes(s2)...) == "ἀποισω"

s3 = "ἀπο#ἱημι" # -> ἀφίημι
@test strcat(PolytonicGreek.splitmorphemes(s3)..., ortho) == "ἀφιημι"
@test strcat(ortho, PolytonicGreek.splitmorphemes(s3)...) == "ἀφιημι"

s4 = "παρα#ἀγγελλω" # -> παραγγελλω
@test strcat(PolytonicGreek.splitmorphemes(s4)..., ortho) == "παραγγελλω"
@test strcat(ortho, PolytonicGreek.splitmorphemes(s4)...) == "παραγγελλω"

s5 = "μετα#ελθειν" # -> μετελθειν
@test strcat(PolytonicGreek.splitmorphemes(s5)..., ortho) == "μετελθειν"
@test strcat(ortho, PolytonicGreek.splitmorphemes(s5)...) == "μετελθειν"

s6 = "ἐπι#ἐθυμουν" # -> ἐπεθυμουν
@test strcat(PolytonicGreek.splitmorphemes(s6)..., ortho) == "ἐπεθυμουν"
@test strcat(ortho, PolytonicGreek.splitmorphemes(s6)...) == "ἐπεθυμουν"

s7 = "ἀντ#αἰρ" # -> ἀνταιρ
@test strcat(PolytonicGreek.splitmorphemes(s7)..., ortho) == "ἀνταιρ"
@test strcat(ortho, PolytonicGreek.splitmorphemes(s7)...) == "ἀνταιρ"

s8 = "ἀντ#αἱρ" # -> ἀνθαιρ
@test strcat(PolytonicGreek.splitmorphemes(s8)..., ortho) == "ἀνθαιρ"
@test strcat(ortho, PolytonicGreek.splitmorphemes(s8)...) == "ἀνθαιρ"


@test strcat("ἀπο", "ἱκνεομαι", ortho) == "ἀφικνεομαι"
@test strcat(ortho, "ἀπο", "ἱκνεομαι") == "ἀφικνεομαι"

end

Expand Down
4 changes: 2 additions & 2 deletions test/test_elision.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ end

@testset "Test string concatenation with elision" begin
ortho = literaryGreek()
@test strcat("παρα","οισω", ortho) == "παροισω"
@test strcat("παρα","οισω", ortho, elision = false) == "παραοισω"
@test strcat(ortho, "παρα","οισω") == "παροισω"
@test strcat(ortho, "παρα","οισω", elision = false) == "παραοισω"
end
16 changes: 8 additions & 8 deletions test/test_morphsim.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
@testset "Simulate phonology used in morphological generation" begin
o = literaryGreek()

ex1 = strcat("λυ", "ει", o)
ex1 = strcat(o, "λυ", "ει")
@test ex1 == "λυει"
@test accentword(ex1,:RECESSIVE, o) == "λύει"
@test accentword(ex1,:RECESSIVE) == "λύει"

dupe = reduplicate("λυ", o)
@test dupe == "λελυ"
@test accentword(strcat(dupe, "κε", o), :RECESSIVE, o) == "λέλυκε"
@test accentword(strcat(o, dupe, "κε"), :RECESSIVE) == "λέλυκε"

aug = augment("λυ", o)
@test aug == "ἐλυ"
@test accentword(strcat(aug, "ομεθα",o), :RECESSIVE, o) == "ἐλυόμεθα"
@test accentword(strcat(o, aug, "ομεθα"), :RECESSIVE) == "ἐλυόμεθα"

ex2 = strcat("ἀνα#λυ", "ει", o)
ex2 = strcat(o, "ἀνα#λυ", "ει")
@test ex2 == "ἀνα#λυει"
@test accentword(ex2,:RECESSIVE, o) == "ἀναλύει"
@test accentword(ex2,:RECESSIVE) == "ἀναλύει"

dupe2 = reduplicate("ἀνα#λυ", o)
@test dupe2 == "ἀνα#λελυ"
@test accentword(strcat(dupe2, "κε", o), :RECESSIVE, o) == "ἀναλέλυκε"
@test accentword(strcat(o, dupe2, "κε"), :RECESSIVE) == "ἀναλέλυκε"

aug2 = augment("ἀνα#λυ", o)
@test aug2 == "ἀν#ελυ"
@test accentword(strcat(aug2, "ομεθα",o), :RECESSIVE, o) == "ἀνελυόμεθα"
@test accentword(strcat(o, aug2, "ομεθα"), :RECESSIVE) == "ἀνελυόμεθα"

end
115 changes: 57 additions & 58 deletions test/test_strcat.jl
Original file line number Diff line number Diff line change
@@ -1,104 +1,103 @@
@testset "Test concatenating strings for literary Greek" begin
ortho = literaryGreek()

@test strcat("λελειπ", "μαι", ortho) == "λελειμμαι"
@test strcat("λελειπ", "σαι", ortho) == "λελειψαι"
@test strcat("λελειπ", "ται", ortho) == "λελειπται"
@test strcat(ortho, "λελειπ", "μαι") == "λελειμμαι"
@test strcat(ortho, "λελειπ", "σαι") == "λελειψαι"
@test strcat(ortho, "λελειπ", "ται") == "λελειπται"

@test strcat("τετριβ", "μαι", ortho) == "τετριμμαι"
@test strcat("τετριβ", "σαι", ortho) == "τετριψαι"
@test strcat("τετριβ", "ται", ortho) == "τετριπται"
@test strcat(ortho, "τετριβ", "μαι") == "τετριμμαι"
@test strcat(ortho, "τετριβ", "σαι") == "τετριψαι"
@test strcat(ortho, "τετριβ", "ται") == "τετριπται"


@test strcat("γεγραφ", "μαι", ortho) == "γεγραμμαι"
@test strcat("γεγραφ", "σαι", ortho) == "γεγραψαι"
@test strcat("γεγραφ", "ται", ortho) == "γεγραπται"
@test strcat(ortho, "γεγραφ", "μαι") == "γεγραμμαι"
@test strcat(ortho, "γεγραφ", "σαι") == "γεγραψαι"
@test strcat(ortho, "γεγραφ", "ται") == "γεγραπται"


@test strcat("πεπλεκ", "μαι", ortho) == "πεπλεγμαι"
@test strcat("πεπλεκ", "σαι", ortho) == "πεπλεξαι"
@test strcat("πεπλεκ", "ται", ortho) == "πεπλεκται"
@test strcat(ortho, "πεπλεκ", "μαι") == "πεπλεγμαι"
@test strcat(ortho, "πεπλεκ", "σαι") == "πεπλεξαι"
@test strcat(ortho, "πεπλεκ", "ται") == "πεπλεκται"

@test strcat("λελεγ", "μαι", ortho) == "λελεγμαι"
@test strcat("λελεγ", "σαι", ortho) == "λελεξαι"
@test strcat("λελεγ", "ται", ortho) == "λελεκται"
@test strcat(ortho, "λελεγ", "μαι") == "λελεγμαι"
@test strcat(ortho, "λελεγ", "σαι") == "λελεξαι"
@test strcat(ortho, "λελεγ", "ται") == "λελεκται"

@test strcat("βεβρεχ", "μαι", ortho) == "βεβρεγμαι"
@test strcat("βεβρεχ", "σαι", ortho) == "βεβρεξαι"
@test strcat("βεβρεχ", "ται", ortho) == "βεβρεκται"
@test strcat(ortho, "βεβρεχ", "μαι") == "βεβρεγμαι"
@test strcat(ortho, "βεβρεχ", "σαι") == "βεβρεξαι"
@test strcat(ortho, "βεβρεχ", "ται") == "βεβρεκται"


@test strcat("πεπειθ", "ται", ortho) == "πεπεισται"
@test strcat(ortho, "πεπειθ", "ται") == "πεπεισται"

@test strcat("λειπ", "σω", ortho) == "λειψω"
@test strcat("τριβ", "σω", ortho) == "τριψω"
@test strcat("γραφ", "σω", ortho) == "γραψω"
@test strcat(ortho, "λειπ", "σω") == "λειψω"
@test strcat(ortho, "τριβ", "σω") == "τριψω"
@test strcat(ortho, "γραφ", "σω") == "γραψω"


@test strcat("ἐν","πιπτω", ortho) == "ἐμπιπτω"
@test strcat("ἐν","βαλλω", ortho) == "ἐμβαλλω"
@test strcat("ἐν","φαινω", ortho) == "ἐμφαινω"
@test strcat(ortho, "ἐν","πιπτω") == "ἐμπιπτω"
@test strcat(ortho, "ἐν","βαλλω") == "ἐμβαλλω"
@test strcat(ortho, "ἐν","φαινω") == "ἐμφαινω"

@test strcat("ἐν","καλεω", ortho) == "ἐγκαλεω"
@test strcat("ἐν","γραφω", ortho) == "ἐγγραφω"
@test strcat("συν","χεω", ortho) == "συγχεω"
@test strcat("συν","ξυω", ortho) == "συγξυω"
@test strcat(ortho, "ἐν","καλεω") == "ἐγκαλεω"
@test strcat(ortho, "ἐν","γραφω") == "ἐγγραφω"
@test strcat(ortho, "συν","χεω") == "συγχεω"
@test strcat(ortho, "συν","ξυω") == "συγξυω"

@test strcat("ἐν","μενω", ortho) == "ἐμμενω"
@test strcat(ortho, "ἐν","μενω") == "ἐμμενω"

@test strcat("συν","λογος", ortho) == "συλλογος"
@test strcat("συν","ρεω", ortho) == "συρρεω"
@test strcat(ortho, "συν","λογος") == "συλλογος"
@test strcat(ortho, "συν","ρεω") == "συρρεω"


@test strcat("δεικ","σ", ortho) == "δειξ"
@test strcat(ortho, "δεικ","σ") == "δειξ"

@test strcat("συν","οἰσω", ortho) == "συνοισω"
@test strcat(ortho, "συν","οἰσω") == "συνοισω"

@test strcat("περι","οἰσω", ortho) == "περιοισω"
@test strcat(ortho, "περι","οἰσω") == "περιοισω"

@test strcat("προ","ἠγγελλε", ortho) == "προηγγελλε"
@test strcat(ortho, "προ","ἠγγελλε") == "προηγγελλε"

@test strcat("κατα","ἀγγελλω", ortho, elision = true) == "καταγγελλω"
@test strcat(ortho, "κατα","ἀγγελλω", elision = true) == "καταγγελλω"


@test strcat("κατα","αἱρεω", ortho, elision = true) == "καθαιρεω"
@test strcat(ortho, "κατα","αἱρεω", elision = true) == "καθαιρεω"

end

#=
@testset "Test working with compounds" begin
pieces = split("παρα#ἐκ#εν#φέρω","#")
@test_broken strcat(literaryGreek(), pieces...) == nfkc("παρεξεν#φέρω")
@test strcat(literaryGreek(), nfkc("ἐν"), nfkc("κελεύω")) == nfkc("ἐγκελεύω")
@test strcat(literaryGreek(), nfkc("ἐν"), "κε", nfkc("λεύ"), "ω") == nfkc("ἐγκελεύω")
end
=#



@testset "Test phonology of perfect active consonants" begin
ortho = literaryGreek()

@test strcat("γεγραπ", "μαι", ortho) == "γεγραμμαι"
@test strcat("γεγραπ", "σαι", ortho) == "γεγραψαι"
@test strcat("γεγραπ", "ται", ortho) == "γεγραπται"
@test strcat(ortho,"γεγραπ", "μαι") == "γεγραμμαι"
@test strcat(ortho,"γεγραπ", "σαι") == "γεγραψαι"
@test strcat(ortho,"γεγραπ", "ται") == "γεγραπται"

@test strcat("γεγραπ", "μεθα", ortho) == "γεγραμμεθα"
@test strcat("γεγραπ", "σθε", ortho) == "γεγραφθε"
@test strcat(ortho,"γεγραπ", "μεθα") == "γεγραμμεθα"
@test strcat(ortho,"γεγραπ", "σθε") == "γεγραφθε"


@test strcat("γεγραφ", "μαι", ortho) == "γεγραμμαι"
@test strcat("γεγραφ", "σαι", ortho) == "γεγραψαι"
@test strcat("γεγραφ", "ται", ortho) == "γεγραπται"
@test strcat(ortho,"γεγραφ", "μαι") == "γεγραμμαι"
@test strcat(ortho,"γεγραφ", "σαι") == "γεγραψαι"
@test strcat(ortho,"γεγραφ", "ται") == "γεγραπται"

@test strcat("γεγραφ", "μεθα", ortho) == "γεγραμμεθα"
@test strcat("γεγραφ", "σθε", ortho) == "γεγραφθε"
@test strcat(ortho,"γεγραφ", "μεθα") == "γεγραμμεθα"
@test strcat(ortho,"γεγραφ", "σθε") == "γεγραφθε"


@test strcat("πεπραγ", "μαι", ortho) == "πεπραγμαι"
@test strcat("πεπραγ", "σαι", ortho) == "πεπραξαι"
@test strcat("πεπραγ", "ται", ortho) == "πεπρακται"
@test strcat(ortho,"πεπραγ", "μαι") == "πεπραγμαι"
@test strcat(ortho,"πεπραγ", "σαι") == "πεπραξαι"
@test strcat(ortho,"πεπραγ", "ται") == "πεπρακται"

@test strcat("πεπραγ", "μεθα", ortho) == "πεπραγμεθα"
@test strcat("πεπραγ", "σθε", ortho) == "πεπραχθε"
@test strcat(ortho,"πεπραγ", "μεθα") == "πεπραγμεθα"
@test strcat(ortho,"πεπραγ", "σθε") == "πεπραχθε"

@test strcat("ἐβη", "", ortho) == "ἐβη"
@test strcat(ortho,"ἐβη", "") == "ἐβη"

end

0 comments on commit b6ff652

Please sign in to comment.