code: public static String toCNF(INode in, String formula) throws ContextClassifierException {
  
          PEParser parser = new PEParser();
          CNFTransformer transformer = new CNFTransformer();
  
          String result = formula;
          if ((formula.contains("&") && formula.contains("|")) || formula.contains("~")) {
              String tmpFormula = formula;
              tmpFormula = tmpFormula.trim();
              tmpFormula = tmpFormula.replace("&", "AND");
              tmpFormula = tmpFormula.replace("|", "OR");
              tmpFormula = tmpFormula.replace("~", "NOT");
              tmpFormula = "(" + tmpFormula + ")";
  
              if (!tmpFormula.isEmpty()) {
                  tmpFormula = tmpFormula.replace('.', 'P');
                  Sentence f = (Sentence) parser.parse(tmpFormula);
                  Sentence cnf = transformer.transform(f);
                  tmpFormula = cnf.toString();
  
                  tmpFormula = tmpFormula.replace("AND", "&");
                  tmpFormula = tmpFormula.replace("OR", "|");
                  tmpFormula = tmpFormula.replace("NOT", "~");
  
                  result = tmpFormula.replace('P', '.');
              } else {
                  result = tmpFormula;
              }
  
          }
          return result;
      }
docs: Converts the formula into CNF.
  
  @param in the owner of the formula
  @param formula the formula to convert
  @return formula in CNF form
  @throws ContextClassifierException ContextClassifierException