Added command line (default 0) min argument for minimum filtering, updated args.py to reflect this

This commit is contained in:
anqixxx
2025-05-29 09:25:08 -07:00
parent 8d0e767826
commit 40d5b78eb8
3 changed files with 11 additions and 5 deletions

View File

@@ -136,6 +136,7 @@ class NominatimArgs:
import_from_wiki: bool
import_from_csv: Optional[str]
no_replace: bool
min: int
# Arguments to all query functions
format: str

View File

@@ -58,6 +58,8 @@ class ImportSpecialPhrases:
help='Import special phrases from a CSV file')
group.add_argument('--no-replace', action='store_true',
help='Keep the old phrases and only add the new ones')
group.add_argument('--min', type=int, default=0,
help='Restrict special phrases by minimum occurance')
def run(self, args: NominatimArgs) -> int:
@@ -82,7 +84,9 @@ class ImportSpecialPhrases:
tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
should_replace = not args.no_replace
min = args.min
with connect(args.config.get_libpq_dsn()) as db_connection:
SPImporter(
args.config, db_connection, loader
).import_phrases(tokenizer, should_replace)
).import_phrases(tokenizer, should_replace, min)