Skip to content

Commit

Permalink
Improve hyphenation with english suffixes 's/'d
Browse files Browse the repository at this point in the history
  • Loading branch information
CZDanol committed Dec 28, 2023
1 parent 5070fd7 commit bb518e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions bin/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<div class="changelog">
<h1>Historie změn/Change log</h1>

<h2>XX</h2>
<h3>Změny | Changes</h3>
<ul>
<li>Zlepšeno slabikování u anglických koncovek 's/'d. | Improved hyphenation with english suffixes 's/'d.</li>
</ul>

<h2>1.3.7.3</h2>
<h3>Opravy | Bugfixes</h3>
<ul>
Expand Down
10 changes: 6 additions & 4 deletions src/job/wordsplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,16 @@ QVector<int> czech(const QString &src, ChordsInSong &chords, int options) {
")")
.arg(rxsMiddleBase, rxsConsonant, rxsOnlyStartConsonant);

static const QString rxsEnglishSuffix = "(?:'[sd])?)";

/// Syllable in the end of the word
static const QString rxsEnd = //
QString("(?:%1%2*)").arg(rxsMiddle, rxsConsonant);
QString("(?:%1%2*%3").arg(rxsMiddle, rxsConsonant, rxsEnglishSuffix);

/// Syllable in the beginningh of the word
/// Syllable in the beginning of the word
static const QString rxsStart = //
QString("(?:"
"(?:[svzk]\\b\\s*)?(?:" // Possible (silent) preposition
"(?:\\b(?<!['])[svzk]\\b\\s*)?(?:" // Possible (silent) preposition
"%4*?%2"
"|%3\\b"
"|%1"
Expand All @@ -132,7 +134,7 @@ QVector<int> czech(const QString &src, ChordsInSong &chords, int options) {

static const QRegularExpression rxWord( //
QString("\\b(%1)(%2*)(%3?)\\b"
"|\\b\\p{L}+\\b%4")
"|\\b(?:\\p{L}|['])+\\b%4")
.arg(rxsStart, rxsMiddle, rxsEnd, (options & IncludeNewlines) ? "|[ \t]*$" : "" //
),
QRegularExpression::CaseInsensitiveOption | QRegularExpression::UseUnicodePropertiesOption | QRegularExpression::MultilineOption);
Expand Down

0 comments on commit bb518e5

Please sign in to comment.