www.pudn.com > SCISDemo.rar > Checkfromciku.cpp
// Checkfromciku.cpp: implementation of the CCheckfromciku class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SCISDemo.h"
#include "Checkfromciku.h"
#define maxlength 1000
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCheckfromciku::CCheckfromciku()
{
maxprobability = 0.0;
nnomatch = 100;
presult = NULL;
}
CCheckfromciku::~CCheckfromciku()
{
}
/////////////////////////////////////////////////////////////////////
BOOL CCheckfromciku::judgewords(char copenfilename[7], CString strpy, int n)
{
CFile fileread;
CString filepath = "newylk\\";
filepath += copenfilename;
filepath += ".txt";
char *pfile;
long lfilelength;
if(!fileread.Open(filepath, CFile::modeRead))
{
return FALSE;
}
fileread.SeekToEnd();
lfilelength = fileread.GetPosition();
pfile = new char[lfilelength];
fileread.SeekToBegin();
fileread.Read(pfile, lfilelength);
fileread.Close();
int npy = strpy.GetLength();
char cstr[50];
int i, k;
long lp = 0;
while (lp < lfilelength)
{
i = 0;
while (pfile[lp] != ' ')
{
cstr[i++] = pfile[lp++];
}
if (i==npy && strncmp(cstr, strpy, i)==0)
{
k = 0;
while (pfile[lp++] != '/')
{
k++;
}
k--;
k /=2;
if (k == n)
{
delete []pfile;
return TRUE;
}
}
while (pfile[lp++] != 10)
{
}
}
delete []pfile;
return FALSE;
}//judgewords
void CCheckfromciku::fetchpystreamcut(char *ppycut)
{
char *ptemp;
char pyfilename[7];
char cpystr[50];
maxprobability = 0.0;
nnomatch = 100;
if (presult != NULL)
{
free(presult);
presult = NULL;
}
ptemp = (char *)malloc(100);
int np = 0;
while (1)
{
if (ppycut[np] == 0)
{
break;
}
int i = 0,
k = 0;
while (ppycut[np] != '/')
{
if (ppycut[np] == '*')
{
k++;
}
ptemp[i] = ppycut[np];
i++;
np++;
}
np++;
int *pwordscond = new int[k*k];
int t1 = 0,
t2;
for(int j=0; j=i)
// {
// break;
// }
t2 = t1;
int n = 1;
for(int p=j+1; p>(k-1) != 1)
{
// int j;
// for (j=0; j>j) & 1;
// }
// ptag[j] = 1;
// ntemp++;
BOOL btag = TRUE;
int j = 0;
while (j>t)&1) != 1 && t>r3)&1) == 1)
{
ctemp[r2++] = '*';
}
r1++;
r3++;
}
else
{
ctemp[r2++] = ptemp[r1++];
}
}
ctemp[r2++] = k + 48;
ctemp[r2] = 0;
AfxMessageBox(ctemp);
*/ }
ntemp++;
}
delete [] pwordscond;
//delete [] ptag;
}
free(ptemp);
return;
}//fetchpystreamcut
void CCheckfromciku::computeprobability(char *pcpy, int ndivideposition, int k)
{
typedef char * PCHAR;
PCHAR *pdivide = new PCHAR[k];
int ntotal = 0;
int *pncurlength = new int[k],
*pndividenum = new int[k];
for (int i=0; i>r3)&1) == 1)
{
ctemp[r4] = 0;
ntemp++;
CFile fileread;
CString filepath = "newylk\\";
filepath += cfilename;
filepath += ".txt";
char *pfile;
long lfilelength;
fileread.Open(filepath, CFile::modeRead);
fileread.SeekToEnd();
lfilelength = fileread.GetPosition();
pfile = new char[lfilelength];
fileread.SeekToBegin();
fileread.Read(pfile, lfilelength);
fileread.Close();
int npy = strlen(ctemp);
char cstr[50];
long lp = 0;
while (lp < lfilelength)
{
i = 0;
while (pfile[lp] != ' ')
{
cstr[i++] = pfile[lp++];
}
if (i==npy && strncmp(cstr, ctemp, i)==0)
{
int s = 0;
lp++;
while (pfile[lp] != '/')
{
cstr[s++] = pfile[lp++];
}
if (s/2 == ntemp)
{
while(pfile[lp] != 13)
{
cstr[s++] = pfile[lp++];
}
cstr[s++] = '*';
strncpy(pdivide[ntotal-1]+pncurlength[ntotal-1], cstr, s);
pncurlength[ntotal-1] += s;
pndividenum[ntotal-1]++;
}
}
while (pfile[lp++] != 10)
{
}
}
delete []pfile;
r1++;
r3++;
r2 = r4 =0;
if (r3 != k)
{
while (pcpy[r1] != '*')
{
cfilename[r2++] = pcpy[r1];
ctemp[r4++] = pcpy[r1++];
}
cfilename[r2] = 0;
ntemp = 0;
pdivide[ntotal++] = (char *)malloc(maxlength);
strncpy(pdivide[ntotal-1]+pncurlength[ntotal-1], cfilename, r2);
pncurlength[ntotal-1] += r2;
pdivide[ntotal-1][pncurlength[ntotal-1]++] = '/';
}
}
else
{
ntemp++;
r1++;
r3++;
}
}
else
{
ctemp[r4++] = pcpy[r1++];
}
}
ctemp[r4] = 0;
CFile fileread;
CString filepath = "newylk\\";
filepath += cfilename;
filepath += ".txt";
char *pfile;
long lfilelength;
fileread.Open(filepath, CFile::modeRead);
fileread.SeekToEnd();
lfilelength = fileread.GetPosition();
pfile = new char[lfilelength];
fileread.SeekToBegin();
fileread.Read(pfile, lfilelength);
fileread.Close();
int npy = strlen(ctemp);
char cstr[50];
long lp = 0;
while (lp < lfilelength)
{
i = 0;
while (pfile[lp] != ' ')
{
cstr[i++] = pfile[lp++];
}
if (i==npy && strncmp(cstr, ctemp, i)==0)
{
int s = 0;
lp++;
while (pfile[lp] != '/')
{
cstr[s++] = pfile[lp++];
}
if (s/2 == ntemp)
{
while(pfile[lp] != 13)
{
cstr[s++] = pfile[lp++];
}
cstr[s++] = '*';
strncpy(pdivide[ntotal-1]+pncurlength[ntotal-1], cstr, s);
pncurlength[ntotal-1] += s;
pndividenum[ntotal-1]++;
}
}
while (pfile[lp++] != 10)
{
}
}
delete []pfile;
int nmaxw = pndividenum[0];
for(i=0; i= 0)
{
if (presult != NULL)
{
free(presult);
presult = NULL;
}
presult = (char *)malloc(100);
int *npresult = new int[ntotal];
npresult[ntotal-1] = max;
for(int j=ntotal-2; j>=0; j--)
{
npresult[j] = plnrelation[npresult[j+1]][j+1];
}
int nresultlength = 0;
for (j=0; j