SegmenterManager.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: GPL 2.0
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License. You should have
  7. * received a copy of the GPL license along with this program; if you
  8. * did not, you can find it at http://www.gnu.org/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is Coreseek.com code.
  16. *
  17. * Copyright (C) 2007-2008. All Rights Reserved.
  18. *
  19. * Author:
  20. * Li monan <li.monan@gmail.com>
  21. *
  22. * ***** END LICENSE BLOCK ***** */
  23. #ifndef css_SegmenterManager_h
  24. #define css_SegmenterManager_h
  25. #include <string>
  26. #include "freelist.h"
  27. #include "UnigramDict.h"
  28. #include "SynonymsDict.h"
  29. #include "ThesaurusDict.h"
  30. #include "Segmenter.h"
  31. namespace css {
  32. // class CrfSegmenter;
  33. using namespace CRFPP;
  34. /** @author Monan Li
  35. */
  36. class SegmenterManager {
  37. /* {TemplatePath=D:\cos\deps\Segment\doc\}*/
  38. public:
  39. /**
  40. * Return a newly created segmenter
  41. */
  42. Segmenter* getSegmenter(bool bFromPool = true);
  43. virtual int init(const char* path, u1 method = SEG_METHOD_NGRAM);
  44. void loadconfig(const char* confile);
  45. void clear();
  46. SegmenterManager();
  47. virtual ~SegmenterManager();
  48. const char* what_() { return m_msg; }
  49. public:
  50. const static u1 SEG_METHOD_NGRAM = 0x1;
  51. protected:
  52. CRFPP::FreeList<Segmenter> seg_freelist_;
  53. UnigramDict m_uni;
  54. UnigramDict m_kw;
  55. UnigramDict m_weight;
  56. SynonymsDict m_sym;
  57. ThesaurusDict m_thesaurus;
  58. Segmenter_ConfigObj m_config;
  59. u1 m_method;
  60. u1 m_inited;
  61. char m_msg[1024];
  62. };
  63. } /* End of namespace css */
  64. #endif