function [total_id, keep_id, totalWords] = csvReader(filename, n_words)
%
%%usage: [sent_ind, sent_len, totalWords] = csvReader(filename, n_words)
%%ptb:<s>: id 45, </s>: id 44
%%wiki:<s>: id 44, </s>: id 43
%%append n_words <s> before each sentences and  </s> at the end of each
fid=fopen(filename,'r');
total_id=[];
sent_len=[];
count = 1;
k = 0;
while 1
    textline=fgetl(fid);
    if ~ischar(textline), break, end
    data=regexp(textline, ',', 'split');
    len = length(data);
    sent_len(count,1) = len + n_words + 1;
    total_id(k+1:k+n_words,1) = 44;
    k = k + n_words;
    total_id(k+1:k+len,1) = str2double(data) + 1;
    k = k+ len + 1;
    total_id(k,1) = 43;
    count = count + 1;
end
totalWords = sum(sent_len);
fclose(fid);
fprintf('total_id part done\n');
%%%%%
keep_sent_len = sent_len - n_words;
realSamples = sum(keep_sent_len,1);
keep_id = zeros(realSamples,1);
k = 0;
m = 0;
for i =  1 : size(keep_sent_len,1)
    keep_id(k+1:k+keep_sent_len(i),1) = m+1 : m+keep_sent_len(i);
    k = k + keep_sent_len(i);
    m = m + keep_sent_len(i) + n_words;
end
%%

