mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-23 11:42:36 +01:00
Fix a few issues from codacy
This commit is contained in:
parent
1f19b0c35a
commit
155f2bb56d
@ -17,8 +17,8 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
int fixCount = 0;
|
||||
var language = Configuration.Settings.Language.FixCommonErrors;
|
||||
var fixAction = language.FixSpanishInvertedQuestionAndExclamationMarks;
|
||||
var p = (Paragraph)null;
|
||||
var oldText = (string)null;
|
||||
Paragraph p;
|
||||
string oldText;
|
||||
|
||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
|
@ -6284,7 +6284,7 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("BinaryAutoDetectBestDb", settings.VobSubOcr.BinaryAutoDetectBestDb.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("LastTesseractSpellCheck", settings.VobSubOcr.LastTesseractSpellCheck);
|
||||
textWriter.WriteElementString("CaptureTopAlign", settings.VobSubOcr.CaptureTopAlign.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
|
||||
textWriter.WriteEndElement();
|
||||
|
||||
textWriter.WriteStartElement("MultipleSearchAndReplaceGroups", string.Empty);
|
||||
|
@ -9055,6 +9055,6 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
}
|
||||
}
|
||||
return bestDbName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
{
|
||||
var w = sbWord.ToString();
|
||||
var wordIsItalic = italicCount > w.Length / 2.0;
|
||||
if (!wordIsItalic && italicCount == w.Length / 2.0 && italicOn)
|
||||
if (!wordIsItalic && Math.Abs(italicCount - w.Length / 2.0) < 0.3 && italicOn)
|
||||
{
|
||||
wordIsItalic = true;
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
private HashSet<string> _nameList = new HashSet<string>();
|
||||
private HashSet<string> _nameListUppercase = new HashSet<string>();
|
||||
private HashSet<string> _nameListWithApostrophe = new HashSet<string>();
|
||||
private List<string> _nameListWithPeriods = new List<string>();
|
||||
private HashSet<string> _nameMultiWordList = new HashSet<string>(); // case sensitive phrases
|
||||
private List<string> _nameMultiWordListAndWordsWithPeriods;
|
||||
private HashSet<string> _abbreviationList;
|
||||
@ -54,8 +53,6 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
private static readonly Regex RegexUppercaseI = new Regex("[a-zæøåöääöéèàùâêîôûëï]I.", RegexOptions.Compiled);
|
||||
private static readonly Regex RegexNumber1 = new Regex(@"(?<=\d) 1(?!/\d)", RegexOptions.Compiled);
|
||||
|
||||
private static readonly char[] SplitChars = { ' ', '¡', '¿', ',', '.', '!', '?', ':', ';', '(', ')', '[', ']', '{', '}', '+', '-', '£', '"', '„', '”', '“', '«', '»', '#', '&', '%', '…', '—', '♪', '\r', '\n', '؟' };
|
||||
|
||||
public bool Abort { get; set; }
|
||||
public OcrSpellCheck.Action LastAction { get; set; } = OcrSpellCheck.Action.Abort;
|
||||
public bool IsBinaryImageCompare { get; set; }
|
||||
@ -240,7 +237,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
_nameMultiWordList = _nameListObj.GetMultiNames();
|
||||
_nameListUppercase = new HashSet<string>();
|
||||
_nameListWithApostrophe = new HashSet<string>();
|
||||
_nameListWithPeriods = new List<string>();
|
||||
var nameListWithPeriods = new List<string>();
|
||||
_abbreviationList = new HashSet<string>();
|
||||
|
||||
bool isEnglish = threeLetterIsoLanguageName.Equals("eng", StringComparison.OrdinalIgnoreCase);
|
||||
@ -267,11 +264,11 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
|
||||
if (name.Contains("."))
|
||||
{
|
||||
_nameListWithPeriods.Add(name);
|
||||
nameListWithPeriods.Add(name);
|
||||
}
|
||||
}
|
||||
|
||||
_nameMultiWordListAndWordsWithPeriods = new List<string>(_nameMultiWordList.Concat(_nameListWithPeriods));
|
||||
_nameMultiWordListAndWordsWithPeriods = new List<string>(_nameMultiWordList.Concat(nameListWithPeriods));
|
||||
if (isEnglish)
|
||||
{
|
||||
if (!_abbreviationList.Contains("a.m."))
|
||||
@ -1261,7 +1258,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
foreach (var w in line.Split(' '))
|
||||
{
|
||||
var word = w.Trim(trimChars);
|
||||
if (w.Length > 1 && w == w.ToUpperInvariant())
|
||||
if (word.Length > 1 && word == word.ToUpperInvariant())
|
||||
{
|
||||
hasAllUpperWord = true;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user