-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninflected.jl
105 lines (80 loc) · 2.15 KB
/
uninflected.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
"""Uninflected forms have a single property: the "part of speech"."""
struct GMFUninflected <: GreekMorphologicalForm
pos::GMPUninflectedType
end
"""Uninflected forms are citable by Cite2Urn"""
CitableTrait(::Type{GMFUninflected}) = CitableByCite2Urn()
"""Extract "part of speech" type from `uform`.
$(SIGNATURES)
"""
function gmpUninflectedType(uform::GMFUninflected)
uform.pos
end
"""Compose digital code for `uform`.
$(SIGNATURES)
"""
function code(uform::GMFUninflected)
string(UNINFLECTED, "00000000", code(uform.pos))
end
"""Compose URN for an `GMFUninflected`.
$(SIGNATURES)
Required by `CitableTrait`.
"""
function urn(uform::GMFUninflected)
Cite2Urn(BASE_MORPHOLOGY_URN * code(uform) )
end
"""Compose a human-readable label for an `GMFUninflected`.
$(SIGNATURES)
Required by `CitableTrait`.
"""
function label(uform::GMFUninflected)
"uninflected form: " * label(uform.pos)
end
"""Create `GMFUninflected` from a Cite2Urn.
$(SIGNATURES)
"""
function gmfUninflected(urn::Cite2Urn)
c = objectcomponent(urn)[end]
pos = parse(Int64, c)
GMFUninflected(gmpUninflectedType(pos))
end
"""Create `GMFUninflected` from a FormUrn.
$(SIGNATURES)
"""
function gmfUninflected(u::FormUrn)
c = u.objectid[end]
GMFUninflected(gmpUninflectedType(parse(Int64,c)))
end
"""Create `GMFUninflected` from a string value.
$(SIGNATURES)
"""
function gmfUninflected(codeString::AbstractString)
morphchars = split(codeString, "")
pos = parse(Int64, morphchars[10])
GMPUninflectedType(pos) |> GMFUninflected
end
"""Create `GMFUninflected` from a Char.
$(SIGNATURES)
"""
function gmfUninflected(ch::Char)
pos = gmpUninflectedType(parse(Int64, ch))
gmfUninflected(pos)
end
"""Create `GMFUninflected` from an Int.
$(SIGNATURES)
"""
function gmfUninflected(code::Int64)
GMFUninflected(code)
end
"""Create `GMFUninflected` from an Analysis.
$(SIGNATURES)
"""
function gmfUninflected(a::Analysis)
gmfUninflected(a.form)
end
"""Compose a `FormUrn` for an `GMFUninflected`.
$(SIGNATURES)
"""
function formurn(uninflected::GMFUninflected)
FormUrn(string("$(COLLECTION_ID).", UNINFLECTED, "00000000", code(uninflected.pos)))
end