필터 지우기
필터 지우기

error in stemming code

조회 수: 1 (최근 30일)
prabi p
prabi p 2016년 4월 18일
답변: Walter Roberson 2016년 4월 23일
>> find_stems Error using cellfun Non-scalar in Uniform output, at index 1, output 1. Set 'UniformOutput' to false.
Error in find_stems (line 3) results = cellfun(@porterdupe, t); ---------------------------------------------------------------------
code: find_stems.m function results = find_stems() t = simple(); results = cellfun(porterdupe, t);
--------------------------------------------- code: porterdupe.m
function [stem] = porterdupe(y) t = y; global j; b = t; k = length(b); k0 = 1; j = k; % With this if statement, strings of length 1 or 2 don't go through the % stemming process. Remove this conditional to match the published % algorithm. %stem = simple(b);
if k > 2 % Output displays per step are commented out. %disp(sprintf('Word to stem: %s', b));
x = step1ab(b, k, k0);
%disp(sprintf('Steps 1A and B yield: %s', x{1}));
x = step1c(x{1}, x{2}, k0);
%disp(sprintf('Step 1C yields: %s', x{1}));
x = step2(x{1}, x{2}, k0);
%disp(sprintf('Step 2 yields: %s', x{1}));
x = step3(x{1}, x{2}, k0);
%disp(sprintf('Step 3 yields: %s', x{1}));
x = step4(x{1}, x{2}, k0);
%disp(sprintf('Step 4 yields: %s', x{1}));
x = step5(x{1}, x{2}, k0);
%disp(sprintf('Step 5 yields: %s', x{1}));
stem = x{1};
end end
% cons(j) is TRUE = b[j] is a consonant.
function c = cons(i, b, k0) c = true; switch(b(i)) case {'a', 'e', 'i', 'o', 'u'} c = false; case 'y' if i == k0 c = true; else c = ~cons(i - 1, b, k0); end end end

답변 (1개)

Walter Roberson
Walter Roberson 2016년 4월 23일
cellfun(@porterdupe, t, 'uniform', 0);

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by