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!