public boolean contains(TextAnnotation ta) { int id = ta.getTokenizedText().hashCode(); Connection connection = DBHelper.getConnection(dbFile); PreparedStatement stmt; try { stmt = connection.prepareStatement("select * from sentences where id = ?"); stmt.setInt(1, id); ResultSet rs = stmt.executeQuery(); return rs.next(); } catch (SQLException e) { throw new RuntimeException(e); } }
public boolean contains(TextAnnotation ta) { int id = ta.getTokenizedText().hashCode(); Connection connection = DBHelper.getConnection(dbFile); PreparedStatement stmt; try { stmt = connection .prepareStatement("select * from sentences where id = ?"); stmt.setInt(1, id); ResultSet rs = stmt.executeQuery(); return rs.next(); } catch (SQLException e) { throw new RuntimeException(e); } }
public boolean contains(TextAnnotation ta) { int id = ta.getTokenizedText().hashCode(); Connection connection = DBHelper.getConnection(dbFile); PreparedStatement stmt; try { stmt = connection.prepareStatement("select * from sentences where id = ?"); stmt.setInt(1, id); ResultSet rs = stmt.executeQuery(); return rs.next(); } catch (SQLException e) { throw new RuntimeException(e); } }
@Override public boolean contains(TextAnnotation ta) { int id = ta.getTokenizedText().hashCode(); Connection connection = DBHelper.getConnection(dbFile); PreparedStatement stmt; try { stmt = connection.prepareStatement("select * from sentences where id = ?"); stmt.setInt(1, id); ResultSet rs = stmt.executeQuery(); return rs.next(); } catch (SQLException e) { throw new RuntimeException(e); } }
@Override public boolean contains(TextAnnotation ta) { int id = ta.getTokenizedText().hashCode(); Connection connection = DBHelper.getConnection(dbFile); PreparedStatement stmt; try { stmt = connection.prepareStatement("select * from sentences where id = ?"); stmt.setInt(1, id); ResultSet rs = stmt.executeQuery(); return rs.next(); } catch (SQLException e) { throw new RuntimeException(e); } }
@Override public TextAnnotation getTextAnnotation(TextAnnotation ta) { for (String dataset : getAllDatasets()) { final ConcurrentMap<Integer, byte[]> data = getMap(dataset); if(data.containsKey(ta.getTokenizedText().hashCode())) { byte[] taData = data.get(ta.getTokenizedText().hashCode()); return SerializationHelper.deserializeTextAnnotationFromBytes(taData); } } return null; }
@Override public TextAnnotation getTextAnnotation(TextAnnotation ta) { for (String dataset : getAllDatasets()) { final ConcurrentMap<Integer, byte[]> data = getMap(dataset); if(data.containsKey(ta.getTokenizedText().hashCode())) { byte[] taData = data.get(ta.getTokenizedText().hashCode()); return SerializationHelper.deserializeTextAnnotationFromBytes(taData); } } return null; }
public void updateTextAnnotation(TextAnnotation ta) { try { Connection connection = DBHelper.getConnection(dbFile); int id = ta.getTokenizedText().hashCode(); byte[] bytes = serialize(ta); PreparedStatement stmt = connection.prepareStatement("update sentences set ta = ? where id = ?"); stmt.setBytes(1, bytes); stmt.setInt(2, id); stmt.execute(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void updateTextAnnotation(TextAnnotation ta) { try { Connection connection = DBHelper.getConnection(dbFile); int id = ta.getTokenizedText().hashCode(); byte[] bytes = serialize(ta); PreparedStatement stmt = connection.prepareStatement("update sentences set ta = ? where id = ?"); stmt.setBytes(1, bytes); stmt.setInt(2, id); stmt.execute(); } catch (Exception e) { throw new RuntimeException(e); } }
public void updateTextAnnotation(TextAnnotation ta) { try { Connection connection = DBHelper.getConnection(dbFile); int id = ta.getTokenizedText().hashCode(); byte[] bytes = serialize(ta); PreparedStatement stmt = connection .prepareStatement("update sentences set ta = ? where id = ?"); stmt.setBytes(1, bytes); stmt.setInt(2, id); stmt.execute(); } catch (Exception e) { throw new RuntimeException(e); } }
public void updateTextAnnotation(TextAnnotation ta) { try { Connection connection = DBHelper.getConnection(dbFile); int id = ta.getTokenizedText().hashCode(); byte[] bytes = serialize(ta); PreparedStatement stmt = connection.prepareStatement("update sentences set ta = ? where id = ?"); stmt.setBytes(1, bytes); stmt.setInt(2, id); stmt.execute(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void removeTextAnnotation(TextAnnotation ta) { for (String dataset : getAllDatasets()) { final ConcurrentMap<Integer, byte[]> data = getMap(dataset); data.remove(ta.getTokenizedText().hashCode()); } }
@Override public void removeTextAnnotation(TextAnnotation ta) { for (String dataset : getAllDatasets()) { final ConcurrentMap<Integer, byte[]> data = getMap(dataset); data.remove(ta.getTokenizedText().hashCode()); } }
/** * checks whether ta with corresponding TEXT is in database -- not whether the same * annotations are present * @param ta * @return */ @Override public boolean contains(TextAnnotation ta) { boolean isContained = false; for (String dataset : getAllDatasets()) { final ConcurrentMap<Integer, byte[]> data = getMap(dataset); isContained |= data.containsKey(ta.getTokenizedText().hashCode()); } return isContained; }
@Override public void addTextAnnotation(String dataset, TextAnnotation ta) { final ConcurrentMap<Integer, byte[]> data = getMap(dataset); try { data.put(ta.getTokenizedText().hashCode(), SerializationHelper.serializeTextAnnotationToBytes(ta)); } catch (IOException e) { throw new RuntimeException(e); } db.commit(); }
@Override public void addTextAnnotation(String dataset, TextAnnotation ta) { final ConcurrentMap<Integer, byte[]> data = getMap(dataset); try { data.put(ta.getTokenizedText().hashCode(), SerializationHelper.serializeTextAnnotationToBytes(ta)); } catch (IOException e) { throw new RuntimeException(e); } db.commit(); }
@Override public void updateTextAnnotation(TextAnnotation ta) { for (String dataset : getAllDatasets()) { final ConcurrentMap<Integer, byte[]> data = getMap(dataset); try { data.replace(ta.getTokenizedText().hashCode(), SerializationHelper.serializeTextAnnotationToBytes(ta)); } catch (IOException e) { throw new RuntimeException(e); } } db.commit(); }
@Override public void updateTextAnnotation(TextAnnotation ta) { for (String dataset : getAllDatasets()) { final ConcurrentMap<Integer, byte[]> data = getMap(dataset); try { data.replace(ta.getTokenizedText().hashCode(), SerializationHelper.serializeTextAnnotationToBytes(ta)); } catch (IOException e) { throw new RuntimeException(e); } } db.commit(); }
@Override public void addView(TextAnnotation ta) throws AnnotatorException { assert (ta.hasView(ViewNames.SENTENCE)); SpanLabelView quantifierView = new SpanLabelView(ViewNames.QUANTITIES, "illinois-quantifier", ta, 1d); List<QuantSpan> quantSpans = getSpans(ta.getTokenizedText(), true, ta); for (QuantSpan span : quantSpans) { int startToken = ta.getTokenIdFromCharacterOffset(span.start); int endToken = ta.getTokenIdFromCharacterOffset(span.end); quantifierView.addSpanLabel(startToken, endToken, span.object.toString(), 1d); } ta.addView(ViewNames.QUANTITIES, quantifierView); }
@Override public void addView(TextAnnotation ta) throws AnnotatorException { assert (ta.hasView(ViewNames.SENTENCE)); SpanLabelView quantifierView = new SpanLabelView(ViewNames.QUANTITIES, "illinois-quantifier", ta, 1d); List<QuantSpan> quantSpans = getSpans(ta.getTokenizedText(), true, ta); for (QuantSpan span : quantSpans) { int startToken = ta.getTokenIdFromCharacterOffset(span.start); int endToken = ta.getTokenIdFromCharacterOffset(span.end); quantifierView.addSpanLabel(startToken, endToken, span.object.toString(), 1d); } ta.addView(ViewNames.QUANTITIES, quantifierView); }