-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmorphgnt-parse.js
More file actions
170 lines (166 loc) · 4.74 KB
/
morphgnt-parse.js
File metadata and controls
170 lines (166 loc) · 4.74 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
const morphologyDictionary = {
greek: {
partOfSpeech: {
N: 'noun',
A: 'adjective',
T: 'article',
V: 'verb',
P: 'personal pronoun',
R: 'relative pronoun',
C: 'reciprocal pronoun',
D: 'demonstrative pronoun',
K: 'correlative pronoun',
I: 'interrogative pronoun',
X: 'indefinite pronoun',
Q: 'correlative or interrogative pronoun',
F: 'reflexive pronoun',
S: 'possessive pronoun',
ADV: 'adverb',
CONJ: 'conjunction',
COND: 'cond',
PRT: 'particle',
PREP: 'preposition',
INJ: 'interjection',
ARAM: 'aramaic',
HEB: 'hebrew'
},
Case: {
N: 'nominative',
V: 'vocative',
G: 'genitive',
D: 'dative',
A: 'accusative',
PRI: 'proper noun indeclinable',
NUI: 'numeral indeclinable',
LI: 'letter indeclinable',
OI: 'noun other type indeclinable',
tense: {
P : 'present',
I : 'imperfect',
F : 'future',
'2F' : 'second future',
A : 'aorist',
'2A' : 'second aorist',
R : 'perfect',
'2R' : 'second perfect',
L : 'pluperfect',
'2L' : 'second pluperfect',
X : 'no tense stated'
},
voice: {
A : 'active',
M : 'middle',
P : 'passive',
E : 'middle or passive',
D : 'middle deponent',
O : 'passive deponent',
N : 'middle or passive deponent',
Q : 'impersonal active',
X : 'no voice'
},
mood: {
I: 'indicative',
S: 'subjunctive',
O: 'optative',
M: 'imperative',
N: 'infinitive',
P: 'participle',
R: 'imperative participle'
}
},
number: {
S: 'singular',
P: 'plural'
},
gender: {
M: 'masculine',
F: 'feminine',
N: 'neuter'
},
person: {
1: 'first person',
2: 'second person',
3 : 'third person'
}
}
};
function parseGreekMorph( morph ) {
var result = '',
gender,
morphArray,
number,
Case,
person,
Person,
case2,
mood,
voice,
tense,
partOfSpeech;
morphArray = morph.split('-');
partOfSpeech = morphArray[0];
result += morphologyDictionary.greek.partOfSpeech[partOfSpeech] + ' ';
Case = morphArray[1];
if (partOfSpeech === 'V') { //for verbs
if (Case !== undefined) {
if (morphologyDictionary.greek.Case[Case] !== undefined) {
result += morphologyDictionary.greek.Case[Case] + ' ';
} else {
if (parseInt(Case[0], 10) > 0) { // second future, second aorist and second perfect
tense = Case[0] + Case[1];
voice = Case[2];
mood = Case[3];
} else {
tense = Case[0];
voice = Case[1];
mood = Case[2];
}
result += morphologyDictionary.greek.Case.tense[tense] + ' ';
result += morphologyDictionary.greek.Case.voice[voice] + ' ';
result += morphologyDictionary.greek.Case.mood[mood];
}
}
if (morphArray[2] !== undefined) {
result += ' ';
if (mood === "P" || mood === "R") {
case2 = morphArray[2][0];
result += morphologyDictionary.greek.Case[case2] + ' ';
number = morphArray[2][1];
result += morphologyDictionary.greek.number[number] + ' ';
gender = morphArray[2][2];
result += morphologyDictionary.greek.gender[gender];
} else {
person = morphArray[2][0];
result += morphologyDictionary.greek.person[person] + ' ';
number = morphArray[2][1];
result += morphologyDictionary.greek.number[number];
}
}
} else {
if (morphArray[1] !== undefined) {
if (morphologyDictionary.greek.Case[Case] !== undefined) { //there are some nouns that have a 3 letter case code
result += morphologyDictionary.greek.Case[Case];
} else {
if ( parseInt( morphArray[1][0] ) > 0 ) {
Person = morphArray[1][0];
Case = morphArray[1][1];
number = morphArray[1][2];
gender = morphArray[1][3];
} else {
Case = morphArray[1][0];
number = morphArray[1][1];
gender = morphArray[1][2];
}
if ( typeof Person !== 'undefined' ) {
result += morphologyDictionary.greek.person[Person] + ' ';
}
result += morphologyDictionary.greek.Case[Case] + ' ';
result += morphologyDictionary.greek.number[number] + ' ';
if ( gender ) {
result += morphologyDictionary.greek.gender[gender];
}
}
}
}
return result;
}