comparison base/TextMatcher.h @ 457:ef14acd6d102

* Add beginnings of capability to search plugins that are not yet installed -- lots more work to do here, though
author Chris Cannam
date Tue, 14 Oct 2008 16:36:35 +0000
parents
children ad5f892c0c4d
comparison
equal deleted inserted replaced
456:64e64e304a12 457:ef14acd6d102
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2008 QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _TEXT_MATCHER_H_
17 #define _TEXT_MATCHER_H_
18
19 #include <QString>
20 #include <QStringList>
21 #include "XmlExportable.h"
22
23 #include <map>
24
25 /// A rather eccentric interface for matching texts in differently-scored fields
26
27 class TextMatcher
28 {
29 public:
30 TextMatcher();
31 virtual ~TextMatcher();
32
33 struct Match
34 {
35 QString key; // This field is not used by TextMatcher
36 int score;
37 typedef std::map<QString, QString> FragmentMap; // text type -> fragment
38 FragmentMap fragments;
39
40 Match() : score(0) { }
41 Match(const Match &m) :
42 key(m.key), score(m.score), fragments(m.fragments) { }
43
44 bool operator<(const Match &m) const; // sort by score first
45 };
46
47 void test(Match &match, // existing match record to be augmented
48 QStringList keywords, // search terms
49 QString text, // to search within
50 QString textType, // key to use for fragment map
51 int score); // relative weight for hits within this text type
52
53 };
54
55
56 #endif