svcore  1.9
TextMatcher.h
Go to the documentation of this file.
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 
26 
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
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
std::map< QString, QString > FragmentMap
Definition: TextMatcher.h:37
void test(Match &match, QStringList keywords, QString text, QString textType, int score)
Definition: TextMatcher.cpp:27
FragmentMap fragments
Definition: TextMatcher.h:38
A rather eccentric interface for matching texts in differently-scored fields.
Definition: TextMatcher.h:27
Match(const Match &m)
Definition: TextMatcher.h:41
virtual ~TextMatcher()
Definition: TextMatcher.cpp:22
bool operator<(const Match &m) const