-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
709 lines (616 loc) · 32.9 KB
/
index.js
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
const https = require('https');
const xmldoc = require("xmldoc");
function getPlatoText(userDialogue, userStephanus) {
return new Promise((resolve, reject) => {
let lastChar = "";
if(userStephanus) {
lastChar = userStephanus[userStephanus.length - 1];
} else {
userStephanus = "NONE"
}
let userStephanusLetter = "";
let stephanusRange = "";
let dialogueName = "";
// Check for stephanus number and letter, if there are any; if so, separate them
if (lastChar !== "") {
if (lastChar === "a" || lastChar === "b" || lastChar === "c" || lastChar === "d" || lastChar == "e") {
userStephanus = userStephanus.slice(0, userStephanus.length - 1);
userStephanusLetter = lastChar;
} else {
if (isNaN(lastChar) && userStephanus !== "NONE") {
return resolve("Search only accepts a-e in final Stephanus position; canceling search.");
}
}
}
let perseusDialogueMarker = "tlg0"
switch (userDialogue) {
case "all":
const allStephanusRanges = ["Alcibiades I: 103a-135e", "Alcibiades II: 138a-151c", "Apology: 17a-42a", "Charmides: 153a-176d", "Clitophon: 406a-410e", "Cratylus: 383a-440e", "Critias: 106a-121c", "Crito: 43a-54e", "Epinomis: 973a-992e", "Euthydemus: 271a-307c", "Euthyphro: 2a-16a", "Gorgias: 447a-527e", "Hipparchus: 225a-232c", "Hippias Major: 281a-304e", "Hippias Minor: 363a-376c", "Ion: 530a-542b", "Laches: 178a-201c", "Laws: 1.624a-650b", "Lysis: 203a-223b", "Menexenus: 234a-249e", "Meno: 70a-100b", "Minos: 313a-321d", "Parmenides: 126a-166c", "Phaedo: 57a-118a", "Phaedrus: 227a-279c", "Philebus: 11a-67b", "Protagoras: 309a-362a", "Republic: 327a-621d", "Rival Lovers: 132a-139a", "Seventh Letter: 7.323d-7.352a", "Sophist: 216a-268d", "Statesman: 257a-311c", "Symposium: 172a-223d", "Theaetetus: 142a-210d", "Theages: 121a-131a", "Timaeus: 17a-92c"]
return resolve(allStephanusRanges);
case "alcibiadesi":
case "alcibiadesI":
case "alcibiades1":
case "alcibiadesi":
case "alci":
case "alcI":
case "alc1":
case "alci":
case "alc.i":
case "alc.I":
case "alc.1":
case "alc.i":
perseusDialogueMarker += "13";
stephanusRange = "Alcibiades I: 103a-135e";
dialogueName = "Alcibiades I";
break;
case "alcibiadesii":
case "alcibiadesII":
case "alcibiades2":
case "alcibiadesii":
case "alcii":
case "alcII":
case "alc2":
case "alcii":
case "alc.ii":
case "alc.II":
case "alc.11":
case "alc.ii":
perseusDialogueMarker += "13";
stephanusRange = "Alcibiades II: 138a-151c";
dialogueName = "Alcibiades II";
break;
case "apology":
case "apol.":
case "apol":
case "apo.":
case "apo":
perseusDialogueMarker += "02";
stephanusRange = "Apology: 17a-42a";
dialogueName = "Apology";
break;
case "charmides":
case "charm":
case "charm.":
case "char.":
case "char":
perseusDialogueMarker += "18";
stephanusRange = "Charmides: 153a-176d";
dialogueName = "Charmides";
break;
case "clitophon":
case "cleitophon":
case "cleit":
case "clit":
case "cleit.":
case "clit.":
perseusDialogueMarker += "29";
stephanusRange = "Clitophon: 406a-410e";
dialogueName = "Clitophon";
break;
case "cratylus":
case "crat.":
case "crat":
perseusDialogueMarker += "05";
stephanusRange = "Cratylus: 383a-440e";
dialogueName = "Cratylus";
break;
case "critias":
case "criti.":
case "criti":
perseusDialogueMarker += "32";
stephanusRange = "Critias: 106a-121c";
dialogueName = "Critias";
break;
case "crito":
case "crit.":
case "crit":
perseusDialogueMarker += "03";
stephanusRange = "Crito: 43a-54e";
dialogueName = "Crito";
break;
case "epinomis":
case "epin.":
case "epin":
case "epi.":
case "epi":
perseusDialogueMarker += "35";
stephanusRange = "Epinomis: 973a-992e";
dialogueName = "Epinomis";
break;
case "euthydemus":
case "euthyd.":
case "euthyd":
perseusDialogueMarker += "21";
stephanusRange = "Euthydemus: 271a-307c";
dialogueName = "Euthydemus";
break;
case "euthyphro":
case "euthy.":
case "euthy":
case "euth.":
case "euth":
perseusDialogueMarker += "01";
stephanusRange = "Euthyphro: 2a-16a";
dialogueName = "Euthyphro";
break;
case "gorgias":
case "gorg.":
case "gorg":
perseusDialogueMarker += "23";
stephanusRange = "Gorgias: 447a-527e";
dialogueName = "Gorgias";
break;
case "hipparchus":
case "hipparch.":
case "hipparch":
perseusDialogueMarker += "15";
stephanusRange = "Hipparchus: 225a-232c";
dialogueName = "Hipparchus";
break;
case "greaterhippias":
case "hipp.maj.":
case "hipp.maj":
case "hippmaj":
perseusDialogueMarker += "25";
stephanusRange = "Hippias Major: 281a-304e";
dialogueName = "Hippias Major";
break;
case "lesserhippias":
case "hipp.min.":
case "hipp.min":
case "hippmin":
perseusDialogueMarker += "26";
stephanusRange = "Hippias Minor: 363a-376c";
dialogueName = "Hippias Minor";
break;
case "ion":
perseusDialogueMarker += "27";
stephanusRange = "Ion: 530a-542b";
dialogueName = "Ion";
break;
case "laches":
case "lach.":
case "lach":
perseusDialogueMarker += "19";
stephanusRange = "Laches: 178a-201c";
dialogueName = "Laches";
break;
case "laws":
case "l":
perseusDialogueMarker += "34";
stephanusRange = "Laws: 1.624a-650b";
dialogueName = "Laws";
break;
case "lysis":
case "lys.":
case "lys":
perseusDialogueMarker += "20";
stephanusRange = "Lysis: 203a-223b";
dialogueName = "Lysis";
break;
case "menexenus":
case "menex.":
case "menex":
perseusDialogueMarker += "28";
stephanusRange = "Menexenus: 234a-249e";
dialogueName = "Menexenus";
break;
case "meno":
case "men.":
case "men":
perseusDialogueMarker += "24";
stephanusRange = "Meno: 70a-100b";
dialogueName = "Meno";
break;
case "minos":
case "min.":
case "min":
perseusDialogueMarker += "33";
stephanusRange = "Minos: 313a-321d";
dialogueName = "Minos";
break;
case "parmenides":
case "parm.":
case "parm":
case "par":
case "par":
perseusDialogueMarker += "09";
stephanusRange = "Parmenides: 126a-166c";
dialogueName = "Parmenides";
break;
case "phaedo":
case "phae.":
case "phae":
case "pha.":
case "pha":
perseusDialogueMarker += "04";
stephanusRange = "Phaedo: 57a-118a";
dialogueName = "Phaedo";
break;
case "phaedrus":
case "phaed.":
case "phaed":
case "Phaedrus: 227a-279c":
perseusDialogueMarker += "12";
stephanusRange = "Phaedrus: 227a-279c";
dialogueName = "Phaedrus";
break;
case "philebus":
case "phileb.":
case "phileb":
case "phile.":
case "phile":
perseusDialogueMarker += "10";
stephanusRange = "Philebus: 11a-67b";
dialogueName = "Philebus";
break;
case "protagoras":
case "prot.":
case "prot":
perseusDialogueMarker += "22";
stephanusRange = "Protagoras: 309a-362a";
dialogueName = "Protagoras";
break;
case "republic":
case "rep.":
case "rep":
case "r":
perseusDialogueMarker += "30";
stephanusRange = "Republic: 327a-621d";
dialogueName = "Republic";
break;
case "rivallovers":
case "rivals":
case "riv":
case "lovers":
case "erastes":
perseusDialogueMarker += "16";
stephanusRange = "Rival Lovers: 132a-139a";
dialogueName = "Rival Lovers";
break;
case "letters":
case "letter":
perseusDialogueMarker += "36";
stephanusRange = "Seventh Letter: 7.323d-7.352a";
dialogueName = "Letters";
break;
case "sophist":
case "soph.":
case "soph":
perseusDialogueMarker += "07";
stephanusRange = "Sophist: 216a-268d";
dialogueName = "Sophist";
break;
case "statesman":
case "stat.":
case "stat":
case "politicus":
case "polit.":
case "polit":
perseusDialogueMarker += "08";
stephanusRange = "Statesman: 257a-311c";
dialogueName = "Statesman";
break;
case "symposium":
case "symp.":
case "symp":
case "sym.":
case "sym":
perseusDialogueMarker += "11";
stephanusRange = "Symposium: 172a-223d";
dialogueName = "Symposium";
break;
case "theaetetus":
case "theaet.":
case "theaet":
case "theae.":
case "theae":
case "thea.":
case "thea":
case "the.":
case "the":
perseusDialogueMarker += "06";
stephanusRange = "Theaetetus: 142a-210d";
dialogueName = "Theaetetus";
break;
case "theages":
case "theag.":
case "theag":
perseusDialogueMarker += "17";
stephanusRange = "Theages: 121a-131a";
dialogueName = "Theages";
break;
case "timaeus":
case "tim.":
case "tim":
perseusDialogueMarker += "31";
stephanusRange = "Timaeus: 17a-92c";
dialogueName = "Timaeus";
break;
default:
return resolve("Dialogue not recognized; canceling request.");
}
// Display dialogue range of references if the user doesn't request a specific passage
if (userStephanus === "NONE" || userStephanus === "rang" || userStephanus === undefined) {
return resolve(stephanusRange + " (possible search range)");
}
// Adding dialogue chosen to search url
let queryURL = "https://scaife-cts.perseus.org/api/cts?request=GetPassage&urn=urn:cts:greekLit:tlg0059." + perseusDialogueMarker;
// For some reason the Euthyphro, dialogue tlg001, is in the perseus-grc1 route, not perseus-grc2
if (perseusDialogueMarker === "tlg001") {
queryURL += ".perseus-grc1:";
} else {
queryURL += ".perseus-grc2:";
}
// Adding stephanus chosen to url
queryURL += userStephanus;
// https request using module built-in to node
https.get(queryURL, (resp) => {
// Temp object to store results of async call in
let textsFound = {};
textsFound["passageRequested"] = dialogueName + " " + userStephanus;
textsFound["URL"] = queryURL;
let currentStephanus = "";
let typeOfResult = "";
let data = '';
let previousLabel = "";
// A chunk of data has been recieved
resp.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received
resp.on('end', () => {
const document = new xmldoc.XmlDocument(data); // to pretty print xmldoc parsing of data: console.log(document.toString({trimmed: true}));
if (document === undefined || document.childNamed("reply") === undefined || document.childNamed("reply").childNamed("passage") === undefined)
return resolve ("Text not found. Check dialogue spelling, stephanus number range, or prefix book before stephanus argument.")
// cut directly to the relevant parts of xml response
let result = document.childNamed("reply").childNamed("passage").childNamed("TEI").childNamed("text").childNamed("body").childNamed("div");
if (result === undefined)
return resolve ("Text not found. Check dialogue spelling, stephanus number range, or prefix book before stephanus argument.")
// check for book
if (result.childWithAttribute("subtype").attr.subtype === "book") {
// add two more layers deep to the xml tree
typeOfResult = "book"
result = document.childNamed("reply").childNamed("passage").childNamed("TEI").childNamed("text").childNamed("body").childNamed("div").childNamed("div").childNamed("div");
} else if (result.childWithAttribute("subtype").attr.subtype === "section") {
// add one more layer deep to the xml tree
typeOfResult = "section"
result = document.childNamed("reply").childNamed("passage").childNamed("TEI").childNamed("text").childNamed("body").childNamed("div").childNamed("div");
} else {
return resolve ("Unknown organization found. Email [email protected] with your URL request, dialogue, and stephanus number.", result.childWithAttribute("subtype").attr.subtype);
}
// extract info (text, speakers, stephanus numbers) from each paragraph
const allParagraphs = result.childrenNamed("p");
for (let i = 0; i < allParagraphs.length; i++) {
// check for speakers
const textWithSpeaker = allParagraphs[i].childNamed("said");
// if there is a speaker, log the speaker and check for milestone within "said" node
if (textWithSpeaker) {
// extract speaker
let speaker = textWithSpeaker.attr.who;
speaker = speaker.slice(1)
// extract label for speaker, if there is one; attach this to the text found
let label;
let newLabelFound = false
if (textWithSpeaker.childNamed("label")) {
label = textWithSpeaker.childNamed("label").val
if (previousLabel === "") {
previousLabel = label
}
console.log(label, previousLabel)
// overwrite previousLabel only if it's a new one
if (label !== previousLabel) {
previousLabel = label
newLabelFound = !newLabelFound
}
};
// Extract new stephanus milestone, if there are any
// But since there could be multiple milestones in the same "said" node, we have to put all the children of the "said" node in an array first, and capture the texts and stephanus numbers as they come
const allChildren = allParagraphs[i].childNamed("said").children;
for (let j = 0; j < allChildren.length; j++) {
// If it's an element node, and that node contains a new section, capture the stephanus number and letter
if (allChildren[j].attr) {
if (allChildren[j].attr.unit === "section") {
const stephanus = allChildren[j].attr.n;
currentStephanus = stephanus;
}
// Check for proper name, place name, del node text
if (allChildren[j].name === "persName" || allChildren[j].name === "name" || allChildren[j].name === "placeName" || allChildren[j].name === "del") {
// concatenate name to what's already in textsFound; otherwise, create new key value pair
let newText = allChildren[j].val;
newText = newText.replace(/(\r\n|\n|\r)/gm, "");
if (textsFound[currentStephanus]) {
textsFound[currentStephanus] += newText.trim() + " ";
} else {
if (currentStephanus === undefined) {
// Removes book number and period from search
if (userStephanus.charAt(2) === ".") {
userStephanus = userStephanus.slice(3) // Cuts out both digits and period if it's book 10, 11, or 12
} else if (userStephanus.length > 1 && typeOfResult === "book") { // Doesn't touch single numbers, e.g. in Euthyphro
userStephanus = userStephanus.slice(2)
}
// Calculate what the previous stephanus number is, immediately prior to user search
currentStephanus = ((parseInt(userStephanus) - 1)) + "e";
textsFound[currentStephanus] = newText.trim();
} else {
textsFound[currentStephanus] = newText.trim();
}
}
}
// Check if there's a q node, check for new section and text
if (allChildren[j].name === "q"){
// First create an array of all the nested children
const allNestedChildren = allChildren[j].children
for (let k = 0; k < allNestedChildren.length; k++) {
// Capture the milestone if there is one inside the q section
if (allNestedChildren[k].attr) {
if (allNestedChildren[k].attr.unit === "section") {
const stephanus = allNestedChildren[k].attr.n;
currentStephanus = stephanus;
}
}
// If it's a text node, capture the text (REFACTOR AS FUNCTION, THIS CODE IS REPEATED TOO MANY TIMES)
if (allNestedChildren[k].text) {
let newText;
// Don't do labels, since a label has already been added when the person began speaking
newText = allNestedChildren[k].text.trim();
// strip out line breaks
newText = newText.replace(/(\r\n|\n|\r)/gm, "");
// concatenate text to what's already in textsFound; otherwise, create new key value pair
if (textsFound[currentStephanus]) {
textsFound[currentStephanus] += newText.trim() + " ";
} else {
if (currentStephanus === undefined) {
// Removes book number and period from search
if (userStephanus.charAt(2) === ".") {
userStephanus = userStephanus.slice(3) // Cuts out both digits and period if it's book 10, 11, or 12
} else if (userStephanus.length > 1 && typeOfResult === "book") { // Doesn't touch single numbers, e.g. in Euthyphro
userStephanus = userStephanus.slice(2)
}
// Calculate what the previous stephanus number is, immediately prior to user search
currentStephanus = ((parseInt(userStephanus) - 1)) + "e";
textsFound[currentStephanus] = newText.trim();
} else {
textsFound[currentStephanus] = newText.trim();
}
}
}
}
}
}
// If it's a text node, capture the text
if (allChildren[j].text) {
let newText;
// Concatenate label to text, if there is a label AND it's not the most recent addition to the label
if (label && !textsFound[currentStephanus]) {
newText = label.trim() + " " + allChildren[j].text.trim();
} else if (label && newLabelFound) {
newText = label.trim() + " " + allChildren[j].text.trim();
newLabelFound = !newLabelFound;
} else {
newText = allChildren[j].text.trim();
}
// strip out line breaks
newText = newText.replace(/(\r\n|\n|\r)/gm, "");
// concatenate text to what's already in textsFound; otherwise, create new key value pair
if (textsFound[currentStephanus]) {
textsFound[currentStephanus] += newText.trim() + " ";
} else {
if (currentStephanus === undefined) {
// Removes book number and period from search
if ((userStephanus.charAt(1) === ".") || (userStephanus.charAt(2)) === ".") {
userStephanus = userStephanus.slice(3) // Cuts out both digits if it's book 10, 11, or 12
} else if (userStephanus.length > 1 && typeOfResult === "book") { // Doesn't touch single numbers, e.g. in Euthyphro
userStephanus = userStephanus.slice(2)
}
// Calculate what the previous stephanus number is, immediately prior to user search
currentStephanus = ((parseInt(userStephanus) - 1)) + "e";
textsFound[currentStephanus] = newText.trim();
} else {
textsFound[currentStephanus] = newText.trim();
}
}
}
}
} else {
// since there is no speaker, check for milestones directly in the "p" node
// but since there could be multiple milestones in the same "p" node, we have to put all the children in an array first, and capture the texts and stephanus numbers as they come
const allChildren = allParagraphs[i].children;
for (let j = 0; j < allChildren.length; j++) {
// if it's an element node, and that node contains a new section, capture the stephanus number and letter
if (allChildren[j].attr) {
if (allChildren[j].attr.unit === "section") {
const stephanus = allChildren[j].attr.n;
currentStephanus = stephanus;
}
}
// Check for proper name, place name, del node text
if (allChildren[j].name === "persName" || allChildren[j].name === "name" || allChildren[j].name === "placeName" || allChildren[j].name === "del") {
// concatenate name to what's already in textsFound; otherwise, create new key value pair
let newText = allChildren[j].val;
newText = newText.replace(/(\r\n|\n|\r)/gm, "");
if (textsFound[currentStephanus]) {
textsFound[currentStephanus] += newText.trim() + " ";
} else {
if (currentStephanus === undefined) {
// Removes book number and period from search
if (userStephanus.charAt(2) === ".") {
userStephanus = userStephanus.slice(3) // Cuts out both digits and period if it's book 10, 11, or 12
} else if (userStephanus.length > 1 && typeOfResult === "book") { // Doesn't touch single numbers, e.g. in Euthyphro
userStephanus = userStephanus.slice(2)
}
// Calculate what the previous stephanus number is, immediately prior to user search
currentStephanus = ((parseInt(userStephanus) - 1)) + "e";
textsFound[currentStephanus] = newText.trim();
} else {
textsFound[currentStephanus] = newText.trim();
}
}
}
// if it's a text node, capture the text
if (allChildren[j].text) {
let newText;
newText = allChildren[j].text.trim();
// concatenate text to what's already in textsFound; otherwise, create new key value pair
if (textsFound[currentStephanus]) {
textsFound[currentStephanus] += newText.trim();
} else {
if (currentStephanus === undefined) {
// Removes book number and period from search
if ((userStephanus.charAt(1) === ".") || (userStephanus.charAt(2)) === ".") {
userStephanus = userStephanus.slice(3) // Cuts out both digits if it's book 10, 11, or 12
} else if (userStephanus.length > 1) { // Doesn't touch single numbers, e.g. in Euthyphro
userStephanus = userStephanus.slice(2)
}
// Calculate what the previous stephanus number is, immediately prior to user search
currentStephanus = ((parseInt(userStephanus) - 1)) + "e";
textsFound[currentStephanus] = newText.trim();
} else {
textsFound[currentStephanus] = newText.trim();
}
}
}
}
}
}
let singleTextFound = {};
// Depending on the type of search input, either give a single section or a whole section
if (userStephanusLetter && typeOfResult === "book") {
singleTextFound["passageRequested"] = dialogueName + " " + userStephanus + userStephanusLetter;
singleTextFound["URL"] = queryURL;
// Removes book number and period from userStephanus
if (userStephanus.charAt(2) === ".") { // Remove three characters if it's a double digit book
userStephanus = userStephanus.slice(3)
} else if (userStephanus.charAt(1) === ".") {
userStephanus = userStephanus.slice(2) // Remove only two characters if it's a single digit book
}
singleTextFound[userStephanus + userStephanusLetter] = textsFound[userStephanus + userStephanusLetter];
// console.log(singleTextFound);
return resolve(singleTextFound);
} else if (userStephanusLetter) {
singleTextFound["passageRequested"] = dialogueName + " " + userStephanus + userStephanusLetter;
singleTextFound["URL"] = queryURL;
singleTextFound[userStephanus + userStephanusLetter] = textsFound[userStephanus + userStephanusLetter];
// console.log(singleTextFound);
return resolve(singleTextFound);
} else {
// return entire stephanus number
// console.log(textsFound);
return resolve(textsFound);
}
});
}).on("error", (err) => {
reject (err);
});
})
}
// For testing
// let userStephanus = "";
// const userDialogue = process.argv[2].toLowerCase().trim();
// if (process.argv[3]) {
// userStephanus = process.argv[3].toLowerCase().trim();
// } else {
// userStephanus = "NONE";
// }
// getPlatoText(userDialogue, userStephanus);
module.exports = getPlatoText;