Skip to content

Commit

Permalink
Use the snorkel context sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
iross committed Dec 17, 2016
1 parent 5e80fb5 commit 1e0717c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions remap_sentences.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

count = 1
for docid in cursor:
snorkel_cursor.execute("INSERT INTO context (id, type, stable_id) VALUES (nextval('seq'), 'document', %(stable_id)s)", {"stable_id": docid[0] + "::document:0:0"})
snorkel_cursor.execute("INSERT INTO document (id, name) VALUES (currval('seq'), %(docid)s)", {"count" : count, "docid": docid[0]})
snorkel_cursor.execute("INSERT INTO context (id, type, stable_id) VALUES (nextval('context_id_seq'), 'document', %(stable_id)s)", {"stable_id": docid[0] + "::document:0:0"})
snorkel_cursor.execute("INSERT INTO document (id, name) VALUES (currval('context_id_seq'), %(docid)s)", {"count" : count, "docid": docid[0]})
snorkel_connection.commit()
count += 1

Expand Down Expand Up @@ -79,12 +79,12 @@
doc_char_counts[sent[0]] = sentence_running_count

# keep this running count as the sentence-level offset stable_id
snorkel_cursor.execute("INSERT INTO context (id, type, stable_id) VALUES (nextval('seq'), 'sentence', %(stable_id)s)", {"stable_id": sent[0] + "::sentence:%s:%s" % (sentence_start, doc_char_counts[sent[0]])})
snorkel_cursor.execute("INSERT INTO context (id, type, stable_id) VALUES (nextval('context_id_seq'), 'sentence', %(stable_id)s)", {"stable_id": sent[0] + "::sentence:%s:%s" % (sentence_start, doc_char_counts[sent[0]])})

snorkel_connection.commit()
snorkel_cursor.execute(" \
INSERT INTO sentence (id, document_id, position, words, pos_tags, ner_tags, lemmas, dep_labels, dep_parents, char_offsets, text) VALUES \
(currval('seq'), \
(currval('context_id_seq'), \
%(document_id)s, \
%(position)s, \
%(words)s, \
Expand Down

0 comments on commit 1e0717c

Please sign in to comment.