mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-23 19:52:48 +01:00
Merge pull request #2338 from ivandrofly/names-list
[Nameslist] - Minor fixes for NamesList.cs
This commit is contained in:
commit
8f55e47a88
@ -244,7 +244,7 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsInNamesEtcMultiWordList(string text, string word)
|
||||
public bool IsInNamesMultiWordList(string text, string word)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text))
|
||||
return false;
|
||||
@ -252,13 +252,15 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
text = text.Replace(Environment.NewLine, " ");
|
||||
text = text.FixExtraSpaces();
|
||||
|
||||
foreach (string s in _namesMultiList)
|
||||
if (_namesMultiList.Contains(word))
|
||||
{
|
||||
if (s.Contains(word) && text.Contains(s))
|
||||
{
|
||||
if (s.StartsWith(word + " ", StringComparison.Ordinal) || s.EndsWith(" " + word, StringComparison.Ordinal) || s.Contains(" " + word + " "))
|
||||
return true;
|
||||
if (word == s)
|
||||
}
|
||||
foreach (string multiWordName in _namesMultiList)
|
||||
{
|
||||
if (text.Contains(multiWordName))
|
||||
{
|
||||
if (multiWordName.StartsWith(word + " ", StringComparison.Ordinal) || multiWordName.EndsWith(" " + word, StringComparison.Ordinal) || multiWordName.Contains(" " + word + " "))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ namespace Nikse.SubtitleEdit.Core.SpellCheck
|
||||
|
||||
public bool HasNameExtended(string word, string text)
|
||||
{
|
||||
return _namesEtcListUppercase.Contains(word) || _namesEtcListWithApostrophe.Contains(word) || _namesList.IsInNamesEtcMultiWordList(text, word);
|
||||
return _namesEtcListUppercase.Contains(word) || _namesEtcListWithApostrophe.Contains(word) || _namesList.IsInNamesMultiWordList(text, word);
|
||||
}
|
||||
|
||||
public bool HasUserWord(string word)
|
||||
|
@ -1388,7 +1388,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
if (word.Length > 2 && _namesEtcListWithApostrophe.Contains(word))
|
||||
return true;
|
||||
|
||||
if (_namesList != null && _namesList.IsInNamesEtcMultiWordList(line, word))
|
||||
if (_namesList != null && _namesList.IsInNamesMultiWordList(line, word))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -43,7 +43,7 @@ namespace Test.Logic.Dictionaries
|
||||
|
||||
// Act
|
||||
namesList.Add("Charlie Parker123");
|
||||
var exists = namesList.IsInNamesEtcMultiWordList("This is Charlie Parker123!", "Charlie Parker123");
|
||||
var exists = namesList.IsInNamesMultiWordList("This is Charlie Parker123!", "Charlie Parker123");
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(exists);
|
||||
|
Loading…
Reference in New Issue
Block a user