/extensions/spellcheck/hunspell/src/suggestmgr.hxx

http://github.com/zpao/v8monkey · C++ Header · 168 lines · 90 code · 21 blank · 57 comment · 0 complexity · 92df8bf140f172fc8062ecf4e978639e MD5 · raw file

  1. /******* BEGIN LICENSE BLOCK *******
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Initial Developers of the Original Code are Kevin Hendricks (MySpell)
  15. * and László Németh (Hunspell). Portions created by the Initial Developers
  16. * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved.
  17. *
  18. * Contributor(s): Kevin Hendricks (kevin.hendricks@sympatico.ca)
  19. * David Einstein (deinst@world.std.com)
  20. * László Németh (nemethl@gyorsposta.hu)
  21. * Caolan McNamara (caolanm@redhat.com)
  22. * Davide Prina
  23. * Giuseppe Modugno
  24. * Gianluca Turconi
  25. * Simon Brouwer
  26. * Noll Janos
  27. * Biro Arpad
  28. * Goldman Eleonora
  29. * Sarlos Tamas
  30. * Bencsath Boldizsar
  31. * Halacsy Peter
  32. * Dvornik Laszlo
  33. * Gefferth Andras
  34. * Nagy Viktor
  35. * Varga Daniel
  36. * Chris Halls
  37. * Rene Engelhard
  38. * Bram Moolenaar
  39. * Dafydd Jones
  40. * Harri Pitkanen
  41. * Andras Timar
  42. * Tor Lillqvist
  43. *
  44. * Alternatively, the contents of this file may be used under the terms of
  45. * either the GNU General Public License Version 2 or later (the "GPL"), or
  46. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  47. * in which case the provisions of the GPL or the LGPL are applicable instead
  48. * of those above. If you wish to allow use of your version of this file only
  49. * under the terms of either the GPL or the LGPL, and not to allow others to
  50. * use your version of this file under the terms of the MPL, indicate your
  51. * decision by deleting the provisions above and replace them with the notice
  52. * and other provisions required by the GPL or the LGPL. If you do not delete
  53. * the provisions above, a recipient may use your version of this file under
  54. * the terms of any one of the MPL, the GPL or the LGPL.
  55. *
  56. ******* END LICENSE BLOCK *******/
  57. #ifndef _SUGGESTMGR_HXX_
  58. #define _SUGGESTMGR_HXX_
  59. #define MAXSWL 100
  60. #define MAXSWUTF8L (MAXSWL * 4)
  61. #define MAX_ROOTS 100
  62. #define MAX_WORDS 100
  63. #define MAX_GUESS 200
  64. #define MAXNGRAMSUGS 4
  65. #define MAXPHONSUGS 2
  66. #define MAXCOMPOUNDSUGS 3
  67. // timelimit: max ~1/4 sec (process time on Linux) for a time consuming function
  68. #define TIMELIMIT (CLOCKS_PER_SEC >> 2)
  69. #define MINTIMER 100
  70. #define MAXPLUSTIMER 100
  71. #define NGRAM_LONGER_WORSE (1 << 0)
  72. #define NGRAM_ANY_MISMATCH (1 << 1)
  73. #define NGRAM_LOWERING (1 << 2)
  74. #define NGRAM_WEIGHTED (1 << 3)
  75. #include "hunvisapi.h"
  76. #include "atypes.hxx"
  77. #include "affixmgr.hxx"
  78. #include "hashmgr.hxx"
  79. #include "langnum.hxx"
  80. #include <time.h>
  81. enum { LCS_UP, LCS_LEFT, LCS_UPLEFT };
  82. class LIBHUNSPELL_DLL_EXPORTED SuggestMgr
  83. {
  84. char * ckey;
  85. int ckeyl;
  86. w_char * ckey_utf;
  87. char * ctry;
  88. int ctryl;
  89. w_char * ctry_utf;
  90. AffixMgr* pAMgr;
  91. int maxSug;
  92. struct cs_info * csconv;
  93. int utf8;
  94. int langnum;
  95. int nosplitsugs;
  96. int maxngramsugs;
  97. int maxcpdsugs;
  98. int complexprefixes;
  99. public:
  100. SuggestMgr(const char * tryme, int maxn, AffixMgr *aptr);
  101. ~SuggestMgr();
  102. int suggest(char*** slst, const char * word, int nsug, int * onlycmpdsug);
  103. int ngsuggest(char ** wlst, char * word, int ns, HashMgr** pHMgr, int md);
  104. int suggest_auto(char*** slst, const char * word, int nsug);
  105. int suggest_stems(char*** slst, const char * word, int nsug);
  106. int suggest_pos_stems(char*** slst, const char * word, int nsug);
  107. char * suggest_morph(const char * word);
  108. char * suggest_gen(char ** pl, int pln, char * pattern);
  109. char * suggest_morph_for_spelling_error(const char * word);
  110. private:
  111. int testsug(char** wlst, const char * candidate, int wl, int ns, int cpdsuggest,
  112. int * timer, clock_t * timelimit);
  113. int checkword(const char *, int, int, int *, clock_t *);
  114. int check_forbidden(const char *, int);
  115. int capchars(char **, const char *, int, int);
  116. int replchars(char**, const char *, int, int);
  117. int doubletwochars(char**, const char *, int, int);
  118. int forgotchar(char **, const char *, int, int);
  119. int swapchar(char **, const char *, int, int);
  120. int longswapchar(char **, const char *, int, int);
  121. int movechar(char **, const char *, int, int);
  122. int extrachar(char **, const char *, int, int);
  123. int badcharkey(char **, const char *, int, int);
  124. int badchar(char **, const char *, int, int);
  125. int twowords(char **, const char *, int, int);
  126. int fixstems(char **, const char *, int);
  127. int capchars_utf(char **, const w_char *, int wl, int, int);
  128. int doubletwochars_utf(char**, const w_char *, int wl, int, int);
  129. int forgotchar_utf(char**, const w_char *, int wl, int, int);
  130. int extrachar_utf(char**, const w_char *, int wl, int, int);
  131. int badcharkey_utf(char **, const w_char *, int wl, int, int);
  132. int badchar_utf(char **, const w_char *, int wl, int, int);
  133. int swapchar_utf(char **, const w_char *, int wl, int, int);
  134. int longswapchar_utf(char **, const w_char *, int, int, int);
  135. int movechar_utf(char **, const w_char *, int, int, int);
  136. int mapchars(char**, const char *, int, int);
  137. int map_related(const char *, char *, int, int, char ** wlst, int, int, const mapentry*, int, int *, clock_t *);
  138. int ngram(int n, char * s1, const char * s2, int opt);
  139. int mystrlen(const char * word);
  140. int leftcommonsubstring(char * s1, const char * s2);
  141. int commoncharacterpositions(char * s1, const char * s2, int * is_swap);
  142. void bubblesort( char ** rwd, char ** rwd2, int * rsc, int n);
  143. void lcs(const char * s, const char * s2, int * l1, int * l2, char ** result);
  144. int lcslen(const char * s, const char* s2);
  145. char * suggest_hentry_gen(hentry * rv, char * pattern);
  146. };
  147. #endif