1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{ int k=1; int nb=0;
//ShowMessage(Form2->nb);
//if(is_int("4664")) ShowMessage("good");
for(int i=0;i<Form2->rest.size();i++) {
for(int j=0;j<30;j++) {
if(!Form2->rest[i].mot[j].IsEmpty()) {
//Form1->ADOTable1->Filter="lemme=Form2->rest[i].mot[j];
TLocateOptions Option; // Creer un objet option
Option << loCaseInsensitive; // Rajout de l'option "ne fait pas attention à la casse"
if(!Form1->is_int(Form2->rest[i].mot[j])&&ADOTable1->Locate("ortho",Form2->rest[i].mot[j],Option)==true) {
nb++;
Form1->StringGrid1->RowCount=nb+1;
Form1->StringGrid1->Cells[0][k]=IntToStr(i);
Form1->StringGrid1->Cells[1][k]=ADOTable1->FieldByName("lemme")->AsString;
Form1->StringGrid1->Cells[2][k]=ADOTable1->FieldByName("ortho")->AsString;
Form1->StringGrid1->Cells[3][k]=ADOTable1->FieldByName("cgram")->AsString;
Form1->StringGrid1->Cells[4][k]=ADOTable1->FieldByName("ID")->AsString;
Form1->StringGrid1->Cells[5][k]=ADOTable1->FieldByName("nombre")->AsString;
k++;
}
else if(Form1->is_int(Form2->rest[i].mot[j])==true) {
// ShowMessage(Form2->rest[i].mot[j]);
nb++;
Form1->StringGrid1->RowCount=nb+1;
Form1->StringGrid1->Cells[0][k]=IntToStr(i);
Form1->StringGrid1->Cells[1][k]=Form2->rest[i].mot[j];
Form1->StringGrid1->Cells[2][k]=Form2->rest[i].mot[j];
Form1->StringGrid1->Cells[3][k]="chiffre";
k++;
}
else {
//ShowMessage(Form2->rest[i].mot[j]);
nb++;
Form1->StringGrid1->RowCount=nb+1;
Form1->StringGrid1->Cells[0][k]=IntToStr(i);
Form1->StringGrid1->Cells[1][k]=Form2->rest[i].mot[j];
Form1->StringGrid1->Cells[2][k]=Form2->rest[i].mot[j];
Form1->StringGrid1->Cells[3][k]="inconnu";
k++;
}
}
//if(is_int(Form2->rest[i].mot[j])) {
//ShowMessage(Form2->rest[i].mot[j]);
//Form1->StringGrid1->Cells[0][j]=IntToStr(i);
//Form1->StringGrid1->Cells[1][j]=Form2->rest[i].mot[j];
//Form1->StringGrid1->Cells[2][j]="oui";
//}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Form1->StringGrid1->Cells[0][0]="référance de mot";
Form1->StringGrid1->Cells[1][0]="Mot";
Form1->StringGrid1->Cells[2][0]="ortho";
Form1->StringGrid1->Cells[3][0]="cgram";
Form1->StringGrid1->Cells[4][0]="ID";
Form1->StringGrid1->Cells[5][0]="nombre";
}
//---------------------------------------------------------------------------
bool __fastcall TForm1::is_int(AnsiString mot)
{
int i; bool R=true;
for(i=1;i<=mot.Length();i++)
{
if(isalpha(mot[i])||mot=="à") return false;
}
return R;
}
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
if (!Edit1->Text.IsEmpty()) // test pour voir si le Edit est vide
{
TLocateOptions Option; // Creer un objet option
Option << loCaseInsensitive; // Rajout de l'option "ne fait pas attention à la casse"
ADOTable1->Locate("ortho",Edit1->Text,Option); /* Recherche l'enregistrement suivant
les critères */
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{
Form1->XMLDocument1->Active = true; // Activer le document avant d'écrire dedans
Form1->XMLDocument1->Version = "1.0";
Form1->XMLDocument1->Encoding = "UTF-8";
AnsiString mot=""; int k=0;
int i=1;
int j=0;
while(j<Form2->rest.size()){
XMLDocument1->DocumentElement = XMLDocument1->CreateElement("phrase"+IntToStr(j),"");
while(i<Form1->StringGrid1->RowCount&&Form1->StringGrid1->Cells[0][i].ToInt()==j) {
AnsiString ART=StringGrid1->Cells[3][i];
AnsiString NOM=StringGrid1->Cells[3][i+1];
AnsiString PER=StringGrid1->Cells[3][i-1];
int p=StringGrid1->RowCount;
if(i+1<p &&i!=0&&PER=="ADJ"&&ART=="ART:def" && NOM=="NOM")
{
//_di_IXMLNode NewStock = XMLDocument1->DocumentElement->AddChild(WideString("GN"+IntToStr(k)));
//NewStock ->Text = WideString(StringGrid1->Cells[1][i]+" "+StringGrid1->Cells[1][i+1]);
//NewStock->SetAttribute(WideString("det"),WideString(StringGrid1->Cells[1][i]));
//NewStock->SetAttribute(WideString("NOM"),WideString(StringGrid1->Cells[1][i+1]));
_di_IXMLNode New = XMLDocument1->DocumentElement->AddChild(WideString("GP"));
_di_IXMLNode ValueNode = New->AddChild(WideString("GN"+IntToStr(k)));
// Ne = NewStock->AddChild(WideString("price"));
ValueNode ->Text = WideString(StringGrid1->Cells[1][i]+" "+StringGrid1->Cells[1][i+1]);
ValueNode ->SetAttribute(WideString("det"),WideString(StringGrid1->Cells[1][i]));
ValueNode ->SetAttribute(WideString("NOM"),WideString(StringGrid1->Cells[1][i+1]));
//New ->Text = WideString(StringGrid1->Cells[1][i]+" "+StringGrid1->Cells[1][i+1]);
New->SetAttribute(WideString("ADJ"),WideString(StringGrid1->Cells[1][i-1]));
New->SetAttribute(WideString("NOM"),WideString("GN"+IntToStr(k)));
k++;
}
else if(i+1<p &&i!=0&&PER=="VER"&&ART=="ART:def" && NOM=="NOM" ) {
_di_IXMLNode New = XMLDocument1->DocumentElement->AddChild(WideString("GV"));
_di_IXMLNode ValueNode = New->AddChild(WideString("GN"+IntToStr(k)));
// Ne = NewStock->AddChild(WideString("price"));
ValueNode ->Text = WideString(StringGrid1->Cells[1][i]+" "+StringGrid1->Cells[1][i+1]);
ValueNode ->SetAttribute(WideString("det"),WideString(StringGrid1->Cells[1][i]));
ValueNode ->SetAttribute(WideString("NOM"),WideString(StringGrid1->Cells[1][i+1]));
//New ->Text = WideString(StringGrid1->Cells[1][i]+" "+StringGrid1->Cells[1][i+1]);
New->SetAttribute(WideString("VER"),WideString(StringGrid1->Cells[1][i-1]));
New->SetAttribute(WideString("NOM"),WideString("GN"+IntToStr(k)));
k++;
}
else if(ART=="ART:def" && NOM=="NOM") {
_di_IXMLNode New = XMLDocument1->DocumentElement->AddChild(WideString("GN"));
New ->Text = WideString(StringGrid1->Cells[1][i]+" "+StringGrid1->Cells[1][i+1]);
New ->SetAttribute(WideString("det"),WideString(StringGrid1->Cells[1][i]));
New ->SetAttribute(WideString("NOM"),WideString(StringGrid1->Cells[1][i+1]));// k++;
}
else if(ART=="VER" && NOM=="NOM") {
_di_IXMLNode New = XMLDocument1->DocumentElement->AddChild(WideString("GV"));
New ->Text = WideString(StringGrid1->Cells[1][i]+" "+StringGrid1->Cells[1][i+1]);
New ->SetAttribute(WideString("VER"),WideString(StringGrid1->Cells[1][i]));
New ->SetAttribute(WideString("NOM"),WideString(StringGrid1->Cells[1][i+1]));// k++;
}
Form1->XMLDocument1->SaveToFile("C:\\Users\\Joker\\Desktop\\XML\\TestXml"+IntToStr(j)+".xml");
mot+=Form1->StringGrid1->Cells[3][i]+" ";
i++;
}
//_di_IXMLNode BorlandStock = XMLDocument1->DocumentElement->ChildNodes->GetNode(0);
//int h=XMLDocument1->DocumentElement
// Form1->ListBox1->Items->Strings[j]=mot; // ShowMessage(XML);
_di_IXMLNode Racine = XMLDocument1->DocumentElement;
int Nb = Racine->ChildNodes->GetCount();
// Récupérer le nom d'un noeud (ici le nom de la racine)
AnsiString Nom = Racine->GetNodeName(); //ShowMessage(Nb);
for(int i=0;i<Nb-1;i++) {
_di_IXMLNode BorlandStock = XMLDocument1->DocumentElement->ChildNodes->GetNode(i);
_di_IXMLNode Borland = XMLDocument1->DocumentElement->ChildNodes->GetNode(i+1);
AnsiString GV= BorlandStock->GetNodeName(); ShowMessage(GV);
AnsiString GP = Borland->GetNodeName();ShowMessage(GP);
if(GV=="GV"&&GP=="GP") {
_di_IXMLNode New = XMLDocument1->DocumentElement->AddChild(WideString("GV"));
BorlandStock=New->AddChild(WideString("GV"));
Borland=New->AddChild(WideString("GP"));
}
Form1->XMLDocument1->SaveToFile("C:\\Users\\Joker\\Desktop\\XML\\TestXml"+IntToStr(j)+".xml");
}
mot="";
j++;
}
} |
Partager