Exemplo n.º 1
0
 public void sortFiles() {
   Iterator<Node> iterator = placeList.iterator();
   Collections.sort(placeList);
   while (iterator.hasNext()) {
     Node node = iterator.next();
     String nodeText = node.getTokenText();
     String docId = node.getDocId();
     String indexPos = String.valueOf(node.getIndexPos());
     String docLen = String.valueOf(node.getDocLength());
     writer.print(nodeText + " ;! " + docId + " ;! ");
     writer.println(indexPos + " ;! " + docLen);
   }
   writer.close();
 }
Exemplo n.º 2
0
  public void writeDictionary(TokenStream tokenStream, String docId, int docSize) {

    count++;
    while (tokenStream.hasNext()) {
      Node node = new Node();
      node.setDocId(docId);
      Token token = tokenStream.next();
      String tokenText = token.toString();
      int indexPos = token.getIndexPos();
      node.setIndexPos(indexPos);
      node.setDocLength(docSize);

      if (!tokenText.isEmpty()) {
        node.setTokenText(tokenText);
        placeList.add(node);
      }
    }
    if (count == 20000) {
      count = 0;
      sortFiles();
      placeList = new ArrayList<Node>();
      initializeWriter();
    }
  }