KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > nutch > clustering > carrot2 > NutchDocument


1 /* Copyright (c) 2003 The Nutch Organization. All rights reserved. */
2 /* Use subject to the conditions in http://www.nutch.org/LICENSE.txt. */
3
4 package net.nutch.clustering.carrot2;
5
6 import net.nutch.searcher.HitDetails;
7
8 import com.dawidweiss.carrot.core.local.clustering.RawDocument;
9 import com.dawidweiss.carrot.core.local.clustering.RawDocumentBase;
10
11 /**
12  * An adapter class that implements {@link RawDocument} for
13  * Carrot2.
14  *
15  * @author Dawid Weiss
16  * @version $Id: NutchDocument.java,v 1.2 2004/08/10 00:18:43 johnnx Exp $
17  */

18 public class NutchDocument extends RawDocumentBase {
19
20   private final Integer JavaDoc id;
21   
22   /**
23    * Creates a new document with the given id, <code>summary</code> and wrapping
24    * a <code>details</code> hit details.
25    */

26   public NutchDocument(int id, HitDetails details, String JavaDoc summary) {
27     super.setProperty(RawDocument.PROPERTY_URL, details.getValue("url"));
28     super.setProperty(RawDocument.PROPERTY_SNIPPET, summary);
29     
30     String JavaDoc title = details.getValue("title");
31     if (title != null && !"".equals(title)) {
32       super.setProperty(RawDocument.PROPERTY_TITLE, title);
33     }
34     
35     this.id = new Integer JavaDoc(id);
36   }
37   
38   /*
39    * @see com.dawidweiss.carrot.core.local.clustering.RawDocument#getId()
40    */

41   public Object JavaDoc getId() {
42     return id;
43   }
44 }
45
Popular Tags