-
Notifications
You must be signed in to change notification settings - Fork 0
/
participles.jl
136 lines (102 loc) · 2.58 KB
/
participles.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
"""Finite verbs have person, number, tense, mood and voice."""
struct GMFParticiple <: GreekMorphologicalForm
tense::GMPTense
voice::GMPVoice
pgender::GMPGender
pcase::GMPCase
pnumber::GMPNumber
end
"""Participle forms are citable by Cite2Urn"""
CitableTrait(::Type{GMFParticiple}) = CitableByCite2Urn()
"""Extract tense property from `p`.
$(SIGNATURES)
"""
function gmpTense(p::GMFParticiple)
p.tense
end
"""Extract voice property from `p`.
$(SIGNATURES)
"""
function gmpVoice(p::GMFParticiple)
p.voice
end
"""Extract gender property from `p`.
$(SIGNATURES)
"""
function gmpGender(p::GMFParticiple)
p.pgender
end
"""Extract case property from `p`.
$(SIGNATURES)
"""
function gmpCase(p::GMFParticiple)
p.pcase
end
"""Extract tense property from `p`.
$(SIGNATURES)
"""
function gmpNumber(p::GMFParticiple)
p.pnumber
end
"""Compose a label for a `GMFVerbalAdjective`
$(SIGNATURES)
"""
function label(ptcpl::GMFParticiple)
join(["participle:", label(ptcpl.tense), label(ptcpl.voice), label(ptcpl.pgender), label(ptcpl.pcase), label(ptcpl.pnumber)], " ")
end
"""Compose digital code for `ptcpl`.
$(SIGNATURES)
"""
function code(ptcpl::GMFParticiple)
#PosPNTMVGCDCat
string(PARTICIPLE,"0",code(ptcpl.pnumber), code(ptcpl.tense), "0", code(ptcpl.voice), code(ptcpl.pgender), code(ptcpl.pcase), "00")
end
"""Compose a Cite2Urn for a `GMFParticiple`.
$(SIGNATURES)
"""
function urn(ptcpl::GMFParticiple)
# PosPNTMVGCDCat
Cite2Urn(BASE_MORPHOLOGY_URN * code(ptcpl))
end
"""Create a `GMFParticiple` from a string value.
$(SIGNATURES)
"""
function gmfParticiple(code::AbstractString)
morphchars = split(code, "")
pgender = gmpGender(parse(Int64, morphchars[7]))
pcase = gmpCase(parse(Int64, morphchars[8]))
pnumber = gmpNumber(parse(Int64, morphchars[3]))
ptense = gmpTense(parse(Int64, morphchars[4]))
pvoice = gmpVoice(parse(Int64, morphchars[6]))
GMFParticiple(
ptense,
pvoice,
pgender,
pcase,
pnumber
)
end
"""Create a `GMFParticiple` from a `Cite2Urn`.
$(SIGNATURES)
"""
function gmfParticiple(urn::Cite2Urn)
gmfParticiple(objectcomponent(urn))
end
"""Create a `GMFParticiple` from a `FormUrn`.
$(SIGNATURES)
"""
function gmfParticiple(f::FormUrn)
gmfParticiple(f.objectid)
end
"""Create a `GMFParticiple` from an `Analysis`.
$(SIGNATURES)
"""
function gmfParticiple(a::Analysis)
gmfParticiple(a.form)
end
"""Compose a `FormUrn` for an `GMFParticiple`.
$(SIGNATURES)
"""
function formurn(ptcpl::GMFParticiple)
FormUrn("$(COLLECTION_ID)." * code(ptcpl))
end