-
Notifications
You must be signed in to change notification settings - Fork 0
/
verbaladjectiverules.jl
118 lines (92 loc) · 2.93 KB
/
verbaladjectiverules.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
"""Inflectional rule for a verbal adjective.
$(SIGNATURES)
"""
struct VerbalAdjectiveRule <: KanonesVerbalRule
ruleid::AbbreviatedUrn
inflectionclass
ending
vagender::GMPGender
vacase::GMPCase
vanumber::GMPNumber
end
"""Verbal adjective rules are citable by Cite2Urn"""
CitableTrait(::Type{VerbalAdjectiveRule}) = CitableByCite2Urn()
"""Identify inflection class for `rule`.
$(SIGNATURES)
"""
function inflectionclass(rule::VerbalAdjectiveRule)
rule.inflectionclass
end
"""Identify ending for `rule`.
$(SIGNATURES)
"""
function ending(rule::VerbalAdjectiveRule)
rule.ending
end
"""Human-readlable label for a `VerbalAdjectiveRule`.
$(SIGNATURES)
Required for `CitableTrait`.
"""
function label(vadj::VerbalAdjectiveRule)
string("Verbal adjective inflection rule: ending -", vadj.ending, " in class ", vadj.inflectionclass, " can be ", label(vadj.vagender), " ", label(vadj.vacase), " ", label(vadj.vanumber), ".")
end
"""Identifying URN for a `VerbalAdjectiveRule`. If
no registry is included, use abbreviated URN;
otherwise, expand to full `Cite2Urn`.
$(SIGNATURES)
Required for `CitableTrait`.
"""
function urn(vadj::VerbalAdjectiveRule; registry = nothing)
if isnothing(registry)
vadj.ruleid
else
expand(vadj.ruleid, registry)
end
end
"""Identifying `RuleUrn` for a `VerbalAdjectiveRule`.
$(SIGNATURES)
"""
function ruleurn(vadj::VerbalAdjectiveRule)
vadj.ruleid
end
"""Compose CEX text for a `VerbalAdjectiveRule`.
If `registry` is nothing, use abbreivated URN;
otherwise, expand identifier to full `Cite2Urn`.
$(SIGNATURES)
Required for `CitableTrait`.
"""
function cex(vadj::VerbalAdjectiveRule; delimiter = "|", registry = nothing)
if isnothing(registry)
join([vadj.ruleid, label(vadj), ending(vadj), inflectionclass(vadj), formurn(vadj)], delimiter)
else
c2urn = expand(vadj.ruleid, registry)
join([c2urn, label(vadj), ending(vadj), inflectionclass(vadj), formurn(vadj)], delimiter)
end
end
"""Read one row of a rules table for infinitives and create an `InfinitiveRule`.
$(SIGNATURES)
"""
function readrulerow(usp::VerbalAdjectiveIO, delimited::AbstractString; delimiter = "|")
parts = split(delimited, delimiter)
if length(parts) < 6
msg = "Invalid syntax for verbal adjective: too few components in $(delimited)"
throw(ArgumentError(msg))
else
ruleid = RuleUrn(parts[1])
inflclass = parts[2]
ending = parts[3]
g = gmpGender(parts[4])
c = gmpCase(parts[5])
n = gmpNumber(parts[6])
VerbalAdjectiveRule(ruleid, inflclass, ending,g,c,n)
end
end
function code(rule::VerbalAdjectiveRule)
string(VERBALADJECTIVE,"0",code(rule.vanumber),"000",code(rule.vagender),code(rule.vacase),"00")
end
"""Compose an abbreviated URN for a rule from a `VerbalAdjectiveRule`.
$(SIGNATURES)
"""
function formurn(rule::VerbalAdjectiveRule)
FormUrn("$(COLLECTION_ID)." * code(rule))
end