1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
// This file is part of The New Aspell
// Copyright (C) 2004 by Kevin Atkinson under the GNU LGPL
// license version 2.0 or 2.1. You should have received a copy of the
// LGPL license along with this library if you did not you can find it
// at http://www.gnu.org/.
//
// Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada And
// Contributors. All rights reserved.
//
#ifndef ASPELL_AFFIX__HPP
#define ASPELL_AFFIX__HPP
#include "posib_err.hpp"
#include "wordinfo.hpp"
#include "fstream.hpp"
#include "parm_string.hpp"
#include "simple_string.hpp"
#include "char_vector.hpp"
#include "objstack.hpp"
#define SETSIZE 256
#define MAXAFFIXES 256
#define MAXWORDLEN 255
#define XPRODUCT (1 << 0)
#define MAXLNLEN 1024
#define TESTAFF( a , b) strchr(a, b)
namespace acommon {
class Config;
struct CheckInfo;
struct Conv;
}
namespace aspeller {
using namespace acommon;
class Language;
class SpellerImpl;
using acommon::CheckInfo;
struct GuessInfo;
struct LookupInfo;
struct AffEntry;
struct PfxEntry;
struct SfxEntry;
struct WordAff
{
SimpleString word;
const unsigned char * aff;
WordAff * next;
};
enum CheckAffixRes {InvalidAffix, InapplicableAffix, ValidAffix};
class AffixMgr
{
const Language * lang;
PfxEntry * pStart[SETSIZE];
SfxEntry * sStart[SETSIZE];
PfxEntry * pFlag[SETSIZE];
SfxEntry * sFlag[SETSIZE];
int max_strip_f[SETSIZE];
int max_strip_;
const char * encoding;
//const char * compound;
//int cpdmin;
ObjStack data_buf;
const char * affix_file;
public:
AffixMgr(const Language * l);
~AffixMgr();
unsigned int max_strip() const {return max_strip_;}
PosibErr<void> setup(ParmString affpath, Conv &);
bool affix_check(const LookupInfo &, ParmString, CheckInfo &, GuessInfo *) const;
bool prefix_check(const LookupInfo &, ParmString, CheckInfo &, GuessInfo *,
bool cross = true) const;
bool suffix_check(const LookupInfo &, ParmString, CheckInfo &, GuessInfo *,
int sfxopts, AffEntry* ppfx) const;
void munch(ParmString word, GuessInfo *, bool cross = true) const;
// None of the expand methods reset the objstack
WordAff * expand(ParmString word, ParmString aff,
ObjStack &, int limit = INT_MAX) const;
CheckAffixRes check_affix(ParmString word, char aff) const;
WordAff * expand_prefix(ParmString word, ParmString aff,
ObjStack & buf) const
{
return expand(word,aff,buf,0);
}
WordAff * expand_suffix(ParmString word, const unsigned char * aff,
ObjStack &, int limit = INT_MAX,
unsigned char * new_aff_2 = 0, WordAff * * * l = 0,
ParmString orig_word = 0) const;
private:
PosibErr<void> parse_file(const char * affpath, Conv &);
PosibErr<void> build_pfxlist(PfxEntry* pfxptr);
PosibErr<void> build_sfxlist(SfxEntry* sfxptr);
PosibErr<void> process_pfx_order();
PosibErr<void> process_sfx_order();
};
PosibErr<AffixMgr *> new_affix_mgr(ParmString name,
Conv &,
const Language * lang);
}
#endif
|