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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInNamesEtcMultiWordList(string text, string word)
|
public bool IsInNamesMultiWordList(string text, string word)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(text))
|
if (string.IsNullOrEmpty(text))
|
||||||
return false;
|
return false;
|
||||||
@ -252,13 +252,15 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
|||||||
text = text.Replace(Environment.NewLine, " ");
|
text = text.Replace(Environment.NewLine, " ");
|
||||||
text = text.FixExtraSpaces();
|
text = text.FixExtraSpaces();
|
||||||
|
|
||||||
foreach (string s in _namesMultiList)
|
if (_namesMultiList.Contains(word))
|
||||||
{
|
{
|
||||||
if (s.Contains(word) && text.Contains(s))
|
return true;
|
||||||
|
}
|
||||||
|
foreach (string multiWordName in _namesMultiList)
|
||||||
|
{
|
||||||
|
if (text.Contains(multiWordName))
|
||||||
{
|
{
|
||||||
if (s.StartsWith(word + " ", StringComparison.Ordinal) || s.EndsWith(" " + word, StringComparison.Ordinal) || s.Contains(" " + word + " "))
|
if (multiWordName.StartsWith(word + " ", StringComparison.Ordinal) || multiWordName.EndsWith(" " + word, StringComparison.Ordinal) || multiWordName.Contains(" " + word + " "))
|
||||||
return true;
|
|
||||||
if (word == s)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ namespace Nikse.SubtitleEdit.Core.SpellCheck
|
|||||||
|
|
||||||
public bool HasNameExtended(string word, string text)
|
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)
|
public bool HasUserWord(string word)
|
||||||
|
@ -1388,7 +1388,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
|||||||
if (word.Length > 2 && _namesEtcListWithApostrophe.Contains(word))
|
if (word.Length > 2 && _namesEtcListWithApostrophe.Contains(word))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (_namesList != null && _namesList.IsInNamesEtcMultiWordList(line, word))
|
if (_namesList != null && _namesList.IsInNamesMultiWordList(line, word))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -43,7 +43,7 @@ namespace Test.Logic.Dictionaries
|
|||||||
|
|
||||||
// Act
|
// Act
|
||||||
namesList.Add("Charlie Parker123");
|
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
|
||||||
Assert.IsTrue(exists);
|
Assert.IsTrue(exists);
|
||||||
|
Loading…
Reference in New Issue
Block a user