function KB = CS_SATCNF2KB(fn)
% CS_SATCNF2KB - convert SAT .xz --> .cnf files to struct KB
% On input:
%     fn (string): SAT.cnf filename
% On output:
%     KB (struct KB): KB info
%      (k).clauses (1xk vector): disjunction as integers
%      (k).prob (float): probability of clause (==1 for SAT)
% Call:
%     KBSAT1 = CS_SATCNF2KB('testSAT1.cnf');
% Author:
%     T. Henderson
%     UU
%     Summer 2022
%

fid = fopen(fn,'r');
KB = [];
% s = fgets(fid);
% if s==-1
%     fclose(fid);
%     return
% end
% s = fgets(fid);
% if s==-1
%     fclose(fid);
%     return
% end

done = 0;
index = 0;
while done==0
    s = fgets(fid);
    if s==-1
        fclose(fid);
        return
    elseif s(1)=='-'|s(1)=='1'|s(1)=='2'|s(1)=='3'|s(1)=='4'|s(1)=='5'...
            |s(1)=='6'|s(1)=='7'|s(1)=='8'|s(1)=='9'
        sn = str2num(s);
        index = index + 1;
        KB(index).clauses = sn(1:end-1);
        KB(index).prob = 1;
    end
end
