mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Do not remove longer sentence with colon in Remove text for HI - thx Martha :)
This commit is contained in:
parent
7fd87795a7
commit
325d537a1f
@ -23,6 +23,8 @@
|
||||
* Update Hungarian translation - thx Zityi
|
||||
* Update Brazil translation - thx Igor
|
||||
* Update French translation - thx Pierre
|
||||
* Update Italian translation - thx NAMP
|
||||
* Update Korean translation - thx domddol
|
||||
* MPC: Try to search for mpc-be too - thx Fábio
|
||||
* Shortcut F5 is now "Play selected lines"
|
||||
* Support read of time codes with format "<number>f" in TTML - thx LeonCheung
|
||||
|
@ -12,12 +12,12 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
private readonly HashSet<string> _namesList;
|
||||
private readonly HashSet<string> _namesMultiList;
|
||||
private readonly HashSet<string> _blackList;
|
||||
private readonly string _languageName;
|
||||
public string LanguageName { get; private set; }
|
||||
|
||||
public NameList(string dictionaryFolder, string languageName, bool useOnlineNameList, string namesUrl)
|
||||
{
|
||||
_dictionaryFolder = dictionaryFolder;
|
||||
_languageName = languageName;
|
||||
LanguageName = languageName;
|
||||
|
||||
_namesList = new HashSet<string>();
|
||||
_namesMultiList = new HashSet<string>();
|
||||
@ -84,10 +84,10 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
private string GetLocalNamesFileName()
|
||||
{
|
||||
// Converts e.g en_US => en (Neutral culture).
|
||||
string twoLetterIsoLanguageName = _languageName;
|
||||
if (_languageName.Length > 2)
|
||||
string twoLetterIsoLanguageName = LanguageName;
|
||||
if (LanguageName.Length > 2)
|
||||
{
|
||||
twoLetterIsoLanguageName = _languageName.Substring(0, 2);
|
||||
twoLetterIsoLanguageName = LanguageName.Substring(0, 2);
|
||||
}
|
||||
return Path.Combine(_dictionaryFolder, twoLetterIsoLanguageName + "_names.xml");
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
|
||||
return preAssTag + text;
|
||||
}
|
||||
|
||||
string language = Settings.NameList != null ? Settings.NameList.LanguageName : "en";
|
||||
string newText = string.Empty;
|
||||
var lines = text.Trim().SplitToLines();
|
||||
int noOfNames = 0;
|
||||
@ -241,7 +242,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
|
||||
}
|
||||
}
|
||||
|
||||
if (remove && !ShouldRemoveNarrator(pre))
|
||||
if (remove && !ShouldRemoveNarrator(pre, language))
|
||||
{
|
||||
remove = false;
|
||||
}
|
||||
@ -581,7 +582,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
|
||||
}
|
||||
else if (noOfNames == 2 && Utilities.GetNumberOfLines(newText) == 3 && Utilities.GetNumberOfLines(text) == 3)
|
||||
{
|
||||
var dialogHelper = new DialogSplitMerge { DialogStyle = Configuration.Settings.General.DialogStyle, TwoLetterLanguageCode = "en" };
|
||||
var dialogHelper = new DialogSplitMerge { DialogStyle = Configuration.Settings.General.DialogStyle, TwoLetterLanguageCode = language };
|
||||
if (dialogHelper.IsDialog(text.SplitToLines()))
|
||||
{
|
||||
if (removedInFirstLine && removedInSecondLine)
|
||||
@ -636,7 +637,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
|
||||
}
|
||||
else if (noOfNames == 1 && Utilities.GetNumberOfLines(newText) == 3 && Utilities.GetNumberOfLines(text) == 3)
|
||||
{
|
||||
var dialogHelper = new DialogSplitMerge { DialogStyle = Configuration.Settings.General.DialogStyle, TwoLetterLanguageCode = "en" };
|
||||
var dialogHelper = new DialogSplitMerge { DialogStyle = Configuration.Settings.General.DialogStyle, TwoLetterLanguageCode = language };
|
||||
if (dialogHelper.IsDialog(text.SplitToLines()))
|
||||
{
|
||||
if (removedInFirstLine)
|
||||
@ -784,10 +785,31 @@ namespace Nikse.SubtitleEdit.Core.Forms
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool ShouldRemoveNarrator(string pre)
|
||||
private static bool ShouldRemoveNarrator(string pre, string language)
|
||||
{
|
||||
// Skip these: Barry, remember: She cannot; http://google.com; Improved by: ...
|
||||
if (pre.IndexOfAny(new[] { "Previously on", "Improved by", "http", ", " }, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
if (pre.Length > 30 || pre.IndexOfAny(new[] { "http", ", " }, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (language == "en" && pre.Length > 15 && pre.IndexOfAny(new[]
|
||||
{
|
||||
"Previously on",
|
||||
"Improved by",
|
||||
" is ",
|
||||
" are ",
|
||||
" were ",
|
||||
" was ",
|
||||
" think ",
|
||||
" guess ",
|
||||
" will ",
|
||||
" believe ",
|
||||
" say ",
|
||||
" said ",
|
||||
" do ",
|
||||
" want ",
|
||||
"That's "
|
||||
}, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user