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

多国语言处理

开发平台:

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: Span.h: 
  24.  * Abstract:
  25.  *          interface for the CSpan class.
  26.  * Author:   Kevin Zhang 
  27.  *          (zhanghp@software.ict.ac.cn)
  28.  * Date:     2002-4-23
  29.  *
  30.  * Notes:    Tagging with Hidden Markov Model
  31.  *                
  32.  ****************************************************************************/
  33. #if !defined(AFX_SPAN_H__178113DA_8D45_4D47_B6DA_CB62C001BC35__INCLUDED_)
  34. #define AFX_SPAN_H__178113DA_8D45_4D47_B6DA_CB62C001BC35__INCLUDED_
  35. #if _MSC_VER > 1000
  36. #pragma once
  37. #endif // _MSC_VER > 1000
  38. #include "..\Utility\Dictionary.h"
  39. #include "..\Utility\ContextStat.h"
  40. #include "..\Segment\DynamicArray.h"
  41. #define MAX_WORDS_PER_SENTENCE 120
  42. #define MAX_UNKNOWN_PER_SENTENCE 200
  43. #define MAX_POS_PER_WORD 20
  44. #define LITTLE_FREQUENCY 6
  45. enum TAG_TYPE{
  46. TT_NORMAL,
  47. TT_PERSON,
  48. TT_PLACE,
  49. TT_TRANS_PERSON
  50. };
  51. class CSpan  
  52. {
  53. public:
  54. bool PlaceRecognize(CDictionary &dictCore,CDictionary &placeDict);
  55. bool PersonRecognize(CDictionary &personDict);
  56. bool POSTagging(PWORD_RESULT pWordItems,CDictionary &dictCore,CDictionary &dictUnknown);
  57. //POS tagging with Hidden Markov Model
  58. void SetTagType(enum TAG_TYPE nType=TT_NORMAL);
  59. //Set the tag type
  60. bool LoadContext(char *sFilename);
  61. CSpan();//CDictionary &dict
  62. virtual ~CSpan();
  63. int m_nUnknownIndex;
  64. //The number of unknown word
  65. int m_nUnknownWords[MAX_UNKNOWN_PER_SENTENCE][2];
  66. //The start and ending possition of unknown position
  67. ELEMENT_TYPE m_dWordsPossibility[MAX_UNKNOWN_PER_SENTENCE];
  68. //The possibility of unknown words
  69. CContextStat m_context;//context
  70. protected:
  71. ELEMENT_TYPE  ComputePossibility(int nStartPos,int nLength,CDictionary &dict);
  72. int GetFrom(PWORD_RESULT pWordItems,int nIndex,CDictionary &dictCore,CDictionary &dictUnknown);
  73. //Get words from the word items, start from nIndex, Function for unknown words recognition
  74. bool GuessPOS(int nIndex,int *pSubIndex);
  75. bool GetBestPOS();
  76. bool Reset(bool bContinue=true);
  77. bool Disamb();
  78. private:
  79. enum TAG_TYPE m_tagType;//The type of tagging
  80. int m_nStartPos;
  81. int m_nBestTag[MAX_WORDS_PER_SENTENCE];
  82. //Record the Best Tag
  83. char m_sWords[MAX_WORDS_PER_SENTENCE][WORD_MAXLENGTH];
  84. int m_nWordPosition[MAX_WORDS_PER_SENTENCE];
  85. int m_nTags[MAX_WORDS_PER_SENTENCE][MAX_POS_PER_WORD];
  86. char m_nBestPrev[MAX_WORDS_PER_SENTENCE][MAX_POS_PER_WORD];
  87. /* 
  88. * ----- commented by huangjin@ict.ac.cn 2006-7-23 ------ 
  89. *
  90. *  char m_nCurLength;
  91. *
  92. */
  93. /*----Added By huangjin@ict.ac.cn 2006-7-23----*/
  94. //从定义的名字来看,显然应该是int型数据
  95. int m_nCurLength;
  96. /*---------------------------------------------*/
  97. double m_dFrequency[MAX_WORDS_PER_SENTENCE][MAX_POS_PER_WORD];
  98. };
  99. #endif // !defined(AFX_SPAN_H__178113DA_8D45_4D47_B6DA_CB62C001BC35__INCLUDED_)