Pascal/Turbo Pascal - Ayuda! , separar en silabas con las 10 condiciones

 
Vista:
Imágen de perfil de Alejandro

Ayuda! , separar en silabas con las 10 condiciones

Publicado por Alejandro (2 intervenciones) el 07/12/2014 04:15:58
PRIMERO: estas son las consonantes inseparables (br, bl, cr, cl, dr, fr, fl, gr, gl, kr, ll, pr, pl, tr, rr, ch) aquellas que al separar una palabra estas no se dispersan ej : callar= ca llar (ll), computador = com pu ta dor (mp no es consonante inseparable) , NECECITO UN METODO PARA HALLARLAS EN UN FUNCTION PARA LUEGO PODER LLAMARLA A MI BEGIN END.

SEGUNDO:como puedo eliminar el stack overflow error ? , en la regla numero 7(diptongo) me da este error , encierro uno de los "if" en llaves como un comentario y el programa me corre , pero porsupusto no esta leyendo dicho if . Trate de "duplicar" los functions "va" y "vc" o mejor dicho cree otros nuevos con otros nombres y estos hacian lo mismo que va y vc pero me sigue dando el stack overflow error.


TERCERO:en la regla 9(acentuacion) no me separa la palabra como es , es decir , cuando escribo la palabra mama la separa como : ma ma , pero si introduzco la palabra mamá con acento en la a no separa nada




program separarsilabas;
uses crt;


var

i:integer;
frase:string;

function hache(frase:string):boolean;
var i:integer;
begin
hache:= false;
for i:=1 to length(frase) do
case frase[i] of
'h','H': hache:= true;
end;
end;


function v(frase:string):boolean;
var i:integer;
begin
v:= false;
for i:=1 to length(frase) do
case frase[i] of
'a','e','i','o','u','A','E','i','O','U','y','Y': v:= true;
end;
end;


function va(frase:string):boolean;
var i:integer;
begin
va:= false;
for i:=1 to length(frase) do
case frase[i] of
'a','e','o','A','E','O': va := true;
end;
end;

function vc(frase:string):boolean;
var i:integer;
begin
vc:= false;
for i:=1 to length(frase) do
case frase[i] of
'i','u','I','U','y','Y': vc := true;
end;
end;

function consonante(frase:string):boolean;
var i:integer;
begin
consonante:= false;
for i:=1 to length(frase) do
case frase[i] of {borre h}
'b','c','d','f','g','i','j','k','l','m','n','p','q','r','s','t','v','w','x','z': consonante:= true;
end;
end;

function vcvocacent(frase:string):boolean;
var i:integer;
begin
vcvocacent:= false;
for i:=1 to length(frase) do
case frase[i] of
'¡','£': vcvocacent:= true;
end;
end;

function vavocacent(frase:string):boolean;
var i:integer;
begin
vavocacent:= false;
for i:=1 to length(frase) do
case frase[i] of
' ','‚','¢': vavocacent:= true;
end;
end;

begin

clrscr;
writeln;
writeln('indique la frase u oracion a separar en silabas:');
readln(frase);
{REGLA 3(UNA CONSONANTE ENTRE 2 VOCALES)} {une : u ne}
for i:= 1 to length(frase+frase) do
begin
if (v(frase[i]) = true) and (consonante(frase[i+1])= true ) and (v(frase[i+2]) = true) then

insert (' ',frase,i+1)

else
{REGLA 4(DOS CONSONANTES ENTRE 2 VOCALES)} {agregar condicion cc} {componer : com po ner}
if (v(frase[i]) = true) and (consonante(frase[i+1])= true )
and (consonante (frase[i+2]) = true) and ( v(frase[i+3]) = true) then

insert (' ',frase,i+2)

else
{REGLA 5(TRES CONSONANTES ENTRES 2 VOCALES)} {agregar condicion cc} {transporte : trans por te}
if (v(frase[i]) = true) and (consonante(frase[i+1])= true )
and (consonante (frase[i+2]) = true) and ( consonante(frase[i+3]) = true) and
(v(frase[i+4]) = true) then

insert (' ',frase,i+3)

else
{REGLA 6(INTRODUCCION DE 'H')} {anhelo : an he lo}
if ((v(frase[i]) = true) and (consonante(frase[i+1]) = true)
and (hache(frase[i+2]) = true) and(v(frase[i+3]) = true)) or
((v(frase[i]) = true) and (hache(frase[i+1]) = true)
and (consonante(frase[i+2]) = true) and (v(frase[i+3]) = true)) then

insert (' ',frase,i+2)

else
{REGLA 7(DIPTONGO)} {seleccion : se lec cion}
if ((va(frase[i]) = true) and (vc(frase[i+1])=true) and (consonante(frase[i+2])=true)) or
((vc(frase[i]) = true) and (va(frase[i+1])=true) and (consonante(frase[i+2])=true)) or
((vc(frase[i]) = true) and (vc(frase[i+1])=true) and (consonante(frase[i+2])=true)) or
((va(frase[i]) = true) and (va(frase[i+1])=true) and (consonante(frase[i+2])=true)) then

insert (' ',frase,i+3)


else
{sleccionar : se lec cio nar}
if ((va(frase[i]) = true) and (vc(frase[i+1])=true)
and (consonante(frase[i+2])=true) and (v(frase[i+3]) = true)) or
((vc(frase[i]) = true) and (va(frase[i+1])=true)
and (consonante(frase[i+2])=true) and (v(frase[i+3]) = true)) then

insert (' ',frase,i+4)

else
{ esto hace lo mismo que el de arriba pero con vc+vc y va+va}
if ((vc(frase[i]) = true) and (vc(frase[i+1])=true)
and (consonante(frase[i+2])=true) and (v(frase[i+3]) = true)) or
((va(frase[i]) = true) and (va(frase[i+1])=true)
and (consonante(frase[i+2])=true) and (v(frase[i+3]) = true)) then

insert (' ',frase,i+4)


else
{REGLA 8 (H ENTRE 2 VOCALES)}
if (v(frase[i]) = true) and (hache(frase[i+1]) = true) and (v(frase[i+2]) = true) then
insert(' ',frase,i+3)

else

{REGLA 9(ACENTUACION)} {corregir error ,ej: mari   , ma ri  }
if ((vavocacent(frase[i]) = true) and (vc(frase[i+1])=true)) or
((vcvocacent(frase[i]) = true) and (va(frase[i+1])=true)) or
((va(frase[i]) = true) and (vcvocacent(frase[i+1])=true)) or
((vc(frase[i]) = true) and (vavocacent(frase[i+1])=true)) or
((vcvocacent(frase[i]) = true) and (vc(frase[i+1])=true)) or
((vc(frase[i]) = true) and (vcvocacent(frase[i+1])=true)) then

insert (' ',frase,i+1)

else

if (vavocacent(frase[i]) = true) and (va(frase[i+1])=true) or
(va(frase[i]) = true) and (vavocacent(frase[i+1])=true) then

insert (' ',frase,i+1)


{ else

{REGLA 10(TRIPTONGO)
if ((vc(frase[i]) = true) and (va(frase[i+1])= true) and (vc(frase[i+2]) = true)) then


insert (' ',frase,i+4);}
end;

writeln;
writeln(frase);
readln;

end.
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

Ayuda! , separar en silabas con las 10 condiciones

Publicado por ramon (2158 intervenciones) el 19/12/2014 21:05:40
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
{Mira te corrijo el programa para lo que pides pero tendrás que afinar mas
 el stack overflow error  esta causado por el incremento del string con insert}
 
 program separarsilabas;
 uses
   crt;
   type
   string2 = string[2];
 
  const
    consonant2 : array[1..16] of string2 = (
  'br', 'bl', 'cr', 'cl', 'dr', 'fr', 'fl', 'gr',
  'gl', 'kr', 'll', 'pr', 'pl', 'tr', 'rr', 'ch');
 
 
 
  var
      ti, i : integer;
      frase : string;
 
 
  function consonantes2(ff : string) : string2;
  var
  ii, hh : integer;
 begin
    consonantes2 := '  ';
    for ii := 1 to length(ff) - 1 do
    begin
       for hh := 1 to 16 do
       if (ff[ii] = consonant2[hh][1]) and
           (ff[ii + 1] = consonant2[hh][2]) then
      begin
         consonantes2 := ff[ii] + ff[ii + 1];
         break;
      end;
    end;
 end;
 
  function hache(ff : string) : boolean;
  begin
    hache := false;
    for ti := 1 to length(ff) do
    begin
    if ff[ti] in['h','H'] then
    begin
    hache := true;
    break;
    end;
   end;
  end;
 
  function v(ff : string) : boolean;
  begin
    v := false;
    for ti := 1 to length(ff) do
    begin
      if ff[ti] in['a','e','i','o','u','A','E','i','O','U','y','Y'] then
      begin
         v := true;
         break;
      end;
    end;
  end;
 
  function va(ff : string) : boolean;
  begin
    va := false;
   for ti := 1 to length(ff) do
   begin
      if ff[ti] in['a','e','o','A','E','O'] then
      begin
       va := true;
       break;
     end;
   end;
  end;
 
  function vc(ff : string) : boolean;
  begin
    vc := false;
    for ti := 1 to length(ff) do
    begin
      if ff[ti] in['i','u','I','U','y','Y'] then
      begin
        vc := true;
        break;
     end;
    end;
   end;
 
   function consonante(ff : string) : boolean;
   begin
     consonante := false;
     for ti := 1 to length(ff) do
     begin
    if ff[ti] in['b','c','d','f','g','i','j','k','l','m','n','p',
                   'q','r','s','t','v','w','x','z'] then {borre h}
    begin
    consonante:= true;
    break;
    end;
   end;
  end;
 
 function vcvocacent(ff : string) : boolean;
 begin
     vcvocacent := false;
     for ti := 1 to length(ff) do
     begin
     if ff[ti] in['¡','£'] then
     begin
     vcvocacent:= true;
     break;
     end;
   end;
 end;
 
 function vavocacent(ff : string) : boolean;
 begin
     vavocacent := false;
     for ti := 1 to length(ff) do
     begin
     if ff[ti] in[' ','‚','¢'] then
     begin
       vavocacent:= true;
       break;
     end;
   end;
  end;
 
 
 
  begin
     clrscr;
     writeln;
     write('   indique la frase u oracion a separar en silabas : ');
     readln(frase);
     writeln('   Alguna Consonante Dable = ',consonantes2(frase));
     {REGLA 3(UNA CONSONANTE ENTRE 2 VOCALES)} {une : u ne}
     for i:= 1 to length(frase) do
     begin
         if (v(frase[i]) = true) and (consonante(frase[i + 1]) = true ) and
                           (v(frase[i + 2]) = true) then
         begin
          insert(' ',frase,i + 1);
          i := i + 3;
         end;
    {REGLA 4(DOS CONSONANTES ENTRE 2 VOCALES)} {agregar condicion cc} {componer : com po ner}
     if (v(frase[i]) = true) and (consonante(frase[i+1])= true ) and
         (consonante(frase[i+2]) = true) and ( v(frase[i+3]) = true) then
     begin
      insert(' ',frase,i + 2);
      i := i + 5;
     end;
    {REGLA 5(TRES CONSONANTES ENTRES 2 VOCALES)} {agregar condicion cc} {transporte : trans por te}
     if (v(frase[i]) = true) and (consonante(frase[i + 1]) = true ) and
        (consonante (frase[i + 2]) = true) and
        (consonante(frase[i + 3]) = true) and (v(frase[i + 4]) = true) then
        begin
         insert (' ',frase,i + 3);
         i := i + 7;
        end;
    {REGLA 6(INTRODUCCION DE 'H')} {anhelo : an he lo}
    if ((v(frase[i]) = true) and (consonante(frase[i+1]) = true) and
    (hache(frase[i+2]) = true) and(v(frase[i+3]) = true)) or
    ((v(frase[i]) = true) and (hache(frase[i+1]) = true) and
    (consonante(frase[i+2]) = true) and (v(frase[i+3]) = true)) then
    begin
    insert(' ',frase,i + 2);
    i := i + 5;
    end;
    {REGLA 7(DIPTONGO)} {seleccion : se lec cion}
   if ((va(frase[i]) = true) and (vc(frase[i + 1]) = true) and
   (consonante(frase[i + 2]) = true)) or
   ((vc(frase[i]) = true) and (va(frase[i + 1]) = true) and
   (consonante(frase[i + 2]) = true)) or ((vc(frase[i]) = true) and
   (vc(frase[i + 1]) = true) and (consonante(frase[i + 2]) = true)) or
   ((va(frase[i]) = true) and (va(frase[i + 1]) = true) and
   (consonante(frase[i + 2]) = true)) then
   begin
   insert (' ',frase,i + 3);
   i := i + 5;
   end;
    {sleccionar : se lec cio nar}
    if ((va(frase[i]) = true) and (vc(frase[i + 1]) = true) and
       (consonante(frase[i + 2]) = true) and (v(frase[i + 3]) = true)) or
       ((vc(frase[i]) = true) and (va(frase[i + 1]) = true) and
       (consonante(frase[i + 2]) = true) and (v(frase[i + 3]) = true)) then
       begin
       insert(' ',frase,i + 4);
       i := i + 7;
       end;
     { esto hace lo mismo que el de arriba pero con vc+vc y va+va}
     if ((vc(frase[i]) = true) and (vc(frase[i + 1]) = true) and
        (consonante(frase[i + 2]) = true) and (v(frase[i + 3]) = true)) or
        ((va(frase[i]) = true) and (va(frase[i + 1]) = true) and
        (consonante(frase[i + 2]) = true) and (v(frase[i + 3]) = true)) then
        begin
        insert(' ',frase,i + 4);
        i := i + 7;
        end;
    {REGLA 8 (H ENTRE 2 VOCALES)}
     if (v(frase[i]) = true) and (hache(frase[i + 1]) = true) and
        (v(frase[i + 2]) = true) then
        begin
          insert(' ',frase,i + 3);
          i := i + 5;
          end;
     {REGLA 9(ACENTUACION)} {corregir error ,ej: mari   , ma ri  }
     if ((vavocacent(frase[i]) = true) and (vc(frase[i + 1]) = false)) or
        ((vcvocacent(frase[i]) = true) and (va(frase[i + 1]) = false)) or
        ((va(frase[i]) = false) and (vcvocacent(frase[i + 1]) = true)) or
        ((vc(frase[i]) = false) and (vavocacent(frase[i + 1]) = true)) or
        ((vcvocacent(frase[i]) = true) and (vc(frase[i + 1]) = false)) or
        ((vc(frase[i]) = false) and (vcvocacent(frase[i + 1]) = true)) then
        begin
          insert(' ',frase,i);
          i := i + 1;
        end;
    if (vavocacent(frase[i]) = true) and (va(frase[i + 1]) = true) or
       (va(frase[i]) = true) and (vavocacent(frase[i + 1]) = true) then
       begin
       insert(' ',frase,i + 1);
       i := i + 2;
       end;
   end;
   writeln;
   writeln('   ',frase);
   readkey;
  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