need help to write rules.
It is necessary to make a parser for the building adress in mask X-X-X. Moreover, the names of buildings can be written in different ways. For example synonyms are abbreviated or used.
text = [
"Building 1В-98-1У",
"Building 1-4-13",
"Build. 1-4-13",
"1-4-13",
"Line 1-4-13",
"4-13",
"Line 4-13",
"Building 1А-02-1Б",
"Building 1А-02/1Б",
"1А-02/1Б",
"Building 1Г-86",
"1Г-86",
"Building СТ6-19У",
"СТ6-19У",
"Building Line 6-19",
"Building Line 6 prefix 19",
"Lines 3",
"L. 3",
]
INTEGER = Word(nums)
DELIMITER = Word("- /", max=1)
rus_alphas = 'йцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ'
NAME = Word(alphas + rus_alphas + nums)
synonymsDefinitions = [
("Building", 'building'),
("Build", 'building'),
("Line", 'building'),
("l", 'building'),
]
SYNONYMS = pp.MatchFirst(makeLit(s, v) for s, v in synonymsDefinitions)
rule = ?????
for i in text:
print(i, "->", BUILDING.parseString(i))