Add option to ignore lyrics

This commit is contained in:
Martijn van Berkel (Flitskikker) 2020-04-12 21:28:22 +02:00
parent c181e92587
commit 5e69ba94cc
10 changed files with 49 additions and 8 deletions

View File

@ -2164,6 +2164,7 @@ Continue?</RestoreDefaultSettingsMsg>
<UncheckInsertsItalic>Detect and uncheck italic single titles, or lyrics</UncheckInsertsItalic>
<UncheckInsertsLowercase>Detect and uncheck single titles, or lyrics, in lowercase</UncheckInsertsLowercase>
<HideContinuationCandidatesWithoutName>Hide unlikely continuation sentences</HideContinuationCandidatesWithoutName>
<IgnoreLyrics>Ignore lyrics between music symbols</IgnoreLyrics>
</Settings>
<SettingsMpv>
<Title>Settings for mpv</Title>

View File

@ -31,6 +31,15 @@ namespace Nikse.SubtitleEdit.Core
checkString = Regex.Replace(checkString, "\\(.*?\\)", string.Empty, RegexOptions.Singleline);
checkString = Regex.Replace(checkString, "\\[.*?\\]", string.Empty, RegexOptions.Singleline);
checkString = Regex.Replace(checkString, "\\{.*?\\}", string.Empty);
if (Configuration.Settings.General.FixContinuationStyleIgnoreLyrics)
{
foreach (char c in MusicSymbols)
{
checkString = Regex.Replace(checkString, "\\" + c + ".*?\\" + c, string.Empty, RegexOptions.Singleline);
}
}
checkString = checkString.Trim();
// Remove string elevation

View File

@ -2457,7 +2457,8 @@ can edit in same subtitle file (collaboration)",
UncheckInsertsAllCaps = "Detect and uncheck single titles in all-caps (for example: NO ENTRY)",
UncheckInsertsItalic = "Detect and uncheck italic single titles, or lyrics",
UncheckInsertsLowercase = "Detect and uncheck single titles, or lyrics, in lowercase",
HideContinuationCandidatesWithoutName = "Hide unlikely continuation sentences"
HideContinuationCandidatesWithoutName = "Hide unlikely continuation sentences",
IgnoreLyrics = "Ignore lyrics between music symbols"
};
SettingsMpv = new LanguageStructure.SettingsMpv

View File

@ -5902,6 +5902,9 @@ namespace Nikse.SubtitleEdit.Core
case "Settings/HideContinuationCandidatesWithoutName":
language.Settings.HideContinuationCandidatesWithoutName = reader.Value;
break;
case "Settings/IgnoreLyrics":
language.Settings.IgnoreLyrics = reader.Value;
break;
case "SettingsMpv/Title":
language.SettingsMpv.Title = reader.Value;
break;

View File

@ -2326,6 +2326,7 @@
public string UncheckInsertsItalic { get; set; }
public string UncheckInsertsLowercase { get; set; }
public string HideContinuationCandidatesWithoutName { get; set; }
public string IgnoreLyrics { get; set; }
}
public class SettingsMpv

View File

@ -780,6 +780,7 @@ $HorzAlign = Center
public bool FixContinuationStyleUncheckInsertsItalic { get; set; }
public bool FixContinuationStyleUncheckInsertsLowercase { get; set; }
public bool FixContinuationStyleHideContinuationCandidatesWithoutName { get; set; }
public bool FixContinuationStyleIgnoreLyrics { get; set; }
public string SpellCheckLanguage { get; set; }
public string VideoPlayer { get; set; }
public int VideoPlayerDefaultVolume { get; set; }
@ -926,6 +927,7 @@ $HorzAlign = Center
FixContinuationStyleUncheckInsertsItalic = true;
FixContinuationStyleUncheckInsertsLowercase = true;
FixContinuationStyleHideContinuationCandidatesWithoutName = true;
FixContinuationStyleIgnoreLyrics = true;
SpellCheckLanguage = null;
VideoPlayer = string.Empty;
VideoPlayerDefaultVolume = 75;
@ -2591,6 +2593,12 @@ $HorzAlign = Center
settings.General.FixContinuationStyleHideContinuationCandidatesWithoutName = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("FixContinuationStyleIgnoreLyrics");
if (subNode != null)
{
settings.General.FixContinuationStyleIgnoreLyrics = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("SpellCheckLanguage");
if (subNode != null)
{

View File

@ -34,6 +34,7 @@
this.checkBoxUncheckInsertsItalic = new System.Windows.Forms.CheckBox();
this.checkBoxUncheckInsertsLowercase = new System.Windows.Forms.CheckBox();
this.checkBoxHideContinuationCandidatesWithoutName = new System.Windows.Forms.CheckBox();
this.checkBoxIgnoreLyrics = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// buttonCancel
@ -41,7 +42,7 @@
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(351, 128);
this.buttonCancel.Location = new System.Drawing.Point(351, 151);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 10;
@ -53,7 +54,7 @@
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(270, 128);
this.buttonOK.Location = new System.Drawing.Point(270, 151);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 9;
@ -101,13 +102,24 @@
this.checkBoxHideContinuationCandidatesWithoutName.Text = "Hide interruption continuation candidates that don\'t start with a name";
this.checkBoxHideContinuationCandidatesWithoutName.UseVisualStyleBackColor = true;
//
// checkBoxIgnoreLyrics
//
this.checkBoxIgnoreLyrics.AutoSize = true;
this.checkBoxIgnoreLyrics.Location = new System.Drawing.Point(12, 104);
this.checkBoxIgnoreLyrics.Name = "checkBoxIgnoreLyrics";
this.checkBoxIgnoreLyrics.Size = new System.Drawing.Size(196, 17);
this.checkBoxIgnoreLyrics.TabIndex = 5;
this.checkBoxIgnoreLyrics.Text = "Ignore lyrics between music symbols";
this.checkBoxIgnoreLyrics.UseVisualStyleBackColor = true;
//
// SettingsFixContinuationStyle
//
this.AcceptButton = this.buttonOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(438, 163);
this.ClientSize = new System.Drawing.Size(438, 186);
this.Controls.Add(this.checkBoxIgnoreLyrics);
this.Controls.Add(this.checkBoxHideContinuationCandidatesWithoutName);
this.Controls.Add(this.checkBoxUncheckInsertsLowercase);
this.Controls.Add(this.checkBoxUncheckInsertsItalic);
@ -136,5 +148,6 @@
private System.Windows.Forms.CheckBox checkBoxUncheckInsertsItalic;
private System.Windows.Forms.CheckBox checkBoxUncheckInsertsLowercase;
private System.Windows.Forms.CheckBox checkBoxHideContinuationCandidatesWithoutName;
private System.Windows.Forms.CheckBox checkBoxIgnoreLyrics;
}
}

View File

@ -26,11 +26,13 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxUncheckInsertsItalic.Text = language.UncheckInsertsItalic;
checkBoxUncheckInsertsLowercase.Text = language.UncheckInsertsLowercase;
checkBoxHideContinuationCandidatesWithoutName.Text = language.HideContinuationCandidatesWithoutName;
checkBoxIgnoreLyrics.Text = language.IgnoreLyrics;
checkBoxUncheckInsertsAllCaps.Checked = settings.FixContinuationStyleUncheckInsertsAllCaps;
checkBoxUncheckInsertsItalic.Checked = settings.FixContinuationStyleUncheckInsertsItalic;
checkBoxUncheckInsertsLowercase.Checked = settings.FixContinuationStyleUncheckInsertsLowercase;
checkBoxHideContinuationCandidatesWithoutName.Checked = settings.FixContinuationStyleHideContinuationCandidatesWithoutName;
checkBoxIgnoreLyrics.Checked = settings.FixContinuationStyleIgnoreLyrics;
buttonOK.Text = Configuration.Settings.Language.General.Ok;
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
@ -43,6 +45,7 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.General.FixContinuationStyleUncheckInsertsItalic = checkBoxUncheckInsertsItalic.Checked;
Configuration.Settings.General.FixContinuationStyleUncheckInsertsLowercase = checkBoxUncheckInsertsLowercase.Checked;
Configuration.Settings.General.FixContinuationStyleHideContinuationCandidatesWithoutName = checkBoxHideContinuationCandidatesWithoutName.Checked;
Configuration.Settings.General.FixContinuationStyleIgnoreLyrics = checkBoxIgnoreLyrics.Checked;
DialogResult = DialogResult.OK;
}

View File

@ -2165,6 +2165,7 @@ of tijdens het exporteren naar op beeld gebaseerde formaten.</FontNote>
<UncheckInsertsItalic>Cursieve beeldtitels of songteksten detecteren en uitvinken</UncheckInsertsItalic>
<UncheckInsertsLowercase>Beeldtitels of songteksten in kleine letters detecteren en uitvinken</UncheckInsertsLowercase>
<HideContinuationCandidatesWithoutName>Onwaarschijnlijke vervolgzinnen verbergen</HideContinuationCandidatesWithoutName>
<IgnoreLyrics>Songteksten tussen muzieksymbolen negeren</IgnoreLyrics>
</Settings>
<SettingsMpv>
<Title>mpv instellingen</Title>

View File

@ -121,6 +121,7 @@ namespace Test.Logic
public void SanitizeString11()
{
string line1 = "<i>♪ la la la ♪</i>";
Configuration.Settings.General.FixContinuationStyleIgnoreLyrics = false;
string line1Actual = ContinuationUtilities.SanitizeString(line1, false);
string line1Expected = "la la la";
Assert.AreEqual(line1Expected, line1Actual);