zhash.c
author viric@mandarina
Sat, 08 Sep 2007 09:13:15 +0200
changeset 29 84abeba4ef3b
parent 16 b4e251400e36
child 32 6a1a709330bf
permissions -rw-r--r--
Removing binary.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
     1
#include <stdio.h>
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
     2
#include <assert.h>
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
     3
#include "dictre.h"
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
     4
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
     5
enum
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
     6
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
     7
    MAXHASH=1<<16
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
     8
};
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
     9
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    10
struct BareWord
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    11
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    12
    struct BareWord *next;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    13
    char *str;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    14
};
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    15
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    16
struct WordEntry
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    17
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    18
    struct WordEntry *next;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    19
    char *str;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    20
    struct BareWord *accented;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    21
    struct BareWord *unflexed;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    22
};
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    23
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    24
static struct WordEntry * wordlist[MAXHASH];
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    25
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    26
struct WordEntry * new_WordEntry()
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    27
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    28
    struct WordEntry *tmp;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    29
    tmp =  (struct WordEntry *) malloc(sizeof(*tmp));
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    30
    assert(tmp != 0);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    31
    return tmp;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    32
}
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    33
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    34
struct BareWord * new_BareWord()
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    35
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    36
    struct BareWord *tmp;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    37
    tmp =  (struct BareWord *) malloc(sizeof(*tmp));
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    38
    assert(tmp != 0);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    39
    return tmp;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    40
}
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    41
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    42
void init_wordlist()
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    43
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    44
    int i;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    45
    for(i=0; i < MAXHASH; ++i)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    46
    {
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    47
        struct WordEntry *nodata;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    48
        nodata = new_WordEntry();
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    49
        assert(nodata != 0);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    50
        nodata->str = 0;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    51
        nodata->accented = 0;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    52
        nodata->unflexed = 0;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    53
        nodata->next = 0;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    54
        wordlist[i] = nodata;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    55
    }
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    56
}
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    57
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    58
static unsigned int hash_func(const unsigned char *str)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    59
{
16
b4e251400e36 Improved hash on zprocess, and added parsing for "jo".
viric@llimona
parents: 13
diff changeset
    60
    unsigned int v;
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    61
16
b4e251400e36 Improved hash on zprocess, and added parsing for "jo".
viric@llimona
parents: 13
diff changeset
    62
    /* for hashmax of 2^16 */
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    63
16
b4e251400e36 Improved hash on zprocess, and added parsing for "jo".
viric@llimona
parents: 13
diff changeset
    64
    v = (str[1] & 15) << 4*3;
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    65
    if (str[2] != 0)
16
b4e251400e36 Improved hash on zprocess, and added parsing for "jo".
viric@llimona
parents: 13
diff changeset
    66
        v += (str[3] & 15) << 4*2;
b4e251400e36 Improved hash on zprocess, and added parsing for "jo".
viric@llimona
parents: 13
diff changeset
    67
    if (str[4] != 0)
b4e251400e36 Improved hash on zprocess, and added parsing for "jo".
viric@llimona
parents: 13
diff changeset
    68
        v += (str[5] & 15) << 4;
b4e251400e36 Improved hash on zprocess, and added parsing for "jo".
viric@llimona
parents: 13
diff changeset
    69
    if (str[6] != 0)
b4e251400e36 Improved hash on zprocess, and added parsing for "jo".
viric@llimona
parents: 13
diff changeset
    70
        v += (str[7] & 15);
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    71
16
b4e251400e36 Improved hash on zprocess, and added parsing for "jo".
viric@llimona
parents: 13
diff changeset
    72
    return v;
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    73
}
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    74
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    75
/* Word without accent */
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    76
struct WordEntry * does_word_exist(int hash, const char *word)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    77
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    78
    struct WordEntry *tmp;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    79
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    80
    for(tmp = wordlist[hash]; tmp != 0; tmp = tmp->next)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    81
    {
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    82
        if (tmp->str) /* The last item in the linked list will have str=0 */
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    83
            if (strcmp(word, tmp->str) == 0)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    84
                return tmp;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    85
    }
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    86
    return 0;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    87
}
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    88
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    89
void add_to_unflexed(struct WordEntry *pos, const char *word)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    90
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    91
    struct BareWord *tmp;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    92
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    93
    if (pos->unflexed == 0)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    94
    {
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    95
        pos->unflexed = new_BareWord();
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    96
        tmp = pos->unflexed;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    97
        tmp->str = strdup(word);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    98
        tmp->next = 0;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
    99
    } else
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   100
    {
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   101
        /* Look for the same word */
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   102
        for(tmp = pos->unflexed; tmp != 0; tmp = tmp->next)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   103
        {
13
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   104
            if (strcmp(word, tmp->str) == 0)
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   105
                break;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   106
        }
13
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   107
        /* If not found... */
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   108
        if (tmp == 0)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   109
        {
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   110
            tmp = new_BareWord();
13
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   111
            tmp->str = strdup(word);
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   112
            tmp->next = pos->unflexed;
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   113
            pos->unflexed = tmp;
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   114
        }
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   115
    }
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   116
}
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   117
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   118
void set_accented(struct WordEntry *pos, const char *word)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   119
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   120
    if (pos->accented)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   121
        /* Will free the first parameter */
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   122
        pos->accented->str = mix_accents(pos->accented->str, word);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   123
    else
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   124
    {
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   125
        pos->accented = new_BareWord();
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   126
        pos->accented->str = strdup(word);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   127
        pos->accented->next = 0;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   128
    }
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   129
}
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   130
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   131
void insert_word(const char *word, const char *unflexed)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   132
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   133
    int hash;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   134
    unsigned char word_no_accent[MAXWORD];
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   135
    struct WordEntry *found;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   136
    unsigned int hash_num;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   137
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   138
    remove_accent(word_no_accent, word);
16
b4e251400e36 Improved hash on zprocess, and added parsing for "jo".
viric@llimona
parents: 13
diff changeset
   139
    remove_jo(word_no_accent);
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   140
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   141
    hash_num = hash_func(word_no_accent);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   142
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   143
    /* Where to insert */
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   144
    found = does_word_exist(hash_num, word_no_accent);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   145
    if (found)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   146
    {
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   147
        set_accented(found, word);
13
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   148
        add_to_unflexed(found, unflexed);
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   149
    } else /* Does not exist */
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   150
    {
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   151
        /* new word */
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   152
        struct WordEntry *new;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   153
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   154
        new = new_WordEntry();
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   155
        new->str = strdup(word_no_accent);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   156
        new->unflexed = 0;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   157
        add_to_unflexed(new, unflexed);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   158
        new->accented = 0;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   159
        set_accented(new, word);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   160
        /* Put it on the head of the hash list */
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   161
        new->next = wordlist[hash_num];
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   162
        wordlist[hash_num] = new;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   163
    }
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   164
}
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   165
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   166
static void dump_word(struct WordEntry *word)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   167
{
13
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   168
    struct BareWord *tmp;
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   169
    printf(":%s:%s", word->str, word->accented->str);
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   170
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   171
    for(tmp = word->unflexed; tmp != 0; tmp = tmp->next)
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   172
    {
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   173
        printf(" %s", tmp->str);
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   174
    }
f71e89074c62 Added root words in the result.
viric@llimona
parents: 11
diff changeset
   175
    printf("\n");
11
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   176
}
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   177
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   178
void dump_wordlist()
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   179
{
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   180
    int i;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   181
    for(i=0; i < MAXHASH; ++i)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   182
    {
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   183
        struct WordEntry *word;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   184
        word = wordlist[i];
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   185
        while (word != 0)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   186
        {
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   187
            if (word->str)
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   188
                dump_word(word);
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   189
            word = word->next;
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   190
        }
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   191
    }
68ea18fe402c Adding code for the zprocess, for processing the Zaliznjak dictionary.
viric@llimona
parents:
diff changeset
   192
}