fix to support synonyms within specials too -- for linux only so far.

Seems to work, though the dawg2dict.pl script is broken.
This commit is contained in:
Eric House 2013-04-09 07:43:04 -07:00
parent 3a628f4375
commit 07cfdad699
7 changed files with 76 additions and 49 deletions

View file

@ -83,4 +83,6 @@ typedef struct Xloc_specialEntry {
short hasSmall;
} Xloc_specialEntry;
#define SYNONYM_DELIM ' '
#endif /* _DAWG_H_ */

View file

@ -101,24 +101,32 @@ dict_getTileString( const DictionaryCtxt* dict, Tile tile )
}
const XP_UCHAR*
dict_getNextTileString( const DictionaryCtxt* ctxt, Tile tile,
dict_getNextTileString( const DictionaryCtxt* dict, Tile tile,
const XP_UCHAR* cur )
{
const XP_UCHAR* result = NULL;
if ( NULL == cur ) {
result = dict_getTileString( ctxt, tile );
result = dict_getTileString( dict, tile );
} else {
cur += XP_STRLEN( cur ) + 1;
/* use cur only if it is is not now off the end or pointing to to the
next tile */
if ( ++tile == ctxt->nFaces ) {
if ( cur < ctxt->facesEnd ) {
XP_Bool isSpecial = dict_faceIsBitmap( dict, tile );
if ( isSpecial ) {
const XP_UCHAR* facep = dict_getTileStringRaw( dict, tile );
if ( cur < dict->charEnds[(XP_U16)*facep] ) {
result = cur;
}
} else {
const XP_UCHAR* nxt = dict_getTileStringRaw( ctxt, tile );
if ( nxt != cur ) {
result = cur;
/* use cur only if it is is not now off the end or pointing to to the
next tile */
if ( ++tile == dict->nFaces ) {
if ( cur < dict->facesEnd ) {
result = cur;
}
} else {
const XP_UCHAR* nxt = dict_getTileStringRaw( dict, tile );
if ( nxt != cur ) {
result = cur;
}
}
}
}

View file

@ -81,6 +81,7 @@ struct DictionaryCtxt {
SpecialBitmaps* bitmaps;
XP_UCHAR** chars;
XP_UCHAR** charEnds;
XP_U32 nWords;
XP_LangCode langCode;

View file

@ -36,9 +36,9 @@ endif
endif
LANG_SPECIAL_INFO = \
"L·L" $(PBITMS)/large_ll.pbitm $(PBITMS)/small_ll.pbitm \
"NY" $(PBITMS)/large_ny.pbitm $(PBITMS)/small_ny.pbitm \
"QU" $(PBITMS)/large_qu.pbitm $(PBITMS)/small_qu.pbitm \
"L·L L-L ĿL l·l l-l ŀl" $(PBITMS)/large_ll.pbitm $(PBITMS)/small_ll.pbitm \
"NY ny" $(PBITMS)/large_ny.pbitm $(PBITMS)/small_ny.pbitm \
"QU qu" $(PBITMS)/large_qu.pbitm $(PBITMS)/small_qu.pbitm \
include ../Makefile.langcommon

View file

@ -63,32 +63,32 @@ XLOC_HEADER:0x8C00
<BEGIN_TILES>
2 0 {"_"}
12 1 'A'
2 3 'B'
3 2 'C'
1 10 'Ç'
3 2 'D'
13 1 'E'
1 4 'F'
2 3 'G'
1 8 'H'
8 1 'I'
1 8 'J'
4 1 'L'
1 10 {"L·L"}
3 2 'M'
6 1 'N'
1 10 {"NY"}
5 1 'O'
2 3 'P'
1 8 {"QU"}
8 1 'R'
8 1 'S'
5 1 'T'
4 1 'U'
1 4 'V'
1 10 'X'
1 8 'Z'
12 1 'A|a'
2 3 'B|b'
3 2 'C|c'
1 10 'Ç'
3 2 'D|d'
13 1 'E|e'
1 4 'F|f'
2 3 'G|g'
1 8 'H|h'
8 1 'I|i'
1 8 'J|j'
4 1 'L|l'
1 10 {"L·L|L-L|ĿL|l·l|l-l|ŀl"}
3 2 'M|m'
6 1 'N|n'
1 10 {"ny|ny"}
5 1 'O|o'
2 3 'P|p'
1 8 {"QU|qu"}
8 1 'R|r'
8 1 'S|s'
5 1 'T|t'
4 1 'U|u'
1 4 'V|v'
1 10 'X|x'
1 8 'Z|z'
<END_TILES>
#
# NOTES:

View file

@ -146,6 +146,7 @@ skipBitmaps( LinuxDictionaryCtxt* ctxt, const XP_U8** ptrp )
XP_U16 nSpecials;
XP_UCHAR* text;
XP_UCHAR** texts;
XP_UCHAR** textEnds;
SpecialBitmaps* bitmaps;
Tile tile;
const XP_U8* ptr = *ptrp;
@ -154,6 +155,8 @@ skipBitmaps( LinuxDictionaryCtxt* ctxt, const XP_U8** ptrp )
texts = (XP_UCHAR**)XP_MALLOC( ctxt->super.mpool,
nSpecials * sizeof(*texts) );
textEnds = (XP_UCHAR**)XP_MALLOC( ctxt->super.mpool,
nSpecials * sizeof(*textEnds) );
bitmaps = (SpecialBitmaps*)XP_MALLOC( ctxt->super.mpool,
nSpecials * sizeof(*bitmaps) );
XP_MEMSET( bitmaps, 0, nSpecials * sizeof(*bitmaps) );
@ -167,23 +170,35 @@ skipBitmaps( LinuxDictionaryCtxt* ctxt, const XP_U8** ptrp )
XP_ASSERT( *facep < nSpecials );
/* get the string */
txtlen = *ptr++;
text = (XP_UCHAR*)XP_MALLOC(ctxt->super.mpool, txtlen+1);
memcpy( text, ptr, txtlen );
ptr += txtlen;
txtlen = *ptr++;
text = (XP_UCHAR*)XP_MALLOC(ctxt->super.mpool, txtlen+1);
memcpy( text, ptr, txtlen );
ptr += txtlen;
text[txtlen] = '\0';
texts[(XP_U16)*facep] = text;
text[txtlen] = '\0';
texts[(XP_U16)*facep] = text;
textEnds[(XP_U16)*facep] = text + txtlen + 1;
/* Now replace the delimiter char with \0. It must be one byte in
length and of course equal to the delimiter */
while ( '\0' != *text ) {
XP_UCHAR* cp = g_utf8_offset_to_pointer( text, 1 );
if ( 1 == (cp - text) && *text == SYNONYM_DELIM ) {
*text = '\0';
}
text = cp;
}
XP_DEBUGF( "skipping bitmaps for " XP_S, texts[asIndex] );
XP_DEBUGF( "skipping bitmaps for " XP_S, texts[asIndex] );
bitmaps[asIndex].largeBM = skipBitmap( ctxt, &ptr );
bitmaps[asIndex].smallBM = skipBitmap( ctxt, &ptr );
bitmaps[asIndex].largeBM = skipBitmap( ctxt, &ptr );
bitmaps[asIndex].smallBM = skipBitmap( ctxt, &ptr );
}
}
*ptrp = ptr;
ctxt->super.chars = texts;
ctxt->super.charEnds = textEnds;
ctxt->super.bitmaps = bitmaps;
} /* skipBitmaps */
@ -207,7 +222,7 @@ dict_splitFaces( DictionaryCtxt* dict, const XP_U8* utf8,
XP_MEMCPY( next, bytes, len );
next += len;
bytes += len;
if ( ' ' != bytes[0] ) {
if ( SYNONYM_DELIM != bytes[0] ) {
break;
}
++bytes; /* skip delimiter */

View file

@ -1377,7 +1377,8 @@ walk_dict_test( const LaunchParams* XP_UNUSED_DBG(params),
XP_UCHAR bufPrev[32] = {0};
dict_wordToString( &iter, buf, VSIZE(buf) );
XP_ASSERT( 0 == strncasecmp( buf, prefix, lenMatched ) );
/* This doesn't work with synonyms like "L-L" for "L·L" */
// XP_ASSERT( 0 == strncasecmp( buf, prefix, lenMatched ) );
DictPosition pos = dict_getPosition( &iter );
XP_ASSERT( 0 == strcmp( buf, words[pos] ) );