-
Notifications
You must be signed in to change notification settings - Fork 0
/
irregularinfinitivestems.jl
152 lines (113 loc) · 3.39 KB
/
irregularinfinitivestems.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
"A record for a single irregular verb stem."
struct IrregularInfinitiveStem <: KanonesIrregularStem
stemid::AbbreviatedUrn
lexid::AbbreviatedUrn
form::AbstractString
tense::GMPTense
voice::GMPVoice
inflectionclass
end
function pos(inf::IrregularInfinitiveStem)
:verb
end
"""Identify tense of `inf`.
$(SIGNATURES)
"""
function gmpTense(inf::IrregularInfinitiveStem)
inf.tense
end
"""Identify voice of `inf`.
$(SIGNATURES)
"""
function gmpVoice(inf::IrregularInfinitiveStem)
inf.voice
end
"""Irregular noun stems are citable by Cite2Urn"""
CitableTrait(::Type{IrregularInfinitiveStem}) = CitableByCite2Urn()
"""Human-readlable label for an `IrregularInfinitiveStem`.
$(SIGNATURES)
Required for `CitableTrait`.
"""
function label(inf::IrregularInfinitiveStem)
string("Irregular infinitive form ", inf.form, " (", label(inf.tense)," ", label(inf.voice), ")")
end
"""Identifying URN for an `IrregularNounStem`. If
no registry is included, use abbreviated URN;
otherwise, expand to full `Cite2Urn`.
$(SIGNATURES)
Required for `CitableTrait`.
"""
function urn(inf::IrregularInfinitiveStem; registry = nothing)
if isnothing(registry)
inf.stemid
else
expand(inf.stemid, registry)
end
end
"""Compose CEX text for an `IrregularInfinitiveStem`.
If `registry` is nothing, use abbreivated URN;
otherwise, expand identifier to full `Cite2Urn`.
$(SIGNATURES)
Required for `CitableTrait`.
"""
function cex(inf::IrregularInfinitiveStem; delimiter = "|", registry = nothing)
if isnothing(registry)
join([inf.stemid, label(inf), stemstring(inf), lexeme(inf), inflectionclass(inf), label(inf.tense), label(inf.voice) ], delimiter)
else
c2urn = expand(inf.stemid, registry)
join([c2urn, label(inf), stemstring(inf), lexeme(inf), inflectionclass(inf), label(inf.tense), label(inf.voice)], delimiter)
end
end
"""
Read one row of a stems table for irregular infinititve tokens and create an `IrregularInfinitiveStem`.
$(SIGNATURES)
"""
function readstemrow(infinio::Kanones.IrregularInfinitiveIO, delimited::AbstractString; delimiter = "|")
parts = split(delimited, delimiter)
if length(parts) < 5
msg = "Too few parts in $delimited."
@warn msg
throw(new(ArgumentError(msg)))
end
stemid = StemUrn(parts[1])
lexid = LexemeUrn(parts[2])
stem = knormal(parts[3])
t = gmpTense(parts[4])
v = gmpVoice(parts[5])
inflclass = parts[6]
IrregularInfinitiveStem(stemid,lexid,stem,t,v, inflclass)
end
"""Identify value of stem string for `inf`.
$(SIGNATURES)
"""
function stemstring(inf::IrregularInfinitiveStem)
inf.form |> knormal
end
"""Identify lexeme for `inf`.
$(SIGNATURES)
"""
function lexeme(inf::IrregularInfinitiveStem)
inf.lexid
end
"""Identify inflection class for `inf`.
$(SIGNATURES)
"""
function inflectionclass(inf::IrregularInfinitiveStem)
inf.inflectionclass
end
"""Compose a digital code string for the form identified in `inf`.
$(SIGNATURES)
"""
function code(inf::IrregularInfinitiveStem)
# PosPNTMVGCDCat
string( INFINITIVE,"00$(code(inf.tense))0$(code(inf.voice))0000")
end
"""Compose an abbreviated URN for a rule from a `IrregularAdjectiveStem`.
$(SIGNATURES)
"""
function formurn(inf::IrregularInfinitiveStem)
FormUrn("$(COLLECTION_ID)." * code(inf))
end
function greekForm(inf::IrregularInfinitiveStem)
formurn(inf) |> greekForm
end