forked from snorkel-team/snorkel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.py
26 lines (20 loc) · 973 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from builtins import *
import pandas as pd
from snorkel.models import StableLabel
from snorkel.db_helpers import reload_annotator_labels
FPATH = 'data/gold_labels.tsv'
def load_external_labels(session, candidate_class, annotator_name='gold'):
gold_labels = pd.read_csv(FPATH, sep="\t")
for index, row in gold_labels.iterrows():
session.add(StableLabel(tweet = row['content'], annotator_name = annotator_name, value = row['label']))
# Commit session
session.commit()
# Reload annotator labels
reload_annotator_labels(session, candidate_class, annotator_name, split=1, filter_label_split=False)
reload_annotator_labels(session, candidate_class, annotator_name, split=2, filter_label_split=False)
def load_gold_labels(session, candidate_class, annotator_name='gold'):
pass