|
From: <fri...@us...> - 2008-12-19 09:22:28
|
Revision: 9618
http://zaf.svn.sourceforge.net/zaf/?rev=9618&view=rev
Author: friedelwolff
Date: 2008-12-19 09:22:23 +0000 (Fri, 19 Dec 2008)
Log Message:
-----------
Move definitions of palatalisations and define them as a plain list first
Modified Paths:
--------------
trunk/dict/zu/myspell/zu_aff.py
Modified: trunk/dict/zu/myspell/zu_aff.py
===================================================================
--- trunk/dict/zu/myspell/zu_aff.py 2008-12-15 11:12:11 UTC (rev 9617)
+++ trunk/dict/zu/myspell/zu_aff.py 2008-12-19 09:22:23 UTC (rev 9618)
@@ -41,6 +41,32 @@
rules = [a_rules, A_rules, V_rules, i_rules]
"""all rules"""
+#These regular expressions will be used to do search-replace palatalisation. It
+#is defined outside the function so that it only needs to be done once. It is
+#crucial that the palatalisations starting on 'm' be listed first. Otherwise
+#the rules for the m-less forms will fire first. Hash signs indicate the more
+#common ones.
+
+palatalisation_list = [
+ ["mbw", "njw"],#
+ ["mpw", "ntshw"],
+ ["mw", "nyw"], #
+ ["bw", "tshw"],
+ ["bhw", "jw"],
+ ["phw", "shw"],#
+]
+
+palatalisation_re_list = []
+for palatalisation in palatalisation_list:
+ palatalisation_re_list.append([re.compile(palatalisation[0]), palatalisation[1]])
+
+def palatalise(string):
+ """Perform palatalisation substitutions on the given string."""
+ new_string = string
+ for palatalisation_re in palatalisation_re_list:
+ new_string = palatalisation_re[0].sub(palatalisation_re[1], new_string)
+ return new_string
+
def illegal_reflexive(subject, object):
"""Returns whether using the given concords together would result in an
illegal reflexive
@@ -138,26 +164,6 @@
return changed
-#These regular expressions will be used to do search-replace palatalisation. It
-#is defined outside the function so that it only needs to be done once. It is
-#crucial that the palatalisations starting on 'm' be listed first. Otherwise
-#the rules for the m-less forms will fire first. Hash signs indicate the more
-#common ones.
-palatalisations = []
-palatalisations.append([re.compile("mbw"), "njw"]) #
-palatalisations.append([re.compile("mpw"), "ntshw"])
-palatalisations.append([re.compile("mw"), "nyw"]) #
-palatalisations.append([re.compile("bw"), "tshw"])
-palatalisations.append([re.compile("bhw"), "jw"])
-palatalisations.append([re.compile("phw"), "shw"]) #
-
-def palatalise(string):
- """Perform palatalisation substitutions on the given string."""
- new_string = string
- for palatalisation in palatalisations:
- new_string = palatalisation[0].sub(palatalisation[1], new_string)
- return new_string
-
def quicksort(l):
if l == []:
return []
@@ -182,10 +188,11 @@
def output_myspell():
"""Output the generated rules in the format required for a myspell affix
file."""
- print "# Automatically generated by zu_aff.py"
- print "SET ISO8859-1"
- print "TRY aeinulkhosbgywmztdpfcqrvj-ASJMHxEKBGNPTRLDIZFOUWVYC"
- print
+ print """# Automatically generated by zu_aff.py"
+SET ISO8859-1
+TRY aeinulkhosbgywmztdpfcqrvj-ASJMHxEKBGNPTRLDIZFOUWVYC
+
+"""
for rule_set in rules:
identifier = rule_set[0][0]
rule_set[0][0] = ''
@@ -338,4 +345,3 @@
rules[i] = remove_duplicates(rules[i])
output_myspell()
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|