【发布时间】:2016-01-20 06:42:57
【问题描述】:
我有两个元胞数组,每个元胞都存储一元和二元,它们是我从文本文件中提取的。现在我必须将每个 unigram 与 bigram 进行比较,以找到 bigram 中出现的 unigram 的计数和后来的概率。谁能帮我解决这个问题,我已经使用了 strcmp 但它不起作用。我在下面写我的代码:
for i = 1
for j = 1:bigramRow
bigram1 = regexp(splitBigramCellsA{j},'<s>|\w*|</s>','match');
b1 = cellfun(@(x,y)[x], bigram1(1:end-1)','un',0)
match = strcmp(splitUnigramCellsA, splitBigramCellsA{j,1});
if match ==1
bigram1count = splitbigramCellsB{j};
unigram1count = splitUnigramCellsB{j};
disp(bigram1count)
disp(unigram1count)
end
end
end
【问题讨论】:
-
你能解释一下一元和二元是什么吗? splitBigramCells 包含什么?
-
Unigrams 是句子中每个唯一的单词。 Bigrams是一次取两个词。例如:'It is a lovely day',包含二元组、'It is'、'is a'、'a lovely'、'lovely day'。