Package net.sourceforge.align.calculator

Examples of net.sourceforge.align.calculator.Calculator


   * but based on Forward Backward method instead of Viterbi method.
   */
  @Before
  public void setUp() {
    Counter counter = new CharCounter();
    Calculator calculator = new NormalDistributionCalculator(counter);
    MatrixFactory matrixFactory = new FullMatrixFactory();
   
    algorithm = new ForwardBackwardAlgorithm(calculator,
        CategoryDefaults.BEST_CATEGORY_MAP, matrixFactory);
  }
View Full Code Here


   */
  @Test
  public void calculate() {
    List<Calculator> calculatorList = Arrays.asList(new Calculator[] {
        new CalculatorMock(0.5f), new CalculatorMock(0.25f)});
    Calculator calculator = new CompositeCalculator(calculatorList);
    assertEquals(0.75f, calculator.calculateScore(null, null), 0.75f);
  }
View Full Code Here

public class PoissonMacro implements Macro {

  public List<Alignment> apply(List<Alignment> alignmentList) {
   
    Counter counter = new SplitCounter();
    Calculator calculator =
      new PoissonDistributionCalculator(counter, alignmentList);
   
    HmmAlignAlgorithmFactory algorithmFactory =
      new ForwardBackwardAlgorithmFactory();
   
View Full Code Here

  private AlignAlgorithm createAlgorithm(CommandLine commandLine,
      List<Alignment> alignmentList) {
    String cls = commandLine.getOptionValue('c');
    AlignAlgorithm algorithm;
    if (cls.equals("fb") || cls.equals("viterbi")) {
      Calculator calculator = createCalculator(commandLine,
          alignmentList);
      Map<Category, Float> categoryMap =
        CategoryDefaults.BEST_CATEGORY_MAP;
      String search = commandLine.getOptionValue('s');
      if (search == null) {
View Full Code Here

    List<Calculator> calculatorList = new ArrayList<Calculator>();
    Iterator<String> calculatorStringIterator = calculatorStringList.iterator();
    while (calculatorStringIterator.hasNext()) {
      String calculatorString = calculatorStringIterator.next();
      Calculator calculator;
      if (calculatorString.equals("normal")) {
        calculator = createNormalCalculator(commandLine);
      } else if(calculatorString.equals("poisson")) {
        calculator = createPoissonCalculator(commandLine, alignmentList);
      } else if(calculatorString.equals("translation")) {
        calculator = createTranslationCalculator(commandLine);
      } else if(calculatorString.equals("oracle")) {
        List<String> remainingCalculatorStringList =
          new ArrayList<String>();
        while (calculatorStringIterator.hasNext()) {
          remainingCalculatorStringList.add(calculatorStringIterator.next());
        }
        Calculator remainingCalculator = createCalculator(
            commandLine, alignmentList, remainingCalculatorStringList);
        calculator = createOracleCalculator(commandLine, remainingCalculator);
      } else {
        throw new UnknownParameterException("calculator");
      }
      calculatorList.add(calculator);
    }
   
    Calculator calculator;
    if (calculatorList.size() == 1) {
      calculator = calculatorList.get(0);
    } else {
      calculator = new CompositeCalculator(calculatorList);
    }
View Full Code Here

  private Calculator createNormalCalculator(CommandLine commandLine) {
    Counter counter = createCounter(commandLine);
    if (counter == null) {
      throw new MissingParameterException("counter");
    }
    Calculator calculator = new NormalDistributionCalculator(counter);
    return calculator;
  }
View Full Code Here

    if (lengthCorpus != null) {
      lengthAlignmentList = loadAlignmentList(lengthCorpus);
    } else {
      lengthAlignmentList = alignmentList;
    }
    Calculator calculator = new PoissonDistributionCalculator(counter,
        lengthAlignmentList);
    return calculator;
  }
View Full Code Here

        lengthAlignmentList);
    return calculator;
  }

  private Calculator createTranslationCalculator(CommandLine commandLine) {
    Calculator calculator;
    int iterations = createInt(commandLine, "iterations",
        TranslationModelUtil.DEFAULT_TRAIN_ITERATION_COUNT);
    String translationCorpus = commandLine.getOptionValue('t');
    String languageModels = commandLine.getOptionValue("x");
    String transModel = commandLine.getOptionValue("y");
View Full Code Here

    return calculator;
  }

  private Calculator createOracleCalculator(CommandLine commandLine,
      Calculator calculator) {
    Calculator resultCalculator;
    String oracleCorpus = commandLine.getOptionValue("oracle-corpus");
    if (oracleCorpus == null) {
      throw new MissingParameterException("oracle-corpus");
    }
    List<Alignment> oracleAlignmentList = loadAlignmentList(oracleCorpus);
View Full Code Here

  private List<Alignment> lengthAlign(List<Alignment> alignmentList) {

    List<Filter> filterList = new ArrayList<Filter>();
   
    Counter counter = new CharCounter();
    Calculator calculator = new NormalDistributionCalculator(counter);
   
    HmmAlignAlgorithmFactory algorithmFactory =
      new ForwardBackwardAlgorithmFactory();
   
    AlignAlgorithm algorithm =
View Full Code Here

TOP

Related Classes of net.sourceforge.align.calculator.Calculator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.