/** * For testing only. Doubles combined by multiplication. */ private boolean canAddPath(List path) { Object node = this.getStartNode(); for (int j = 0; j < path.size() - 1; j++) { Object input = path.get(j); Arc arc = this.getArcBySourceAndInput(node, input); // next input in path if (arc == null) { return true; } node = arc.getTargetNode(); } Object input = path.get(path.size() - 1); // last element Arc arc = this.getArcBySourceAndInput(node, input); // next input in path if (arc == null) { return true; } else { return getEndNodes().contains(arc.getTargetNode()); } }
/** * For testing only. Doubles combined by addition. */ public double getOutputOfPathInGraph(List path) { double score = 0.0; Object node = getStartNode(); for (Object input : path) { Arc arc = getArcBySourceAndInput(node, input); // next input in path if (arc == null) { System.out.println(" NOT ACCEPTED :" + path); return Double.NEGATIVE_INFINITY; } score += ((Double) arc.getOutput()).doubleValue(); node = arc.getTargetNode(); } return score; }
public static void addOnePathToGraph(List path, double count, int markovOrder, TransducerGraph graph) { Object source = graph.getStartNode(); for (int j = 0; j < path.size(); j++) { Object input = path.get(j); Arc a = graph.getArcBySourceAndInput(source, input); if (a != null) { // increment the arc weight a.output = new Double(((Double) a.output).doubleValue() + count); } else { Object target; if (input.equals(TransducerGraph.EPSILON_INPUT)) { target = "END"; // to ensure they all share the same end node } else if (markovOrder == 0) { // we all transition back to the same state target = source; } else if (markovOrder > 0) { // the state is described by the partial history target = path.subList((j < markovOrder ? 0 : j - markovOrder + 1), j + 1); } else { // the state is described by the full history target = path.subList(0, j + 1); } Double output = new Double(count); a = new Arc(source, target, input, output); graph.addArc(a); } source = a.getTargetNode(); } graph.setEndNode(source); }
/** * For testing only. Doubles combined by multiplication. */ private boolean canAddPath(List path) { Object node = this.getStartNode(); for (int j = 0; j < path.size() - 1; j++) { Object input = path.get(j); Arc arc = this.getArcBySourceAndInput(node, input); // next input in path if (arc == null) { return true; } node = arc.getTargetNode(); } Object input = path.get(path.size() - 1); // last element Arc arc = this.getArcBySourceAndInput(node, input); // next input in path if (arc == null) { return true; } else { return getEndNodes().contains(arc.getTargetNode()); } }
/** * For testing only. Doubles combined by multiplication. */ private boolean canAddPath(List path) { Object node = this.getStartNode(); for (int j = 0; j < path.size() - 1; j++) { Object input = path.get(j); Arc arc = this.getArcBySourceAndInput(node, input); // next input in path if (arc == null) { return true; } node = arc.getTargetNode(); } Object input = path.get(path.size() - 1); // last element Arc arc = this.getArcBySourceAndInput(node, input); // next input in path if (arc == null) { return true; } else { return getEndNodes().contains(arc.getTargetNode()); } }
/** * For testing only. Doubles combined by multiplication. */ private boolean canAddPath(List path) { Object node = this.getStartNode(); for (int j = 0; j < path.size() - 1; j++) { Object input = path.get(j); Arc arc = this.getArcBySourceAndInput(node, input); // next input in path if (arc == null) { return true; } node = arc.getTargetNode(); } Object input = path.get(path.size() - 1); // last element Arc arc = this.getArcBySourceAndInput(node, input); // next input in path if (arc == null) { return true; } else { return getEndNodes().contains(arc.getTargetNode()); } }
/** * For testing only. Doubles combined by multiplication. */ public boolean canAddPath(List path) { Object node = this.getStartNode(); for (int j = 0; j < path.size() - 1; j++) { Object input = path.get(j); Arc arc = this.getArcBySourceAndInput(node, input); // next input in path if (arc == null) { return true; } node = arc.getTargetNode(); } Object input = path.get(path.size() - 1); // last element Arc arc = this.getArcBySourceAndInput(node, input); // next input in path if (arc == null) { return true; } else { if (getEndNodes().contains(arc.getTargetNode())) { return true; } else { return false; } } }
/** * For testing only. Doubles combined by addition. */ public double getOutputOfPathInGraph(List path) { double score = 0.0; Object node = getStartNode(); for (Object input : path) { Arc arc = getArcBySourceAndInput(node, input); // next input in path if (arc == null) { System.out.println(" NOT ACCEPTED :" + path); return Double.NEGATIVE_INFINITY; } score += ((Double) arc.getOutput()).doubleValue(); node = arc.getTargetNode(); } return score; }
/** * For testing only. Doubles combined by addition. */ public double getOutputOfPathInGraph(List path) { double score = 0.0; Object node = getStartNode(); for (Object input : path) { Arc arc = getArcBySourceAndInput(node, input); // next input in path if (arc == null) { System.out.println(" NOT ACCEPTED :" + path); return Double.NEGATIVE_INFINITY; } score += ((Double) arc.getOutput()).doubleValue(); node = arc.getTargetNode(); } return score; }
/** * For testing only. Doubles combined by addition. */ public double getOutputOfPathInGraph(List path) { double score = 0.0; Object node = getStartNode(); for (Object input : path) { Arc arc = getArcBySourceAndInput(node, input); // next input in path if (arc == null) { System.out.println(" NOT ACCEPTED :" + path); return Double.NEGATIVE_INFINITY; } score += ((Double) arc.getOutput()).doubleValue(); node = arc.getTargetNode(); } return score; }
/** * For testing only. Doubles combined by addition. */ public double getOutputOfPathInGraph(List path) { double score = 0.0; Object node = getStartNode(); for (Object input : path) { Arc arc = getArcBySourceAndInput(node, input); // next input in path if (arc == null) { System.out.println(" NOT ACCEPTED :" + path); return Double.NEGATIVE_INFINITY; } score += ((Double) arc.getOutput()).doubleValue(); node = arc.getTargetNode(); } return score; }
public static void addOnePathToGraph(List path, double count, int markovOrder, TransducerGraph graph) { Object source = graph.getStartNode(); for (int j = 0; j < path.size(); j++) { Object input = path.get(j); Arc a = graph.getArcBySourceAndInput(source, input); if (a != null) { // increment the arc weight a.output = new Double(((Double) a.output).doubleValue() + count); } else { Object target; if (input.equals(TransducerGraph.EPSILON_INPUT)) { target = "END"; // to ensure they all share the same end node } else if (markovOrder == 0) { // we all transition back to the same state target = source; } else if (markovOrder > 0) { // the state is described by the partial history target = path.subList((j < markovOrder ? 0 : j - markovOrder + 1), j + 1); } else { // the state is described by the full history target = path.subList(0, j + 1); } Double output = new Double(count); a = new Arc(source, target, input, output); graph.addArc(a); } source = a.getTargetNode(); } graph.setEndNode(source); }
public static void addOnePathToGraph(List path, double count, int markovOrder, TransducerGraph graph) { Object source = graph.getStartNode(); for (int j = 0; j < path.size(); j++) { Object input = path.get(j); Arc a = graph.getArcBySourceAndInput(source, input); if (a != null) { // increment the arc weight a.output = new Double(((Double) a.output).doubleValue() + count); } else { Object target; if (input.equals(TransducerGraph.EPSILON_INPUT)) { target = "END"; // to ensure they all share the same end node } else if (markovOrder == 0) { // we all transition back to the same state target = source; } else if (markovOrder > 0) { // the state is described by the partial history target = path.subList((j < markovOrder ? 0 : j - markovOrder + 1), j + 1); } else { // the state is described by the full history target = path.subList(0, j + 1); } Double output = new Double(count); a = new Arc(source, target, input, output); graph.addArc(a); } source = a.getTargetNode(); } graph.setEndNode(source); }
public static void addOnePathToGraph(List path, double count, int markovOrder, TransducerGraph graph) { Object source = graph.getStartNode(); for (int j = 0; j < path.size(); j++) { Object input = path.get(j); Arc a = graph.getArcBySourceAndInput(source, input); if (a != null) { // increment the arc weight a.output = new Double(((Double) a.output).doubleValue() + count); } else { Object target; if (input.equals(TransducerGraph.EPSILON_INPUT)) { target = "END"; // to ensure they all share the same end node } else if (markovOrder == 0) { // we all transition back to the same state target = source; } else if (markovOrder > 0) { // the state is described by the partial history target = path.subList((j < markovOrder ? 0 : j - markovOrder + 1), j + 1); } else { // the state is described by the full history target = path.subList(0, j + 1); } Double output = new Double(count); a = new Arc(source, target, input, output); graph.addArc(a); } source = a.getTargetNode(); } graph.setEndNode(source); }
public static void addOnePathToGraph(List path, double count, int markovOrder, TransducerGraph graph) { Object source = graph.getStartNode(); Object input, target; for (int j = 0; j < path.size(); j++) { input = path.get(j); Arc a = graph.getArcBySourceAndInput(source, input); if (a != null) { // increment the arc weight a.output = new Double(((Double) a.output).doubleValue() + count); } else { if (input.equals(TransducerGraph.EPSILON_INPUT)) { target = "END"; // to ensure they all share the same end node } else if (markovOrder == 0) { // we all transition back to the same state target = source; } else if (markovOrder > 0) { // the state is described by the partial history target = path.subList((j < markovOrder ? 0 : j - markovOrder + 1), j + 1); } else { // the state is described by the full history target = path.subList(0, j + 1); } Double output = new Double(count); a = new Arc(source, target, input, output); graph.addArc(a); } source = a.getTargetNode(); } graph.setEndNode(source); }