[clml] r130 committed - Attempt to auto-generate missing model file in pyphon_maketableaux

0 views
Skip to first unread message

cl...@googlecode.com

unread,
Jul 2, 2011, 4:20:57 PM7/2/11
to cl...@googlegroups.com
Revision: 130
Author: max....@gmail.com
Date: Sat Jul 2 13:20:14 2011
Log: Attempt to auto-generate missing model file in pyphon_maketableaux
http://code.google.com/p/clml/source/detail?r=130

Modified:
/trunk/pyphon/src/pyphon_maketableaux.py
/trunk/pyphon/src/syllables-cv3-ot.csv

=======================================
--- /trunk/pyphon/src/pyphon_maketableaux.py Wed Sep 1 08:34:37 2010
+++ /trunk/pyphon/src/pyphon_maketableaux.py Sat Jul 2 13:20:14 2011
@@ -1,6 +1,6 @@
#!/usr/bin/env python

-import pyphon, csv, sys, pickle, re
+import pyphon, csv, sys, pickle, re, os
from pprint import pprint
from optparse import OptionParser

@@ -57,8 +57,41 @@
return match.group(1)
return re.sub(r'\\(.)', sub, input)

+def autoCreateModel(modelFile):
+ print 'Model file %s does not exist.' % (modelFile,)
+ descriptionFile = modelFile.replace('.mod', '')
+
+ print 'Attempting to auto-generate...'
+ try:
+ import pyphon_makemodel
+ except ImportError:
+ myPath = os.path.split(__file__)[0]
+ if myPath not in sys.path:
+ sys.path.append(myPath)
+ try:
+ import pyphon_makemodel
+ except ImportError:
+ print 'Auto-generation failed. Unable to import
pyphon_makemodel.'
+ return False
+
+ # let exceptions propagate
+ pyphon_makemodel.main(descriptionFile, outputFile=modelFile)
+
+ if os.path.exists(modelFile):
+ print 'Auto-generation successful.'
+ return True
+ else:
+ print 'Auto-generation failed.'
+ return False
+
def main(modelFile, inputFile, opt, outputFile=None, separator=" | "):
modelFile = filenameWithExtension(modelFile, 'mod')
+ if not os.path.exists(modelFile):
+ if not autoCreateModel(modelFile):
+ print 'Aborting pyphon_maketableaux: model file %s not found '\
+ 'and unable to auto-generate.' % modelFile
+ raise SystemExit
+
modelBasename = modelFile.replace('.mod', '')
inputBasename = inputFile.replace('.csv', '')
outputFile = outputFile or '%s-%s-%s' % (modelBasename, inputBasename,
opt)
=======================================
--- /trunk/pyphon/src/syllables-cv3-ot.csv Wed Jan 26 20:11:42 2011
+++ /trunk/pyphon/src/syllables-cv3-ot.csv Sat Jul 2 13:20:14 2011
@@ -3,14 +3,14 @@
#C#,##,,0,0,1,0,0

,,,depC,depV,max,noCoda,onset
-#V#,##,,0,0,1,0,0
-#V#,#V#,,0,0,0,0,1
#V#,#CV#,,1,0,0,0,0
+#V#,#V#,,0,0,0,0,1
+#V#,##,,0,0,1,0,0

,,,depC,depV,max,noCoda,onset
#CC#,##,,0,0,2,0,0
-#CC#,#CV.CV#,,0,2,0,0,0
#CC#,#CVC#,,0,1,0,1,0
+#CC#,#CV.CV#,,0,2,0,0,0

,,,depC,depV,max,noCoda,onset
#CV#,#CV#,,0,0,0,0,0
@@ -31,9 +31,9 @@
#VV#,##,,0,0,2,0,0

,,,depC,depV,max,noCoda,onset
-#CCC#,##,,0,0,3,0,0
-#CCC#,#CV.CV.CV#,,0,3,0,0,0
#CCC#,#CV.CVC# | #CVC.CV#,,0,2,0,1,0
+#CCC#,#CV.CV.CV#,,0,3,0,0,0
+#CCC#,##,,0,0,3,0,0

,,,depC,depV,max,noCoda,onset
#CCV#,#CV.CV#,,0,1,0,0,0
@@ -45,8 +45,8 @@
#CVC#,#CV#,,0,0,1,0,0

,,,depC,depV,max,noCoda,onset
-#CVV#,#CV.V#,,0,0,0,0,1
#CVV#,#CV#,,0,0,1,0,0
+#CVV#,#CV.V#,,0,0,0,0,1
#CVV#,#CV.CV#,,1,0,0,0,0

,,,depC,depV,max,noCoda,onset
@@ -55,30 +55,30 @@
#VCC#,#V.CV.CV#,,0,2,0,0,1
#VCC#,#CV.CV.CV#,,1,2,0,0,0
#VCC#,#VC.CV# | #V.CVC#,,0,1,0,1,1
-#VCC#,#V#,,0,0,2,0,1
+#VCC#,#CVC#,,0,1,1,1,0
#VCC#,#VC#,,0,0,1,1,1
#VCC#,#CV.CV#,,0,2,1,0,0
#VCC#,##,,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