annotate base/TextMatcher.h @ 1791:c2388289fce8 time-frequency-boxes

Rename TimeFrequencyBoxModel to simply BoxModel
author Chris Cannam
date Wed, 25 Sep 2019 09:44:02 +0100
parents c3b5564cfb78
children
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@1581 16 #ifndef SV_TEXT_MATCHER_H
Chris@1581 17 #define SV_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@1733 41
Chris@1733 42 Match(const Match &m) =default;
Chris@1733 43 Match &operator=(const Match &m) =default;
Chris@457 44
Chris@457 45 bool operator<(const Match &m) const; // sort by score first
Chris@457 46 };
Chris@457 47
Chris@457 48 void test(Match &match, // existing match record to be augmented
Chris@457 49 QStringList keywords, // search terms
Chris@457 50 QString text, // to search within
Chris@457 51 QString textType, // key to use for fragment map
Chris@457 52 int score); // relative weight for hits within this text type
Chris@457 53
Chris@457 54 };
Chris@457 55
Chris@457 56
Chris@457 57 #endif