Sayonara Player
SmartCompare.h
1 /* SmartCompare.h */
2 
3 /* Copyright (C) 2011-2016 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 
22 
23 #ifndef SmartCompare_H
24 #define SmartCompare_H
25 #include <QMap>
26 #include <QString>
27 #include <QList>
28 #include <QStringList>
29 
30 class ArtistList;
31 class DatabaseConnector;
32 enum class HashLevel : quint8
33 {
34  zero=0,
35  medium,
36  strong
37 };
38 
39 struct Hash{
40  float penalty;
41  QString hash;
42  QString org_str;
43 
44  void print() const;
45 };
46 
52 {
53 
54 private:
55 
56  QStringList _strlist;
58  QList<QChar> _vocals;
59  QList<QChar> _consonants;
60  QList<QChar> _numbers;
61  QList<QChar> _special;
62 
63  QString remove_special_chars(const QString& str);
64  QString remove_vocals(const QString& str);
65  QString sort_letters(const QString& str);
66 
67  void equalize(QMap<QString, float>&, float min, float max);
68 
69 
70  Hash create_hash(const QString& str, HashLevel level);
71 
72  float compare(const QString& str1, const QString& str2, HashLevel level, bool reverse=false);
73  float compare_hashes(const Hash& str1, const Hash& str2, HashLevel level, bool reverse=false);
74 
75  //float find_artist(const QString&, HashLevel level);
76 
77  SmartCompare();
78 
79 
80 public:
81  SmartCompare(const QStringList& strlist);
82  SmartCompare(const ArtistList& strlist);
83 
84  QMap<QString, float> get_similar_strings(const QString& str);
85 
86 
87 };
88 
89 #endif // SmartCompare_H
Definition: SmartCompare.h:39
Definition: DatabaseConnector.h:40
The SmartCompare class.
Definition: SmartCompare.h:51
ArtistList.
Definition: Artist.h:64
Definition: org_mpris_media_player2_adaptor.h:21