예제 #1
0
  public List<String> getNextNeighbors(Node nextSib) {
    if (nextSib == null) {
      return null;
    }

    String data;
    StringBuilder sb = new StringBuilder();
    String[] neighbors;
    List<String> retList = new ArrayList<String>();
    int count = 0;
    while (count < 5) {
      data = getData(nextSib);
      if (data == null) {
        break;
      }
      neighbors = data.split(" ");
      for (String s : neighbors) {
        if (count == 5) {
          break;
        }
        if (!s.matches("^[a-zA-Z0-9]+$")) {
          s = s.replaceAll("[^\\p{Alpha}\\p{Digit}]+", "");
        }
        sb.append(s.toLowerCase());
        count++;
        sb.append(" ");
      }
      nextSib = nextSib.nextSibling();
    }
    for (String s : sb.toString().split(" ")) {
      retList.add(s);
    }
    return retList;
  }