--- a/Makefile Sat Sep 01 21:49:41 2007 +0200
+++ b/Makefile Sat Sep 01 23:52:38 2007 +0200
@@ -9,7 +9,7 @@
all: dictre idx2index trim-nou8 ia5 asciiigi-utf8-akcenton zprocess \
- zparsetext zrustest http_dec_test
+ zparsetext zrustest http_dec_test prepare_meanings
idx2index: idx2index.o dict.o
trim-nou8: trim-nou8.c
@@ -32,6 +32,9 @@
http_dec_test: http_dec_test.o http_dec.o
$(CXX) -o $@ $^ $(ICULIBS)
+prepare_meanings: prepare_meanings.o find.o dict.o
+ $(CC) -o $@ $^
+
dict.c: dictre.h
write.c: dictre.h
load.c: dictre.h
@@ -49,3 +52,4 @@
zrustest.c: dictre.h
http_dec.c: dictre.h
http_dec_test.c: dictre.h
+prepare_meanings.c: dictre.h
--- a/find.c Sat Sep 01 21:49:41 2007 +0200
+++ b/find.c Sat Sep 01 23:52:38 2007 +0200
@@ -80,7 +80,7 @@
memmove(def, def + i + 1 /* \n */,
len - i - 1);
def[len-i-1] = 0;
- return len-i-1/*\n*/+1/*\0*/;
+ return len-i-2/*\n*/+1/*\0*/;
}
}
return len;
@@ -90,7 +90,10 @@
{
int new_line_pos;
int i,j;
- for(i=len-1; i >= 0; --i)
+ if (len < 2)
+ return len;
+
+ for(i=len-2; i >= 0; --i)
{
if (def[i] != '\n' && def[i] != '\r')
{
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make-signifoj.sh Sat Sep 01 23:52:38 2007 +0200
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+dictfmt -s "Diversaj vortaroj" -j --locale ca_ES.UTF-8 --without-headword signifoj < signifoj.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/prepare_meanings.c Sat Sep 01 23:52:38 2007 +0200
@@ -0,0 +1,92 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "dictre.h"
+
+#define NELEM(x) (sizeof(x)/sizeof(x[0]))
+
+
+const char *dictionarynames[] = { "bokarjovrueo", "slovnyk_ru-en" };
+static struct Dict dictionaries[5/*MAX DICT*/];
+static int ndictionaries;
+
+static void init_dictionaries()
+{
+ ndictionaries = 0;
+
+ init_dictionary(&dictionaries[0], "bokarjovrueo");
+ dictionaries[0].trim_last_newlines = 1;
+ ndictionaries++;
+
+ init_dictionary(&dictionaries[1], "slovnyk_ru-en");
+ dictionaries[1].trim_first_line = 1;
+ dictionaries[1].trim_last_newlines = 1;
+ ndictionaries++;
+}
+
+static void close_dictionaries()
+{
+ int i;
+ for(i=0; i<ndictionaries; ++i)
+ end_dictionary(&dictionaries[i]);
+
+ ndictionaries=0;
+}
+
+void dump_word(const char *word)
+{
+ int i;
+ char def[MAXDEF];
+ int word_header_dumped = 0;
+
+ if (strncmp(word, "00database", sizeof("00database"-1)) == 0)
+ return;
+
+ for (i=0; i < ndictionaries; ++i)
+ {
+ char *found;
+ find_def(&dictionaries[i], word, def);
+ if (def[0])
+ {
+ if(!word_header_dumped)
+ {
+ printf(":%s:", word);
+ word_header_dumped = 1;
+ }
+ printf("[%s]\n%s\n\n", dictionarynames[i], def);
+ }
+ }
+}
+
+void dump_words()
+{
+ FILE *fwords;
+ char word[MAXWORD];
+
+ fwords = fopen("words.txt", "r");
+ if (fwords == 0)
+ {
+ printf("Cannot open words.txt\n");
+ exit(-1);
+ }
+
+ do
+ {
+ char *res;
+ res = fgets(word, MAXWORD, fwords);
+ if (res == 0)
+ break;
+ word[strlen(word) - 1] = 0; /* Remove \n in the line */
+ dump_word(word);
+ } while(1);
+}
+
+int main()
+{
+ init_dictionaries();
+
+ dump_words();
+
+ close_dictionaries();
+
+ return 0;
+}