Added option which allows for, not using hard coded rules in Fix common OCR errors

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@291 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-01-30 15:04:03 +00:00
parent 33d6eccedc
commit 2ac40da6c6
7 changed files with 119 additions and 96 deletions

View File

@ -291,7 +291,6 @@ namespace Nikse.SubtitleEdit.Forms
toolStripComboBoxWaveForm.SelectedIndexChanged += toolStripComboBoxWaveForm_SelectedIndexChanged; toolStripComboBoxWaveForm.SelectedIndexChanged += toolStripComboBoxWaveForm_SelectedIndexChanged;
FixLargeFonts(); FixLargeFonts();
//this.Width = (int)(5304958 / (8 - 8 + (this.Width) - this.Width));
_timerAddHistoryWhenDone.Interval = 500; _timerAddHistoryWhenDone.Interval = 500;
_timerAddHistoryWhenDone.Tick += new EventHandler(timerAddHistoryWhenDone_Tick); _timerAddHistoryWhenDone.Tick += new EventHandler(timerAddHistoryWhenDone_Tick);
} }
@ -1075,16 +1074,19 @@ namespace Nikse.SubtitleEdit.Forms
AudioWaveForm.WavePeaks = null; AudioWaveForm.WavePeaks = null;
AudioWaveForm.Invalidate(); AudioWaveForm.Invalidate();
if (!string.IsNullOrEmpty(videoFileName) && File.Exists(videoFileName)) if (Configuration.Settings.General.ShowVideoPlayer || Configuration.Settings.General.ShowWaveForm)
{ {
OpenVideo(videoFileName); if (!string.IsNullOrEmpty(videoFileName) && File.Exists(videoFileName))
} {
else if (!string.IsNullOrEmpty(fileName) && (toolStripButtonToogleVideo.Checked || toolStripButtonToogleWaveForm.Checked)) OpenVideo(videoFileName);
{ }
TryToFindAndOpenVideoFile(Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName))); else if (!string.IsNullOrEmpty(fileName) && (toolStripButtonToogleVideo.Checked || toolStripButtonToogleWaveForm.Checked))
{
TryToFindAndOpenVideoFile(Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName)));
}
} }
videoFileLoaded = _videoFileName != null; videoFileLoaded = _videoFileName != null;
if (Configuration.Settings.RecentFiles.Files.Count > 0 && if (Configuration.Settings.RecentFiles.Files.Count > 0 &&
Configuration.Settings.RecentFiles.Files[0].FileName == fileName) Configuration.Settings.RecentFiles.Files[0].FileName == fileName)
@ -6353,11 +6355,12 @@ namespace Nikse.SubtitleEdit.Forms
private void OpenVideo(string fileName) private void OpenVideo(string fileName)
{ {
if (File.Exists(fileName)) if (File.Exists(fileName))
{ {
FileInfo fi = new FileInfo(fileName); FileInfo fi = new FileInfo(fileName);
if (fi.Length < 1000) if (fi.Length < 1000)
return; return;
Cursor = Cursors.WaitCursor;
VideoFileName = fileName; VideoFileName = fileName;
if (mediaPlayer.VideoPlayer != null) if (mediaPlayer.VideoPlayer != null)
{ {
@ -6368,7 +6371,6 @@ namespace Nikse.SubtitleEdit.Forms
VideoInfo videoInfo = ShowVideoInfo(fileName); VideoInfo videoInfo = ShowVideoInfo(fileName);
toolStripComboBoxFrameRate.Text = videoInfo.FramesPerSecond.ToString(); toolStripComboBoxFrameRate.Text = videoInfo.FramesPerSecond.ToString();
Utilities.InitializeVideoPlayerAndContainer(fileName, videoInfo, mediaPlayer, VideoLoaded, VideoEnded); Utilities.InitializeVideoPlayerAndContainer(fileName, videoInfo, mediaPlayer, VideoLoaded, VideoEnded);
mediaPlayer.Volume = 0; mediaPlayer.Volume = 0;
labelVideoInfo.Text = Path.GetFileName(fileName) + " " + videoInfo.Width + "x" + videoInfo.Height + " " + videoInfo.VideoCodec; labelVideoInfo.Text = Path.GetFileName(fileName) + " " + videoInfo.Width + "x" + videoInfo.Height + " " + videoInfo.VideoCodec;
@ -6387,6 +6389,7 @@ namespace Nikse.SubtitleEdit.Forms
AudioWaveForm.SetPosition(0, _subtitle, 0, 0); AudioWaveForm.SetPosition(0, _subtitle, 0, 0);
timerWaveForm.Start(); timerWaveForm.Start();
} }
Cursor = Cursors.Default;
} }
} }
@ -6409,19 +6412,6 @@ namespace Nikse.SubtitleEdit.Forms
_videoInfo = Utilities.GetVideoInfo(fileName, delegate { Application.DoEvents(); }); _videoInfo = Utilities.GetVideoInfo(fileName, delegate { Application.DoEvents(); });
var info = new FileInfo(fileName); var info = new FileInfo(fileName);
long fileSizeInBytes = info.Length; long fileSizeInBytes = info.Length;
//labelVideoInfo.Text = string.Format(_languageGeneral.FileNameXAndSize, fileName, Utilities.FormatBytesToDisplayFileSize(fileSizeInBytes)) + Environment.NewLine +
// string.Format(_languageGeneral.ResolutionX, +_videoInfo.Width + "x" + _videoInfo.Height) + " ";
//if (_videoInfo.FramesPerSecond > 5 && _videoInfo.FramesPerSecond < 200)
// labelVideoInfo.Text += string.Format(_languageGeneral.FrameRateX + " ", _videoInfo.FramesPerSecond);
//if (_videoInfo.TotalFrames > 10)
// labelVideoInfo.Text += string.Format(_languageGeneral.TotalFramesX + " ", (int)_videoInfo.TotalFrames);
//if (!string.IsNullOrEmpty(_videoInfo.VideoCodec))
// labelVideoInfo.Text += string.Format(_languageGeneral.VideoEncodingX, _videoInfo.VideoCodec) + " ";
//TimeSpan span = TimeSpan.FromMilliseconds(_videoInfo.TotalMilliseconds);
//_totalPositionString = " / " + string.Format("{0:00}:{1:00}:{2:00},{3:000}", span.Hours, span.Minutes, span.Seconds, span.Milliseconds);
return _videoInfo; return _videoInfo;
} }
@ -6456,7 +6446,6 @@ namespace Nikse.SubtitleEdit.Forms
else else
mediaPlayer.CurrentPosition = 0; mediaPlayer.CurrentPosition = 0;
Utilities.ShowSubtitle(_subtitle.Paragraphs, videoPlayerContainer); Utilities.ShowSubtitle(_subtitle.Paragraphs, videoPlayerContainer);
// ShowPosition(labelPosition, mediaPlayer);
} }
} }

View File

@ -33,6 +33,7 @@
this.tabControlSettings = new System.Windows.Forms.TabControl(); this.tabControlSettings = new System.Windows.Forms.TabControl();
this.tabPageGenerel = new System.Windows.Forms.TabPage(); this.tabPageGenerel = new System.Windows.Forms.TabPage();
this.groupBoxMiscellaneous = new System.Windows.Forms.GroupBox(); this.groupBoxMiscellaneous = new System.Windows.Forms.GroupBox();
this.checkBoxAutoWrapWhileTyping = new System.Windows.Forms.CheckBox();
this.labelMergeShortLines = new System.Windows.Forms.Label(); this.labelMergeShortLines = new System.Windows.Forms.Label();
this.comboBoxMergeShortLineLength = new System.Windows.Forms.ComboBox(); this.comboBoxMergeShortLineLength = new System.Windows.Forms.ComboBox();
this.checkBoxAllowEditOfOriginalSubtitle = new System.Windows.Forms.CheckBox(); this.checkBoxAllowEditOfOriginalSubtitle = new System.Windows.Forms.CheckBox();
@ -195,7 +196,7 @@
this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog(); this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog();
this.fontDialogSSAStyle = new System.Windows.Forms.FontDialog(); this.fontDialogSSAStyle = new System.Windows.Forms.FontDialog();
this.labelStatus = new System.Windows.Forms.Label(); this.labelStatus = new System.Windows.Forms.Label();
this.checkBoxAutoWrapWhileTyping = new System.Windows.Forms.CheckBox(); this.checkBoxFixCommonOcrErrorsUsingHardcodedRules = new System.Windows.Forms.CheckBox();
this.tabControlSettings.SuspendLayout(); this.tabControlSettings.SuspendLayout();
this.tabPageGenerel.SuspendLayout(); this.tabPageGenerel.SuspendLayout();
this.groupBoxMiscellaneous.SuspendLayout(); this.groupBoxMiscellaneous.SuspendLayout();
@ -329,6 +330,16 @@
this.groupBoxMiscellaneous.TabStop = false; this.groupBoxMiscellaneous.TabStop = false;
this.groupBoxMiscellaneous.Text = "Miscellaneous"; this.groupBoxMiscellaneous.Text = "Miscellaneous";
// //
// checkBoxAutoWrapWhileTyping
//
this.checkBoxAutoWrapWhileTyping.AutoSize = true;
this.checkBoxAutoWrapWhileTyping.Location = new System.Drawing.Point(193, 146);
this.checkBoxAutoWrapWhileTyping.Name = "checkBoxAutoWrapWhileTyping";
this.checkBoxAutoWrapWhileTyping.Size = new System.Drawing.Size(132, 17);
this.checkBoxAutoWrapWhileTyping.TabIndex = 4;
this.checkBoxAutoWrapWhileTyping.Text = "Auto-wrap while typing";
this.checkBoxAutoWrapWhileTyping.UseVisualStyleBackColor = true;
//
// labelMergeShortLines // labelMergeShortLines
// //
this.labelMergeShortLines.AutoSize = true; this.labelMergeShortLines.AutoSize = true;
@ -352,7 +363,7 @@
this.checkBoxAllowEditOfOriginalSubtitle.AutoSize = true; this.checkBoxAllowEditOfOriginalSubtitle.AutoSize = true;
this.checkBoxAllowEditOfOriginalSubtitle.Location = new System.Drawing.Point(436, 296); this.checkBoxAllowEditOfOriginalSubtitle.Location = new System.Drawing.Point(436, 296);
this.checkBoxAllowEditOfOriginalSubtitle.Name = "checkBoxAllowEditOfOriginalSubtitle"; this.checkBoxAllowEditOfOriginalSubtitle.Name = "checkBoxAllowEditOfOriginalSubtitle";
this.checkBoxAllowEditOfOriginalSubtitle.Size = new System.Drawing.Size(160, 17); this.checkBoxAllowEditOfOriginalSubtitle.Size = new System.Drawing.Size(155, 17);
this.checkBoxAllowEditOfOriginalSubtitle.TabIndex = 24; this.checkBoxAllowEditOfOriginalSubtitle.TabIndex = 24;
this.checkBoxAllowEditOfOriginalSubtitle.Text = "Allow edit of original subtitle"; this.checkBoxAllowEditOfOriginalSubtitle.Text = "Allow edit of original subtitle";
this.checkBoxAllowEditOfOriginalSubtitle.UseVisualStyleBackColor = true; this.checkBoxAllowEditOfOriginalSubtitle.UseVisualStyleBackColor = true;
@ -520,7 +531,7 @@
this.checkBoxRememberWindowPosition.AutoSize = true; this.checkBoxRememberWindowPosition.AutoSize = true;
this.checkBoxRememberWindowPosition.Location = new System.Drawing.Point(436, 101); this.checkBoxRememberWindowPosition.Location = new System.Drawing.Point(436, 101);
this.checkBoxRememberWindowPosition.Name = "checkBoxRememberWindowPosition"; this.checkBoxRememberWindowPosition.Name = "checkBoxRememberWindowPosition";
this.checkBoxRememberWindowPosition.Size = new System.Drawing.Size(223, 17); this.checkBoxRememberWindowPosition.Size = new System.Drawing.Size(222, 17);
this.checkBoxRememberWindowPosition.TabIndex = 15; this.checkBoxRememberWindowPosition.TabIndex = 15;
this.checkBoxRememberWindowPosition.Text = "Remember main window position and size"; this.checkBoxRememberWindowPosition.Text = "Remember main window position and size";
this.checkBoxRememberWindowPosition.UseVisualStyleBackColor = true; this.checkBoxRememberWindowPosition.UseVisualStyleBackColor = true;
@ -567,7 +578,7 @@
this.checkBoxStartInSourceView.AutoSize = true; this.checkBoxStartInSourceView.AutoSize = true;
this.checkBoxStartInSourceView.Location = new System.Drawing.Point(436, 124); this.checkBoxStartInSourceView.Location = new System.Drawing.Point(436, 124);
this.checkBoxStartInSourceView.Name = "checkBoxStartInSourceView"; this.checkBoxStartInSourceView.Name = "checkBoxStartInSourceView";
this.checkBoxStartInSourceView.Size = new System.Drawing.Size(121, 17); this.checkBoxStartInSourceView.Size = new System.Drawing.Size(119, 17);
this.checkBoxStartInSourceView.TabIndex = 16; this.checkBoxStartInSourceView.TabIndex = 16;
this.checkBoxStartInSourceView.Text = "Start in source view"; this.checkBoxStartInSourceView.Text = "Start in source view";
this.checkBoxStartInSourceView.UseVisualStyleBackColor = true; this.checkBoxStartInSourceView.UseVisualStyleBackColor = true;
@ -577,7 +588,7 @@
this.checkBoxReopenLastOpened.AutoSize = true; this.checkBoxReopenLastOpened.AutoSize = true;
this.checkBoxReopenLastOpened.Location = new System.Drawing.Point(444, 52); this.checkBoxReopenLastOpened.Location = new System.Drawing.Point(444, 52);
this.checkBoxReopenLastOpened.Name = "checkBoxReopenLastOpened"; this.checkBoxReopenLastOpened.Name = "checkBoxReopenLastOpened";
this.checkBoxReopenLastOpened.Size = new System.Drawing.Size(145, 17); this.checkBoxReopenLastOpened.Size = new System.Drawing.Size(140, 17);
this.checkBoxReopenLastOpened.TabIndex = 13; this.checkBoxReopenLastOpened.TabIndex = 13;
this.checkBoxReopenLastOpened.Text = "Start with last file loaded"; this.checkBoxReopenLastOpened.Text = "Start with last file loaded";
this.checkBoxReopenLastOpened.UseVisualStyleBackColor = true; this.checkBoxReopenLastOpened.UseVisualStyleBackColor = true;
@ -587,7 +598,7 @@
this.checkBoxRememberRecentFiles.AutoSize = true; this.checkBoxRememberRecentFiles.AutoSize = true;
this.checkBoxRememberRecentFiles.Location = new System.Drawing.Point(436, 28); this.checkBoxRememberRecentFiles.Location = new System.Drawing.Point(436, 28);
this.checkBoxRememberRecentFiles.Name = "checkBoxRememberRecentFiles"; this.checkBoxRememberRecentFiles.Name = "checkBoxRememberRecentFiles";
this.checkBoxRememberRecentFiles.Size = new System.Drawing.Size(195, 17); this.checkBoxRememberRecentFiles.Size = new System.Drawing.Size(188, 17);
this.checkBoxRememberRecentFiles.TabIndex = 12; this.checkBoxRememberRecentFiles.TabIndex = 12;
this.checkBoxRememberRecentFiles.Text = "Remember recent files (for reopen)"; this.checkBoxRememberRecentFiles.Text = "Remember recent files (for reopen)";
this.checkBoxRememberRecentFiles.UseVisualStyleBackColor = true; this.checkBoxRememberRecentFiles.UseVisualStyleBackColor = true;
@ -598,7 +609,7 @@
this.checkBoxSubtitleFontBold.AutoSize = true; this.checkBoxSubtitleFontBold.AutoSize = true;
this.checkBoxSubtitleFontBold.Location = new System.Drawing.Point(193, 269); this.checkBoxSubtitleFontBold.Location = new System.Drawing.Point(193, 269);
this.checkBoxSubtitleFontBold.Name = "checkBoxSubtitleFontBold"; this.checkBoxSubtitleFontBold.Name = "checkBoxSubtitleFontBold";
this.checkBoxSubtitleFontBold.Size = new System.Drawing.Size(46, 17); this.checkBoxSubtitleFontBold.Size = new System.Drawing.Size(47, 17);
this.checkBoxSubtitleFontBold.TabIndex = 8; this.checkBoxSubtitleFontBold.TabIndex = 8;
this.checkBoxSubtitleFontBold.Text = "Bold"; this.checkBoxSubtitleFontBold.Text = "Bold";
this.checkBoxSubtitleFontBold.UseVisualStyleBackColor = true; this.checkBoxSubtitleFontBold.UseVisualStyleBackColor = true;
@ -1410,9 +1421,9 @@
// groupBoxSpellCheck // groupBoxSpellCheck
// //
this.groupBoxSpellCheck.Controls.Add(this.checkBoxSpellCheckAutoChangeNames); this.groupBoxSpellCheck.Controls.Add(this.checkBoxSpellCheckAutoChangeNames);
this.groupBoxSpellCheck.Location = new System.Drawing.Point(7, 257); this.groupBoxSpellCheck.Location = new System.Drawing.Point(6, 283);
this.groupBoxSpellCheck.Name = "groupBoxSpellCheck"; this.groupBoxSpellCheck.Name = "groupBoxSpellCheck";
this.groupBoxSpellCheck.Size = new System.Drawing.Size(785, 148); this.groupBoxSpellCheck.Size = new System.Drawing.Size(785, 122);
this.groupBoxSpellCheck.TabIndex = 4; this.groupBoxSpellCheck.TabIndex = 4;
this.groupBoxSpellCheck.TabStop = false; this.groupBoxSpellCheck.TabStop = false;
this.groupBoxSpellCheck.Text = "Spell check"; this.groupBoxSpellCheck.Text = "Spell check";
@ -1422,20 +1433,21 @@
this.checkBoxSpellCheckAutoChangeNames.AutoSize = true; this.checkBoxSpellCheckAutoChangeNames.AutoSize = true;
this.checkBoxSpellCheckAutoChangeNames.Location = new System.Drawing.Point(15, 20); this.checkBoxSpellCheckAutoChangeNames.Location = new System.Drawing.Point(15, 20);
this.checkBoxSpellCheckAutoChangeNames.Name = "checkBoxSpellCheckAutoChangeNames"; this.checkBoxSpellCheckAutoChangeNames.Name = "checkBoxSpellCheckAutoChangeNames";
this.checkBoxSpellCheckAutoChangeNames.Size = new System.Drawing.Size(209, 17); this.checkBoxSpellCheckAutoChangeNames.Size = new System.Drawing.Size(216, 17);
this.checkBoxSpellCheckAutoChangeNames.TabIndex = 0; this.checkBoxSpellCheckAutoChangeNames.TabIndex = 0;
this.checkBoxSpellCheckAutoChangeNames.Text = "Auto fix names where only casing differ"; this.checkBoxSpellCheckAutoChangeNames.Text = "Auto fix names where only casing differ";
this.checkBoxSpellCheckAutoChangeNames.UseVisualStyleBackColor = true; this.checkBoxSpellCheckAutoChangeNames.UseVisualStyleBackColor = true;
// //
// groupBoxFixCommonErrors // groupBoxFixCommonErrors
// //
this.groupBoxFixCommonErrors.Controls.Add(this.checkBoxFixCommonOcrErrorsUsingHardcodedRules);
this.groupBoxFixCommonErrors.Controls.Add(this.comboBoxToolsMusicSymbol); this.groupBoxFixCommonErrors.Controls.Add(this.comboBoxToolsMusicSymbol);
this.groupBoxFixCommonErrors.Controls.Add(this.textBoxMusicSymbolsToReplace); this.groupBoxFixCommonErrors.Controls.Add(this.textBoxMusicSymbolsToReplace);
this.groupBoxFixCommonErrors.Controls.Add(this.labelToolsMusicSymbolsToReplace); this.groupBoxFixCommonErrors.Controls.Add(this.labelToolsMusicSymbolsToReplace);
this.groupBoxFixCommonErrors.Controls.Add(this.labelToolsMusicSymbol); this.groupBoxFixCommonErrors.Controls.Add(this.labelToolsMusicSymbol);
this.groupBoxFixCommonErrors.Location = new System.Drawing.Point(7, 129); this.groupBoxFixCommonErrors.Location = new System.Drawing.Point(7, 129);
this.groupBoxFixCommonErrors.Name = "groupBoxFixCommonErrors"; this.groupBoxFixCommonErrors.Name = "groupBoxFixCommonErrors";
this.groupBoxFixCommonErrors.Size = new System.Drawing.Size(785, 121); this.groupBoxFixCommonErrors.Size = new System.Drawing.Size(785, 148);
this.groupBoxFixCommonErrors.TabIndex = 3; this.groupBoxFixCommonErrors.TabIndex = 3;
this.groupBoxFixCommonErrors.TabStop = false; this.groupBoxFixCommonErrors.TabStop = false;
this.groupBoxFixCommonErrors.Text = "Fix common errors"; this.groupBoxFixCommonErrors.Text = "Fix common errors";
@ -1452,7 +1464,7 @@
this.comboBoxToolsMusicSymbol.Location = new System.Drawing.Point(199, 71); this.comboBoxToolsMusicSymbol.Location = new System.Drawing.Point(199, 71);
this.comboBoxToolsMusicSymbol.Name = "comboBoxToolsMusicSymbol"; this.comboBoxToolsMusicSymbol.Name = "comboBoxToolsMusicSymbol";
this.comboBoxToolsMusicSymbol.Size = new System.Drawing.Size(86, 21); this.comboBoxToolsMusicSymbol.Size = new System.Drawing.Size(86, 21);
this.comboBoxToolsMusicSymbol.TabIndex = 36; this.comboBoxToolsMusicSymbol.TabIndex = 1;
// //
// textBoxMusicSymbolsToReplace // textBoxMusicSymbolsToReplace
// //
@ -1460,7 +1472,7 @@
this.textBoxMusicSymbolsToReplace.MaxLength = 100; this.textBoxMusicSymbolsToReplace.MaxLength = 100;
this.textBoxMusicSymbolsToReplace.Name = "textBoxMusicSymbolsToReplace"; this.textBoxMusicSymbolsToReplace.Name = "textBoxMusicSymbolsToReplace";
this.textBoxMusicSymbolsToReplace.Size = new System.Drawing.Size(274, 21); this.textBoxMusicSymbolsToReplace.Size = new System.Drawing.Size(274, 21);
this.textBoxMusicSymbolsToReplace.TabIndex = 35; this.textBoxMusicSymbolsToReplace.TabIndex = 0;
// //
// labelToolsMusicSymbolsToReplace // labelToolsMusicSymbolsToReplace
// //
@ -1516,7 +1528,7 @@
this.comboBoxToolsEndSceneIndex.Location = new System.Drawing.Point(200, 76); this.comboBoxToolsEndSceneIndex.Location = new System.Drawing.Point(200, 76);
this.comboBoxToolsEndSceneIndex.Name = "comboBoxToolsEndSceneIndex"; this.comboBoxToolsEndSceneIndex.Name = "comboBoxToolsEndSceneIndex";
this.comboBoxToolsEndSceneIndex.Size = new System.Drawing.Size(73, 21); this.comboBoxToolsEndSceneIndex.Size = new System.Drawing.Size(73, 21);
this.comboBoxToolsEndSceneIndex.TabIndex = 28; this.comboBoxToolsEndSceneIndex.TabIndex = 2;
// //
// labelToolsStartScene // labelToolsStartScene
// //
@ -1539,7 +1551,7 @@
this.comboBoxToolsStartSceneIndex.Location = new System.Drawing.Point(200, 49); this.comboBoxToolsStartSceneIndex.Location = new System.Drawing.Point(200, 49);
this.comboBoxToolsStartSceneIndex.Name = "comboBoxToolsStartSceneIndex"; this.comboBoxToolsStartSceneIndex.Name = "comboBoxToolsStartSceneIndex";
this.comboBoxToolsStartSceneIndex.Size = new System.Drawing.Size(73, 21); this.comboBoxToolsStartSceneIndex.Size = new System.Drawing.Size(73, 21);
this.comboBoxToolsStartSceneIndex.TabIndex = 26; this.comboBoxToolsStartSceneIndex.TabIndex = 1;
// //
// comboBoxToolsVerifySeconds // comboBoxToolsVerifySeconds
// //
@ -1553,7 +1565,7 @@
this.comboBoxToolsVerifySeconds.Location = new System.Drawing.Point(200, 22); this.comboBoxToolsVerifySeconds.Location = new System.Drawing.Point(200, 22);
this.comboBoxToolsVerifySeconds.Name = "comboBoxToolsVerifySeconds"; this.comboBoxToolsVerifySeconds.Name = "comboBoxToolsVerifySeconds";
this.comboBoxToolsVerifySeconds.Size = new System.Drawing.Size(73, 21); this.comboBoxToolsVerifySeconds.Size = new System.Drawing.Size(73, 21);
this.comboBoxToolsVerifySeconds.TabIndex = 21; this.comboBoxToolsVerifySeconds.TabIndex = 0;
// //
// labelVerifyButton // labelVerifyButton
// //
@ -1988,15 +2000,15 @@
this.labelStatus.TabIndex = 3; this.labelStatus.TabIndex = 3;
this.labelStatus.Text = "labelStatus"; this.labelStatus.Text = "labelStatus";
// //
// checkBoxAutoWrapWhileTyping // checkBoxFixCommonOcrErrorsUsingHardcodedRules
// //
this.checkBoxAutoWrapWhileTyping.AutoSize = true; this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.AutoSize = true;
this.checkBoxAutoWrapWhileTyping.Location = new System.Drawing.Point(193, 146); this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Location = new System.Drawing.Point(15, 115);
this.checkBoxAutoWrapWhileTyping.Name = "checkBoxAutoWrapWhileTyping"; this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Name = "checkBoxFixCommonOcrErrorsUsingHardcodedRules";
this.checkBoxAutoWrapWhileTyping.Size = new System.Drawing.Size(137, 17); this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Size = new System.Drawing.Size(268, 17);
this.checkBoxAutoWrapWhileTyping.TabIndex = 4; this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.TabIndex = 2;
this.checkBoxAutoWrapWhileTyping.Text = "Auto-wrap while typing"; this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Text = "Fix common OCR errors - also use hardcoded rules";
this.checkBoxAutoWrapWhileTyping.UseVisualStyleBackColor = true; this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.UseVisualStyleBackColor = true;
// //
// Settings // Settings
// //
@ -2247,5 +2259,6 @@
private System.Windows.Forms.Label labelMergeShortLines; private System.Windows.Forms.Label labelMergeShortLines;
private System.Windows.Forms.ComboBox comboBoxMergeShortLineLength; private System.Windows.Forms.ComboBox comboBoxMergeShortLineLength;
private System.Windows.Forms.CheckBox checkBoxAutoWrapWhileTyping; private System.Windows.Forms.CheckBox checkBoxAutoWrapWhileTyping;
private System.Windows.Forms.CheckBox checkBoxFixCommonOcrErrorsUsingHardcodedRules;
} }
} }

View File

@ -378,7 +378,7 @@ namespace Nikse.SubtitleEdit.Forms
} }
textBoxMusicSymbolsToReplace.Text = toolsSettings.MusicSymbolToReplace; textBoxMusicSymbolsToReplace.Text = toolsSettings.MusicSymbolToReplace;
checkBoxFixCommonOcrErrorsUsingHardcodedRules.Checked = toolsSettings.OcrFixUseHardcodedRules;
checkBoxSpellCheckAutoChangeNames.Checked = toolsSettings.SpellCheckAutoChangeNames; checkBoxSpellCheckAutoChangeNames.Checked = toolsSettings.SpellCheckAutoChangeNames;
@ -617,6 +617,7 @@ namespace Nikse.SubtitleEdit.Forms
toolsSettings.MusicSymbol = comboBoxToolsMusicSymbol.SelectedItem.ToString(); toolsSettings.MusicSymbol = comboBoxToolsMusicSymbol.SelectedItem.ToString();
toolsSettings.MusicSymbolToReplace = textBoxMusicSymbolsToReplace.Text; toolsSettings.MusicSymbolToReplace = textBoxMusicSymbolsToReplace.Text;
toolsSettings.SpellCheckAutoChangeNames = checkBoxSpellCheckAutoChangeNames.Checked; toolsSettings.SpellCheckAutoChangeNames = checkBoxSpellCheckAutoChangeNames.Checked;
toolsSettings.OcrFixUseHardcodedRules = checkBoxFixCommonOcrErrorsUsingHardcodedRules.Checked;
WordListSettings wordListSettings = Configuration.Settings.WordLists; WordListSettings wordListSettings = Configuration.Settings.WordLists;
wordListSettings.UseOnlineNamesEtc = checkBoxNamesEtcOnline.Checked; wordListSettings.UseOnlineNamesEtc = checkBoxNamesEtcOnline.Checked;

View File

@ -1142,6 +1142,7 @@ can edit in same subtitle file (collaboration)",
MergeLinesShorterThan = "Merge lines shorter than", MergeLinesShorterThan = "Merge lines shorter than",
MusicSymbol = "Music symbol", MusicSymbol = "Music symbol",
MusicSymbolsToReplace = "Music symbols to replace (separate by space)", MusicSymbolsToReplace = "Music symbols to replace (separate by space)",
FixCommonOcrErrorsUseHardcodedRules = "Fix common OCR errors - also use hardcoded rules",
}; };
ShowEarlierLater = new LanguageStructure.ShowEarlierLater ShowEarlierLater = new LanguageStructure.ShowEarlierLater

View File

@ -1076,6 +1076,7 @@
public string MergeLinesShorterThan { get; set; } public string MergeLinesShorterThan { get; set; }
public string MusicSymbol { get; set; } public string MusicSymbol { get; set; }
public string MusicSymbolsToReplace { get; set; } public string MusicSymbolsToReplace { get; set; }
public string FixCommonOcrErrorsUseHardcodedRules { get; set; }
} }
public class ShowEarlierLater public class ShowEarlierLater

View File

@ -248,32 +248,35 @@ namespace Nikse.SubtitleEdit.Logic.OCR
private string FixCommonWordErrors(string word, string lastWord) private string FixCommonWordErrors(string word, string lastWord)
{ {
while (word.Contains("--")) if (Configuration.Settings.Tools.OcrFixUseHardcodedRules)
word = word.Replace("--", "-");
if (word.Contains(""))
word = word.Replace('', '\'');
if (word.Contains("`"))
word = word.Replace('`', '\'');
if (word.Contains(""))
word = word.Replace('', '\'');
if (word.Contains("—"))
word = word.Replace('—', '-');
if (word.Contains("|"))
word = word.Replace("|", "l");
if (word.Contains("vx/"))
word = word.Replace("vx/", "w");
if (word.Contains("¤"))
{ {
var regex = new Regex("[A-ZÆØÅÄÖÉÈÀÙÂÊÎÔÛËÏa-zæøåäöéèàùâêîôûëï]¤"); while (word.Contains("--"))
if (regex.IsMatch(word)) word = word.Replace("--", "-");
word = word.Replace("¤", "o");
if (word.Contains(""))
word = word.Replace('', '\'');
if (word.Contains("`"))
word = word.Replace('`', '\'');
if (word.Contains(""))
word = word.Replace('', '\'');
if (word.Contains("—"))
word = word.Replace('—', '-');
if (word.Contains("|"))
word = word.Replace("|", "l");
if (word.Contains("vx/"))
word = word.Replace("vx/", "w");
if (word.Contains("¤"))
{
var regex = new Regex("[A-ZÆØÅÄÖÉÈÀÙÂÊÎÔÛËÏa-zæøåäöéèàùâêîôûëï]¤");
if (regex.IsMatch(word))
word = word.Replace("¤", "o");
}
} }
string pre = string.Empty; string pre = string.Empty;
@ -359,16 +362,19 @@ namespace Nikse.SubtitleEdit.Logic.OCR
return _wordReplaceList[from]; return _wordReplaceList[from];
} }
// uppercase I or 1 inside lowercase word (will be replaced by lowercase L) if (Configuration.Settings.Tools.OcrFixUseHardcodedRules)
word = FixIor1InsideLowerCaseWord(word); {
// uppercase I or 1 inside lowercase word (will be replaced by lowercase L)
word = FixIor1InsideLowerCaseWord(word);
// uppercase 0 inside lowercase word (will be replaced by lowercase L) // uppercase 0 inside lowercase word (will be replaced by lowercase L)
word = Fix0InsideLowerCaseWord(word); word = Fix0InsideLowerCaseWord(word);
// uppercase I or 1 inside lowercase word (will be replaced by lowercase L) // uppercase I or 1 inside lowercase word (will be replaced by lowercase L)
word = FixIor1InsideLowerCaseWord(word); word = FixIor1InsideLowerCaseWord(word);
word = FixLowerCaseLInsideUpperCaseWord(word); // eg. SCARLETTl => SCARLETTI word = FixLowerCaseLInsideUpperCaseWord(word); // eg. SCARLETTl => SCARLETTI
}
// Retry word replace list // Retry word replace list
foreach (string from in _wordReplaceList.Keys) foreach (string from in _wordReplaceList.Keys)
@ -506,26 +512,29 @@ namespace Nikse.SubtitleEdit.Logic.OCR
input = FixOcrErrorsViaHardcodedRules(input, lastLine, _abbreviationList); input = FixOcrErrorsViaHardcodedRules(input, lastLine, _abbreviationList);
input = FixOcrErrorViaLineReplaceList(input); input = FixOcrErrorViaLineReplaceList(input);
// e.g. "selectionsu." -> "selections..." if (Configuration.Settings.Tools.OcrFixUseHardcodedRules)
if (input.EndsWith("u.") && _hunspell != null)
{ {
string[] words = input.Split(" .".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); // e.g. "selectionsu." -> "selections..."
if (words.Length > 0) if (input.EndsWith("u.") && _hunspell != null)
{ {
string lastWord = words[words.Length -1].Trim(); string[] words = input.Split(" .".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
if (lastWord.Length > 2 && if (words.Length > 0)
!IsWordOrWordsCorrect(_hunspell, lastWord) && {
IsWordOrWordsCorrect(_hunspell, lastWord.Substring(0, lastWord.Length-1))) string lastWord = words[words.Length - 1].Trim();
input = input.Substring(0, input.Length-2) + "..."; if (lastWord.Length > 2 &&
!IsWordOrWordsCorrect(_hunspell, lastWord) &&
IsWordOrWordsCorrect(_hunspell, lastWord.Substring(0, lastWord.Length - 1)))
input = input.Substring(0, input.Length - 2) + "...";
}
}
// music notes
if (input.StartsWith(".'") && input.EndsWith(".'"))
{
input = input.Replace(".'", Configuration.Settings.Tools.MusicSymbol);
} }
} }
// music notes
if (input.StartsWith(".'") && input.EndsWith(".'"))
{
input = input.Replace(".'", Configuration.Settings.Tools.MusicSymbol);
}
return input; return input;
} }
@ -547,6 +556,9 @@ namespace Nikse.SubtitleEdit.Logic.OCR
public static string FixOcrErrorsViaHardcodedRules(string input, string lastLine, List<string> abbreviationList) public static string FixOcrErrorsViaHardcodedRules(string input, string lastLine, List<string> abbreviationList)
{ {
if (!Configuration.Settings.Tools.OcrFixUseHardcodedRules)
return input;
if (lastLine == null || if (lastLine == null ||
lastLine.EndsWith(".") || lastLine.EndsWith(".") ||
lastLine.EndsWith("!") || lastLine.EndsWith("!") ||

View File

@ -77,6 +77,7 @@ namespace Nikse.SubtitleEdit.Logic
public string MusicSymbol { get; set; } public string MusicSymbol { get; set; }
public string MusicSymbolToReplace { get; set; } public string MusicSymbolToReplace { get; set; }
public bool SpellCheckAutoChangeNames { get; set; } public bool SpellCheckAutoChangeNames { get; set; }
public bool OcrFixUseHardcodedRules { get; set; }
public string Interjections { get; set; } public string Interjections { get; set; }
public ToolsSettings() public ToolsSettings()
@ -88,6 +89,7 @@ namespace Nikse.SubtitleEdit.Logic
MusicSymbol = "♪"; MusicSymbol = "♪";
MusicSymbolToReplace = "♪ ⶠ♪ âTª ã¢â™âª ?t×3 ?t¤3"; MusicSymbolToReplace = "♪ ⶠ♪ âTª ã¢â™âª ?t×3 ?t¤3";
SpellCheckAutoChangeNames = true; SpellCheckAutoChangeNames = true;
OcrFixUseHardcodedRules = true;
Interjections = "Ah;Ahh;Ahhh;Eh;Ehh;Ehhh;Hm;Hmm;Hmmm;Phew;Gah;Oh;Ohh;Ohhh;Ow;Oww;Owww;Ugh;Ughh;Uh;Uhh;Uhhh;Whew"; Interjections = "Ah;Ahh;Ahhh;Eh;Ehh;Ehhh;Hm;Hmm;Hmmm;Phew;Gah;Oh;Ohh;Ohhh;Ow;Oww;Owww;Ugh;Ughh;Uh;Uhh;Uhhh;Whew";
} }
} }
@ -679,6 +681,9 @@ namespace Nikse.SubtitleEdit.Logic
subNode = node.SelectSingleNode("SpellCheckAutoChangeNames"); subNode = node.SelectSingleNode("SpellCheckAutoChangeNames");
if (subNode != null) if (subNode != null)
settings.Tools.SpellCheckAutoChangeNames = Convert.ToBoolean(subNode.InnerText); settings.Tools.SpellCheckAutoChangeNames = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("OcrFixUseHardcodedRules");
if (subNode != null)
settings.Tools.OcrFixUseHardcodedRules = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("Interjections"); subNode = node.SelectSingleNode("Interjections");
if (subNode != null) if (subNode != null)
settings.Tools.Interjections = subNode.InnerText; settings.Tools.Interjections = subNode.InnerText;
@ -979,6 +984,7 @@ namespace Nikse.SubtitleEdit.Logic
textWriter.WriteElementString("MusicSymbol", settings.Tools.MusicSymbol); textWriter.WriteElementString("MusicSymbol", settings.Tools.MusicSymbol);
textWriter.WriteElementString("MusicSymbolToReplace", settings.Tools.MusicSymbolToReplace); textWriter.WriteElementString("MusicSymbolToReplace", settings.Tools.MusicSymbolToReplace);
textWriter.WriteElementString("SpellCheckAutoChangeNames", settings.Tools.SpellCheckAutoChangeNames.ToString()); textWriter.WriteElementString("SpellCheckAutoChangeNames", settings.Tools.SpellCheckAutoChangeNames.ToString());
textWriter.WriteElementString("OcrFixUseHardcodedRules", settings.Tools.OcrFixUseHardcodedRules.ToString());
textWriter.WriteElementString("Interjections", settings.Tools.Interjections); textWriter.WriteElementString("Interjections", settings.Tools.Interjections);
textWriter.WriteEndElement(); textWriter.WriteEndElement();