-
Notifications
You must be signed in to change notification settings - Fork 1
/
corrector.m
44 lines (40 loc) · 1.2 KB
/
corrector.m
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
function z=corrector(palabra)
h=actxserver('word.application');
h.Document.Add;
% h.CheckGrammar('Las cosas habian llegada lan lrjos para el')
correcto = h.CheckSpelling(palabra);
if correcto
sugerencias=0; %Si es correcto no regresa nada
else
%Si es incorrecto regresa una celda con las sugerencias
if h.GetSpellingSuggestions(palabra).count > 0
sugerencias = h.GetSpellingSuggestions(palabra).count;
for i = 1:sugerencias
sugerir{i} = h.GetSpellingSuggestions(palabra).Item(i).get('name');
end
else
%Sin Sugerencias
sugerencias=0;
end
end
%Cerrar Word
h.Quit
%Seleccionar la primera sugerencia
if sugerencias>0
for i = 1:sugerencias
if length(palabra)==length(sugerir{i})
corregido=sugerir{i}
return;
else
corregido=palabra;
end
end
else
corregido=palabra;
end
% if sugerencias==1
% corregido=sugerir{i};
% else
% corregido=palabra;
% end
z=corregido;