Skip to content

Commit

Permalink
Support for ae, oe, and ss normalization
Browse files Browse the repository at this point in the history
Change replacement character to chr(26)
  • Loading branch information
ManiacDC committed Aug 18, 2015
1 parent 107cf01 commit 7f969cb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
21 changes: 16 additions & 5 deletions Source/Includes/Conversions.ahk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; these functions handle database conversion
; always set the SetDbVersion default argument to the current highest version

SetDbVersion(dBVersion = 6)
SetDbVersion(dBVersion = 7)
{
global g_WordListDB
g_WordListDB.Query("INSERT OR REPLACE INTO LastState VALUES ('databaseVersion', '" . dBVersion . "', NULL);")
Expand Down Expand Up @@ -74,6 +74,11 @@ MaybeConvertDatabase()
RunConversionSix()
}

if (databaseVersion < 7)
{
RunConversionSeven()
}

return, false
}

Expand Down Expand Up @@ -197,6 +202,12 @@ RunConversionFive()

; normalize accented characters
RunConversionSix()
{
; superseded by conversion 7
}

; normalize accented characters
RunConversionSeven()
{
global g_WordListDB
g_WordListDB.BeginTransaction()
Expand All @@ -210,14 +221,14 @@ RunConversionSix()
WordIndexed := row[2]
WordReplacement := row[3]

TransformWord(Word, WordReplacement, WordDescription, WordTransformed, WordIndexTransformed, WordReplacementTransformed, WordDescriptionTransformed)
TransformWord(Word, WordReplacement, WordDescription, WordTransformed, WordIndexedTransformed, WordReplacementTransformed, WordDescriptionTransformed)

StringReplace, OldWordIndexedTransformed, WordIndex, ', '', All
StringReplace, OldWordIndexedTransformed, WordIndexed, ', '', All

g_WordListDB.Query("UPDATE Words SET wordindexed = '" . WordIndexTransformed . "' WHERE word = '" . WordTransformed . "' AND wordindexed = '" . OldWordIndexedTransformed . "' AND wordreplacement = '" . WordReplacementTransformed . "';")
g_WordListDB.Query("UPDATE Words SET wordindexed = '" . WordIndexedTransformed . "' WHERE word = '" . WordTransformed . "' AND wordindexed = '" . OldWordIndexedTransformed . "' AND wordreplacement = '" . WordReplacementTransformed . "';")
}

SetDbVersion(6)
SetDbVersion(7)
g_WordListDB.EndTransaction()
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Includes/ListBox.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ AddToMatchList(position, MaxLength, HalfLength, LongestBaseLength, ComputeBaseLe
{
if (g_SingleMatchReplacement[position])
{
CurrentMatch .= "->" . g_SingleMatchReplacement[position]
CurrentMatch .= " " . chr(26) . " " . g_SingleMatchReplacement[position]
}
if (g_SingleMatchDescription[position])
{
Expand Down
15 changes: 13 additions & 2 deletions Source/Includes/Wordlist.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,13 @@ CheckValid(Word,ForceLearn=false)

TransformWord(AddWord, AddWordReplacement, AddWordDescription, ByRef AddWordTransformed, ByRef AddWordIndexTransformed, ByRef AddWordReplacementTransformed, ByRef AddWordDescriptionTransformed)
{
StringUpper, AddWordIndex, AddWord
AddWordIndex := AddWord

; normalize accented characters
AddWordIndex := StrUnmark(AddWordIndex)

StringUpper, AddWordIndex, AddWordIndex

StringReplace, AddWordTransformed, AddWord, ', '', All
StringReplace, AddWordIndexTransformed, AddWordIndex, ', '', All
if (AddWordReplacement) {
Expand Down Expand Up @@ -463,5 +465,14 @@ StrUnmark(string) {
len *= -1 ; This is the new estimate.
}
; Remove combining marks and return result.
return RegExReplace(StrGet(&buf, len, "UTF-16"), "\pM")
string := RegExReplace(StrGet(&buf, len, "UTF-16"), "\pM")

StringReplace, string, string, æ, ae, All
StringReplace, string, string, Æ, AE, All
StringReplace, string, string, œ, oe, All
StringReplace, string, string, Œ, OE, All
StringReplace, string, string, ß, ss, All

return, string

}

0 comments on commit 7f969cb

Please sign in to comment.