extensions/spellcheck/hunspell/src/suggestmgr.hxx

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/spellcheck/hunspell/src/suggestmgr.hxx	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,168 @@
     1.4 +/******* BEGIN LICENSE BLOCK *******
     1.5 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
     1.6 + * 
     1.7 + * The contents of this file are subject to the Mozilla Public License Version
     1.8 + * 1.1 (the "License"); you may not use this file except in compliance with
     1.9 + * the License. You may obtain a copy of the License at
    1.10 + * http://www.mozilla.org/MPL/
    1.11 + * 
    1.12 + * Software distributed under the License is distributed on an "AS IS" basis,
    1.13 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    1.14 + * for the specific language governing rights and limitations under the
    1.15 + * License.
    1.16 + * 
    1.17 + * The Initial Developers of the Original Code are Kevin Hendricks (MySpell)
    1.18 + * and László Németh (Hunspell). Portions created by the Initial Developers
    1.19 + * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved.
    1.20 + * 
    1.21 + * Contributor(s): Kevin Hendricks (kevin.hendricks@sympatico.ca)
    1.22 + *                 David Einstein (deinst@world.std.com)
    1.23 + *                 László Németh (nemethl@gyorsposta.hu)
    1.24 + *                 Caolan McNamara (caolanm@redhat.com)
    1.25 + *                 Davide Prina
    1.26 + *                 Giuseppe Modugno
    1.27 + *                 Gianluca Turconi
    1.28 + *                 Simon Brouwer
    1.29 + *                 Noll Janos
    1.30 + *                 Biro Arpad
    1.31 + *                 Goldman Eleonora
    1.32 + *                 Sarlos Tamas
    1.33 + *                 Bencsath Boldizsar
    1.34 + *                 Halacsy Peter
    1.35 + *                 Dvornik Laszlo
    1.36 + *                 Gefferth Andras
    1.37 + *                 Nagy Viktor
    1.38 + *                 Varga Daniel
    1.39 + *                 Chris Halls
    1.40 + *                 Rene Engelhard
    1.41 + *                 Bram Moolenaar
    1.42 + *                 Dafydd Jones
    1.43 + *                 Harri Pitkanen
    1.44 + *                 Andras Timar
    1.45 + *                 Tor Lillqvist
    1.46 + * 
    1.47 + * Alternatively, the contents of this file may be used under the terms of
    1.48 + * either the GNU General Public License Version 2 or later (the "GPL"), or
    1.49 + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    1.50 + * in which case the provisions of the GPL or the LGPL are applicable instead
    1.51 + * of those above. If you wish to allow use of your version of this file only
    1.52 + * under the terms of either the GPL or the LGPL, and not to allow others to
    1.53 + * use your version of this file under the terms of the MPL, indicate your
    1.54 + * decision by deleting the provisions above and replace them with the notice
    1.55 + * and other provisions required by the GPL or the LGPL. If you do not delete
    1.56 + * the provisions above, a recipient may use your version of this file under
    1.57 + * the terms of any one of the MPL, the GPL or the LGPL.
    1.58 + *
    1.59 + ******* END LICENSE BLOCK *******/
    1.60 +
    1.61 +#ifndef _SUGGESTMGR_HXX_
    1.62 +#define _SUGGESTMGR_HXX_
    1.63 +
    1.64 +#define MAXSWL 100
    1.65 +#define MAXSWUTF8L (MAXSWL * 4)
    1.66 +#define MAX_ROOTS 100
    1.67 +#define MAX_WORDS 100
    1.68 +#define MAX_GUESS 200
    1.69 +#define MAXNGRAMSUGS 4
    1.70 +#define MAXPHONSUGS 2
    1.71 +#define MAXCOMPOUNDSUGS 3
    1.72 +
    1.73 +// timelimit: max ~1/4 sec (process time on Linux) for a time consuming function
    1.74 +#define TIMELIMIT (CLOCKS_PER_SEC >> 2)
    1.75 +#define MINTIMER 100
    1.76 +#define MAXPLUSTIMER 100
    1.77 +
    1.78 +#define NGRAM_LONGER_WORSE  (1 << 0)
    1.79 +#define NGRAM_ANY_MISMATCH  (1 << 1)
    1.80 +#define NGRAM_LOWERING      (1 << 2)
    1.81 +#define NGRAM_WEIGHTED      (1 << 3)
    1.82 +
    1.83 +#include "hunvisapi.h"
    1.84 +
    1.85 +#include "atypes.hxx"
    1.86 +#include "affixmgr.hxx"
    1.87 +#include "hashmgr.hxx"
    1.88 +#include "langnum.hxx"
    1.89 +#include <time.h>
    1.90 +
    1.91 +enum { LCS_UP, LCS_LEFT, LCS_UPLEFT };
    1.92 +
    1.93 +class LIBHUNSPELL_DLL_EXPORTED SuggestMgr
    1.94 +{
    1.95 +  char *          ckey;
    1.96 +  int             ckeyl;
    1.97 +  w_char *        ckey_utf;
    1.98 +
    1.99 +  char *          ctry;
   1.100 +  int             ctryl;
   1.101 +  w_char *        ctry_utf;
   1.102 +
   1.103 +  AffixMgr*       pAMgr;
   1.104 +  int             maxSug;
   1.105 +  struct cs_info * csconv;
   1.106 +  int             utf8;
   1.107 +  int             langnum;
   1.108 +  int             nosplitsugs;
   1.109 +  int             maxngramsugs;
   1.110 +  int             maxcpdsugs;
   1.111 +  int             complexprefixes;
   1.112 +
   1.113 +
   1.114 +public:
   1.115 +  SuggestMgr(const char * tryme, int maxn, AffixMgr *aptr);
   1.116 +  ~SuggestMgr();
   1.117 +
   1.118 +  int suggest(char*** slst, const char * word, int nsug, int * onlycmpdsug);
   1.119 +  int ngsuggest(char ** wlst, char * word, int ns, HashMgr** pHMgr, int md);
   1.120 +  int suggest_auto(char*** slst, const char * word, int nsug);
   1.121 +  int suggest_stems(char*** slst, const char * word, int nsug);
   1.122 +  int suggest_pos_stems(char*** slst, const char * word, int nsug);
   1.123 +
   1.124 +  char * suggest_morph(const char * word);
   1.125 +  char * suggest_gen(char ** pl, int pln, char * pattern);
   1.126 +  char * suggest_morph_for_spelling_error(const char * word);
   1.127 +
   1.128 +private:
   1.129 +   int testsug(char** wlst, const char * candidate, int wl, int ns, int cpdsuggest,
   1.130 +     int * timer, clock_t * timelimit);
   1.131 +   int checkword(const char *, int, int, int *, clock_t *);
   1.132 +   int check_forbidden(const char *, int);
   1.133 +
   1.134 +   int capchars(char **, const char *, int, int);
   1.135 +   int replchars(char**, const char *, int, int);
   1.136 +   int doubletwochars(char**, const char *, int, int);
   1.137 +   int forgotchar(char **, const char *, int, int);
   1.138 +   int swapchar(char **, const char *, int, int);
   1.139 +   int longswapchar(char **, const char *, int, int);
   1.140 +   int movechar(char **, const char *, int, int);
   1.141 +   int extrachar(char **, const char *, int, int);
   1.142 +   int badcharkey(char **, const char *, int, int);
   1.143 +   int badchar(char **, const char *, int, int);
   1.144 +   int twowords(char **, const char *, int, int);
   1.145 +   int fixstems(char **, const char *, int);
   1.146 +
   1.147 +   int capchars_utf(char **, const w_char *, int wl, int, int);
   1.148 +   int doubletwochars_utf(char**, const w_char *, int wl, int, int);
   1.149 +   int forgotchar_utf(char**, const w_char *, int wl, int, int);
   1.150 +   int extrachar_utf(char**, const w_char *, int wl, int, int);
   1.151 +   int badcharkey_utf(char **, const w_char *, int wl, int, int);
   1.152 +   int badchar_utf(char **, const w_char *, int wl, int, int);
   1.153 +   int swapchar_utf(char **, const w_char *, int wl, int, int);
   1.154 +   int longswapchar_utf(char **, const w_char *, int, int, int);
   1.155 +   int movechar_utf(char **, const w_char *, int, int, int);
   1.156 +
   1.157 +   int mapchars(char**, const char *, int, int);
   1.158 +   int map_related(const char *, char *, int, int, char ** wlst, int, int, const mapentry*, int, int *, clock_t *);
   1.159 +   int ngram(int n, char * s1, const char * s2, int opt);
   1.160 +   int mystrlen(const char * word);
   1.161 +   int leftcommonsubstring(char * s1, const char * s2);
   1.162 +   int commoncharacterpositions(char * s1, const char * s2, int * is_swap);
   1.163 +   void bubblesort( char ** rwd, char ** rwd2, int * rsc, int n);
   1.164 +   void lcs(const char * s, const char * s2, int * l1, int * l2, char ** result);
   1.165 +   int lcslen(const char * s, const char* s2);
   1.166 +   char * suggest_hentry_gen(hentry * rv, char * pattern);
   1.167 +
   1.168 +};
   1.169 +
   1.170 +#endif
   1.171 +

mercurial