|
From: <fri...@us...> - 2008-12-23 15:23:37
|
Revision: 9628
http://zaf.svn.sourceforge.net/zaf/?rev=9628&view=rev
Author: friedelwolff
Date: 2008-12-23 15:23:29 +0000 (Tue, 23 Dec 2008)
Log Message:
-----------
Remove format handling. Provide basic hunspell skeleton using hunspell_format.py
Modified Paths:
--------------
trunk/dict/zu/hunspell/zu_aff.py
Modified: trunk/dict/zu/hunspell/zu_aff.py
===================================================================
--- trunk/dict/zu/hunspell/zu_aff.py 2008-12-23 15:16:09 UTC (rev 9627)
+++ trunk/dict/zu/hunspell/zu_aff.py 2008-12-23 15:23:29 UTC (rev 9628)
@@ -20,6 +20,7 @@
"""This module creates an affix file for a Zulu spell checker."""
+from hunspell_format import *
import re
subject_concords = ["ngi", "u", "si", "ni", "u", "ba", "i", "li", "a", "si", "zi", "lu", "bu", "ku"]
@@ -191,53 +192,7 @@
pass
return changed
-def quicksort(l):
- if l == []:
- return []
- return quicksort([x for x in l[1:] if x[1] < l[0][1]]) + \
- l[0:1] + \
- quicksort([x for x in l[1:] if x[1] >= l[0][1]])
-def remove_duplicates(rules):
- """Remove duplicate rules and return the trimmed rules list."""
- rules = [rules[0]] + quicksort(rules[1:])
-
- before = rules[0]
- for i in rules[1:]:
- if i == before:
- rules.remove(i)
- before = i
-
- return rules
-
-def output_myspell():
- """Output the generated rules in the format required for a myspell affix
- file."""
- print """# Automatically generated by zu_aff.py"
-SET ISO8859-1
-TRY aeinulkhosbgywmztdpfcqrvj-ASJMHxEKBGNPTRLDIZFOUWVYC
-
-"""
- print "REP %d" % len(replace_list)
- for rep in replace_list:
- print "REP %s %s" % (rep[0], rep[1].replace(' ', '_'))
- print
-
- for rule_set in rules:
- identifier = rule_set[0][0]
- rule_set[0][0] = ''
- affix_type = rule_set[0][2]
- rule_set[0][2] = str(len(rule_set)-1)
- #remember that the first element does not count
- for rule in rule_set:
- print affix_type + " " + identifier + ' ' + rule[0],
- if len(rule[1]) > 0:
- print rule[1],
- else:
- print "0",
- print rule[2]
- print
-
################################################################################
for i in concords:
@@ -352,7 +307,15 @@
V_rules.append(['a', 'waphi', '[^w]a'])
#The above can also be used with negatives, can't they? As in: Igama alipelwa.
-for i in range(len(rules)):
- rules[i] = remove_duplicates(rules[i])
-output_myspell()
+if __name__ == '__main__':
+ aff = HunspellOptions()
+ aff.header = "Automatically generated by zu_aff.py. For copyright information, see zu_aff.py"
+ aff.try_list = "aeinulkhosbgywmztdpfcqrvj-ASJMHxEKBGNPTRLDIZFOUWVYC"
+ aff.encoding = "ISO8859-1"
+ aff.replace_list = replace_list
+ aff.circumfix = "X"
+ aff.needaffix = "Y"
+ aff.complexprefixes = True
+
+ print aff.hunspell()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|