[clml] r137 committed - Added tutorial files.

0 views
Skip to first unread message

cl...@googlecode.com

unread,
Jul 12, 2011, 3:54:53 PM7/12/11
to cl...@googlegroups.com
Revision: 137
Author: sbo...@isetsu.net
Date: Tue Jul 12 12:54:26 2011
Log: Added tutorial files.
http://code.google.com/p/clml/source/detail?r=137

Added:
/trunk/pyphon/src/tutorial-harmony
/trunk/pyphon/src/tutorial-harmony/simple_IO_pairs.csv
/trunk/pyphon/src/tutorial-harmony/simple_inputs.csv
/trunk/pyphon/src/tutorial-harmony/typology-tOrder.dot
Modified:
/trunk/pyphon/src/pyphon/twotierlangs.py
/trunk/pyphon/src/pyphon_generate.py
/trunk/pyphon/src/pyphon_recurse.py
/trunk/pyphon/src/pyphon_twotier.py

=======================================
--- /dev/null
+++ /trunk/pyphon/src/tutorial-harmony/simple_IO_pairs.csv Tue Jul 12
12:54:26 2011
@@ -0,0 +1,8 @@
+# Put one input, output pair on each line
+# Mark stem boundaries in the input with \#, and inter-affix boundaries
with \.
+# Do not mark boundaries in the output
+
+CoCu, CoCu
+\#Co\#Co, CoCo
+a\#CoCuo\#, oCoCuo
+I.a\#CoCuo\#, uoCoCuo
=======================================
--- /dev/null
+++ /trunk/pyphon/src/tutorial-harmony/simple_inputs.csv Tue Jul 12
12:54:26 2011
@@ -0,0 +1,7 @@
+# Put one input on each line
+# Mark stem boundaries in the input with \#, and inter-affix boundaries
with \.
+
+CoCu
+\#Co\#Co
+a\#CoCuo\#
+I\.a\#CoCuo\#
=======================================
--- /dev/null
+++ /trunk/pyphon/src/tutorial-harmony/typology-tOrder.dot Tue Jul 12
12:54:26 2011
@@ -0,0 +1,13 @@
+digraph torder {
+ rankdir=LR;ranksep=1.2
+ node [shape=box,fillcolor="lightgray"];
+ 0 -> 1;
+ 0 -> 2;
+ 0 -> 3;
+ 0 -> 4;
+ 0 [label="/#Co#Co/ -> [#Co#Co] (0,0,0,0)\n/CoCu/ -> [CoCu] (0,0,0,0)\n4
languages.", style="dotted,filled"];
+ 1 [label="/I.a#CoCuo#/ -> [u.u#CoCuo#] (0,1,2,0)\n/a#CoCuo#/ ->
[u#CoCuo#] (0,1,1,0)\n1 language.", style="bold"];
+ 2 [label="/I.a#CoCuo#/ -> [I.a#CoCuo#] (1,0,0,0)\n/a#CoCuo#/ ->
[a#CoCuo#] (1,0,0,0)\n1 language.", style="bold"];
+ 3 [label="/I.a#CoCuo#/ -> [I.a#CaCIa#] (0,0,3,0)\n/a#CoCuo#/ ->
[a#CaCIa#] (0,0,3,0)\n1 language.", style="bold"];
+ 4 [label="/I.a#CoCuo#/ -> [u.o#CoCuo#] (0,0,2,1)\n/a#CoCuo#/ ->
[o#CoCuo#] (0,0,1,1)\n1 language.", style="bold"];
+}
=======================================
--- /trunk/pyphon/src/pyphon/twotierlangs.py Fri Jul 1 18:36:02 2011
+++ /trunk/pyphon/src/pyphon/twotierlangs.py Tue Jul 12 12:54:26 2011
@@ -6,8 +6,9 @@
from permutationdistance import getrankings, set_dif

def print_languages(languages, log, i):
+ print
for language in languages:
- print "Language:", i
+ print "Language", i
log.write("Language "+str(i)+"\n")
print "Cyclic ERCs", language[0]
log.write(str(language[0]))
@@ -24,7 +25,7 @@
print member[0], member[1], member[2]
log.write(str(member[0])+" "+str(member[1])+" "+str(member[2])+"\n")
#print language[3]
-
+
def compatible_languages(cohort, languages):
retlanguages = []
if languages == []:
=======================================
--- /trunk/pyphon/src/pyphon_generate.py Sat Jul 2 14:18:31 2011
+++ /trunk/pyphon/src/pyphon_generate.py Tue Jul 12 12:54:26 2011
@@ -281,7 +281,7 @@
return

if not os.path.exists(tableauxfile):
- print 'Tableax file %s does not exist.' % (tableauxfile,)
+ print 'Tableaux file %s does not exist.' % (tableauxfile,)
if not autoCreateTableaux(tableauxfile):
print 'Aborting pyphon_generate: tableaux file %s not found '\
'and unable to auto-generate.' % tableauxfile
=======================================
--- /trunk/pyphon/src/pyphon_recurse.py Fri Jul 1 18:36:02 2011
+++ /trunk/pyphon/src/pyphon_recurse.py Tue Jul 12 12:54:26 2011
@@ -27,6 +27,7 @@


def main(model, ifn):
+ ercs_exists = 0

def process(output, con, words):
'Run one tier'
@@ -99,6 +100,7 @@

# Generate ERCs
if erc != "0":
+ ercs_exists = 1
eoutput = open('ercs.csv','w')
eoutput.write('\nERCS, gram\n')
w=[]
@@ -195,8 +197,11 @@
inputs = []

for line in infile:
+ if line[0]=="#" or len(line)==1:
+ continue
+
+ line = line.rstrip("\n")
print line
- line = line.rstrip("\n")

# Separate the affixes
sectioned = line.rsplit('\#')
@@ -219,16 +224,20 @@


output = open(model + '_' + infilename + '_recursive_typology.csv','w')
- #output.write('Input, '+input+"\n")
+ output.write('Input, Output, ERCs, Intermediate Forms\n')
+#output.write('Input, '+input+"\n")


process(output, [], inputs)
output.close()
+ print "Wrote recursive typology to", model + '_' + infilename
+ '_recursive_typology.csv'
os.remove('recurse_temp.csv')
os.remove('recurse_inp_temp.csv')
os.remove('recurse_tab_temp.csv')
os.remove('recurse_typ_temp.csv')
- os.remove('ercs.csv')
+ if ercs_exists:
+ os.remove('ercs.csv')
+

=======================================
--- /trunk/pyphon/src/pyphon_twotier.py Fri Jul 1 18:36:02 2011
+++ /trunk/pyphon/src/pyphon_twotier.py Tue Jul 12 12:54:26 2011
@@ -75,7 +75,7 @@
for line in infile: #take these as inputs for MakeTab
line = line.replace("\r","")
line = line.replace("\n","")
- if (line and line[0] == ","):
+ if (line and line[0] == ",") or line=="Input, Output, ERCs, Intermediate
Forms":
continue
print line
sectioned = line.rsplit(', ')
@@ -112,7 +112,7 @@

infile.close()

- pyphon_generate.main("twotier_tab_temp", "twotier_temp", "ot")
+ pyphon_generate.main("twotier_tab_temp.csv", "twotier_temp", "ot")

infile = open("twotier_temp.csv", 'r')

@@ -172,7 +172,7 @@

#Found an I-I-O mapping!
pair[5] = True
- print "Found",pair[0], input, output,initialerc,localerc,"\n"
+ #print "Found",pair[0], input, output,initialerc,localerc,"\n"

log.write(pair[0]+","+input+","+output+","+initialerc+","+localerc+'\n')
combinations.append([pair[0], pair[6], output, initialerc, localerc])

Reply all
Reply to author
Forward
0 new messages