annotate base/TextMatcher.h @ 1038:cc27f35aa75c cxx11

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