mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Improve "Fix uppercase 'i' nside lowercase words - thx
taxen :)
This commit is contained in:
parent
53b7338e91
commit
8d173b8d47
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
@ -67,5 +68,9 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
return new HashSet<string>();
|
||||
}
|
||||
|
||||
public bool DoSpell(string word)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class FixDialogsOnOneLine : IFixCommonError
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class FixDoubleApostrophes : IFixCommonError
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class FixHyphensAdd : IFixCommonError
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class FixHyphensRemove : IFixCommonError
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class FixInvalidItalicTags : IFixCommonError
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class FixLongDisplayTimes : IFixCommonError
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class FixLongLines : IFixCommonError
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class FixShortDisplayTimes : IFixCommonError
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class FixShortLines : IFixCommonError
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Globalization;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class FixTurkishAnsiToUnicode : IFixCommonError
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
@ -8,6 +9,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
private static readonly Regex ReAfterLowercaseLetter = new Regex(@"[a-zæøåäöéùáàìéóúñüéíóúñü]I", RegexOptions.Compiled);
|
||||
private static readonly Regex ReBeforeLowercaseLetter = new Regex(@"I[a-zæøåäöéùáàìéóúñüéíóúñü]", RegexOptions.Compiled);
|
||||
|
||||
|
||||
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
|
||||
{
|
||||
var l = Configuration.Settings.Language.FixCommonErrors;
|
||||
@ -68,6 +70,10 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
word.Equals("islands", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
}
|
||||
else if (word.StartsWith("I") && !callbacks.DoSpell("l" + word.Remove(0,1)))
|
||||
{
|
||||
// word starting with "I", replaced by "l" is not spell check correct, so we skip it (probably a name)
|
||||
}
|
||||
else if (match.Index == 0)
|
||||
{ // first letter in paragraph
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
{
|
||||
public class RemoveSpaceBetweenNumbers : IFixCommonError
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
namespace Nikse.SubtitleEdit.Core.Interfaces
|
||||
{
|
||||
public interface IFixCallbacks
|
||||
public interface IFixCallbacks : IDoSpell
|
||||
{
|
||||
bool AllowFix(Paragraph p, string action);
|
||||
void AddFixToListView(Paragraph p, string action, string before, string after);
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
namespace Nikse.SubtitleEdit.Core.Interfaces
|
||||
{
|
||||
public interface IFixCommonError
|
||||
{
|
||||
|
@ -12,6 +12,8 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Nikse.SubtitleEdit.Core.Interfaces;
|
||||
using Nikse.SubtitleEdit.Logic.SpellCheck;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
@ -1825,5 +1827,34 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
|
||||
private Hunspell _hunspell;
|
||||
|
||||
public bool DoSpell(string word)
|
||||
{
|
||||
if (_hunspell == null && Language != null)
|
||||
{
|
||||
var fileMatches = Directory.GetFiles(Utilities.DictionaryFolder, Language + "*.dic");
|
||||
if (fileMatches.Length > 0)
|
||||
{
|
||||
var dictionary = fileMatches[0].Substring(0, fileMatches[0].Length - 4);
|
||||
try
|
||||
{
|
||||
_hunspell = Hunspell.GetHunspell(dictionary);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_hunspell = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_hunspell == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _hunspell.Spell(word);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user