def __read_inflection_rule(file): while True: line = file.readline() if not line.endswith('\n'): return None strippedLine = voikkoutils.removeComments(line).strip() if len(strippedLine) == 0: continue columns = strippedLine.split() if columns[0] == 'end:': return None r = InflectionRule() if columns[0].startswith(u'!'): r.name = columns[0][1:] r.isCharacteristic = True else: r.name = columns[0] if columns[0] in ['nominatiivi', 'genetiivi', 'partitiivi', 'illatiivi', 'nominatiivi_mon', 'genetiivi_mon', 'partitiivi_mon', 'illatiivi_mon', 'infinitiivi_1', 'preesens_yks_1', 'imperfekti_yks_3', 'kondit_yks_3', 'imperatiivi_yks_3', 'partisiippi_2', 'imperfekti_pass']: r.isCharacteristic = True else: r.isCharacteristic = False if columns[1] != u'0': r.delSuffix = columns[1] if columns[2] != u'0': r.addSuffix = columns[2] if columns[3] == u's': r.gradation = voikkoutils.GRAD_STRONG if len(columns) > 4: if __read_option(columns[4], u'ps', u'') == u'r': continue r.rulePriority = int(__read_option(columns[4], u'prio', u'1')) return r
def __read_inflection_rule(file): while True: line = file.readline() if not line.endswith('\n'): return None strippedLine = voikkoutils.removeComments(line).strip() if len(strippedLine) == 0: continue columns = strippedLine.split() if columns[0] == 'end:': return None r = InflectionRule() if columns[0].startswith(u'!'): r.name = columns[0][1:] r.isCharacteristic = True else: r.name = columns[0] if columns[0] in [ 'nominatiivi', 'genetiivi', 'partitiivi', 'illatiivi', 'nominatiivi_mon', 'genetiivi_mon', 'partitiivi_mon', 'illatiivi_mon', 'infinitiivi_1', 'preesens_yks_1', 'imperfekti_yks_3', 'kondit_yks_3', 'imperatiivi_yks_3', 'partisiippi_2', 'imperfekti_pass' ]: r.isCharacteristic = True else: r.isCharacteristic = False if columns[1] != u'0': r.delSuffix = columns[1] if columns[2] != u'0': r.addSuffix = columns[2] if columns[3] == u's': r.gradation = voikkoutils.GRAD_STRONG if len(columns) > 4: if __read_option(columns[4], u'ps', u'') == u'r': continue r.rulePriority = int(__read_option(columns[4], u'prio', u'1')) return r
def __read_header(file): while True: line = file.readline() if not line.endswith('\n'): return None strippedLine = voikkoutils.removeComments(line).strip() if len(strippedLine) == 0: continue valStart = strippedLine.find(':') if valStart < 1: print 'Malformed input file: the problematic line was' print line return None return (strippedLine[:valStart].strip(), strippedLine[valStart+1:].strip())
def __read_header(file): while True: line = file.readline() if not line.endswith('\n'): return None strippedLine = voikkoutils.removeComments(line).strip() if len(strippedLine) == 0: continue valStart = strippedLine.find(':') if valStart < 1: print 'Malformed input file: the problematic line was' print line return None return (strippedLine[:valStart].strip(), strippedLine[valStart + 1:].strip())