public static void main(String[] args) {
    TestUser user = null;
    try {
      user = new TestUser(2899, 5213);
      user.getLogger().setEnabled(false);

      DrugDescriptionMatcher matcher = new DrugDescriptionMatcher(user);

      ArrayList descriptions = getTestDescriptions(user);
      Iterator iter = descriptions.iterator();
      while (iter.hasNext()) {
        String desc = (String) iter.next();

        // ArrayList drugs = matcher.match("Amoxicillin 250 mg cap",1);
        ArrayList drugs = matcher.match(desc);

        if (Lists.isEmpty(drugs)) {
          System.out.println(desc + ":\n--> No drugs found.");
        } else {
          System.out.println(desc + ":\n--> Found " + drugs.size() + " drugs:");

          Iterator drugIter = drugs.iterator();
          while (drugIter.hasNext()) {
            Drug drug = (Drug) drugIter.next();
            System.out.println(
                "--> ID " + drug.getID() + ": " + drug.getName() + " " + drug.getFormula());
          }
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      user.finish();
    }
  }
Esempio n. 2
0
  public boolean isLeaf() {
    if (!open) {
      // Debug.println("leaf because closed");
      return true;
    }

    if (Lists.isEmpty(node.children) && Lists.isEmpty(node.drugs)) {
      // Debug.println("leaf because no children");
      return true;
    }

    return false;
  }
  public Drug matchOne(String description) throws IOException {
    ArrayList list = match(description, 0);
    if (Lists.isEmpty(list)) return null;

    return (Drug) list.get(0);
  }