PageSourceSearch

https://www.laparola.net/app/js/bible/morphology.js

js laparola.net collected 2026-10-01 10:25:29 UTC 9,926 bytes, 466 lines download raw bytes

1/* language tools */
2if (typeof(window.bible) == 'undefined')
3	window.bible = {};
4
5
6bible.morphology = {};
7
8// http://wiki.logos.com/Morphology_Codes
9//
10bible.morphology['robinson'] = {
11
12	format: function(morph) {
13
14		var firstDash = morph.indexOf('-'),
15			partOfSpeechKey = (firstDash > -1) ? morph.substring(0, firstDash) : morph,
16			partOfSpeech = this.partsOfSpeech[partOfSpeechKey.toUpperCase()],
17
18			parsingInfo = (firstDash > -1) ? morph.substring(firstDash+1) : '',
19			formattedParsing = '';
20
21		switch (partOfSpeechKey.toUpperCase()) {
22			case 'A':
23			case 'N':
24			case 'RA':
25			case 'RN':
26			case 'RP':
27			case 'RC':
28			case 'RD':
29			case 'RK':
30			case 'RI':
31			case 'RX':
32			case 'RQ':
33			case 'RF':
34			case 'RS':
35				var c = this.nounCases[parsingInfo.substring(0, 1)];
36				var n = this.wordNumber[parsingInfo.substring(1, 2)];
37				var g = this.wordGender[parsingInfo.substring(2, 3)];
38				formattedParsing = c + ((n) ? ', ' + n + ((g) ? ', ' + g : '') : '');
39				break;
40
41			case 'T':
42
43				var firstLetter = parsingInfo.substr(0,1);
44				if (firstLetter == '1' || firstLetter == '2') {
45
46					var p = this.wordPerson[parsingInfo.substring(0, 1)];
47					var c = this.nounCases[parsingInfo.substring(1, 2)];
48					var n = this.wordNumber[parsingInfo.substring(2, 3)];
49					formattedParsing = p + ((c) ? ', ' + c + ((n) ? ', ' + n : '') : '');
50				} else {
51					var c = this.nounCases[parsingInfo.substring(0, 1)];
52					var n = this.wordNumber[parsingInfo.substring(1, 2)];
53					var g = this.wordGender[parsingInfo.substring(2, 3)];
54					formattedParsing = c + ((n) ? ', ' + n + ((g) ? ', ' + g : '') : '');
55				}
56
57				break;
58
59			//case 'A':
60			//	var c = this.nounCases[parsingInfo.substring(0, 1)];
61			//	var n = this.wordNumber[parsingInfo.substring(1, 2)];
62			//	formattedParsing =   c + ', ' + n;
63			//	break;
64
65			case 'P':
66
67				formattedParsing = '';//this.particleTypes[parsingInfo];
68				break;
69
70			case 'V':
71				var t = '';
72				var rem = '';
73                var person = '';
74				if (parsingInfo.substring(0, 1) == '1' || parsingInfo.substring(0, 1) == '2' || parsingInfo.substring(0, 1) == '3') {
75                    person = this.wordPerson[parsingInfo.substring(0, 1)];
76					t = this.verbTenses[parsingInfo.substring(1, 2)];
77					rem = parsingInfo.substring(2);
78                }
79                else { // V-PPPNSN
80				    t = this.verbTenses[parsingInfo.substring(0, 1)];
81				    rem = parsingInfo.substring(1);
82                }
83                // lpnrmw lots of changes here
84				//if (parsingInfo.substring(0, 1) == '2') {
85				//	t = this.verbTenses[parsingInfo.substring(0, 2)];
86				//	rem = parsingInfo.substring(2);
87				//} else {
88				//	t = this.verbTenses[parsingInfo.substring(0, 1)];
89				//	rem = parsingInfo.substring(1);
90				//}
91				var v = this.verbVoices[rem.substring(0, 1)];
92				var m = this.verbMoods[rem.substring(1, 2)];
93
94				if (rem.length == 2) {
95					formattedParsing = t + ', ' + v + ', ' + m;
96				} else if (rem.length == 3) {
97					var n = this.wordNumber[rem.substring(2, 3)];
98					formattedParsing =  t + ', ' + v + ', ' + m + ', ' + person + ', ' + n;
99//				} else if (rem.length == 5) {
100//					var p = this.wordPerson[rem.substring(3, 4)];
101//					var n = this.wordNumber[rem.substring(4, 5)];
102//					formattedParsing =  t + ', ' + v + ', ' + m + ', ' + p + ', ' + n;
103
104				} else if (rem.length == 5) {
105					var c = this.nounCases[rem.substring(2, 3)];
106					var n = this.wordNumber[rem.substring(3, 4)];
107					var g = this.wordGender[rem.substring(4, 5)];
108
109					formattedParsing =  t + ', ' + v + ', ' + m + ', ' + c + ', ' + n + ', ' + g;
110				}
111				break;
112
113				//m = this.verbMoods[parsingInfo.substring(2+offset,3+offset)];
114			default:
115				formattedParsing =  parsingInfo;
116
117		}
118
119		return (typeof partOfSpeech != 'undefined' ? partOfSpeech + (formattedParsing != '' ? ': ' : '') : '') + formattedParsing;
120
121	},
122
123	partsOfSpeech: {
124		N: 'noun',
125		A: 'adjective',
126		RA: 'article',
127		V: 'verb',
128		RP: 'personal pronoun',
129		RR: 'relative pronoun',
130		RC: 'reciprocal pronoun',
131		RD: 'demonstrative pronoun',
132		RK: 'correlative pronoun',
133		RI: 'interrogative pronoun',
134		RX: 'indefinite pronoun',
135		RQ: 'correlative or interrogative pronoun',
136		RF: 'reflexive pronoun',
137		RS: 'posessive pronoun',
138		D: 'adverb',
139		C: 'conjunction',
140		COND: 'cond',
141		X: 'particle',
142		P: 'preposition',
143		INJ: 'interjection',
144		ARAM: 'aramaic',
145		HEB: 'hebrew'
146	},
147
148	getPartofSpeech: function(partOfSpeechKey) {
149		var full = this.partsOfSpeech[partOfSpeechKey.toUpperCase()];
150
151		return (full != null) ? full : '?';
152	},
153
154	nounCases: {
155		'N': 'nominative',
156		'V': 'vocative',
157		'G': 'genitive',
158		'D': 'dative',
159		'A': 'accusative',
160		'P': 'proper name'
161	},
162
163	wordNumber: {
164		'S': 'singular',
165		'P': 'plural'
166	},
167
168	wordGender: {
169		'M': 'masculine',
170		'F': 'feminine',
171		'N': 'neuter'
172	},
173
174	wordPerson: {
175		'1': '1st',
176		'2': '2nd',
177		'3': '3rd'
178	},
179
180	verbTenses: {
181		'P': 'present',
182		'I': 'imperfect',
183		'F': 'future',
184		'2F': 'second future',
185		'A': 'aorist',
186		'2A': 'second aorist',
187		'R': 'perfect',
188		'2R': 'second perfect',
189		'L': 'pluperfect',
190		'2L': 'second pluperfect',
191		'X': 'no tense stated'
192	},
193
194	verbVoices: {
195		'A': 'active',
196		'M': 'middle',
197		'P': 'passive',
198		'E': 'middle or passive',
199		'D': 'middle deponent',
200		'O': 'passive deponent',
201		'N': 'middle or passive deponent',
202		'Q': 'impersonal active',
203		'X': 'no voice'
204	},
205
206	verbMoods: {
207		'I': 'indicative',
208		'S': 'subjunctive',
209		'O': 'optative',
210		'D': 'imperative',
211		'M': 'imperative',
212		'N': 'infinitive',
213		'P': 'participle',
214		'R': 'imperative participle'
215	},
216
217	particleTypes: {
218		'I': 'interogative',
219		'N': 'negative'
220	}
221};
222bible.morphology['Greek'] = bible.morphology['robinson'];
223
224
225
226// http://openscriptures.github.io/morphhb/parsing/HebrewMorphologyCodes.html
227bible.morphology['OSHB'] = {
228	format: function(morph) {
229		var languageKey = morph.substr(0,1),
230			language = this.languages[languageKey],
231			morphParts = morph.substr(1).split('/'),
232			formattedOutput = '';
233
234		for (var i=0, il=morphParts.length; i<il; i++) {
235			var m = morphParts[i],
236				partOfSpeechKey = m.substr(0,1),
237				partOfSpeech = this.partsOfSpeech[partOfSpeechKey],
238				morphCodes = m.length > 0 ? m.substr(1) : '',
239
240				partsList = [],
241				details = [];
242
243			switch (partOfSpeechKey) {
244
245				case 'A':
246					partsList = ['adjectiveTypes', 'gender', 'number', 'state'];
247
248					break;
249				case 'C':
250				case 'D':
251					// nothing
252
253					break;
254				case 'N':
255
256					partsList = ['nounTypes', 'gender', 'number', 'state'];
257
258					break;
259				case 'P':
260
261					partsList = ['pronounTypes', 'person', 'gender', 'number'];
262
263					break;
264				case 'R':
265					partsList = ['prepositionTypes'];
266
267					break;
268				case 'S':
269
270					partsList = ['suffixTypes', 'person', 'gender', 'number'];
271
272					break;
273				case 'T':
274
275					partsList = ['particleTypes'];
276
277					break;
278				case 'V':
279
280					partsList = [language.toLowerCase() + 'VerbStems', 'verbConjugationTypes', 'person', 'gender', 'number', 'state'];
281
282					break;
283
284			}
285
286			for (var j=0, jl=partsList.length; j<jl; j++) {
287				if (morphCodes.length > j) {
288					details.push( this[ partsList[j] ][ morphCodes.substr(j, 1) ] );
289				}
290			}
291
292
293
294			formattedOutput += (i>0 ? '; ' : '') + partOfSpeech + (details.length > 0 ? ': ' + details.join(', ') : '');
295		}
296
297		return formattedOutput;
298	},
299
300	partsOfSpeech: {
301
302		'A':'adjective',
303		'C':'conjunction',
304		'D':'adverb',
305		'N':'noun',
306		'P':'pronoun',
307		'R':'preposition',
308		'S':'suffix',
309		'T':'particle',
310		'V':'verb'
311
312	},
313
314	hebrewVerbStems: {
315
316		'q': 'qal',
317		'N': 'niphal',
318		'p': 'piel',
319		'P': 'pual',
320		'h': 'hiphil',
321		'H': 'hophal',
322		't': 'hithpael',
323		'o': 'polel',
324		'O': 'polal',
325		'r': 'hithpolel',
326		'm': 'poel',
327		'M': 'poal',
328		'k': 'palel',
329		'K': 'pulal',
330
331		'Q': 'qal passive',
332		'l': 'pilpel',
333		'L': 'polpal',
334		'f': 'hithpalpel',
335		'D': 'nithpael',
336		'j': 'pealal',
337		'i': 'pilel',
338		'u': 'hothpaal',
339		'c': 'tiphil',
340		'v': 'hishtaphel',
341		'w': 'nithpalel',
342		'y': 'nithpoel',
343		'z': 'hithpoel'
344	},
345
346	aramaicVerbStems: {
347
348		'q': 'peal',
349		'Q': 'peil',
350		'u': 'hithpeel',
351		'p': 'pael',
352		'P': 'ithpaal',
353		'M': 'hithpaal',
354		'a': 'aphel',
355		'h': 'haphel',
356		's': 'saphel',
357		'e': 'shaphel',
358		'H': 'hophal',
359		'i': 'ithpeel',
360		't': 'hishtaphel',
361		'v': 'ishtaphel',
362		'w': 'hithaphel',
363		'o': 'polel',
364		'z': 'ithpoel',
365		'r': 'hithpolel',
366		'f': 'hithpalpel',
367		'b': 'hephal',
368		'c': 'tiphel',
369		'm': 'poel',
370		'l': 'palpel',
371		'L': 'ithpalpel',
372		'O': 'ithpolel',
373		'G': 'ittaphal'
374
375	},
376
377	verbConjugationTypes: {
378		'p': 'perfect (qatal)',
379		'q': 'sequential perfect (weqatal)',
380		'i': 'imperfect (yiqtol)',
381		'w': 'sequential imperfect (wayyiqtol)',
382		'h': 'cohortative',
383		'j': 'jussive',
384		'v': 'imperative',
385		'r': 'participle active',
386		's': 'participle passive',
387		'a': 'infinitive absolute',
388		'c': 'infinitive construct'
389	},
390
391	adjectiveTypes: {
392		'a': 'adjective',
393		'c': 'cardinal number',
394		'g': 'gentilic',
395		'o': 'ordinal number'
396	},
397
398	nounTypes: {
399		'c': 'common',
400		'g': 'gentilic',
401		'p': 'proper name'
402	},
403
404	pronounTypes: {
405		'd': 'demonstrative',
406		'f': 'indefinite',
407		'i': 'interrogative',
408		'p': 'personal',
409		'r': 'relative'
410	},
411
412	prepositionTypes: {
413		'd': 'definite article'
414	},
415
416	suffixTypes: {
417		'd': 'directional he',
418		'h': 'paragogic he',
419		'n': 'paragogic nun',
420		'p': 'pronominal'
421	},
422
423	particleTypes: {
424		'a': 'affirmation',
425		'd': 'definite article',
426		'e': 'exhortation',
427		'i': 'interrogative',
428		'j': 'interjection',
429		'm': 'demonstrative',
430		'n': 'negative',
431		'o': 'direct object marker',
432		'r': 'relative'
433	},
434
435	person: {
436		'1': 'first',
437		'2': 'second',
438		'3': 'third'
439	},
440
441	gender: {
442		'b': 'both (noun)',
443		'c': 'common (verb)',
444		'f': 'feminine',
445		'm': 'masculine'
446	},
447
448	number: {
449		'd': 'dual',
450		'p': 'plural',
451		's': 'singular'
452	},
453
454	state: {
455		'a': 'absolute',
456		'c': 'construct',
457		'd': 'determined'
458	},
459
460	languages: {
461		'H': 'Hebrew',
462		'A': 'Aramaic'
463	}
464};
465
466bible.morphology['Hebrew'] = bible.morphology['OSHB'];

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.