Package net.sourceforge.align.filter

Examples of net.sourceforge.align.filter.Filter


  protected void run(CommandLine commandLine) {
    String cls = commandLine.getOptionValue('c');
    if (cls == null) {
      throw new MissingParameterException("class");
    }
    Filter filter;
   
    if (cls.equals("one-to-one")) {
      filter = new OneToOneSelector();
    } else if (cls.equals("fraction")) {
      float fraction = createFloat(commandLine, "fraction");
      filter = new FractionSelector(fraction);
    } else if (cls.equals("probability")) {
      float probability = createFloat(commandLine, "probability");
      filter = new ProbabilitySelector(probability);
    } else if (cls.equals("intersection") || cls.equals("difference")) {
      String alignmentString = commandLine.getOptionValue("alignment");
      if (alignmentString == null) {
        throw new MissingParameterException("alignment");
      }
      List<Alignment> alignment = loadAlignmentList(alignmentString);
      if (cls.equals("intersection")) {
        filter = new IntersectionSelector(alignment);
      } else if (cls.equals("difference")) {
        filter = new DifferenceSelector(alignment);
      } else {
        throw new UnknownParameterException("class");
      }
    } else {
      throw new UnknownParameterException("class");
    }
   
    filter = FilterDecorators.decorate(filter);
   
    Parser parser = new AlParser(getIn());
    Formatter formatter = new AlFormatter(getOut());
    List<Alignment> alignmentList = parser.parse();
    alignmentList = filter.apply(alignmentList);
    formatter.format(alignmentList);
  }
View Full Code Here


   * Tests whether alignments with infinite score are ignored and
   * the ones without are not by using {@link OneToOneAlgorithm} aligner.
   */
  @Test
  public void testIgnoreInfiniteProbability() {
    Filter oneToOneAligner = new Aligner(new OneToOneAlgorithm());
    Filter filter =
      new IgnoreInfiniteProbabilityAlignmentsFilterDecorator(oneToOneAligner);

    List<Alignment> alignmentList = createAlignmentList(
        SOURCE_SEGMENT_ARRAY, TARGET_SEGMENT_ARRAY);
   
    // Mark middle alignment as fixed.
    alignmentList.get(1).setScore(Float.NEGATIVE_INFINITY);
   
    List<Alignment> resultAlignmentList = filter.apply(alignmentList);
    assertAlignmentListEquals(EXPECTED_SOURCE_SEGMENT_ARRAY,
        EXPECTED_TARGET_SEGMENT_ARRAY, resultAlignmentList);
  }
View Full Code Here

 
  protected void run(CommandLine commandLine) {
    if (commandLine.getOptions().length == 0) {
      throw new MissingParameterException("class");
    }
    Filter filter;
    Parser parser = new AlParser(getIn());
    List<Alignment> alignmentList = null;
    String cls = commandLine.getOptionValue('c');
    if (cls == null) {
      throw new MissingParameterException("class");
    }
    if (cls.equals("unify")) {
      String unificationCorpus = commandLine.getOptionValue('u');
      if (unificationCorpus == null) {
        throw new MissingParameterException("unification-corpus");
      }
      List<Alignment> unificationAlignmentList =
        loadAlignmentList(unificationCorpus);
      filter = new UnifyAligner(unificationAlignmentList);
    } else {
      alignmentList = parser.parse();
      AlignAlgorithm algorithm = createAlgorithm(commandLine, alignmentList);
      filter = new Aligner(algorithm);
    }
    filter = FilterDecorators.decorate(filter);
    Formatter formatter = new AlFormatter(getOut());
    if (alignmentList == null) {
      alignmentList = parser.parse();
    }
    alignmentList = filter.apply(alignmentList);
    formatter.format(alignmentList);
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.align.filter.Filter

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.