Создание исследовательского прототипа системы идентификации табличных данных
Рефераты >> Программирование и компьютеры >> Создание исследовательского прототипа системы идентификации табличных данных

DocL = new TList();

}

//---------------------------------------------------------------------------

void fastcall TfCompare::FormDestroy(TObject *Sender)

{

delete DocL,BaseL,Doc,Base;

}

//---------------------------------------------------------------------------

bool TfCompare::GetInfo(){

for(int i=0;i<FlowNum;i++)

for(int j=0;j<FlowNum;j++){

B[i][j]=-1;

D[i][j]=-1;

Unind[i][j]=-1;

FromBaseToDoc[i][0]=-1;

FromBaseToDoc[i][1]=-1;

for(int k=0;k<MaxID;k++)

United[i][j][k]=-1;

if(i<3){

Ids[i][j]=-1;

MUs[i][j]=AnsiString();

}

}

if(!FileExists(ChangeFileExt(BaseF,".hdr")))

return(false);

if(!FileExists(ChangeFileExt(DocF,".hdr")))

return(false);

if(!FileExists("InternalSigns.lst"))

return(false);

if(!FileExists("MeterUnits.lst"))

return(false);

TStringList *X=new TStringList();

TStringList *Y=new TStringList();

//Íàñòðîéêè

Y->Clear();

Y->LoadFromFile("MeterUnits.lst");

for(int j=1;j<Y->Count&&j<FlowNum;j++){

X->CommaText=Y->Strings[j];

for(int i=0;i<3&&i<X->Count;i++)

MUs[i][j-1]=X->Strings[i];

X->Clear();

}

Y->Clear();

Y->LoadFromFile("InternalSigns.lst");

for(int j=1;j<Y->Count&&j<FlowNum;j++){

X->CommaText=Y->Strings[j];

Ids[0][j-1]=X->Strings[0].ToInt();

if(X->Strings[2].AnsiCompare("DIGIT")==0){

Ids[1][j-1]=1;

for(int i=0;i<FlowNum;i++)

if(!MUs[0][i].IsEmpty())

if(MUs[0][i].ToInt()==X->Values[X->Names[3]].ToInt())

Ids[2][j-1]=i;

}

else

Ids[1][j-1]=0;

X->Clear();

}

//ôàéëû

Y->Clear();

Y->LoadFromFile(ChangeFileExt(BaseF,".hdr"));

for(int i=1;i<=FlowNum/2&&i<=Y->Count/2;i++){

X->CommaText=Y->Strings[2*i];

if(!(X->Strings[0].ToInt()))

for(int j=1;j<X->Count&&j<FlowNum;j++){

B[i-1][j-1]=X->Strings[j].ToInt();

for(int k=0;k<FlowNum;k++){

if(B[i-1][j-1]==Ids[0][k]){

B[i-1][j-1]=k;

break;

}

}

}

}

Y->Clear();

Y->LoadFromFile(ChangeFileExt(DocF,".hdr"));

for(int i=1;i<=FlowNum/2&&i<=Y->Count/2;i++){

X->CommaText=Y->Strings[2*i];

if(!(X->Strings[0].ToInt()))

for(int j=1;j<X->Count&&j<FlowNum;j++){

D[i-1][j-1]=X->Strings[j].ToInt();

for(int k=0;k<FlowNum;k++){

if(D[i-1][j-1]==Ids[0][k]){

D[i-1][j-1]=k;

break;

}

}

}

}

delete X,Y;

//Åäèíèöû èçìåðåíèÿ

Prefix[0][0]="";Prefix[0][1]="";Prefix[0][2]="0";

Prefix[1][0]="êèëî";Prefix[1][1]="ê";Prefix[1][2]="-3";

Prefix[2][0]="ìèëëè";Prefix[2][1]="ì";Prefix[2][2]="3";

for(int f=0;f<FlowNum;f++){

if(MUs[1][f].IsEmpty())

continue;

FMU[f][0][0]=MUs[1][f];

FMU[f][0][1]="0";

if(!MUs[2][f].IsEmpty())

FMU[f][1][0]=MUs[2][f];

else

FMU[f][1][0]=MUs[1][f].SubString(1,1);

FMU[f][1][1]="0";

for(int mu=1;mu<MUPNum;mu++)

for(int a=0;a<2;a++){

FMU[f][2*mu+a][0]=Prefix[mu][a]+FMU[f][a][0];

FMU[f][2*mu+a][1]=Prefix[mu][2];

}

}

for(int f1=0;f1<FlowNum;f1++)

for(int f2=0;f2<FlowNum;f2++){

TStringList* BMU= new TStringList();

TStringList* DMU= new TStringList();

//-----------

int IsBStr=0;

int IsDStr=0;

//-----------

for(int j=0;j<FlowNum;j++){

if(B[f1][j]!=-1){

if(Ids[1][B[f1][j]]==1)

BMU->Add(Ids[2][B[f1][j]]);

if(Ids[1][B[f1][j]]==0)

IsBStr=1;

}

if(D[f2][j]!=-1){

if(Ids[1][D[f2][j]]==1)

DMU->Add(Ids[2][D[f2][j]]);

if(Ids[1][D[f1][j]]==0)

IsDStr=1;

}

}

int k=0;

while(k<DMU->Count){

if(BMU->IndexOf(DMU->Strings[k])==-1){

DMU->Delete(k);

k--;

}

k++;

}

Unind[f1][f2]=DMU->Count;

for(int j=0;j<Unind[f1][f2];j++){

United[f1][f2][j]=DMU->Strings[j].ToInt();

}

//---------------------------------

if(DMU->Count)

FromBaseToDoc[f1][1]=f2;

if(IsBStr*IsDStr)

FromBaseToDoc[f1][0]=f2;

//---------------------------------

delete DMU,BMU;

}

return(true);

}

//--------------------------------------------------------------------

int TfCompare::StringCompare(int f1,int f2,TPositions Fst,TPositions Snd){

AnsiString ABC;

for(int i=1;i<=Fst.ABC[f1].Length();i++)

if(Snd.ABC[f2].Pos(Fst.ABC[f1][i])&&!ABC.Pos(Fst.ABC[f1][i]))

ABC+=Fst.ABC[f1][i];

int minLengthABC=min(Fst.ABC[f1].Length(),Snd.ABC[f2].Length());

if(!minLengthABC)

return(0);

int rABC=ABC.Length()*2;

if(rABC<minLengthABC)

return(0);

int minLength=min(Fst.Sentence(f1).Length(),Snd.Sentence(f2).Length());

int MaxLPayMent=(1000/(minLength));

int AccumPayMent=0;

int MaxCurPayMent;

int CurPayMent;

for(int i=0;i<Fst.WC[f1];i++){

MaxCurPayMent=0;

for(int j=0;j<Snd.WC[f2];j++){

CurPayMent=CheckSum(Fst.Words[i][f1],Snd.Words[j][f2],MaxLPayMent);

if(CurPayMent>MaxCurPayMent)

MaxCurPayMent=CurPayMent;

}

AccumPayMent+=MaxCurPayMent;

}

return(AccumPayMent);

}

int TfCompare::AnalizeUnitWithMU(AnsiString Unit,int MUIndex,int&Multiplier){

/* if(Unit.IsEmpty())

if(MUIndex==FlowNum)

return(2);

else

return(0);*/

int CP;

int MP=0;

int MI=0;

int MaxPay=1;

int UnitLength=Unit.Length();

for(int i=1;i<4/*2*MUPNum+2*/;i+=2){

if(Unit.AnsiCompare(FMU[MUIndex][i][0])==0)

CP=MaxPay*UnitLength;

else

CP=CheckSum(Unit,FMU[MUIndex][i][0],MaxPay);

if(CP>MP){

MP=CP;

MI=i;

}

if(CP==MaxPay*UnitLength)

break;

}

Multiplier=pow(10,(FMU[MUIndex][MI][1].ToInt()));

return(MP);

}

int TfCompare::AnalizePosWithMU(TPositions Fst,int Flow,int MUindex,int &PosIndex,int &Multiplier){

int MP=0;

int CP;

int CurMultiplier=0;

for(int i=0;i<Fst.NC[Flow];i++){

CP=AnalizeUnitWithMU(Fst.StrNumbers[i][Flow],MUindex,CurMultiplier);

if(CP>MP){

Multiplier=CurMultiplier;

MP=CP;

PosIndex=i;

}

}

return(MP);

}

int TfCompare::NumberCompare(int f1,int f2,TPositions Fst,TPositions Snd){


Страница: