예제 #1
0
//After unknown word recognition
bool CSegment::OptimumSegmet(int nResultCount)
{
	int **nSegRoute;//The segmentation route
	nSegRoute=new int*[MAX_SEGMENT_NUM];
	for(int i=0;i<MAX_SEGMENT_NUM;i++)
	{
		nSegRoute[i]=new int[MAX_SENTENCE_LEN/2];
	}
	CNShortPath sp(&m_graphOptimum,nResultCount);
	sp.ShortPath();
	sp.Output((int **)nSegRoute,false,&m_nSegmentCount);
	int i=0;
	m_graphSeg.m_segGraph=m_graphOptimum;
	m_graphOptimum.SetEmpty();//Set graph optimum empty
	while(i<m_nSegmentCount)
	{
		GenerateWord(nSegRoute,i);
		//Gernerate word according the Segmentation route
		i++;
	}
	
	//free the memory
	for(i=0;i<MAX_SEGMENT_NUM;i++)
	{
		delete [] nSegRoute[i];//free the pointer memory
	}
	delete [] nSegRoute;//free the pointer array
	return true;
}
예제 #2
0
bool CSegment::Segment(char *sSentence,CDictionary &dictCore,int nResultCount)
{
	int **nSegRoute;//The segmentation route
	nSegRoute=new int*[MAX_SEGMENT_NUM];
	for(int i=0;i<MAX_SEGMENT_NUM;i++)
	{
		nSegRoute[i]=new int[MAX_SENTENCE_LEN/2];
		memset(nSegRoute[i],0,MAX_SENTENCE_LEN/2*sizeof(int));
	}
	m_graphSeg.m_segGraph.SetRowFirst(false);
	m_graphOptimum.SetRowFirst(false);
 	m_graphSeg.GenerateWordNet(sSentence,dictCore);
	CNShortPath sp(&m_graphSeg.m_segGraph,nResultCount);
	sp.ShortPath();
	sp.Output((int **)nSegRoute,false,&m_nSegmentCount);
	m_graphOptimum.SetEmpty();//Set graph optimum empty
	int i=0;
	while(i<m_nSegmentCount)
	{
		GenerateWord(nSegRoute,i);
		//Gernerate word according the Segmentation route
		i++;
	}
	
	//free the memory
	for(i=0;i<MAX_SEGMENT_NUM;i++)
	{
		delete [] nSegRoute[i];//free the pointer memory
	}
	delete [] nSegRoute;//free the pointer array
	
	return true;
}
예제 #3
0
bool CSegment::Segment(char *sSentence,CDictionary &dictCore,int nResultCount)
{
	int i  = 0;
	for(i=0;i<MAX_SEGMENT_NUM;i++)
	{
		 //memset(m_nSegRoute[i],0,MAX_SENTENCE_LEN/2*sizeof(int));
		memzeroquad(m_nSegRoute[i],MAX_SENTENCE_LEN/2);
	}

	for(i=0;i<MAX_SEGMENT_NUM;i++)
	{
	   //memset( m_pWordSeg[i], 0, sizeof(WORD_RESULT) * MAX_WORDS );
		memzeroquad(m_pWordSeg[i],sizeof(WORD_RESULT)*MAX_WORDS/4);
	}
	

 	m_graphSeg.GenerateWordNet(sSentence,dictCore);
	CNShortPath sp(&m_graphSeg.m_segGraph);
	sp.ShortPath();
	sp.Output((int **)m_nSegRoute, false, &m_nSegmentCount);
	m_graphOptimum.SetEmpty();//Set graph optimum empty
	i=0;
	while(i<m_nSegmentCount)
	{
		GenerateWord(m_nSegRoute,i);
		//Generate word according the Segmentation route
		i++;
	}
	
	return true;
}
예제 #4
0
bool CArithWordAnalyser::AnalyseWords(char* Expression,CCalculator& Cal){
	
	
	m_CurrentWordNum = 0;
	
	m_pCurrentLocation = NULL;
	
	strcpy(m_strExpression,"("); //以"("开头
	
	strcat(m_strExpression,Expression);
	
	strcat(m_strExpression,"#");  //加上结束单词
	
	m_pCurrentLocation = m_strExpression+1;  //当前位置为原表达式第一个
	
	m_pLastLocation = m_strExpression;       //指向 (
	
	
	while(*m_pCurrentLocation != '\0'){  //直到表达式最后
		if(!GenerateWord(Cal)){
			
			return false;
		}
		Cal.m_nNumWords++;
	}
	
	Cal.m_bWASucceed = true;
	return true;
}
예제 #5
0
bool CSegment::BiSegment(char *sSentence, double dSmoothingPara, CDictionary &dictCore, CDictionary &dictBinary, unsigned int nResultCount)
{
//	int **nSegRoute;//The segmentation route
//	nSegRoute=new int*[MAX_SEGMENT_NUM];
    intPtr nSegRoute[MAX_SEGMENT_NUM];
    memset(nSegRoute,0,MAX_SEGMENT_NUM*sizeof(intPtr));
	unsigned int nLen=strlen(sSentence)+10;
    int i;
	for(i=0;i<MAX_SEGMENT_NUM;i++)
	{
	//modify by xiaofei
		nSegRoute[i]=new int[nLen];
		memset(nSegRoute[i],-1,nLen*sizeof(int));
	}
 	m_graphSeg.GenerateWordNet(sSentence,dictCore,true);//Generate words array
    CDynamicArray aBiwordsNet;
	BiGraphGenerate(m_graphSeg.m_segGraph,aBiwordsNet,dSmoothingPara,dictBinary,dictCore);
    //Generate the biword link net
    
	CNShortPath sp(&aBiwordsNet,nResultCount);
	sp.ShortPath();
	sp.Output(nSegRoute,false,&m_nSegmentCount);
	
            

	m_graphOptimum.SetEmpty();//Set graph optimum empty

	i=0;

	while(i<m_nSegmentCount)
	{
		BiPath2UniPath(nSegRoute[i]);
		//Path convert to unipath
		GenerateWord(nSegRoute,i);
		//Gernerate word according the Segmentation route
		i++;
	}
            
	//free the memory
	for(i=0;i<MAX_SEGMENT_NUM;i++)
	{
		delete [] nSegRoute[i];//free the pointer memory
	}
//	delete [] nSegRoute;//free the pointer array
	
	return true;
}
예제 #6
0
bool CSegment::BiOptimumSegment(unsigned int nResultCount,double dSmoothingPara, CDictionary &dictBinary, CDictionary &dictCore)
{
//	int **nSegRoute;//The segmentation route
//	nSegRoute=new int*[MAX_SEGMENT_NUM];
    intPtr nSegRoute[MAX_SEGMENT_NUM];
    memset(nSegRoute,0,MAX_SEGMENT_NUM*sizeof(intPtr));
    int i;
	for(i=0;i<MAX_SEGMENT_NUM;i++)
	{
		nSegRoute[i]=new int[MAX_SENTENCE_LEN/2];
		memset(nSegRoute[i],-1,MAX_SENTENCE_LEN/2*sizeof(int));
	}
    CDynamicArray aBiwordsNet;
	BiGraphGenerate(m_graphOptimum,aBiwordsNet,dSmoothingPara,dictBinary,dictCore);
    //Generate the biword link net
    
	CNShortPath sp(&aBiwordsNet,nResultCount);
	sp.ShortPath();
	sp.Output((int **)nSegRoute,false,&m_nSegmentCount);
	i=0;
	m_graphSeg.m_segGraph=m_graphOptimum;
	m_graphOptimum.SetEmpty();//Set graph optimum empty

	while(i<m_nSegmentCount)
	{
		BiPath2UniPath(nSegRoute[i]);
		//Path convert to unipath
		GenerateWord(nSegRoute,i);
		//Gernerate word according the Segmentation route
		i++;
	}
	
	//free the memory
	for(i=0;i<MAX_SEGMENT_NUM;i++)
	{
		delete [] nSegRoute[i];//free the pointer memory
	}
//	delete [] nSegRoute;//free the pointer array
	return true;
}
예제 #7
0
파일: Outcode.cpp 프로젝트: robfinch/Cores
void dumplits()
{
	char *cp;
	int64_t nn;
	slit *lit;

	dfs.printf("<Dumplits>\n");
	roseg();
	if (casetab) {
		nl();
		align(8);
		nl();
	}
	while (casetab != nullptr) {
		nl();
		if (casetab->pass == 2)
			put_label(casetab->label, "", casetab->nmspace, 'D');
		for (nn = 0; nn < casetab->num; nn++) {
			if (casetab->cases[nn].pass==2)
				GenerateLabelReference(casetab->cases[nn].label, 0);
		}
		casetab = casetab->next;
	}
	if (quadtab) {
		nl();
		align(8);
		nl();
	}

	// Dumping to ro segment - no need for GC skip
	/*
	nn = GetQuadtabLen();
	if (nn) {
		sprintf_s(buf, sizeof(buf), "\tdw\t$%I64X ; GC_skip\n", nn | 0xFFF0200000000000LL);
		ofs.printf("%s", buf);
	}
	*/
	while(quadtab != nullptr) {
		nl();
		if (DataLabels[quadtab->label]) {
			put_label(quadtab->label, "", quadtab->nmspace, 'D');
			ofs.printf("\tdh\t");
			quadtab->Pack(64);
			ofs.printf("%s", quadtab->ToString(64));
			outcol += 35;
		}
		quadtab = quadtab->next;
	}
	if (strtab) {
		nl();
		align(8);
		nl();
	}

	//nn = GetStrtabLen();
	//if (nn) {
	//	sprintf_s(buf, sizeof(buf), "\tdw\t$%I64X ; GC_skip\n", nn | 0xFFF0200000000000LL);
	//	ofs.printf("%s", buf);
	//}
	for (lit = strtab; lit; lit = lit->next) {
		ENODE *ep;
		agr = ep = (ENODE *)lit->str;
		dfs.printf(".");
		nl();
		if (!lit->isString) {
			if (DataLabels[lit->label])
				put_label(lit->label, strip_crlf(&lit->str[1]), lit->nmspace, 'D');
		}
		else
			put_label(lit->label,strip_crlf(&lit->str[1]),lit->nmspace,'D');
		if (lit->isString) {
			cp = lit->str;
			switch (*cp) {
			case 'B':
				cp++;
				while (*cp)
					GenerateByte(*cp++);
				GenerateByte(0);
				break;
			case 'C':
				cp++;
				while (*cp)
					GenerateChar(*cp++);
				GenerateChar(0);
				break;
			case 'H':
				cp++;
				while (*cp)
					GenerateHalf(*cp++);
				GenerateHalf(0);
				break;
			case 'W':
				cp++;
				while (*cp)
					GenerateWord(*cp++);
				GenerateWord(0);
				break;
			}
		}
		else {
			if (DataLabels[lit->label]) {
				ep->PutStructConst(ofs);
			}
		}
	}
	strtab = nullptr;
	nl();
	dfs.printf("</Dumplits>\n");
}
예제 #8
0
int initshort()
{
	GenerateWord(GetIntegerExpression((ENODE **)NULL));
    return 1;
}
예제 #9
0
파일: Initializers.c 프로젝트: BigEd/Cores
int initshort()
{
	GenerateWord(GetIntegerExpression());
    return 1;
}