Mercurial > hg > classical
changeset 40:40e3f0049c00
* Track guessing fixes
author | Chris Cannam |
---|---|
date | Tue, 06 Apr 2010 17:36:27 +0100 |
parents | 94cdfacc4910 |
children | a42493a3baf8 |
files | common/Matcher.cpp utilities/track/track.cpp |
diffstat | 2 files changed, 21 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/common/Matcher.cpp Thu Apr 01 14:26:51 2010 +0100 +++ b/common/Matcher.cpp Tue Apr 06 17:36:27 2010 +0100 @@ -243,11 +243,11 @@ text = text.replace(QRegExp("^[0-9]+"), ""); QString quoted; - QRegExp quoteRe("\\b[\"']([^\"]+)[\"']\\b"); + QRegExp quoteRe("(^|\\s)[\"']([^\"]+)[\"']($|[^\\w])"); int qthresh = 0; if (quoteRe.indexIn(text) >= 0) { - quoted = quoteRe.cap(1); + quoted = quoteRe.cap(2); if (quoted.length() < 4) quoted = ""; qthresh = quoted.length() / 4; } @@ -267,6 +267,8 @@ } } + std::cerr << "reduced = " << reduced.join(" ").toStdString() << std::endl; + EditDistance ed; foreach (Work *w, m_works) { @@ -281,7 +283,8 @@ foreach (QString name, names) { - float score = 0.f; + float pro = 0.f; + float con = 0.f; if (quoted != "") { if (quoteRe.indexIn(name) >= 0) { @@ -289,9 +292,9 @@ int dist = ed.calculate(quoted, q, qthresh); if (dist < qthresh) { std::cerr << "quoted name match: " << q.toStdString() << std::endl; - score += 0.7f - 0.1f * dist; - if (score > highScore) { - highScore = score; + pro += 0.7f - 0.1f * dist; + if (pro - con > highScore) { + highScore = pro - con; continue; } } @@ -307,13 +310,14 @@ foreach (QString rc, reduced) { if (wr.contains(rc)) { std::cerr << "component match: " << rc.toStdString() << std::endl; - score += 0.1; + pro += 0.1; } else { - score -= 0.101; + con += 0.101; + if (con > 0.25) con = 0.25; } } - if (score > highScore) highScore = score; + if (pro - con > highScore) highScore = pro - con; } if (highScore > 0.f) {
--- a/utilities/track/track.cpp Thu Apr 01 14:26:51 2010 +0100 +++ b/utilities/track/track.cpp Tue Apr 06 17:36:27 2010 +0100 @@ -407,7 +407,10 @@ guessWorkFromTitleTag(AudioFileReader::TagMap tags, QString tag, float scale, Composer *composer, GuessSet &guesses) { + cerr << "guessWorkFromTitleTag: " << tag << endl; + if (tags.find(tag) != tags.end()) { + cerr << "guessWorkFromTitleTag: tag is " << tags[tag] << endl; GuessSet myGuesses; guessWorkFromTitle(tags[tag], scale, composer, myGuesses); integrateGuesses(guesses, myGuesses); @@ -532,14 +535,14 @@ QString bestTitle; GuessSet workGuesses; + if (tags["TIT2"] != "") { + bestTitle = tags["TIT2"]; + guessWorkFromTitleTag(tags, "TIT2", 0.5, confidentComposer, workGuesses); + } if (tags["TITLE"] != "") { bestTitle = tags["TITLE"]; guessWorkFromTitleTag(tags, "TITLE", 0.5, confidentComposer, workGuesses); } - if (tags["TIT2"] != "") { - bestTitle = tags["TIT2"]; - guessWorkFromTitleTag(tags, "TIT2", 0.5, confidentComposer, workGuesses); - } if (workGuesses.empty()) { guessWorkFromTitleTag(tags, "TIT1", 0.2, confidentComposer, workGuesses); guessWorkFromTitleTag(tags, "TALB", 0.2, confidentComposer, workGuesses); @@ -567,7 +570,7 @@ foreach (Guess g, guesses) { if (g.entity() == wc) { consistentComposers.insert(g); - consistentWorks.insert(Guess(g.confidence(), wg.entity())); + consistentWorks.insert(wg); } } }