Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
e03b4294
Commit
e03b4294
authored
13 years ago
by
satok
Committed by
Android (Google) Code Review
13 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Fix a bug on German umlaut digraph correction"
parents
3e2d3858
219a5140
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
native/src/unigram_dictionary.cpp
+18
-6
18 additions, 6 deletions
native/src/unigram_dictionary.cpp
native/src/unigram_dictionary.h
+1
-0
1 addition, 0 deletions
native/src/unigram_dictionary.h
with
19 additions
and
6 deletions
native/src/unigram_dictionary.cpp
+
18
−
6
View file @
e03b4294
...
@@ -91,12 +91,16 @@ bool UnigramDictionary::isDigraph(const int *codes, const int i, const int codes
...
@@ -91,12 +91,16 @@ bool UnigramDictionary::isDigraph(const int *codes, const int i, const int codes
// codesRemain is the remaining size in codesSrc.
// codesRemain is the remaining size in codesSrc.
void
UnigramDictionary
::
getWordWithDigraphSuggestionsRec
(
ProximityInfo
*
proximityInfo
,
void
UnigramDictionary
::
getWordWithDigraphSuggestionsRec
(
ProximityInfo
*
proximityInfo
,
const
int
*
xcoordinates
,
const
int
*
ycoordinates
,
const
int
*
codesBuffer
,
const
int
*
xcoordinates
,
const
int
*
ycoordinates
,
const
int
*
codesBuffer
,
int
*
xCoordinatesBuffer
,
int
*
yCoordinatesBuffer
,
const
int
codesBufferSize
,
const
int
flags
,
const
int
*
codesSrc
,
const
int
codesBufferSize
,
const
int
flags
,
const
int
*
codesSrc
,
const
int
codesRemain
,
const
int
currentDepth
,
int
*
codesDest
,
Correction
*
correction
,
const
int
codesRemain
,
const
int
currentDepth
,
int
*
codesDest
,
Correction
*
correction
,
WordsPriorityQueuePool
*
queuePool
)
{
WordsPriorityQueuePool
*
queuePool
)
{
const
int
startIndex
=
(
codesDest
-
codesBuffer
)
/
MAX_PROXIMITY_CHARS
;
if
(
currentDepth
<
MAX_UMLAUT_SEARCH_DEPTH
)
{
if
(
currentDepth
<
MAX_UMLAUT_SEARCH_DEPTH
)
{
for
(
int
i
=
0
;
i
<
codesRemain
;
++
i
)
{
for
(
int
i
=
0
;
i
<
codesRemain
;
++
i
)
{
xCoordinatesBuffer
[
startIndex
+
i
]
=
xcoordinates
[
codesBufferSize
-
codesRemain
+
i
];
yCoordinatesBuffer
[
startIndex
+
i
]
=
ycoordinates
[
codesBufferSize
-
codesRemain
+
i
];
if
(
isDigraph
(
codesSrc
,
i
,
codesRemain
))
{
if
(
isDigraph
(
codesSrc
,
i
,
codesRemain
))
{
// Found a digraph. We will try both spellings. eg. the word is "pruefen"
// Found a digraph. We will try both spellings. eg. the word is "pruefen"
...
@@ -108,7 +112,7 @@ void UnigramDictionary::getWordWithDigraphSuggestionsRec(ProximityInfo *proximit
...
@@ -108,7 +112,7 @@ void UnigramDictionary::getWordWithDigraphSuggestionsRec(ProximityInfo *proximit
++
i
;
++
i
;
memcpy
(
codesDest
,
codesSrc
,
i
*
BYTES_IN_ONE_CHAR
);
memcpy
(
codesDest
,
codesSrc
,
i
*
BYTES_IN_ONE_CHAR
);
getWordWithDigraphSuggestionsRec
(
proximityInfo
,
xcoordinates
,
ycoordinates
,
getWordWithDigraphSuggestionsRec
(
proximityInfo
,
xcoordinates
,
ycoordinates
,
codesBuffer
,
codesBufferSize
,
flags
,
codesBuffer
,
xCoordinatesBuffer
,
yCoordinatesBuffer
,
codesBufferSize
,
flags
,
codesSrc
+
(
i
+
1
)
*
MAX_PROXIMITY_CHARS
,
codesRemain
-
i
-
1
,
codesSrc
+
(
i
+
1
)
*
MAX_PROXIMITY_CHARS
,
codesRemain
-
i
-
1
,
currentDepth
+
1
,
codesDest
+
i
*
MAX_PROXIMITY_CHARS
,
correction
,
currentDepth
+
1
,
codesDest
+
i
*
MAX_PROXIMITY_CHARS
,
correction
,
queuePool
);
queuePool
);
...
@@ -119,7 +123,7 @@ void UnigramDictionary::getWordWithDigraphSuggestionsRec(ProximityInfo *proximit
...
@@ -119,7 +123,7 @@ void UnigramDictionary::getWordWithDigraphSuggestionsRec(ProximityInfo *proximit
memcpy
(
codesDest
+
i
*
MAX_PROXIMITY_CHARS
,
codesSrc
+
i
*
MAX_PROXIMITY_CHARS
,
memcpy
(
codesDest
+
i
*
MAX_PROXIMITY_CHARS
,
codesSrc
+
i
*
MAX_PROXIMITY_CHARS
,
BYTES_IN_ONE_CHAR
);
BYTES_IN_ONE_CHAR
);
getWordWithDigraphSuggestionsRec
(
proximityInfo
,
xcoordinates
,
ycoordinates
,
getWordWithDigraphSuggestionsRec
(
proximityInfo
,
xcoordinates
,
ycoordinates
,
codesBuffer
,
codesBufferSize
,
flags
,
codesBuffer
,
xCoordinatesBuffer
,
yCoordinatesBuffer
,
codesBufferSize
,
flags
,
codesSrc
+
i
*
MAX_PROXIMITY_CHARS
,
codesRemain
-
i
,
currentDepth
+
1
,
codesSrc
+
i
*
MAX_PROXIMITY_CHARS
,
codesRemain
-
i
,
currentDepth
+
1
,
codesDest
+
i
*
MAX_PROXIMITY_CHARS
,
correction
,
queuePool
);
codesDest
+
i
*
MAX_PROXIMITY_CHARS
,
correction
,
queuePool
);
return
;
return
;
...
@@ -133,11 +137,16 @@ void UnigramDictionary::getWordWithDigraphSuggestionsRec(ProximityInfo *proximit
...
@@ -133,11 +137,16 @@ void UnigramDictionary::getWordWithDigraphSuggestionsRec(ProximityInfo *proximit
// eg. if the word is "ueberpruefen" we'll test, in order, against
// eg. if the word is "ueberpruefen" we'll test, in order, against
// "uberprufen", "uberpruefen", "ueberprufen", "ueberpruefen".
// "uberprufen", "uberpruefen", "ueberprufen", "ueberpruefen".
const
unsigned
int
remainingBytes
=
BYTES_IN_ONE_CHAR
*
codesRemain
;
const
unsigned
int
remainingBytes
=
BYTES_IN_ONE_CHAR
*
codesRemain
;
if
(
0
!=
remainingBytes
)
if
(
0
!=
remainingBytes
)
{
memcpy
(
codesDest
,
codesSrc
,
remainingBytes
);
memcpy
(
codesDest
,
codesSrc
,
remainingBytes
);
memcpy
(
&
xCoordinatesBuffer
[
startIndex
],
&
xcoordinates
[
codesBufferSize
-
codesRemain
],
sizeof
(
int
)
*
codesRemain
);
memcpy
(
&
yCoordinatesBuffer
[
startIndex
],
&
ycoordinates
[
codesBufferSize
-
codesRemain
],
sizeof
(
int
)
*
codesRemain
);
}
getWordSuggestions
(
proximityInfo
,
x
c
oordinates
,
y
c
oordinates
,
codesBuffer
,
getWordSuggestions
(
proximityInfo
,
x
C
oordinates
Buffer
,
y
C
oordinates
Buffer
,
codesBuffer
,
(
codesDest
-
codesBuffer
)
/
MAX_PROXIMITY_CHARS
+
codesRemain
,
flags
,
correction
,
startIndex
+
codesRemain
,
flags
,
correction
,
queuePool
);
queuePool
);
}
}
...
@@ -146,11 +155,15 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
...
@@ -146,11 +155,15 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
const
int
*
ycoordinates
,
const
int
*
codes
,
const
int
codesSize
,
const
int
flags
,
const
int
*
ycoordinates
,
const
int
*
codes
,
const
int
codesSize
,
const
int
flags
,
unsigned
short
*
outWords
,
int
*
frequencies
)
{
unsigned
short
*
outWords
,
int
*
frequencies
)
{
queuePool
->
clearAll
();
Correction
*
masterCorrection
=
correction
;
Correction
*
masterCorrection
=
correction
;
if
(
REQUIRES_GERMAN_UMLAUT_PROCESSING
&
flags
)
if
(
REQUIRES_GERMAN_UMLAUT_PROCESSING
&
flags
)
{
// Incrementally tune the word and try all possibilities
{
// Incrementally tune the word and try all possibilities
int
codesBuffer
[
getCodesBufferSize
(
codes
,
codesSize
,
MAX_PROXIMITY_CHARS
)];
int
codesBuffer
[
getCodesBufferSize
(
codes
,
codesSize
,
MAX_PROXIMITY_CHARS
)];
int
xCoordinatesBuffer
[
codesSize
];
int
yCoordinatesBuffer
[
codesSize
];
getWordWithDigraphSuggestionsRec
(
proximityInfo
,
xcoordinates
,
ycoordinates
,
codesBuffer
,
getWordWithDigraphSuggestionsRec
(
proximityInfo
,
xcoordinates
,
ycoordinates
,
codesBuffer
,
xCoordinatesBuffer
,
yCoordinatesBuffer
,
codesSize
,
flags
,
codes
,
codesSize
,
0
,
codesBuffer
,
masterCorrection
,
queuePool
);
codesSize
,
flags
,
codes
,
codesSize
,
0
,
codesBuffer
,
masterCorrection
,
queuePool
);
}
else
{
// Normal processing
}
else
{
// Normal processing
getWordSuggestions
(
proximityInfo
,
xcoordinates
,
ycoordinates
,
codes
,
codesSize
,
flags
,
getWordSuggestions
(
proximityInfo
,
xcoordinates
,
ycoordinates
,
codes
,
codesSize
,
flags
,
...
@@ -192,7 +205,6 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo,
...
@@ -192,7 +205,6 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo,
PROF_OPEN
;
PROF_OPEN
;
PROF_START
(
0
);
PROF_START
(
0
);
queuePool
->
clearAll
();
PROF_END
(
0
);
PROF_END
(
0
);
PROF_START
(
1
);
PROF_START
(
1
);
...
...
This diff is collapsed.
Click to expand it.
native/src/unigram_dictionary.h
+
1
−
0
View file @
e03b4294
...
@@ -89,6 +89,7 @@ class UnigramDictionary {
...
@@ -89,6 +89,7 @@ class UnigramDictionary {
bool
isDigraph
(
const
int
*
codes
,
const
int
i
,
const
int
codesSize
)
const
;
bool
isDigraph
(
const
int
*
codes
,
const
int
i
,
const
int
codesSize
)
const
;
void
getWordWithDigraphSuggestionsRec
(
ProximityInfo
*
proximityInfo
,
void
getWordWithDigraphSuggestionsRec
(
ProximityInfo
*
proximityInfo
,
const
int
*
xcoordinates
,
const
int
*
ycoordinates
,
const
int
*
codesBuffer
,
const
int
*
xcoordinates
,
const
int
*
ycoordinates
,
const
int
*
codesBuffer
,
int
*
xCoordinatesBuffer
,
int
*
yCoordinatesBuffer
,
const
int
codesBufferSize
,
const
int
flags
,
const
int
*
codesSrc
,
const
int
codesBufferSize
,
const
int
flags
,
const
int
*
codesSrc
,
const
int
codesRemain
,
const
int
currentDepth
,
int
*
codesDest
,
Correction
*
correction
,
const
int
codesRemain
,
const
int
currentDepth
,
int
*
codesDest
,
Correction
*
correction
,
WordsPriorityQueuePool
*
queuePool
);
WordsPriorityQueuePool
*
queuePool
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment