function KB = BR_s2KB(s)
% BR_s2KB - convert logical sentence to KB
% On input:
%     s (string): logical sentence (fully parenthesized)
% On output:
%     KB (KB data structure): knowledge base
%       (k).clauses (vector): or clause
%       (k).prob (float): probability of clause
% Call:
%     s7 = '((((1)^(2))v((3)^(4)))v((5)^(6)))';
%     s7a = BR_switch_vars(s7,6);
%      KB = BR_s2KB(s7a);
% Author:
%     T. Henderson
%     UU
%     Fal 2018
%

s = BR_s2CNF(s);

frontier = [1];
sentences(1).s = s;
num_sentences = 1;
num_clauses = 0;

while ~isempty(frontier)
    s = sentences(frontier(1)).s;
    frontier = frontier(2:end);
    if BR_only_OR(s)
        num_clauses = num_clauses + 1;
        clauses(num_clauses).clause = s;
    else
        [S1,S2] = BR_getANDargs(s);
        num_sentences = num_sentences + 1;
        sentences(num_sentences).s = S1;
        num_sentences = num_sentences + 1;
        sentences(num_sentences).s = S2;
        frontier = [frontier,num_sentences-1,num_sentences];
    end
end
n = 0;
for s = 1:num_sentences
    if BR_only_OR(sentences(s).s)
        n = n + 1;
        KB(n).clauses = BR_s2clause(sentences(s).s);
        KB(n).prob = 0;
    end
end

tch = 0;
