words.append(Y) return words if __name__ == "__main__": import sys import pickle from iadfa import IncrementalAdfa sys.argv = sys.argv[1:] etr = ErrorTolerantRecognizer() pFile = "test4.pickle" if "--gen" in sys.argv: sys.argv.remove("--gen") file = open("test.dico", "r") words = [] for word in file: if word[-1] == "\n": word = word[:-1] words.append(word) words.sort() iadfa = IncrementalAdfa(words, sorted=True) pickle.dump(iadfa, open(pFile, "w")) else: iadfa = pickle.load(open(pFile, "r")) if "--export" in sys.argv: sys.argv.remove("--export") iadfa.graphVizExport("test4.dot") etr.recognize(sys.argv[0], iadfa, 2)
words.append(Y) return words if __name__ == "__main__": import sys import pickle from iadfa import IncrementalAdfa sys.argv = sys.argv[1:] etr = ErrorTolerantRecognizer() pFile = "test4.pickle" if "--gen" in sys.argv: sys.argv.remove("--gen") file = open("test.dico", "r") words = [] for word in file: if word[-1] == "\n": word = word[:-1] words.append(word) words.sort() iadfa = IncrementalAdfa(words, sorted = True) pickle.dump(iadfa, open(pFile,"w")) else: iadfa = pickle.load(open(pFile, "r")) if "--export" in sys.argv: sys.argv.remove("--export") iadfa.graphVizExport("test4.dot") etr.recognize(sys.argv[0],iadfa,2)
from iadfa import IncrementalAdfa f = ["append", "appendice", "bappend"] fsa = IncrementalAdfa(f, sorted = True) fsa.graphVizExport("test.dot")