function data = make_data(domain, label_percent)
% creates a struct containing x, t, train, and test fields
% train and test are logical arrays indicating different trials' data

load([domain '.mat']); % this loads pos, neg, unl (but we'll skip unl and just divide pos/neg into labeled and unlabeled)
clear unl

%features = textread([domain '.features'], '%s', 'delimiter', '\n');

X = [pos; neg];
Y = [ones(size(pos,1),1); -ones(size(neg,1),1)];

data = struct('x', X, 't', Y); %, 'features', features);

[n,d] = size(X);

trials = 100;

train = zeros(trials,n);
test = zeros(trials,n);

lab_size = floor(label_percent * n);

for t = 1:trials,
    fprintf('Generating trial %d\n', t);
    randidx = randperm(n);
        
    train(t,randidx(1:lab_size)) = true;
    train(t,randidx(lab_size+1:end)) = false;    

    test(t,randidx(1:lab_size)) = false;
    test(t,randidx(lab_size+1:end)) = true;
end

train = logical(train);
test = logical(test);

data.train = train;
data.test = test;
