Is there any way to check spelling from within MATLAB?
33 views (last 30 days)
Show older comments
MathWorks Support Team
on 13 Jun 2013
Answered: Pedro Busc
on 24 Aug 2022
I would like to be able to check the spelling of a word within MATLAB without having to write my own spell checking algorithm.
Accepted Answer
MathWorks Support Team
on 13 Jun 2013
There is currently no spell checking functionality contained in MATLAB. However, using ActiveX, you can implement the spell checker of another program and bring the results back to MATLAB. The following example shows how to do this using Microsoft Word's spell checker:
function suggestion = checkSpelling(word)
%CHECKSPELLING uses MSWord to correct spelling
% CHECKSPELLING(WORD) checks the spelling of WORD and returns spelling
% suggestions as a cell array. If WORD is spelled correctly, CHECKSPELLING
% will return empty brackets. If no suggestions are found. CHECKSPELLING
% returns 'no suggestions'.
%Start the Word ActiveX Server and check the spelling of WORD
h = actxserver('word.application');
h.Document.Add;
correct = h.CheckSpelling(word);
if correct
suggestion = []; %return empty if spelled correctly
else
%If incorrect and there are suggestions, return them in a cell array
if h.GetSpellingSuggestions(word).count > 0
count = h.GetSpellingSuggestions(word).count;
for i = 1:count
suggestion{i} = h.GetSpellingSuggestions(word).Item(i).get('name');
end
else
%If incorrect but there are no suggestions, return this:
suggestion = 'no suggestions';
end
end
%Quit Word to release the server
h.Quit
Currently there is no workaround for platforms other than Windows.
0 Comments
More Answers (1)
Pedro Busc
on 24 Aug 2022
The question is from 2013... Now it is 2022, 9 years latter and.... Nothing, no speel checker for comments.
Is there a dev team working on Matlab or what?? For Visual Studio we just add a pluging and it is done.
0 Comments
See Also
Categories
Find more on Programming Utilities in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!