| 1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* libdatrie - Double-Array Trie Library |
| 4 |
* Copyright (C) 2006 Theppitak Karoonboonyanan <[email protected]> |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU Lesser General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 2.1 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public |
| 17 |
* License along with this library; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 |
*/ |
| 20 |
|
| 21 |
/* |
| 22 |
* alpha-map.h - map between character codes and trie alphabet |
| 23 |
* Created: 2006-08-19 |
| 24 |
* Author: Theppitak Karoonboonyanan <[email protected]> |
| 25 |
*/ |
| 26 |
|
| 27 |
#ifndef __ALPHA_MAP_H |
| 28 |
#define __ALPHA_MAP_H |
| 29 |
|
| 30 |
#include <stdio.h> |
| 31 |
|
| 32 |
#include <datrie/triedefs.h> |
| 33 |
|
| 34 |
#ifdef __cplusplus |
| 35 |
extern "C" { |
| 36 |
#endif |
| 37 |
|
| 38 |
/** |
| 39 |
* @file alpha-map.h |
| 40 |
* @brief AlphaMap data type and functions |
| 41 |
* |
| 42 |
* AlphaMap is a mapping between AlphaChar and TrieChar. AlphaChar is the |
| 43 |
* alphabet character used in words of a target language, while TrieChar |
| 44 |
* is a small integer with packed range of values and is actually used in |
| 45 |
* trie state transition calculations. |
| 46 |
* |
| 47 |
* Since double-array trie relies on sparse state transition table, |
| 48 |
* a small set of input characters can make the table small, i.e. with |
| 49 |
* small number of columns. But in real life, alphabet characters can be |
| 50 |
* of non-continuous range of values. The unused slots between them can |
| 51 |
* waste the space in the table, and can increase the chance of unused |
| 52 |
* array cells. |
| 53 |
* |
| 54 |
* AlphaMap is thus defined for mapping between non-continuous ranges of |
| 55 |
* values of AlphaChar and packed and continuous range of Triechar. |
| 56 |
* |
| 57 |
* In this implementation, TrieChar is defined as a single-byte integer, |
| 58 |
* which means the largest AlphaChar set that is supported is of 255 |
| 59 |
* values, as the special value of 0 is reserved for null-termination code. |
| 60 |
*/ |
| 61 |
|
| 62 |
/** |
| 63 |
* @brief AlphaMap data type |
| 64 |
*/ |
| 65 |
typedef struct _AlphaMap AlphaMap; |
| 66 |
|
| 67 |
AlphaMap * alpha_map_new (void); |
| 68 |
|
| 69 |
AlphaMap * alpha_map_clone (const AlphaMap *a_map); |
| 70 |
|
| 71 |
void alpha_map_free (AlphaMap *alpha_map); |
| 72 |
|
| 73 |
int alpha_map_add_range (AlphaMap *alpha_map, |
| 74 |
AlphaChar begin, |
| 75 |
AlphaChar end); |
| 76 |
|
| 77 |
int alpha_char_strlen (const AlphaChar *str); |
| 78 |
int alpha_char_strcmp (const AlphaChar *str1, const AlphaChar *str2); |
| 79 |
|
| 80 |
#ifdef __cplusplus |
| 81 |
} |
| 82 |
#endif |
| 83 |
|
| 84 |
#endif /* __ALPHA_MAP_H */ |
| 85 |
|
| 86 |
|
| 87 |
/* |
| 88 |
vi:ts=4:ai:expandtab |
| 89 |
*/ |