Skip to content

Commit

Permalink
ENG-74: refine credit inference regex
Browse files Browse the repository at this point in the history
This commit refines the regex for inferring credit directions. It
ultimately removes requirements for names (the part after the word
"by") due to the inordinate difficulty of writing strict regex that
catches all possible characters included in names. To mitigate false
positives, it clarifies/restricts the regex for the part before the word
"by". This compromise decreases the number of false negatives without
significantly increasing false positives.

Duplicate of musescore#8678, part 3
  • Loading branch information
iveshenry18 authored and Jojo-Schmitz committed Jul 28, 2021
1 parent 526dff2 commit 3406ada
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion importexport/musicxml/importmxmlpass2.cpp
Expand Up @@ -3385,7 +3385,7 @@ bool MusicXMLParserDirection::isLikelyCredit(const Fraction& tick) const
&& _rehearsalText == ""
&& _metroText == ""
&& _tpoSound < 0.1
&& _wordsText.contains(QRegularExpression("^\\s*((Words|Music|Lyrics).*)*by\\s+([A-Z][a-zA-Zö'’-]+\\s[A-Z][a-zA-Zös'’-]+.*)+"));
&& _wordsText.contains(QRegularExpression("^\\s*((Words|Music|Lyrics),?(\\sand|\\s&amp;)?\\s)*[Bb]y\\s+(?!$)"));
}

//---------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion mtest/musicxml/io/testInferredCredits.xml
Expand Up @@ -87,13 +87,19 @@
</attributes>
<direction placement="above">
<direction-type>
<words default-y="34.66" relative-y="10.00">Words and Music by Henry Ives
<words default-y="34.66" relative-y="10.00">Words &amp; Music by Henry Ives (and ampersands)
</words>
<words>
</words>
<words></words>
</direction-type>
</direction>
<direction placement="above">
<direction-type>
<words default-y="34.66" relative-y="10.00">Lyrics to be sung by candlelight
(and this not to be inferred)</words>
</direction-type>
</direction>
<note default-x="73.72" default-y="-15.00">
<pitch>
<step>C</step>
Expand Down
6 changes: 5 additions & 1 deletion mtest/musicxml/io/testInferredCredits_ref.mscx
Expand Up @@ -125,7 +125,7 @@
</Text>
<Text>
<style>Composer</style>
<text>Words and Music by Henry Ives</text>
<text>Words &amp; Music by Henry Ives (and ampersands)</text>
</Text>
<Text>
<style>Subtitle</style>
Expand All @@ -143,6 +143,10 @@ the video game: a tone poem</text>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<StaffText>
<text>Lyrics to be sung by candlelight
(and this not to be inferred)</text>
</StaffText>
<Beam>
<StemDirection>down</StemDirection>
<l1>17</l1>
Expand Down

0 comments on commit 3406ada

Please sign in to comment.