Пример #1
0
  public void setAdvancedValues() {
    // get pretty ranges for the current parameters
    // get the range for the station value
    double min = 10000;
    double max = 0;
    for (int fc = 0; fc < mFileViewer.mNumOpenFiles; fc++) {
      OpenDataFile of = (OpenDataFile) mFileViewer.mOpenFiles.elementAt(fc);

      for (int sec = 0; sec < of.mNumSections; sec++) {
        Section sech = (Section) of.mSections.elementAt(sec);

        if (sech.mNumCasts == 0) {
          continue;
        }

        for (int stc = 0; stc < sech.mStations.size(); stc++) {
          Station sh = (Station) sech.mStations.elementAt(stc);
          if (!sh.mUseStn) {
            continue;
          }

          // get the station value
          double y = sh.getStnValue(mSelYParam);
          if (y == JOAConstants.MISSINGVALUE || y >= JOAConstants.EPICMISSINGVALUE) {
            continue;
          } else {
            min = y < min ? y : min;
            max = y > max ? y : max;
          }
        }
      }
    }

    Triplet newRange = JOAFormulas.GetPrettyRange(min, max);
    double yMinv = newRange.getVal1();
    double yMaxv = newRange.getVal2();
    double yIncv = newRange.getVal3();
    yMin.setText(JOAFormulas.formatDouble(String.valueOf(yMinv), 3, false));
    yMax.setText(JOAFormulas.formatDouble(String.valueOf(yMaxv), 3, false));
    yInc.setText(JOAFormulas.formatDouble(String.valueOf(yIncv), 3, false));
    yTics.setValue(new Integer(yTicsVal));
    if (b1.isSelected()) {
      mOffset = JOAConstants.PROFSEQUENCE;
      setXRangeToSequence();
    } else if (b2.isSelected()) {
      mOffset = JOAConstants.PROFDISTANCE;
      setXRangeToDistance();
    } else if (b3.isSelected()) {
      mOffset = JOAConstants.PROFTIME;
      setXRangeToTime();
    }
  }
Пример #2
0
 public void setXRangeToSequence() {
   hideTime();
   // set the x axis from the total mercator distance
   double tempXMin = 0;
   double tempXMax = mFileViewer.mTotalStations;
   Triplet newRange = JOAFormulas.GetPrettyRange(tempXMin, tempXMax);
   double xMinv = newRange.getVal1();
   double xMaxv = newRange.getVal2();
   double xIncv = newRange.getVal3();
   xMin.setText(String.valueOf((int) xMinv));
   xMax.setText(String.valueOf((int) xMaxv));
   xInc.setText(String.valueOf((int) xIncv));
   xTics.setValue(new Integer(xTicsVal));
 }
Пример #3
0
 public void setXRangeToDistance() {
   hideTime();
   // set the x axis from the total mercator distance
   double tempXMin = 0;
   double tempXMax = mFileViewer.mTotMercDist * 1.852;
   Triplet newRange = JOAFormulas.GetPrettyRange(tempXMin, tempXMax);
   double xMinv = newRange.getVal1();
   double xMaxv = newRange.getVal2();
   double xIncv = newRange.getVal3();
   xMin.setText(JOAFormulas.formatDouble(String.valueOf(xMinv), 3, false));
   xMax.setText(JOAFormulas.formatDouble(String.valueOf(xMaxv), 3, false));
   xInc.setText(JOAFormulas.formatDouble(String.valueOf(xIncv), 3, false));
   xTics.setValue(new Integer(xTicsVal));
 }
Пример #4
0
    private Tree<String> makeTree(
        List<List<Map<Object, Triplet<Integer, Object, Object>>>> backs,
        int begin,
        int end,
        Object A) {

      Triplet<Integer, Object, Object> backptr = backs.get(begin).get(end).get(A);
      String tag = getParent(A);

      // System.out.println("makeTree: begin=" + begin + ",end=" + end + ",A=" + A + " : " +
      // "backptr=" + backptr);

      List<Tree<String>> children = new ArrayList<Tree<String>>();

      if (backptr == null) {
        // No back pointer. Terminal
        Tree<String> child = new Tree<String>(((UnaryRule) A).getChild());
        children.add(child);
      } else if (backptr.getFirst() < 0) {
        // Single back pointer. Unary rule
        Object B = backptr.getSecond();
        Tree<String> child = makeTree(backs, begin, end, B);
        children.add(child);
      } else {
        // Two back pointers. Binary rule
        int split = backptr.getFirst();
        Object B = backptr.getSecond();
        Object C = backptr.getThird();
        Tree<String> childB = makeTree(backs, begin, split, B);
        Tree<String> childC = makeTree(backs, split, end, C);
        children.add(childB);
        children.add(childC);
      }
      return new Tree<String>(tag, children);
    }
Пример #5
0
    public Tree<String> getParseTreeOld(
        List<String> sentence,
        HashMap<String, Triplet<Integer, String, String>> backHash,
        int begin,
        int end,
        String parent) {
      // Start from the root and keep going down till you reach the leafs.
      // System.out.println("In recursion!!");
      if (begin == end - 1) {

        if ((begin + " " + end).equals("0 1")) {
          // System.out.println("CounterMap");
          // System.out.println(parseScores.getCounter(begin+" "+end).toString());
          // backHash.get(begin+ " " + end+ " "+parent);
        }

        // String parent = parseScores.getCounter(begin+" "+end).argMax();

        // System.out.println("Terminal cond :"+begin+ " "+ end+ " "+parent);
        Triplet<Integer, String, String> triplet = backHash.get(begin + " " + end + " " + parent);
        int split = -1;
        if (triplet != null) {
          split = triplet.getFirst();
        }
        if ((begin + " " + end).equals("0 1")) {
          // System.out.println("CounterMap");
          // System.out.println(parseScores.getCounter(begin+" "+end).toString());
          // System.out.println(backHash.get(begin+ " " + end+ " "+parent).toString());
        }

        Tree<String> topTree = new Tree<String>(parent);
        Tree<String> tree = topTree;
        while (triplet != null && split == -1) {

          Tree<String> singleTree = new Tree<String>(triplet.getSecond());
          tree.setChildren(Collections.singletonList(singleTree));

          triplet = backHash.get(begin + " " + end + " " + triplet.getSecond());
          if (triplet != null) {
            split = triplet.getFirst();
          }
          tree = tree.getChildren().get(0);
        }

        // return new Tree<String>(tree.getLabel(), ));
        tree.setChildren(Collections.singletonList(new Tree<String>(sentence.get(begin))));
        return topTree;
      }

      /*if((begin +" " + end).equals("1 5")){
      	System.out.println("CounterMap");
      	System.out.println(parseScores.getCounter(begin+" "+end).toString());
      	//backHash.get(begin+ " " + end+ " "+parent);
      }*/
      // String parent = parseScores.getCounter(begin+" "+end).argMax();
      // System.out.println(parent);
      Triplet<Integer, String, String> triplet = backHash.get(begin + " " + end + " " + parent);
      // System.out.println(triplet.getSecond() + "  " + triplet.getFirst());

      if ((begin + " " + end).equals("0 6")) {
        // System.out.println("CounterMap");
        // System.out.println(parent);
        // System.out.println(backHash.get(begin+ " " + end+ " "+parent).toString());
      }

      if (triplet == null) {
        System.out.println(begin + " " + end + " " + parent);
      }
      int split = triplet.getFirst();
      Tree<String> topTree = new Tree<String>(parent);
      Tree<String> tree = topTree;
      // System.out.println("parent : " +parent);
      while (split == -1) {
        // System.out.println(tree.toString());
        Tree<String> singleTree = new Tree<String>(triplet.getSecond());
        // System.out.println(triplet.getSecond());
        tree.setChildren(Collections.singletonList(singleTree));
        // System.out.println(tree.toString());
        // System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXxx");
        // System.out.println(triplet.getSecond());
        triplet = backHash.get(begin + " " + end + " " + triplet.getSecond());
        if (triplet != null) {
          split = triplet.getFirst();
        }
        tree = tree.getChildren().get(0);
      }
      // System.out.println(tree.toString());

      Tree<String> leftTree =
          getParseTreeOld(sentence, backHash, begin, split, triplet.getSecond());
      Tree<String> rightTree = getParseTreeOld(sentence, backHash, split, end, triplet.getThird());
      // System.out.println("leftTree: "+ leftTree.toString());
      // System.out.println("rightTree :" +rightTree.toString());
      // System.out.println("topTree :"+topTree.toString());
      List<Tree<String>> children = new ArrayList<Tree<String>>();
      children.add(leftTree);
      children.add(rightTree);
      tree.setChildren(children);
      return topTree;
    }
Пример #6
0
    public Tree<String> getParseTree(
        List<String> sentence,
        HashMap<Triplet<Integer, Integer, String>, Triplet<Integer, String, String>> backHash,
        int begin,
        int end,
        String parent) {
      // Start from the root and keep going down till you reach the leafs.
      if (begin == end - 1) {
        Triplet<Integer, String, String> triplet =
            backHash.get(new Triplet<Integer, Integer, String>(begin, end, parent));
        int split = -1;
        if (triplet != null) {
          split = triplet.getFirst();
        }

        Tree<String> topTree = new Tree<String>(parent);
        Tree<String> tree = topTree;
        while (triplet != null && split == -1) {

          Tree<String> singleTree = new Tree<String>(triplet.getSecond());
          tree.setChildren(Collections.singletonList(singleTree));

          triplet =
              backHash.get(new Triplet<Integer, Integer, String>(begin, end, triplet.getSecond()));
          if (triplet != null) {
            split = triplet.getFirst();
          }
          tree = tree.getChildren().get(0);
        }

        tree.setChildren(Collections.singletonList(new Tree<String>(sentence.get(begin))));
        return topTree;
      }

      Triplet<Integer, String, String> triplet =
          backHash.get(new Triplet<Integer, Integer, String>(begin, end, parent));

      if (triplet == null) {
        System.out.println(begin + " " + end + " " + parent);
      }
      int split = triplet.getFirst();
      Tree<String> topTree = new Tree<String>(parent);
      Tree<String> tree = topTree;

      while (split == -1) {
        Tree<String> singleTree = new Tree<String>(triplet.getSecond());
        tree.setChildren(Collections.singletonList(singleTree));
        triplet =
            backHash.get(new Triplet<Integer, Integer, String>(begin, end, triplet.getSecond()));
        if (triplet != null) {
          split = triplet.getFirst();
        }
        tree = tree.getChildren().get(0);
      }

      Tree<String> leftTree = getParseTree(sentence, backHash, begin, split, triplet.getSecond());
      Tree<String> rightTree = getParseTree(sentence, backHash, split, end, triplet.getThird());

      List<Tree<String>> children = new ArrayList<Tree<String>>();
      children.add(leftTree);
      children.add(rightTree);
      tree.setChildren(children);
      return topTree;
    }