View Javadoc

1   /*
2    * Copyright (C) 2004-2006 Christian Siefkes <christian@siefkes.net>.
3    * Development of this software is supported by the German Research Society,
4    * Berlin-Brandenburg Graduate School in Distributed Information Systems
5    * (DFG grant no. GRK 316).
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, visit
19   * http://www.gnu.org/licenses/gpl.html or write to the Free Software
20   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21   */
22  package de.fu_berlin.ties.context.sensor;
23  
24  import java.io.File;
25  import java.io.IOException;
26  
27  import org.apache.commons.collections.KeyValue;
28  
29  import de.fu_berlin.ties.ProcessingException;
30  import de.fu_berlin.ties.text.TokenizerFactory;
31  
32  /***
33   * A sensor is an object that looks up information for a token, for example
34   * semantic information from gazetteers or thesauri.
35   *
36   * @author Christian Siefkes
37   * @version $Revision: 1.6 $, $Date: 2006/10/21 16:04:07 $, $Author: siefkes $
38   */
39  public interface Sensor {
40  
41      /***
42       * Called when starting to process a new document.
43       *
44       * @param filename the name of the file
45       * @param tFactory a factory that can be used for creating tokenizers,
46       * if required
47       * @throws ProcessingException if an error occurs while starting to
48       * process the document
49       * @throws IOException if an I/O error occurs
50       */
51      void initDocument(final File filename, final TokenizerFactory tFactory)
52              throws ProcessingException, IOException;
53  
54      /***
55       * Looks up a token and returns the information as an array of key/value
56       * pairs (values can be <code>null</code>, but <code>null</code> are not
57       * allowed). If no information for the given token can be found, an
58       * empty array (length 0) is returned.
59       *
60       * @param token the token to look up
61       * @return an array of key/value pairs describing the token
62       */
63      KeyValue[] lookup(final String token);
64  
65  }