Map<Node, Node> parents = new HashMap<Node, Node>(); Node startNode = new Node(0, 0); cost.put(startNode, 0); openSet.add(startNode); continue; if (q.isTarget()) { List<Node> backtrace = new ArrayList<Node>(); while (parents.containsKey(q)) { if (!q.isBoundary() && q.hasMatch()) backtrace.add(q); q = parents.get(q); for (Node nb : q.adjacent()) { qScore = Integer.MAX_VALUE; int newScore = qScore + nb.getValue() - l; if (newScore < oldScore) { cost.put(nb, newScore);
public String getDatabaseWord() { if (databaseIndex > 0) return reftup.get(getDatabaseIndex()); return null; }
public boolean hasMatch() { return getQueryWord().equals(getDatabaseWord()); }
Map<Node, Node> parents = new HashMap<Node, Node>(); Node startNode = new Node(0, 0); cost.put(startNode, 0); openSet.add(startNode); continue; if (q.isTarget()) { List<Node> backtrace = new ArrayList<Node>(); while (parents.containsKey(q)) { if (!q.isBoundary() && q.hasMatch()) backtrace.add(q); q = parents.get(q); for (Node nb : q.adjacent()) { qScore = Integer.MAX_VALUE; int newScore = qScore + nb.getValue() - l; if (newScore < oldScore) { cost.put(nb, newScore);
/** * Aligns query sequence with the previously built database. * @param words list words to look for * @param range range of database to look for alignment * * @return indices of alignment */ public int[] align(List<String> words, Range range) { if (range.upperEndpoint() - range.lowerEndpoint() < tupleSize || words.size() < tupleSize) { return alignTextSimple(refWords.subList(range.lowerEndpoint(), range.upperEndpoint()), words, range.lowerEndpoint()); } int[] result = new int[words.size()]; fill(result, -1); int lastIndex = 0; for (Alignment.Node node : new Alignment(getTuples(words), range) .getIndices()) { // for (int j = 0; j < tupleSize; ++j) lastIndex = max(lastIndex, node.getQueryIndex()); for (; lastIndex < node.getQueryIndex() + tupleSize; ++lastIndex) result[lastIndex] = node.getDatabaseIndex() + lastIndex - node.getQueryIndex(); } return result; }
public List<Node> adjacent() { List<Node> result = new ArrayList<Node>(3); if (queryIndex < indices.size() && databaseIndex < shifts.size()) { result.add(new Node(queryIndex + 1, databaseIndex + 1)); } if (databaseIndex < shifts.size()) { result.add(new Node(queryIndex, databaseIndex + 1)); } if (queryIndex < indices.size()) { result.add(new Node(queryIndex + 1, databaseIndex)); } return result; }
public boolean hasMatch() { return getQueryWord().equals(getDatabaseWord()); }
public String getDatabaseWord() { if (databaseIndex > 0) return reftup.get(getDatabaseIndex()); return null; }
public int getValue() { if (isBoundary()) return max(queryIndex, databaseIndex); return hasMatch() ? 0 : 1; }
public String getQueryWord() { if (queryIndex > 0) return query.get(getQueryIndex()); return null; }
/** * Aligns query sequence with the previously built database. * @param words list words to look for * @param range range of database to look for alignment * * @return indices of alignment */ public int[] align(List<String> words, Range range) { if (range.upperEndpoint() - range.lowerEndpoint() < tupleSize || words.size() < tupleSize) { return alignTextSimple(refWords.subList(range.lowerEndpoint(), range.upperEndpoint()), words, range.lowerEndpoint()); } int[] result = new int[words.size()]; fill(result, -1); int lastIndex = 0; for (Alignment.Node node : new Alignment(getTuples(words), range) .getIndices()) { // for (int j = 0; j < tupleSize; ++j) lastIndex = max(lastIndex, node.getQueryIndex()); for (; lastIndex < node.getQueryIndex() + tupleSize; ++lastIndex) result[lastIndex] = node.getDatabaseIndex() + lastIndex - node.getQueryIndex(); } return result; }
public List<Node> adjacent() { List<Node> result = new ArrayList<Node>(3); if (queryIndex < indices.size() && databaseIndex < shifts.size()) { result.add(new Node(queryIndex + 1, databaseIndex + 1)); } if (databaseIndex < shifts.size()) { result.add(new Node(queryIndex, databaseIndex + 1)); } if (queryIndex < indices.size()) { result.add(new Node(queryIndex + 1, databaseIndex)); } return result; }
public String getQueryWord() { if (queryIndex > 0) return query.get(getQueryIndex()); return null; }
public int getValue() { if (isBoundary()) return max(queryIndex, databaseIndex); return hasMatch() ? 0 : 1; }