Skip to content

Commit 3406ada

Browse files
iveshenry18Jojo-Schmitz
authored andcommitted
ENG-74: refine credit inference regex
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
1 parent 526dff2 commit 3406ada

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

importexport/musicxml/importmxmlpass2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3385,7 +3385,7 @@ bool MusicXMLParserDirection::isLikelyCredit(const Fraction& tick) const
33853385
&& _rehearsalText == ""
33863386
&& _metroText == ""
33873387
&& _tpoSound < 0.1
3388-
&& _wordsText.contains(QRegularExpression("^\\s*((Words|Music|Lyrics).*)*by\\s+([A-Z][a-zA-Zö'’-]+\\s[A-Z][a-zA-Zös'’-]+.*)+"));
3388+
&& _wordsText.contains(QRegularExpression("^\\s*((Words|Music|Lyrics),?(\\sand|\\s&amp;)?\\s)*[Bb]y\\s+(?!$)"));
33893389
}
33903390

33913391
//---------------------------------------------------------

mtest/musicxml/io/testInferredCredits.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,19 @@
8787
</attributes>
8888
<direction placement="above">
8989
<direction-type>
90-
<words default-y="34.66" relative-y="10.00">Words and Music by Henry Ives
90+
<words default-y="34.66" relative-y="10.00">Words &amp; Music by Henry Ives (and ampersands)
9191
</words>
9292
<words>
9393
</words>
9494
<words></words>
9595
</direction-type>
9696
</direction>
97+
<direction placement="above">
98+
<direction-type>
99+
<words default-y="34.66" relative-y="10.00">Lyrics to be sung by candlelight
100+
(and this not to be inferred)</words>
101+
</direction-type>
102+
</direction>
97103
<note default-x="73.72" default-y="-15.00">
98104
<pitch>
99105
<step>C</step>

mtest/musicxml/io/testInferredCredits_ref.mscx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
</Text>
126126
<Text>
127127
<style>Composer</style>
128-
<text>Words and Music by Henry Ives</text>
128+
<text>Words &amp; Music by Henry Ives (and ampersands)</text>
129129
</Text>
130130
<Text>
131131
<style>Subtitle</style>
@@ -143,6 +143,10 @@ the video game: a tone poem</text>
143143
<sigN>4</sigN>
144144
<sigD>4</sigD>
145145
</TimeSig>
146+
<StaffText>
147+
<text>Lyrics to be sung by candlelight
148+
(and this not to be inferred)</text>
149+
</StaffText>
146150
<Beam>
147151
<StemDirection>down</StemDirection>
148152
<l1>17</l1>

0 commit comments

Comments
 (0)