suggestmgr.hxx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef _SUGGESTMGR_HXX_
  2. #define _SUGGESTMGR_HXX_
  3. #define MAXSWL 100
  4. #define MAXSWUTF8L (MAXSWL * 4)
  5. #define MAX_ROOTS 100
  6. #define MAX_WORDS 100
  7. #define MAX_GUESS 200
  8. #define MAXNGRAMSUGS 4
  9. #define MAXPHONSUGS 2
  10. #define MAXCOMPOUNDSUGS 3
  11. // timelimit: max ~1/4 sec (process time on Linux) for a time consuming function
  12. #define TIMELIMIT (CLOCKS_PER_SEC >> 2)
  13. #define MINTIMER 100
  14. #define MAXPLUSTIMER 100
  15. #define NGRAM_LONGER_WORSE (1 << 0)
  16. #define NGRAM_ANY_MISMATCH (1 << 1)
  17. #define NGRAM_LOWERING (1 << 2)
  18. #define NGRAM_WEIGHTED (1 << 3)
  19. #include "hunvisapi.h"
  20. #include "atypes.hxx"
  21. #include "affixmgr.hxx"
  22. #include "hashmgr.hxx"
  23. #include "langnum.hxx"
  24. #include <time.h>
  25. enum { LCS_UP, LCS_LEFT, LCS_UPLEFT };
  26. class LIBHUNSPELL_DLL_EXPORTED SuggestMgr
  27. {
  28. char * ckey;
  29. int ckeyl;
  30. w_char * ckey_utf;
  31. char * ctry;
  32. int ctryl;
  33. w_char * ctry_utf;
  34. AffixMgr* pAMgr;
  35. int maxSug;
  36. struct cs_info * csconv;
  37. int utf8;
  38. int langnum;
  39. int nosplitsugs;
  40. int maxngramsugs;
  41. int maxcpdsugs;
  42. int complexprefixes;
  43. public:
  44. SuggestMgr(const char * tryme, int maxn, AffixMgr *aptr);
  45. ~SuggestMgr();
  46. int suggest(char*** slst, const char * word, int nsug, int * onlycmpdsug);
  47. int ngsuggest(char ** wlst, char * word, int ns, HashMgr** pHMgr, int md);
  48. int suggest_auto(char*** slst, const char * word, int nsug);
  49. int suggest_stems(char*** slst, const char * word, int nsug);
  50. int suggest_pos_stems(char*** slst, const char * word, int nsug);
  51. char * suggest_morph(const char * word);
  52. char * suggest_gen(char ** pl, int pln, char * pattern);
  53. char * suggest_morph_for_spelling_error(const char * word);
  54. private:
  55. int testsug(char** wlst, const char * candidate, int wl, int ns, int cpdsuggest,
  56. int * timer, clock_t * timelimit);
  57. int checkword(const char *, int, int, int *, clock_t *);
  58. int check_forbidden(const char *, int);
  59. int capchars(char **, const char *, int, int);
  60. int replchars(char**, const char *, int, int);
  61. int doubletwochars(char**, const char *, int, int);
  62. int forgotchar(char **, const char *, int, int);
  63. int swapchar(char **, const char *, int, int);
  64. int longswapchar(char **, const char *, int, int);
  65. int movechar(char **, const char *, int, int);
  66. int extrachar(char **, const char *, int, int);
  67. int badcharkey(char **, const char *, int, int);
  68. int badchar(char **, const char *, int, int);
  69. int twowords(char **, const char *, int, int);
  70. int fixstems(char **, const char *, int);
  71. int capchars_utf(char **, const w_char *, int wl, int, int);
  72. int doubletwochars_utf(char**, const w_char *, int wl, int, int);
  73. int forgotchar_utf(char**, const w_char *, int wl, int, int);
  74. int extrachar_utf(char**, const w_char *, int wl, int, int);
  75. int badcharkey_utf(char **, const w_char *, int wl, int, int);
  76. int badchar_utf(char **, const w_char *, int wl, int, int);
  77. int swapchar_utf(char **, const w_char *, int wl, int, int);
  78. int longswapchar_utf(char **, const w_char *, int, int, int);
  79. int movechar_utf(char **, const w_char *, int, int, int);
  80. int mapchars(char**, const char *, int, int);
  81. int map_related(const char *, char *, int, int, char ** wlst, int, int, const mapentry*, int, int *, clock_t *);
  82. int ngram(int n, char * s1, const char * s2, int opt);
  83. int mystrlen(const char * word);
  84. int leftcommonsubstring(char * s1, const char * s2);
  85. int commoncharacterpositions(char * s1, const char * s2, int * is_swap);
  86. void bubblesort( char ** rwd, char ** rwd2, int * rsc, int n);
  87. void lcs(const char * s, const char * s2, int * l1, int * l2, char ** result);
  88. int lcslen(const char * s, const char* s2);
  89. char * suggest_hentry_gen(hentry * rv, char * pattern);
  90. };
  91. #endif