Skip to content

Commit

Permalink
Work guesser nows uses works search terms too
Browse files Browse the repository at this point in the history
  • Loading branch information
Open Opus committed Jul 19, 2020
1 parent 6e27846 commit b022a01
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions html/dyn/work/guess/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

// finding the works

$wkdb = mysqlfetch ($mysql, "select composer_id, id, title, subtitle, genre, popular, recommended from work where composer_id in (". implode (",", $compids). ") order by composer_id asc, title asc");
$wkdb = mysqlfetch ($mysql, "select composer_id, id, title, searchterms, subtitle, genre, popular, recommended from work where composer_id in (". implode (",", $compids). ") order by composer_id asc, title asc");

foreach ($reqworks as $comp => $works)
{
Expand Down Expand Up @@ -100,6 +100,7 @@
{
// db: catalogue number

unset ($wk["searchterms"]);
preg_match_all (CATALOGUE_REGEX, $wk["title"], $matches);

if (sizeof ($matches[0]))
Expand Down Expand Up @@ -129,18 +130,27 @@
}
else
{
$wktt = str_replace ("-", "", slug (worksimplifier ($wk["title"])));

similar_text ($work, $wktt, $similarity);
// db: work title

if ($similarity > 80 && $retworks[$comp. "-". $work]["similarity"] < round ($similarity))
$titles = $wk["title"]. ", ". $wk["searchterms"];

foreach (explode (",", $titles) as $tit)
{
$retworks[$comp. "-". $work] = Array
(
"similarity" => $similarity,
"requested" => ["composer" => $reqcomps[$comp], "title" => $work_title],
"guessed" => array_merge ($wk, ["composer" => $reqworks[$comp]["composer"]["composer"]])
);
$wktt = str_replace ("-", "", slug (worksimplifier ($tit)));

similar_text ($work, $wktt, $similarity);

if ($similarity > 80 && $retworks[$comp. "-". $work]["similarity"] < round ($similarity))
{
unset ($wk["searchterms"]);

$retworks[$comp. "-". $work] = Array
(
"similarity" => $similarity,
"requested" => ["composer" => $reqcomps[$comp], "title" => $work_title],
"guessed" => array_merge ($wk, ["composer" => $reqworks[$comp]["composer"]["composer"]])
);
}
}
}
}
Expand Down

0 comments on commit b022a01

Please sign in to comment.