diff --git a/src/yuheng/__init__.py b/src/yuheng/__init__.py index ecacb70..cd53104 100644 --- a/src/yuheng/__init__.py +++ b/src/yuheng/__init__.py @@ -341,14 +341,12 @@ def have_multi_elements(element_id_string: str) -> bool: ) ) + "/" - + ( - prefix_normalization(element_type, mode="p2prefix") - + "s" + + prefix_normalization( + element_type, mode="p2prefix", plural=True ) + "?" - + ( - prefix_normalization(element_type, mode="p2prefix") - + "s" + + prefix_normalization( + element_type, mode="p2prefix", plural=True ) + "=" + ",".join(pure_id_list) diff --git a/src/yuheng/method/transform.py b/src/yuheng/method/transform.py index 7fe5e01..1d6addd 100644 --- a/src/yuheng/method/transform.py +++ b/src/yuheng/method/transform.py @@ -1,28 +1,43 @@ from typing import Optional -def prefix_normalization(source: str, mode="p2prefix") -> str: +def prefix_normalization(source: str, mode="p2prefix", plural=False) -> str: if mode == "p2prefix": if source == "n" or source == "node": - return "node" + if plural == False: + return "node" + else: + return "nodes" if source == "w" or source == "way": - return "way" + if plural == False: + return "way" + else: + return "ways" if source == "r" or source == "relation": - return "relation" + if plural == False: + return "relation" + else: + return "relations" if source == "c" or source == "changeset": - return "changeset" + if plural == False: + return "changeset" + else: + return "changesets" if source == "v" or source == "version": - return "version" + if plural == False: + return "version" + else: + return "versions" elif mode == "prefix2p": - if source == "n" or source == "node": + if source in ["n", "node", "nodes"]: return "n" - if source == "w" or source == "way": + if source in ["w", "way", "nodes"]: return "w" - if source == "r" or source == "relation": + if source in ["r", "relation", "relations"]: return "r" - if source == "c" or source == "changeset": + if source in ["c", "changeset", "changesets"]: return "c" - if source == "v" or source == "version": + if source in ["v", "version", "versions"]: return "v"