Package net.sourceforge.align.coretypes

Examples of net.sourceforge.align.coretypes.Category


        targetSegmentList.size());
    int x = 0;
    int y = 0;
    while (x < sourceSegmentList.size() || y < targetSegmentList.size()) {
      float bestScore = Float.POSITIVE_INFINITY;
      Category bestCategory = null;
      for (Category category : categoryMap.keySet()) {
        int newX = x + category.getSourceSegmentCount();
        int newY = y + category.getTargetSegmentCount();
        if (newX <= sourceSegmentList.size() &&
            newY <= targetSegmentList.size()) {
          if (forwardMatrix.get(newX, newY) != null &&
              backwardMatrix.get(newX, newY) != null) {
            float forwardScore = forwardMatrix.get(newX, newY);
            float backwardScore = backwardMatrix.get(newX, newY);
            float score = forwardScore + backwardScore - totalScore;
            if (score < bestScore) {
              bestScore = score;
              bestCategory = category;
            }
          }
        }
      }
      List<String> sourceList = createSubList(sourceSegmentList,
          x, x + bestCategory.getSourceSegmentCount());
      List<String> targetList = createSubList(targetSegmentList,
          y, y + bestCategory.getTargetSegmentCount());
      Alignment alignment =
          new Alignment(sourceList, targetList, bestScore);
      alignmentList.add(alignment);
      x += bestCategory.getSourceSegmentCount();
      y += bestCategory.getTargetSegmentCount();
      log.trace("(" + x + ", " + y + ") - s: " + bestScore + " (" + Math.exp(-bestScore) + ")");
    }

    /*
    int previousX = 0;
View Full Code Here


  private float createForwardData(int x, int y,
      List<String> sourceSegmentList, List<String> targetSegmentList,
      Matrix<Float> matrix) {
    List<Float> scoreList = new ArrayList<Float>(categoryMap.size());
    for (Map.Entry<Category, Float> entry : categoryMap.entrySet()) {
      Category category = entry.getKey();
      float categoryScore = entry.getValue();
      int startX = x - category.getSourceSegmentCount();
      int startY = y - category.getTargetSegmentCount();
      if (elementExists(matrix, startX, startY)) {
        List<String> sourceList = sourceSegmentList.subList(startX, x);
        List<String> targetList = targetSegmentList.subList(startY, y);
        float score = categoryScore +
            calculator.calculateScore(sourceList, targetList);
View Full Code Here

  private float createBackwardData(int x, int y,
      List<String> sourceSegmentList, List<String> targetSegmentList,
      Matrix<Float> matrix) {
    List<Float> scoreList = new ArrayList<Float>(categoryMap.size());
    for (Map.Entry<Category, Float> entry : categoryMap.entrySet()) {
      Category category = entry.getKey();
      float categoryScore = entry.getValue();
      int endX = x + category.getSourceSegmentCount();
      int endY = y + category.getTargetSegmentCount();
      if (elementExists(matrix, endX, endY)) {
        List<String> sourceList = sourceSegmentList.subList(x, endX);
        List<String> targetList = targetSegmentList.subList(y, endY);
        float score = categoryScore +
            calculator.calculateScore(sourceList, targetList);
View Full Code Here

    int alignmentCount = alignmentList.size();
   
    Map<Category, Integer> categoryMap =
      new TreeMap<Category, Integer>(new CategoryComparator());
    for (Alignment alignment : alignmentList) {
      Category category = alignment.getCategory();
      Integer occurenceCount = categoryMap.get(category);
      if (occurenceCount == null) {
        occurenceCount = 1;
      } else {
        ++occurenceCount;
View Full Code Here

   */
  private ViterbiData createData(int sourceNr, int targetNr,
      List<String> sourceSegmentList, List<String> targetSegmentList,
      Matrix<ViterbiData> matrix) {
    if (sourceNr == 0 && targetNr == 0) {
      return new ViterbiData(new Category(0, 0), 0, 0);
    }
    Category bestCategory = null;
    float minScore = Float.POSITIVE_INFINITY;
    float minTotalScore = Float.POSITIVE_INFINITY;
    for (Map.Entry<Category, Float> entry : categoryMap.entrySet()) {
      Category category = entry.getKey();
      float categoryScore = entry.getValue();
      int sourceStart = sourceNr - category.getSourceSegmentCount();
      int targetStart = targetNr - category.getTargetSegmentCount();
      if (elementExists(matrix, sourceStart, targetStart)) {
        List<String> sourceList = sourceSegmentList.subList(sourceStart,
            sourceNr);
        List<String> targetList = targetSegmentList.subList(targetStart,
            targetNr);
View Full Code Here

TOP

Related Classes of net.sourceforge.align.coretypes.Category

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.