我有一本同义词词典:
synonym = {"this": ["this", "same"],
"all": ["all", "any", "*"],
"alluptolastyear": ["alluptolastyear", "uptolastyear"],
"dekadbefore": ["dekadbefore", "lastdekad", "formerdekad", "precedingdekad"],
"dekadafter": ["dekadafter", "nextdekad", "followingdekad"],
"yearbefore": ["yearbefore", "lastyear", "formeryear"],
"monthbefore": ["monthbefore", "lastmonth", "precedingmonth"]}
每个数组存储同义词,通过键引用。我从一个 XML 文件中读取了两个字符串,并尝试比较它们。
例如:
"this"
并且"same"
相等(同义词)- '"lastyear"' 和 '"formeryear"' 相等(同义词)
"all"
并且"nextdekad"
是不同的- 当然,每个键值都在其对应的数组中找到,因此每个键都是其数组字符串的同义词。
有人可以帮助我使用同义词字典编写这些字符串的pythonic比较吗?