#! /usr/bin/env python3 import argparse import phonagen def parseArgs(): # Define argument parser parser = argparse.ArgumentParser(description='Convert an example list to a rule generator.') parser.add_argument('file', metavar='listfile', help='list file to convert') parser.add_argument('--id', metavar='id', help='id of the generator', required = True) parser.add_argument('--description', metavar='description', help='description of the generator; empty if not provided', default='') parser.add_argument('--phonology', metavar='phonology', help='id of the phonology on which is based the generator', required = True) parser.add_argument('--phonologyfile', metavar='phonologyfile', help='file containing the phonology; mandatory; phonology will present in the output', required = True) parser.add_argument('--output', metavar='output-file', help='Output file for the generator. The file is printed to standard output if not given.', default='') # Parse arguments return parser.parse_args() # Main if __name__ == '__main__': args = parseArgs() generator = phonagen.RuleGenerator(id = args.id, description = args.description, phonology = args.phonology) phonology = phonagen.Phonology() phonologyFile = phonagen.PhonagenFile() phonologyFile.load(args.phonologyfile) phonology = phonologyFile.getPhonology(args.phonology) # generator.fromExamples(args.file, phonology) phonagenFile = phonagen.PhonagenFile() phonagenFile.addPhonology(phonology) phonagenFile.addGenerator(generator) phonagenFile.writeTo(args.output)