annotate base/TextMatcher.h @ 717:bcdb2a18d9bc library_integration

Revert that change -- this code is used only in Sonic Annotator
author Chris Cannam
date Tue, 18 Oct 2011 10:14:17 +0100
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