View Javadoc

1   /*
2    * Copyright (C) 2005-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.extract.reestimate;
23  
24  import de.fu_berlin.ties.TiesConfiguration;
25  
26  /***
27   * A {@link de.fu_berlin.ties.extract.reestimate.LengthEstimator} that uses
28   * the rounded square root of the length (token count) instead of the raw
29   * token count. This representation reduced data sparseness and can be
30   * considered as a kind of smoothing.
31   *
32   * @author Christian Siefkes
33   * @version $Revision: 1.5 $, $Date: 2006/10/21 16:04:17 $, $Author: siefkes $
34   */
35  public class RootLengthEstimator extends LengthEstimator {
36  
37      /***
38       * Creates a new instance.
39       *
40       * @param precReestimator the preceding re-estimator to use if this
41       * re-estimator is part of a <em>chain</em>; <code>null</code> otherwise
42       * @param config the configuration to use
43       */
44      public RootLengthEstimator(final Reestimator precReestimator,
45              final TiesConfiguration config) {
46          super(precReestimator, config);
47      }
48  
49      /***
50       * {@inheritDoc}
51       */
52      protected double doReestimate(final String type, final int length) {
53          // delegate to super using rounded square root
54          return super.doReestimate(type, (int) Math.round(Math.sqrt(length)));
55      }
56  
57      /***
58       * {@inheritDoc}
59       */
60      protected void doTrain(final String type, final int length) {
61          // delegate to super using rounded square root
62          super.doTrain(type, (int) Math.round(Math.sqrt(length)));
63      }
64  
65  }