can anyone help me to complete this code

1 回表示 (過去 30 日間)
shafaq innam
shafaq innam 2013 年 5 月 1 日
this code is for generating a text watermark.the code mentioned below reads the text file, and finds the frequently occurring word in it which i named kw.now what i want to do is to make a function that counts the no of characters in a preceding and next word to the keyword(kw) each time kw occurs in the text file. can i get any help about this... fid = fopen('hello.txt');
text = textscan(fid,'%s');
fclose(fid);
text = lower(text{:});
Nwords = numel(text);
[uniqueWords, numericIDs, wordOrder] = unique(text);
numel(uniqueWords);
counts = histc(wordOrder,1:numel(uniqueWords));
[frequency,order] = sort(counts,'descend');
freqcell = num2cell(frequency);
sortedWords = uniqueWords(order);
display([sortedWords(1:3),freqcell(1:3)]);
kw=sortedWords(1);
kwcount=freqcell(1);
disp(kw);

回答 (0 件)

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by