]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/clicmd/refresh.py
add new command for cleaning word tokens
[nominatim.git] / nominatim / clicmd / refresh.py
index e7d7d7ba1d33cc032b3c0260a5ffc3d05f772344..c741dcf63632fc0c01d8592a66f46d3be0c8bdbd 100644 (file)
@@ -1,3 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2022 by the Nominatim developer community.
+# For a full list of authors see the git log.
 """
 Implementation of 'refresh' subcommand.
 """
 """
 Implementation of 'refresh' subcommand.
 """
@@ -33,6 +39,8 @@ class UpdateRefresh:
         group = parser.add_argument_group('Data arguments')
         group.add_argument('--postcodes', action='store_true',
                            help='Update postcode centroid table')
         group = parser.add_argument_group('Data arguments')
         group.add_argument('--postcodes', action='store_true',
                            help='Update postcode centroid table')
+        group.add_argument('--word-tokens', action='store_true',
+                           help='Clean up search terms')
         group.add_argument('--word-counts', action='store_true',
                            help='Compute frequency of full-word search terms')
         group.add_argument('--address-levels', action='store_true',
         group.add_argument('--word-counts', action='store_true',
                            help='Compute frequency of full-word search terms')
         group.add_argument('--address-levels', action='store_true',
@@ -70,15 +78,18 @@ class UpdateRefresh:
                 LOG.error("The place table doesn't exist. "
                           "Postcode updates on a frozen database is not possible.")
 
                 LOG.error("The place table doesn't exist. "
                           "Postcode updates on a frozen database is not possible.")
 
+        if args.word_tokens:
+            tokenizer = self._get_tokenizer(args.config)
+            tokenizer.update_word_tokens()
+
         if args.word_counts:
             LOG.warning('Recompute word statistics')
             self._get_tokenizer(args.config).update_statistics()
 
         if args.address_levels:
         if args.word_counts:
             LOG.warning('Recompute word statistics')
             self._get_tokenizer(args.config).update_statistics()
 
         if args.address_levels:
-            cfg = Path(args.config.ADDRESS_LEVEL_CONFIG)
-            LOG.warning('Updating address levels from %s', cfg)
+            LOG.warning('Updating address levels')
             with connect(args.config.get_libpq_dsn()) as conn:
             with connect(args.config.get_libpq_dsn()) as conn:
-                refresh.load_address_levels_from_file(conn, cfg)
+                refresh.load_address_levels_from_config(conn, args.config)
 
         if args.functions:
             LOG.warning('Create functions')
 
         if args.functions:
             LOG.warning('Create functions')