Loop database SQL query through array cell - Text analytics
显示 更早的评论
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 个评论
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
2017-11-8
编辑:Doudou Bety
2017-11-8
Guillaume
2017-11-8
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
2017-11-8
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!