public static List<LinkedHashMap<String, Object>> getPhrases(
      GraphDatabaseService db, String text, GraphManager graphManager) {
    // This method trains a model on a supplied label and text content
    Map<Long, Integer> patternMatchers =
        PatternMatcher.match(GraphManager.ROOT_TEMPLATE, text, db, graphManager);

    // Translate map to phrases
    List<LinkedHashMap<String, Object>> results =
        patternMatchers
            .keySet()
            .stream()
            .map(
                a -> {
                  LinkedHashMap<String, Object> linkHashMap = new LinkedHashMap<>();
                  linkHashMap.put("feature", NodeManager.getNodeFromGlobalCache(a).get("phrase"));
                  linkHashMap.put("frequency", patternMatchers.get(a));
                  return linkHashMap;
                })
            .collect(Collectors.toList());

    results.sort(
        (a, b) -> {
          Integer diff = ((Integer) a.get("frequency")) - ((Integer) b.get("frequency"));
          return diff > 0 ? -1 : diff.equals(0) ? 0 : 1;
        });

    return results;
  }
  private Vector<String> checkEntries(String[] entries, File parent, String prefix) {

    if (entries == null) {
      return null;
    }

    Vector<String> matches = new Vector<String>();
    for (String listEntry : entries) {
      File tempFile;
      if (!"".equals(prefix)) {
        tempFile = new File(parent, prefix + "/" + listEntry);
      } else {
        tempFile = new File(parent, listEntry);
      }
      if (tempFile.isDirectory() && !(".".equals(listEntry) || "..".equals(listEntry))) {
        if (!"".equals(prefix)) {
          matches.addAll(checkEntries(tempFile.list(), parent, prefix + "/" + listEntry));
        } else {
          matches.addAll(checkEntries(tempFile.list(), parent, listEntry));
        }
      } else {

        String entryToCheck;
        if ("".equals(prefix)) {
          entryToCheck = listEntry;
        } else {
          entryToCheck = prefix + "/" + listEntry;
        }

        if (compared.contains(entryToCheck)) {
          continue;
        } else {
          compared.add(entryToCheck);
        }

        boolean doesMatch =
            patternMatcher.match(new HashMap<String, String>(), entryToCheck, compiledPattern);
        if (doesMatch) {
          matches.add(entryToCheck);
        }
      }
    }
    return matches;
  }