Segment.h
上传用户:sunyong76
上传日期:2021-10-03
资源大小:2236k
文件大小:3k
源码类别:

多国语言处理

开发平台:

Java

  1. //////////////////////////////////////////////////////////////////////
  2. //ICTCLAS简介:计算所汉语词法分析系统ICTCLAS(Institute of Computing Technology, Chinese Lexical Analysis System),
  3. //             功能有:中文分词;词性标注;未登录词识别。
  4. //             分词正确率高达97.58%(973专家评测结果),
  5. //             未登录词识别召回率均高于90%,其中中国人名的识别召回率接近98%;
  6. //             处理速度为31.5Kbytes/s。
  7. //著作权:  Copyright?2002-2005中科院计算所 职务著作权人:张华平 刘群
  8. //遵循协议:自然语言处理开放资源许可证1.0
  9. //Email: zhanghp@software.ict.ac.cn
  10. //Homepage:www.nlp.org.cn;mtgroup.ict.ac.cn
  11. /****************************************************************************
  12.  *
  13.  * Copyright (c) 2000, 2001 
  14.  *     Machine Group
  15.  *     Software Research Lab.
  16.  *     Institute of Computing Tech.
  17.  *     Chinese Academy of Sciences
  18.  *     All rights reserved.
  19.  *
  20.  * This file is the confidential and proprietary property of 
  21.  * Institute of Computing Tech. and the posession or use of this file requires 
  22.  * a written license from the author.
  23.  * Filename: Segment.cpp
  24.  * Abstract:
  25.  *           interface for the CSegment class.
  26.  * Author:   Kevin Zhang 
  27.  *          (zhanghp@software.ict.ac.cn)
  28.  * Date:     2002-4-23
  29.  *
  30.  * Notes:  N-Shortest paths Word segmentation
  31.  *                
  32.  ****************************************************************************/
  33. #if !defined(AFX_SEGMENT_H__76DAE34D_434F_4989_8F00_64F17B5E19ED__INCLUDED_)
  34. #define AFX_SEGMENT_H__76DAE34D_434F_4989_8F00_64F17B5E19ED__INCLUDED_
  35. #if _MSC_VER > 1000
  36. #pragma once
  37. #endif // _MSC_VER > 1000
  38. #include "DynamicArray.h"
  39. #include "..\Utility\Dictionary.h"
  40. #include "SegGraph.h"//The segmentation graph
  41. #define MAX_WORDS 650
  42. #define MAX_SEGMENT_NUM 10
  43. class CSegment  
  44. {
  45. public:
  46. bool BiOptimumSegment(unsigned int nResultCount,double dSmoothingPara, CDictionary &dictBinary, CDictionary &dictCore);
  47. bool BiSegment(char *sSentence,double dSmoothingPara,CDictionary &dictCore,CDictionary &dictBinary,unsigned int nResultCount);
  48. bool GetLastWord(PWORD_RESULT pItem, char *sWordRet);
  49. int GetResultCount(PWORD_RESULT pItem);
  50. bool OptimumSegmet(int nResultCount);
  51. //Word Segmentation based on optimum segmentation graph
  52. //After unknown word recognition
  53. bool Segment(char *sSentence,CDictionary &dictCore,int nResultCount=10);
  54. CSegment();
  55. virtual ~CSegment();
  56. PWORD_RESULT *m_pWordSeg;
  57. int m_nSegmentCount;
  58. //The segmentation result
  59. CDynamicArray m_graphOptimum;//The optimumized segmentation graph
  60. CSegGraph m_graphSeg;//The segmentation graph
  61. /*----Added By huangjin@ict.ac.cn 2006-5-30----*/
  62. void ClearSegmentWord(void);
  63. /*-----------------------------------------------*/
  64. protected:
  65. bool BiPath2UniPath(int *npPath);
  66. bool BiGraphGenerate(CDynamicArray &aWord,CDynamicArray &aBinaryWordNet,double dSmoothingPara,CDictionary &DictBinary,CDictionary &DictCore);
  67. //CDynamicArray &aWord: the words array
  68. //CDynamicArray &aBinaryWordNet:the net between words
  69. //double dSmoothingPara: the parameter of data smoothing
  70. //CDictionary &DictBinary: the binary dictionary
  71. //CDictionary &DictCore: the Core dictionary
  72. bool IsYearTime(char *sNum);
  73. bool GenerateWord(int ** nSegRoute, int nIndex);
  74. private:
  75. int *m_npWordPosMapTable;//Record the position map of possible words
  76. int m_nWordCount;//Record the End position of possible words
  77. };
  78. #endif // !defined(AFX_SEGMENT_H__76DAE34D_434F_4989_8F00_64F17B5E19ED__INCLUDED_)