Pascal/Turbo Pascal - TDA

 
Vista:

TDA

Publicado por Martin (6 intervenciones) el 16/08/2012 07:09:25
hola necesito realizar un diccionario de sinónimos con listas y tda , osea que cuando ingreso una palabra me muestre los sinónimos de dicha palabra, alguien que me pueda ayudar?????? gracias...
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

TDA

Publicado por ramon (2158 intervenciones) el 01/09/2012 17:57:31
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
{A ver esto es para que tu te a gas una idea de como es pero lo puedes realizar a tu manera
 las frases y sinónimos los pongo e una constante y los cargo en archivo para luego poder
 manejar los espero te ayude.}
 
program sinonimos;
 uses
   crt;
 
 type
 datosdic = record
    dat : string;
   end;
 
const
  datodic : array[1..22] of string = (
'amplificar, = ampliar',
'afan, = anhelo, ansia, deseo',
'advertir, = prevenir, avisar',
'aerolito, = meteorito',
'boda, = matrimonio',
'bonito, = hermoso',
'bondadoso, = benévolo',
'boleto, = billete',
'cabello, = pelo',
'calido, = caliente, caluroso',
'cama, = lecho',
'camino, = via, sendero',
'causa, = motivo',
'comite, = junta, delegacion',
'danza, = baile',
'ebrio, = borracho',
'economizar, = ahorrar',
'eden, = paraiso',
'educar, = ense¤ar',
'elegir, = escoger',
'embuste, = mentira',
'enfurecer, = enojar');
 
 var
   f : file of datosdic;
   dta : datosdic;
 
 procedure cargadicio;
 var
   d : integer;
 begin
     assign(f,'dicsino.dcc');
  {$I-} reset(f); {$I+}
  if ioresult <> 0 then
  begin
     rewrite(f);
     for d := 1 to 22 do
     begin
        seek(f,d - 1);
        dta.dat := copy(datodic[d],1,length(datodic[d]));
        write(f,dta);
     end;
   end
  else
     begin
        seek(f,filesize(f));
        write(f,dta);
     end;
     close(f);
 end;
 
 procedure ampliardici;
 var
   tec : char;
 begin
     clrscr;
     writeln(' *** Ampliacion Dicionario *** ');
     writeln('Ejemplo : cabello, = pelo');
     writeln;
     writeln('Entre nuevo dato : ');
     read(dta.dat);
     writeln;
     writeln('Desea Guardarlo [S/N]');
     repeat
     tec := upcase(readkey);
     until tec in['S','N'];
     if tec = 'S' then
     begin
        cargadicio;
     end;
 end;
 
 procedure busquedaendiccionario;
 var
   sinonimo, tomado, frase : string;
   i : longint;
   t : integer;
   sal, encot : boolean;
 begin
     clrscr;
     write(' Entre Frase : ');
     read(frase);
     assign(f,'dicsino.dcc');
  {$I-} reset(f); {$I+}
  if ioresult <> 0 then
  begin
      writeln(' Archivo no  encontrado pulse [Enter]');
      readln;
      halt(1);
  end;
    i := 0;
    repeat
    seek(f,i);
    read(f,dta);
    t := 1;
    fillchar(tomado,65,' ');
    encot := false;
    sal := false;
    repeat
       if dta.dat[t] = ',' then
       begin
          sal := true;
       end
    else
       begin
          tomado[t] := dta.dat[t];
          tomado[0] := chr(t);
       end;
       t := t + 1;
    until (t > length(dta.dat)) or (sal = true);
    if tomado = frase then
    begin
       encot := true;
    end;
    i := i + 1;
    until (encot = true) or (i > filesize(f) - 1);
    close(f);
    if encot = true then
    begin
       for t := 1 to length(dta.dat) do
       begin
          if dta.dat[t] = '=' then
          begin
              sinonimo := copy(dta.dat,t + 1,length(dta.dat));
              break;
          end;
       end;
       writeln(' La Frase Es [ ',frase,' ]');
       writeln(' y El o Los sininimos [',sinonimo,']');
       writeln(' Pulse [Enter]');
       readkey;
    end
  else
     begin
        writeln('La Frase [',frase,'] No Encontrada Pulse [Enter]');
        readkey;
     end;
 end;
 
 procedure menu;
 var
   tecla : char;
   termina : boolean;
 begin
  termina := false;
  repeat
     clrscr;
     writeln('**** Menu General ****');
     writeln;
     writeln(' C = Cargar Diccionario De Nuebo Si Esta Cargado Ya');
     writeln(' A = Ampliar Datos En El Diccionario');
     writeln(' B = Buscar Sinonimo En Diccionario');
     writeln(' S = Salir');
     writeln;
     writeln(' Elija Opcion');
     repeat
     tecla := upcase(readkey);
     until tecla in['C','A','B','S'];
   case tecla of
  'C' : begin clrscr; cargadicio; end;
  'A' : begin clrscr; ampliardici; end;
  'B' : begin clrscr; busquedaendiccionario; end;
  'S' : termina := true;
    end;
  until termina = true;
  end;
 
 begin
     menu;
 end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar