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 SV_TEXT_MATCHER_H
17 #define SV_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
38  FragmentMap fragments;
39 
40  Match() : score(0) { }
41 
42  Match(const Match &m) =default;
43  Match &operator=(const Match &m) =default;
44 
45  bool operator<(const Match &m) const; // sort by score first
46  };
47 
48  void test(Match &match, // existing match record to be augmented
49  QStringList keywords, // search terms
50  QString text, // to search within
51  QString textType, // key to use for fragment map
52  int score); // relative weight for hits within this text type
53 
54 };
55 
56 
57 #endif
bool operator<(const Match &m) const
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 & operator=(const Match &m)=default
virtual ~TextMatcher()
Definition: TextMatcher.cpp:22