ThesaurusDict.h 1005 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef THESAURUS_DICT_h
  2. #define THESAURUS_DICT_h
  3. #include <cstring>
  4. #include <string>
  5. namespace css {
  6. // using namespace CRFPP;
  7. #ifdef WIN32
  8. using namespace stdext;
  9. #else
  10. using namespace __gnu_cxx;
  11. #endif
  12. #include "darts.h"
  13. #include "csr.h"
  14. #include "csr_mmap.h"
  15. class ThesaurusRecord {
  16. public:
  17. std::string key;
  18. u1 value[1024];
  19. u2 length;
  20. };
  21. class ThesaurusDict {
  22. public:
  23. typedef Darts::DoubleArray::result_pair_type result_pair_type;
  24. ThesaurusDict() : m_stringpool(NULL){};
  25. virtual ~ThesaurusDict(){};
  26. public:
  27. virtual int load(const char* filename);
  28. int import(const char* filename, const char* target_file = NULL);
  29. const char* find(const char* key, u2 key_len,
  30. int* count = NULL); // the return string buffer might
  31. // contains 0, end with \0\0
  32. int isLoad() { return m_da.array() != NULL; }
  33. protected:
  34. _csr_mmap_t* m_file;
  35. u1* m_stringpool;
  36. Darts::DoubleArray m_da;
  37. };
  38. } /* End of namespace css */
  39. #endif