File indexing completed on 2024-04-14 03:48:58

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2016 Dennis Nienhüser <nienhueser@kde.org>
0004 //
0005 
0006 #ifndef TOOLS_SPELLCHECKER_H
0007 #define TOOLS_SPELLCHECKER_H
0008 
0009 #include <TileId.h>
0010 #include "GeoDataPlacemark.h"
0011 
0012 #include <QVector>
0013 
0014 namespace Marble {
0015 
0016 class GeoDataPlacemark;
0017 
0018 class SpellChecker
0019 {
0020 public:
0021     explicit SpellChecker(const QString &citiesFile);
0022     void setVerbose(bool verbose);
0023 
0024     void correctPlaceLabels(const QVector<GeoDataPlacemark*> &placemarks);
0025 
0026 private:
0027     typedef QHash<TileId, QVector<GeoDataPlacemark*> > TileHash;
0028 
0029     static int levenshteinDistance(const QString &a, const QString &b);
0030 
0031     QVector<GeoDataPlacemark*> cityPlaces(const QVector<GeoDataPlacemark*> &placemarks) const;
0032     TileHash parseCities(const QString &filename) const;
0033     QVector<GeoDataPlacemark*> candidatesFor(GeoDataPlacemark* placemark) const;
0034 
0035     int const m_tileLevel;
0036     TileHash m_tileHash;
0037     bool m_verbose;
0038 };
0039 
0040 }
0041 #endif