Loop database SQL query through array cell - Text analytics
Show older comments
can someone help me, I can't loop the database through array cell. I'm new in matlab toolbox text analytics. The problem is in the for loop at end but its good to show the all code.
str = get(handles.edit1,'String');
% Erase the punctuation
a = erasePunctuation(str);
% Convert to lowercase
b = lower(a);
% Tokenize the text.
documents = tokenizedDocument(b);
% Remove a list of stop words.
documents = removeWords(documents,stopWords);
% Normalize the words using the Porter stemmer.
documents = normalizeWords(documents);
%convert to cell array
C = doc2cell(documents);
meaning = C{1};
%Show the result to WordList
set(handles.listbox1, 'String', meaning);
% connect to database
dbname = 'database';
username = 'root';
password = 'root';
conn = database(dbname, username, password);
%Here is the problem begin
for i = 1:length(meaning)
% Matching word
sqlquery = ['SELECT meaning FROM translate WHERE meaning LIKE ',meaning{i},''];
curs = exec(conn,sqlquery);
curs = fetch(curs, 1);
word = curs.Data;
set(handles.listbox2, 'String', word);
end
4 Comments
Since we have no way to test your code. What exactly is the problem. You're not getting the result you expect? If so, what result do you get and what did you expect instead? You're getting an error? If so, what is the error message? The problem is something else? If so, what?
Please use, the {}Code button to format your code appropriately. It should look like this rather than the unreadable mess that you have:
str = get(handles.edit1,'String');
% Erase the punctuation
a = erasePunctuation(str);
Doudou Bety
on 8 Nov 2017
Edited: Doudou Bety
on 8 Nov 2017
Guillaume
on 8 Nov 2017
Again, What exactly is the problem?
- You're not getting the result you expect? If so, what result do you get and what did you expect instead?
- You're getting an error? If so, what is the error message?
- The problem is something else? If so, what?
Again, we have no way to test your code since we don't have access to your database, nor do we have your inputs.
Doudou Bety
on 8 Nov 2017
Answers (0)
Categories
Find more on Database Toolbox 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!