/
number.jl
57 lines (45 loc) · 1.1 KB
/
number.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
"Number of substantive or of finite verb form."
struct LMPNumber <: LatinMorphologicalProperty
code::Int64
function LMPNumber(code)
code in keys(numberlabeldict) ? new(code) : throw(DomainError(string(code, " is out of range.")))
end
end
"""Create `LMPPerson` from descriptive string.
$(SIGNATURES)
"""
function lmpNumber(s::AbstractString)
s in keys(numbercodedict) ? LMPNumber(numbercodedict[s]) : DomainError(string(s, " is not a valid value for number."))
end
"""Create `LMPPerson` from integer code.
$(SIGNATURES)
"""
function lmpNumber(code::Int64)
LMPNumber(code)
end
"""Integer code for a `LMPPerson` value.
$(SIGNATURES)
"""
function code(num::LMPNumber)
num.code
end
"""Human-readable label for a `LMPPerson` value.
$(SIGNATURES)
"""
function label(num::LMPNumber)
numberlabeldict[num.code]
end
"""Dictionary mapping codes to labels for number.
$(SIGNATURES)
"""
const numberlabeldict = Dict(
1 => "singular",
2 => "plural"
)
"""Dictionary mapping labels to codes for number.
$(SIGNATURES)
"""
const numbercodedict = Dict(
"singular" => 1,
"plural" => 2
)