mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Improve OCR replace list guessses
This commit is contained in:
parent
a1c35e349e
commit
c78dda9571
@ -2820,7 +2820,7 @@
|
|||||||
</PartialWordsAlways>
|
</PartialWordsAlways>
|
||||||
<PartialWords>
|
<PartialWords>
|
||||||
<!-- Will be used to check words not in dictionary.
|
<!-- Will be used to check words not in dictionary.
|
||||||
If new word(s) and longer than 5 chars and exists in spelling dictionary, it is (or they are) accepted -->
|
If new word(s) and longer than 4 chars and exists in spelling dictionary, it is (or they are) accepted -->
|
||||||
<WordPart from="IVI" to="M" />
|
<WordPart from="IVI" to="M" />
|
||||||
<WordPart from="/" to="l" />
|
<WordPart from="/" to="l" />
|
||||||
<WordPart from="|" to="I" />
|
<WordPart from="|" to="I" />
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<PartialWordsAlways />
|
<PartialWordsAlways />
|
||||||
<PartialWords>
|
<PartialWords>
|
||||||
<!-- Will be used to check words not in dictionary.
|
<!-- Will be used to check words not in dictionary.
|
||||||
If new word(s) and longer than 5 chars and exists
|
If new word(s) and longer than 4 chars and exists
|
||||||
in spelling dictionary, it is (or they are) accepted -->
|
in spelling dictionary, it is (or they are) accepted -->
|
||||||
<!-- "f " will be two words -->
|
<!-- "f " will be two words -->
|
||||||
<WordPart from="f" to="f " />
|
<WordPart from="f" to="f " />
|
||||||
|
@ -363,7 +363,7 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
|||||||
if (word.Substring(i).StartsWith(letter, StringComparison.Ordinal))
|
if (word.Substring(i).StartsWith(letter, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (i == word.Length - letter.Length && !_partialWordReplaceList[letter].Contains(" "))
|
if (i == word.Length - letter.Length && !_partialWordReplaceList[letter].Contains(' '))
|
||||||
{
|
{
|
||||||
var guess = word.Remove(i, letter.Length).Insert(i, _partialWordReplaceList[letter]);
|
var guess = word.Remove(i, letter.Length).Insert(i, _partialWordReplaceList[letter]);
|
||||||
AddToGuessList(list, guess);
|
AddToGuessList(list, guess);
|
||||||
@ -379,14 +379,23 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
|||||||
|
|
||||||
if (indexes.Count > 1)
|
if (indexes.Count > 1)
|
||||||
{
|
{
|
||||||
var multiGuess = word;
|
if (!_partialWordReplaceList[letter].Contains(' '))
|
||||||
for (int i = indexes.Count - 1; i >= 0; i--)
|
|
||||||
{
|
{
|
||||||
var idx = indexes[i];
|
var multiGuess = word;
|
||||||
multiGuess = multiGuess.Remove(idx, letter.Length).Insert(idx, _partialWordReplaceList[letter]);
|
for (int i = indexes.Count - 1; i >= 0; i--)
|
||||||
AddToGuessList(list, multiGuess);
|
{
|
||||||
|
var idx = indexes[i];
|
||||||
|
multiGuess = multiGuess.Remove(idx, letter.Length).Insert(idx, _partialWordReplaceList[letter]);
|
||||||
|
AddToGuessList(list, multiGuess);
|
||||||
|
}
|
||||||
|
|
||||||
|
AddToGuessList(list, word.Replace(letter, _partialWordReplaceList[letter]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (indexes.Count > 0)
|
||||||
|
{
|
||||||
|
AddToGuessList(list, word.Replace(letter, _partialWordReplaceList[letter]));
|
||||||
|
}
|
||||||
|
|
||||||
if (indexes.Count > 0)
|
if (indexes.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -1592,7 +1592,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
|||||||
guesses.Add(wordWithVerticalLine);
|
guesses.Add(wordWithVerticalLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (word.Length > 5 && autoGuess == AutoGuessLevel.Aggressive)
|
if (word.Length > 4 && autoGuess == AutoGuessLevel.Aggressive)
|
||||||
{
|
{
|
||||||
guesses.AddRange((List<string>)_ocrFixReplaceList.CreateGuessesFromLetters(word));
|
guesses.AddRange((List<string>)_ocrFixReplaceList.CreateGuessesFromLetters(word));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user