-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_morphology.sc
92 lines (71 loc) · 2.36 KB
/
new_morphology.sc
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
import scala.io.Source
import java.io._
import java.util.Calendar
import scala.collection.mutable.LinkedHashMap
import edu.holycross.shot.scm._
import edu.holycross.shot.cite._
import edu.holycross.shot.ohco2._
import edu.holycross.shot.greek._
import scala.io.StdIn.readLine
import scala.collection.mutable._
import edu.furman.classics.fumorph._
:load newMorphConfig.sc
val filePath:String = ""
val splitters:String = """[\[\])(·⸁.,·;; "?·!–—⸂⸃]"""
def loadLibrary(fp:String):CiteLibrary = {
val library = CiteLibrary(Source.fromFile(fp).getLines.mkString("\n"),"#",",")
library
}
def loadFile(fp:String):Vector[String] = {
Source.fromFile(fp).getLines.toVector
}
def saveString(s:String, fileName:String = "cex/test.cex"):Unit = {
val pw = new PrintWriter(new File(filePath + fileName))
pw.append(s)
pw.append("\n")
pw.close
}
def showMe(v:Any):Unit = {
v match {
case _:Vector[Any] => println(s"""----\n${v.asInstanceOf[Vector[Any]].mkString("\n")}\n----""")
case _:Iterable[Any] => println(s"""----\n${v.asInstanceOf[Iterable[Any]].mkString("\n")}\n----""")
case _ => println(s"-----\n${v}\n----")
}
}
/* Variables Below */
val greekLexIndex = loadFile("lexica/new_greek_index.txt").filter(_.split("#").size == 3)
//val gmlib = loadLibrary(greekMorphLibFile)
//val gtlib = loadLibrary("cex/candaules.cex)
//lazy val gmorph:FuMorph = FuMorph(Some(gmlib), gtlib, Greek, greekLexIndex)
val latinLexIndex = loadFile("lexica/new_latin_index.txt").filter(_.split("#").size == 3)
//val lmlib = loadLibrary(greekMorphLibFile)
//val ltlib = loadLibrary("cex/candaules.cex")
//lazy val lmorph:FuMorph = FuMorph(Some(lmlib), ltlib, Latin, latinLexIndex)
//Load and update
var morphLib:Option[FuMorph] = None
var morphLang:MorphLanguage = lang
def newMorph(libLang:MorphLanguage, textLibFile:String = textLibrary):Unit = {
val textLib:CiteLibrary = loadLibrary(textLibFile)
morphLang match {
case Greek => {
val gmorph:FuMorph = FuMorph(None, textLib, Greek)
morphLib = Some(gmorph)
}
case _ => {
val lmorph:FuMorph = FuMorph(None, textLib, Latin)
morphLib = Some(lmorph)
}
}
}
def newMorphology:Unit = {
newMorph(lang, textLibrary)
saveString(morphLib.get.updateCex, outputFile)
}
def help:Unit = {
println("""---------------------
Start a new morphology:
[ edit file newMorphConfig.sc ]
scala> newMorphology
---------------------""")
}
help