#if !defined(AFX_SPAN_H__178113DA_8D45_4D47_B6DA_CB62C001BC35__INCLUDED_)
#define AFX_SPAN_H__178113DA_8D45_4D47_B6DA_CB62C001BC35__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif
#include "..\\Utility\\Dictionary.h"
#include "..\\Utility\\ContextStat.h"
#include "..\\Segment\\DynamicArray.h"
#define MAX_WORDS_PER_SENTENCE 120
#define MAX_UNKNOWN_PER_SENTENCE 200
#define MAX_POS_PER_WORD 20
#define LITTLE_FREQUENCY 6
enum TAG_TYPE{
TT_NORMAL,
TT_PERSON,
TT_PLACE,
TT_TRANS
};
class CSpan
{
public:
bool TransRecognize(CDictionary &dictCore,CDictionary &transDict);
bool PlaceRecognize(CDictionary &dictCore,CDictionary &placeDict);
bool PersonRecognize(CDictionary &personDict);
bool POSTagging(PWORD_RESULT pWordItems,CDictionary &dictCore,CDictionary &dictUnknown);
void SetTagType(enum TAG_TYPE nType=TT_NORMAL);
bool LoadContext(char *sFilename);
CSpan();
virtual ~CSpan();
int m_nUnknownIndex;
int m_nUnknownWords[MAX_UNKNOWN_PER_SENTENCE][2];
ELEMENT_TYPE m_dWordsPossibility[MAX_UNKNOWN_PER_SENTENCE];
CContextStat m_context;
protected:
ELEMENT_TYPE ComputePossibility(int nStartPos,int nLength,CDictionary &dict);
int GetFrom(PWORD_RESULT pWordItems,int nIndex,CDictionary &dictCore,CDictionary &dictUnknown);
bool GuessPOS(int nIndex,int *pSubIndex);
bool GetBestPOS();
bool Reset(bool bContinue=true);
bool UnknownMatch();
bool SplitPersonPOS(CDictionary &unlistDict);
bool Disamb();
private:
enum TAG_TYPE m_tagType;
int m_nStartPos;
int m_nBestTag[MAX_WORDS_PER_SENTENCE];
char m_sWords[MAX_WORDS_PER_SENTENCE][WORD_MAXLENGTH];
int m_nWordPosition[MAX_WORDS_PER_SENTENCE];
int m_nTags[MAX_WORDS_PER_SENTENCE][MAX_POS_PER_WORD];
char m_nBestPrev[MAX_WORDS_PER_SENTENCE][MAX_POS_PER_WORD];
char m_nCurLength;
double m_dFrequency[MAX_WORDS_PER_SENTENCE][MAX_POS_PER_WORD];
};
#endif