TempleOSCD_150720.ISO
This commit is contained in:
1 parent
401601816c
commit
f8c05f98f4
554 files changed
+26046
-24853
No files matched your search
@@ -4,19 +4,59 @@ which will regenerate processed dictionary
|
||||
files from a raw Project Gutenberg
|
||||
dictionary file.
|
||||
|
||||
Supply the raw dictionary filename in
|
||||
the call at the bottom of this file
|
||||
and #include this file.
|
||||
|
||||
I ran $LK,"::/Misc/ToDolDoc.CPP"$ on it, first.
|
||||
$TX,"http://www.templeos.org/files/DICTIONARY.TXT",HTML="http://www.templeos.org/files/DICTIONARY.TXT"$
|
||||
|
||||
See $LK,"::/Doc/Credits.TXT"$.
|
||||
*/
|
||||
|
||||
U0 ACDPreprocess(U8 *in_name,U8 *out_name)
|
||||
{/*
|
||||
<cr><nl>--> <nl>
|
||||
$$ --> $$$$
|
||||
\'89 --> ‰
|
||||
*/
|
||||
I64 ch,i;
|
||||
U8 *src,*dst;
|
||||
CDoc *doc;
|
||||
CDocEntry *doc_e;
|
||||
if (doc=DocRead(in_name,DOCF_PLAIN_TEXT_WITH_TABS|DOCF_DBL_DOLLARS)) {
|
||||
doc_e=doc->root.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_TEXT) {
|
||||
src=dst=doc_e->tag;
|
||||
while (ch=*src++) {
|
||||
if (ch=='\\' && *src=='\'') {
|
||||
src++;
|
||||
i=0;
|
||||
ch=ToUpper(*src++);
|
||||
if ('0'<=ch<='9')
|
||||
i+=ch-'0';
|
||||
else if ('A'<=ch<='F')
|
||||
i+=ch-'A'+10;
|
||||
i<<=4;
|
||||
ch=ToUpper(*src++);
|
||||
if ('0'<=ch<='9')
|
||||
i+=ch-'0';
|
||||
else if ('A'<=ch<='F')
|
||||
i+=ch-'A'+10;
|
||||
*dst++=i;
|
||||
} else
|
||||
*dst++=ch;
|
||||
}
|
||||
*dst=0;
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
StrCpy(doc->filename.name,out_name);
|
||||
DocWrite(doc);
|
||||
DocDel(doc);
|
||||
}
|
||||
}
|
||||
|
||||
I64 ACDNextCmd(U8 **_ptr)
|
||||
{
|
||||
U8 ch,*ptr=*_ptr,*ptr2;
|
||||
I64 result=-1;
|
||||
U8 *ptr=*_ptr,*ptr2;
|
||||
I64 ch,result=-1;
|
||||
do {
|
||||
do {
|
||||
if (!(ch=*ptr++)) goto ncmd_done;
|
||||
@@ -28,21 +68,22 @@ I64 ACDNextCmd(U8 **_ptr)
|
||||
} while (ch!='>');
|
||||
*--ptr2=0;
|
||||
result=LstMatch(ptr,"h1\0/h1\0def\0/def\0hw\0/hw\0tt\0/tt\0"
|
||||
"ety\0@fld\0@cd\0@blockquote\0@wordforms\0@note\0@altname\0@chform\0@cref\0@syn\0"
|
||||
"/ety\0@/fld\0@/cd\0@/blockquote\0@/wordforms\0@/note\0@/altname\0@/chform\0@/cref\0@/syn\0");
|
||||
"ety\0@fld\0@cd\0@blockquote\0@wordforms\0@note\0@altname\0@chform\0"
|
||||
"@cref\0@syn\0/ety\0@/fld\0@/cd\0@/blockquote\0@/wordforms\0@/note\0"
|
||||
"@/altname\0@/chform\0@/cref\0@/syn\0");
|
||||
*ptr2++='>';
|
||||
ptr=ptr2;
|
||||
} while (result<0);
|
||||
|
||||
ncmd_done:
|
||||
ncmd_done:
|
||||
*_ptr=ptr;
|
||||
return result;
|
||||
}
|
||||
|
||||
U8 *ACDNextEntry(U8 **_ptr)
|
||||
{
|
||||
U8 *result,*ignore,ch,*ptr=*_ptr,buf[ACD_BLK_SIZE],*out_ptr=buf;
|
||||
I64 l;
|
||||
U8 *result,*ignore,*ptr=*_ptr,buf[ACD_BLK_SIZE],*out_ptr=buf;
|
||||
I64 ch,l;
|
||||
while (TRUE) {
|
||||
while (TRUE) {
|
||||
if (!(ch=*ptr++)) goto nentry_done;
|
||||
@@ -54,9 +95,9 @@ U8 *ACDNextEntry(U8 **_ptr)
|
||||
break;
|
||||
}
|
||||
ignore="b>\0i>\0ppp>\0/b>\0/i>\0/p>\0"
|
||||
"ets>\0col>\0spn>\0/ets>\0/col>\0/spn>\0er>\0as>\0cs>\0cd>\0ex>\0"
|
||||
"/er>\0/as>\0/cs>\0/cd>\0/ex>\0"
|
||||
"note>\0/note>\0blockquote>\0/blockquote>\0";
|
||||
"ets>\0col>\0spn>\0/ets>\0/col>\0/spn>\0er>\0as>\0cs>\0cd>\0ex>\0"
|
||||
"/er>\0/as>\0/cs>\0/cd>\0/ex>\0"
|
||||
"note>\0/note>\0blockquote>\0/blockquote>\0";
|
||||
while (*ignore) {
|
||||
l=StrLen(ignore);
|
||||
if (!StrNCmp(ptr,ignore,l)) {
|
||||
@@ -83,8 +124,8 @@ I64 ACDCompareWords(U8 *e1,U8 *e2)
|
||||
U8 *ACDSortWords(U8 *start,I64 size,I64 word_cnt)
|
||||
{
|
||||
U8 **ptr_array=MAlloc(sizeof(U8 *)*word_cnt),
|
||||
*out_start=MAlloc(size),
|
||||
*ptr=start,*ptr2;
|
||||
*out_start=MAlloc(size),
|
||||
*ptr=start,*ptr2;
|
||||
I64 i=0;
|
||||
while (*ptr) {
|
||||
ptr_array[i++]=ptr;
|
||||
@@ -107,14 +148,14 @@ U8 *ACDSortWords(U8 *start,I64 size,I64 word_cnt)
|
||||
return out_start;
|
||||
}
|
||||
|
||||
U0 ACDGen(U8 *raw_dict_filename)
|
||||
U0 ACDGen(U8 *in_file)
|
||||
{
|
||||
I64 cmd,size,word_cnt=0,largest_entry=0;
|
||||
U8 *st,*in_ptr=FileRead(raw_dict_filename,&size),*in_start=in_ptr,
|
||||
*out_ptr=MAlloc(size),*out_start=out_ptr,
|
||||
*word_ptr=MAlloc(size),*word_start=word_ptr,
|
||||
*last_word="",*def_word_start=out_ptr,
|
||||
*sorted_word_start;
|
||||
U8 *st,*in_ptr=FileRead(in_file,&size),*in_start=in_ptr,
|
||||
*out_ptr=MAlloc(size),*out_start=out_ptr,
|
||||
*word_ptr=MAlloc(size),*word_start=word_ptr,
|
||||
*last_word="",*def_word_start=out_ptr,
|
||||
*sorted_word_start;
|
||||
U16 *d;
|
||||
if (!in_ptr) return;
|
||||
do {
|
||||
@@ -137,7 +178,7 @@ next_word:
|
||||
d=word_ptr;
|
||||
*d=(out_ptr-out_start)/ACD_BLK_SIZE;
|
||||
word_ptr+=2;
|
||||
|
||||
|
||||
*out_ptr++=ACD_WORD_CHAR;
|
||||
StrCpy(out_ptr,st);
|
||||
out_ptr+=StrLen(st)+1;
|
||||
@@ -149,7 +190,8 @@ next_word:
|
||||
cmd=ACDNextCmd(&in_ptr);
|
||||
if (cmd==ACD_H1)
|
||||
goto next_word;
|
||||
} while (cmd>=0 && !(cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||cmd==ACD_POS||cmd==ACD_EXTRA));
|
||||
} while (cmd>=0 && !(cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||
|
||||
cmd==ACD_POS||cmd==ACD_EXTRA));
|
||||
if (cmd==ACD_DEF) {
|
||||
if(st=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
@@ -187,7 +229,8 @@ next_word:
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
} while (cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||cmd==ACD_POS||cmd==ACD_EXTRA);
|
||||
} while (cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||
|
||||
cmd==ACD_POS||cmd==ACD_EXTRA);
|
||||
} else
|
||||
Free(st);
|
||||
}
|
||||
@@ -215,4 +258,6 @@ next_word:
|
||||
Free(sorted_word_start);
|
||||
}
|
||||
|
||||
ACDGen("DICTIONARY.TXT");
|
||||
Cd(__DIR__);
|
||||
ACDPreprocess("DICTIONARY.TXT","DICTIONARY2.TXT");
|
||||
ACDGen("DICTIONARY2.TXT");
|
||||
Reference in new issue
Block a user