Sayonara Player
SmartCompare.h
1 /* SmartCompare.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef SMART_COMPARE_H
22 #define SMART_COMPARE_H
23 
24 #include <QMap>
25 #include <QString>
26 #include <QList>
27 #include <QStringList>
28 
29 class ArtistList;
30 class DatabaseConnector;
31 enum class HashLevel : quint8
32 {
33  zero=0,
34  medium,
35  strong
36 };
37 
38 struct Hash{
39  float penalty;
40  QString hash;
41  QString org_str;
42 
43  void print() const;
44 };
45 
51 {
52 private:
53 
54  QStringList _strlist;
56  QList<QChar> _vocals;
57  QList<QChar> _consonants;
58  QList<QChar> _numbers;
59  QList<QChar> _special;
60 
61  QString remove_special_chars(const QString& str);
62  QString remove_vocals(const QString& str);
63  QString sort_letters(const QString& str);
64 
65  void equalize(QMap<QString, float>&, float min, float max);
66 
67 
68  Hash create_hash(const QString& str, HashLevel level);
69 
70  float compare(const QString& str1, const QString& str2, HashLevel level, bool reverse=false);
71  float compare_hashes(const Hash& str1, const Hash& str2, HashLevel level, bool reverse=false);
72 
73  //float find_artist(const QString&, HashLevel level);
74 
75  SmartCompare();
76 
77 
78 public:
79  SmartCompare(const QStringList& strlist);
80  SmartCompare(const ArtistList& strlist);
81 
82  QMap<QString, float> get_similar_strings(const QString& str);
83 };
84 
85 #endif // SmartCompare_H
Definition: SmartCompare.h:38
Definition: DatabaseConnector.h:38
The SmartCompare class.
Definition: SmartCompare.h:50
ArtistList.
Definition: Artist.h:60
Definition: org_mpris_media_player2_adaptor.h:21