Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Predict the next line after this snippet: <|code_start|> agent_type='OTHER',
agent_role='CREATOR',
othertype='SOFTWARE'))
else:
agents = [mets.agent(attributes["organization_name"],
... | mets_element = mets_extend(mets_element, |
Next line prediction: <|code_start|> # define trainable parameters
self._params = [self.X2Y, self.y_bias]
def train(self, a_ts, a_dev_data=None):
"""Method for training the model.
Args:
a_ts (list(2-tuple(x, y))):
list of training JSON data
a_dev_data (2-tu... | a_ts = [(floatX(x), floatX(y)) for x, y in a_ts] |
Using the snippet: <|code_start|> self.y_pred = TT.nnet.softmax(
TT.tensordot(self.x, self.X2Y, ((1, 0), (2, 1))) + self.y_bias)
# predicted label
self.y_lbl = TT.argmax(self.y_pred, axis=1)[0]
self._predict = theano.function([self.x],
[... | f_grad_shared, f_update, _ = rmsprop(self._params, gradients, |
Continue the code snippet: <|code_start|> # name="predict")
gradients = TT.grad(cost, wrt=self._params)
f_grad_shared, f_update, _ = rmsprop(self._params, gradients,
[self.x], y_gold, cost)
# perform actual training
... | if abs(prev_icost - icost) < CONV_EPS: |
Given snippet: <|code_start|># Class
class BaseJudge(object):
"""Meta-classifier.
This classifier unites decisions of other multiple independent classifiers.
Attrs:
Methods:
"""
def __init__(self, a_n_x, a_n_y):
"""Class constructor.
Args:
a_n_x (int):
num... | self.y_bias = theano.shared(value=HE_UNIFORM((1, self.n_y)), |
Predict the next line for this snippet: <|code_start|> self._params = [self.X2Y, self.y_bias]
def train(self, a_ts, a_dev_data=None):
"""Method for training the model.
Args:
a_ts (list(2-tuple(x, y))):
list of training JSON data
a_dev_data (2-tuple(dict, dict) or N... | for i in xrange(MAX_ITERS): |
Here is a snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
"""Module providing class for generic word embeddings.
Attributes:
WEMB (class):
class for fast retrieval and adjustment of the Google word embeddings
"""
#############################################################... | def __init__(self, a_w2v=W2V): |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
"""Module providing class for generic word embeddings.
Attributes:
WEMB (class):
class for fast retrieval and adjustment of the Google word embeddings
"""
######################################... | @singleton |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
#################... | lstm = LSTMImplicitSenser() |
Given the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import, print_function
##################################################################
# Constants
N_Y =... | self.xgb = XGBoostBaseSenser() |
Based on the snippet: <|code_start|>
Returns:
method: wrapped method
"""
def _wrapper(*args, **kwargs):
print(self.msg + " started", file=sys.stderr)
start_time = datetime.utcnow()
a_func(*args, **kwargs)
end_time = datetime.utcnow()
... | return bool(a_rel[CONNECTIVE][TOK_LIST]) |
Next line prediction: <|code_start|>
Returns:
method: wrapped method
"""
def _wrapper(*args, **kwargs):
print(self.msg + " started", file=sys.stderr)
start_time = datetime.utcnow()
a_func(*args, **kwargs)
end_time = datetime.utcnow()
... | return bool(a_rel[CONNECTIVE][TOK_LIST]) |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
################... | xgb = XGBoostImplicitSenser() |
Based on the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
######################... | svd = SVDImplicitSenser() |
Next line prediction: <|code_start|> ["authorization", {"PartOfSpeech": "NN"}],
[".", {"PartOfSpeech": "."}]]}]}}
REL1 = {"DocID": "wsj_2200",
"Arg1": {"CharacterSpanList": [[517, 564]],
"RawText": "to restrict the RTC to Treasury"
... | b = _norm_vec(a) |
Continue the code snippet: <|code_start|> "RawText": "to restrict the RTC to Treasury"
" borrowings only",
"TokenList": [[517, 519, 85, 2, 3], [520, 528, 86, 2, 4],
[529, 532, 87, 2, 5], [533, 536, 88, 2, 6],
... | assert _norm_word("124345") == "1" |
Given the code snippet: <|code_start|> "Arg2": {"CharacterSpanList": [[573, 629]], "RawText": "the agency"
" receives specific congressional authorization",
"TokenList": [[573, 576, 95, 2, 13], [577, 583, 96, 2, 14],
[584, 592, 97, 2, 15], [593, 60... | class NNBase(NNBaseSenser): |
Predict the next line after this snippet: <|code_start|> w2v=word2vec, _trained=True,
_predict_func_emb=fmock):
self.nnbs._init_wemb_funcs()
assert word2vec.load.called
assert self.nnbs.ndim == word2vec.ndim
assert se... | assert self.nnbs.ndim == DFLT_VDIM |
Given snippet: <|code_start|> ["restrict", {"PartOfSpeech": "VB"}],
["the", {"PartOfSpeech": "DT"}],
["RTC", {"PartOfSpeech": "NNP"}],
["to", {"PartOfSpeech": "TO"}],
["Treasury", {"PartOfSpeech":... | CONNECTIVE: {"CharacterSpanList": [[566, 572]], RAW_TEXT: "unless", |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
DOC_I... | SENTENCES: [{WORDS: []}, {WORDS: []}, |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
DOC_ID = "wsj_2200"
PARSE1 = {... | SENTENCES: [{WORDS: []}, {WORDS: []}, |
Using the snippet: <|code_start|> ["restrict", {"PartOfSpeech": "VB"}],
["the", {"PartOfSpeech": "DT"}],
["RTC", {"PartOfSpeech": "NNP"}],
["to", {"PartOfSpeech": "TO"}],
["Treasury", {"PartOfSpee... | CONNECTIVE: {"CharacterSpanList": [[566, 572]], RAW_TEXT: "unless", |
Here is a snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import, unicode_literals, print_function
##################################################################
# Co... | self.svd = SVDBaseSenser(a_w2v=True) |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import, unicode_literals, print_function
#################################... | assert self.svd.intm_dim >= MIN_DIM |
Given the code snippet: <|code_start|>##################################################################
# Constants
##################################################################
# Test Classes
class TestSVDBaseSenser(TestCase):
@fixture(autouse=True)
def set_svd(self):
with patch.object(dsenser.... | ret = get_svd(floatX(np.random.randn(20, 30))) |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
#... | lstm = LSTMExplicitSenser() |
Based on the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
#######################... | wang = WangSenser() |
Using the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Auxiliary Class
@singleton
class Aux(... | assert is_explicit({CONNECTIVE: {TOK_LIST: [1, 2, 3]}}) |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Auxiliary Class
@singleton
class Aux(obje... | assert is_explicit({CONNECTIVE: {TOK_LIST: [1, 2, 3]}}) |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Auxiliary Class
@singleton
cl... | assert is_explicit({CONNECTIVE: {TOK_LIST: [1, 2, 3]}}) |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
"""Module providing class for XGBoost sense disambiguation.
Attributes:
XGBoostSenser (class):
class for XGBoost sense classification of explicit and implicit relations
"""
###############################################... | class XGBoostSenser(WangSenser): |
Next line prediction: <|code_start|># Imports
from __future__ import absolute_import, print_function, \
unicode_literals
##################################################################
# Constants
##################################################################
# Class
class XGBoostSenser(WangSenser):
... | self.explicit = XGBoostExplicitSenser(**kwargs) |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import absolute_import, print_function, \
unicode_literals
##################################################################
# Constants
##################################################################
# Class
class XGBoos... | self.implicit = XGBoostImplicitSenser(**kwargs) |
Here is a snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
ON_THE_CONTRARY = (("on",... | BROWN_CLUSTERS = LoadOnDemand(load_BROWN, TEST_BROWN_PATH) |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
ON_THE_CONTRARY = (("on", "th... | BROWN_CLUSTERS = LoadOnDemand(load_BROWN, TEST_BROWN_PATH) |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
ON_THE_CONTRARY = (("on", "th... | assert ON_THE_CONTRARY in CONNS |
Next line prediction: <|code_start|>
def test_INQUIRER(self):
assert "" not in INQUIRER
assert INQUIRER["won"] == [False, False, False, False, True,
False, True, False, False, False,
False, False, False, False, True,
... | mock_method.assert_any_call(DFLT_W2V_PATH, binary=True) |
Here is a snippet: <|code_start|>##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
ON_THE_CONTRARY = (("on", "the", "contrary"),)
NEITHER_NOT = (("neither", ), ("nor",))
... | assert "" not in INQUIRER |
Continue the code snippet: <|code_start|>BROWN_CLUSTERS = LoadOnDemand(load_BROWN, TEST_BROWN_PATH)
##################################################################
# Test Classes
class TestResources(TestCase):
def test_BROWN_CLUSTERS(self):
assert BROWN_CLUSTERS["jasper"] == "1100011110"
assert... | assert LCSI["unionize"] == set(["45.4.a", "45.4.b", "45.4.c"]) |
Next line prediction: <|code_start|># Test Classes
class TestResources(TestCase):
def test_BROWN_CLUSTERS(self):
assert BROWN_CLUSTERS["jasper"] == "1100011110"
assert BROWN_CLUSTERS["un"] == "1100011110|1110110010|1011010110"
assert "" not in BROWN_CLUSTERS
def test_CONNS(self):
... | assert MPQA["zealously"] == ("negative", "strongsubj", "anypos") |
Given the code snippet: <|code_start|>ON_THE_CONTRARY = (("on", "the", "contrary"),)
NEITHER_NOT = (("neither", ), ("nor",))
EMPTY = ((), )
BROWN_CLUSTERS = LoadOnDemand(load_BROWN, TEST_BROWN_PATH)
##################################################################
# Test Classes
class TestResources(TestCase):
de... | assert INQUIRER["won"] == STEMMED_INQUIRER["won"] |
Here is a snippet: <|code_start|> assert EMPTY not in CONNS
def test_INQUIRER(self):
assert "" not in INQUIRER
assert INQUIRER["won"] == [False, False, False, False, True,
False, True, False, False, False,
False, False, Fa... | W2V["zzz"] |
Given the code snippet: <|code_start|> assert BROWN_CLUSTERS["jasper"] == "1100011110"
assert BROWN_CLUSTERS["un"] == "1100011110|1110110010|1011010110"
assert "" not in BROWN_CLUSTERS
def test_CONNS(self):
assert ON_THE_CONTRARY in CONNS
assert NEITHER_NOT in CONNS
a... | assert conn2str(ON_THE_CONTRARY) == "on_the_contrary" |
Given the code snippet: <|code_start|>POL = "priorpolarity"
POL_IDX = 0
INTENS = "type"
INTENS_IDX = 1
POS = "pos1"
POS_IDX = 2
NEGATIONS = set(["cannot", "not", "none", "nothing",
"nowhere", "neither", "nor", "nobody",
"hardly", "scarcely", "barely", "never",
"n't", "... | with codecs.open(a_fname, 'r', ENCODING, |
Given the code snippet: <|code_start|>
def load(self):
"""Force loading the resource.
Note:
loads the resource
"""
if self.resource is None:
self.resource = self.cmd(*self.args, **self.kwargs)
return self.resource
def unload(self):
"""Unlo... | BROWN_CLUSTERS = LoadOnDemand(load_BROWN, DFLT_BROWN_PATH) |
Based on the snippet: <|code_start|> def load(self):
"""Force loading the resource.
Note:
loads the resource
"""
if self.resource is None:
self.resource = self.cmd(*self.args, **self.kwargs)
return self.resource
def unload(self):
"""Unload ... | CONNS = load_conns(DFLT_ECONN_PATH) |
Next line prediction: <|code_start|>
Note:
unloads the resource
"""
if self.resource is not None:
print("Unloading resource '{:s}'...".format(repr(self.resource)),
file=sys.stderr)
del self.resource
self.resource = None
... | INQUIRER, STEMMED_INQUIRER = load_INQUIRER(DFLT_INQUIRER_PATH) |
Predict the next line after this snippet: <|code_start|> return self.resource.__getitem__(a_name)
def load(self):
"""Force loading the resource.
Note:
loads the resource
"""
if self.resource is None:
self.resource = self.cmd(*self.args, **self.kwargs)
... | LCSI = load_LCSI(DFLT_LCSI_PATH) |
Using the snippet: <|code_start|> Note:
unloads the resource
"""
if self.resource is not None:
print("Unloading resource '{:s}'...".format(repr(self.resource)),
file=sys.stderr)
del self.resource
self.resource = None
gc... | MPQA = load_MPQA(DFLT_MPQA_PATH) |
Next line prediction: <|code_start|> unloads the resource
"""
if self.resource is not None:
print("Unloading resource '{:s}'...".format(repr(self.resource)),
file=sys.stderr)
del self.resource
self.resource = None
gc.collect()
... | W2V = LoadOnDemand(load_W2V, DFLT_W2V_PATH) |
Given the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
"""Module providing class for SVD sense disambiguation.
Attributes:
SVDImplicitSenser (class):
class that predicts senses of implicit relations
"""
###############################################################... | class SVDImplicitSenser(SVDBaseSenser): |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
"""Module providing class for SVD sense disambiguation.
Attributes:
SVDImplicitSenser (class):
class that predicts senses of implicit relations
"""
##############################... | @timeit("Training implicit SVD classifier...") |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
#############################... | svd = SVDSenser() |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
####... | assert isinstance(svd.explicit, SVDBaseSenser) |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Variables and C... | self.w2v = Word2Vec |
Predict the next line for this snippet: <|code_start|> np.array: modified ``a_ret``
"""
if self.wbench is None:
self.wbench = np.zeros((len(self.models), len(self.cls2idx)))
else:
self.wbench *= 0
for i, imodel in enumerate(self.models):
imod... | arg = irel[ARG1] |
Predict the next line after this snippet: <|code_start|> if self.wbench is None:
self.wbench = np.zeros((len(self.models), len(self.cls2idx)))
else:
self.wbench *= 0
for i, imodel in enumerate(self.models):
imodel.predict(a_rel, a_data, self.wbench, i)
... | arg = irel[ARG2] |
Continue the code snippet: <|code_start|> Returns:
np.array: modified ``a_ret``
"""
if self.wbench is None:
self.wbench = np.zeros((len(self.models), len(self.cls2idx)))
else:
self.wbench *= 0
for i, imodel in enumerate(self.models):
... | irel[CONNECTIVE].pop(CHAR_SPAN) |
Based on the snippet: <|code_start|> self.models.append(WangSenser(a_grid_search=a_grid_search))
if a_type & XGBOOST:
self.models.append(XGBoostSenser(a_grid_search=a_grid_search))
# NN models have to go last, since we are pruning the parses for them
# to free some memory
... | irel[CONNECTIVE][RAW_TEXT])) |
Given the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
"""Module providing class for sense disambiguation of connectives.
Attributes:
DiscourseSenser (class): class for sense disambiguation of connectives
"""
#############################################################... | with codecs.open(DFLT_ECONN_PATH, 'r', ENCODING) as ifile: |
Continue the code snippet: <|code_start|> self.models.append(WangSenser(a_grid_search=a_grid_search))
if a_type & XGBOOST:
self.models.append(XGBoostSenser(a_grid_search=a_grid_search))
# NN models have to go last, since we are pruning the parses for them
# to free some me... | irel[CONNECTIVE][RAW_TEXT])) |
Using the snippet: <|code_start|> if a_type == 0:
raise RuntimeError("No model type specified.")
if a_dev_data is None:
a_dev_data = ([], {})
# initialize models
if a_type & MJR:
self.models.append(MajorSenser())
if a_type & WANG:
se... | for isense in irel[SENSE]: |
Continue the code snippet: <|code_start|> for isentences in a_parses.itervalues():
for isent in isentences[SENTENCES]:
isent.pop(PARSE_TREE)
isent.pop(DEPS)
for iword in isent[WORDS]:
iword[-1].clear()
return (a_rels, a_parse... | if len(irel[CONNECTIVE][TOK_LIST]) == 0: |
Using the snippet: <|code_start|> relation in question
Returns:
(void)
"""
conn = a_rel[CONNECTIVE]
conn_txt = conn.get(RAW_TEXT, None)
if conn_txt is not None:
if not conn.get(TOK_LIST, None):
rel = IMPLICIT
elif self._n... | return [el[TOK_OFFS_IDX] if isinstance(el, Iterable) else el |
Here is a snippet: <|code_start|> self.models.append(MajorSenser())
if a_type & WANG:
self.models.append(WangSenser(a_grid_search=a_grid_search))
if a_type & XGBOOST:
self.models.append(XGBoostSenser(a_grid_search=a_grid_search))
# NN models have to go last, si... | if irel[TYPE] == EXPLICIT: |
Predict the next line after this snippet: <|code_start|> meta-classifier
cls2idx (dict):
mapping from class to index
idx2cls (dict):
mapping from index to class
econn (set):
connectives marking explicit relations
"""
def __init__(self, a_model=None):
""... | a_path=DFLT_MODEL_PATH, a_dev_data=None, |
Given the code snippet: <|code_start|> judge (dsenser.Judge):
meta-classifier
cls2idx (dict):
mapping from class to index
idx2cls (dict):
mapping from index to class
econn (set):
connectives marking explicit relations
"""
def __init__(self, a_model=None):... | def train(self, a_train_data, a_type=DFLT_MODEL_TYPE, |
Based on the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
"""Module providing class for sense disambiguation of connectives.
Attributes:
DiscourseSenser (class): class for sense disambiguation of connectives
"""
###############################################################... | with codecs.open(DFLT_ECONN_PATH, 'r', ENCODING) as ifile: |
Next line prediction: <|code_start|> """
n_senses = len(self.cls2idx)
isense = isenses = vsense = None
for irel in a_rels:
isenses = irel[SENSE]
vsense = np.zeros(n_senses)
for isense in isenses:
isense = SHORT2FULL.get(isense, isense)
... | rel = ALT_LEX |
Predict the next line after this snippet: <|code_start|> self.models.append(MajorSenser())
if a_type & WANG:
self.models.append(WangSenser(a_grid_search=a_grid_search))
if a_type & XGBOOST:
self.models.append(XGBoostSenser(a_grid_search=a_grid_search))
# NN mod... | if irel[TYPE] == EXPLICIT: |
Based on the snippet: <|code_start|>
Note:
updates ``a_rels`` in place
"""
n_senses = len(self.cls2idx)
isense = isenses = vsense = None
for irel in a_rels:
isenses = irel[SENSE]
vsense = np.zeros(n_senses)
for isense in isenses:
... | rel = IMPLICIT |
Predict the next line after this snippet: <|code_start|> a_type (str):
type of the model to be trained
a_dev_data (list or None):
development set
a_grid_search (bool):
use grid search in order to determine hyper-paramaters of
the model
... | if a_type & SVD: |
Given the following code snippet before the placeholder: <|code_start|> a_lstsq (bool):
use least squares method
Returns:
void:
"""
if a_type == 0:
raise RuntimeError("No model type specified.")
if a_dev_data is None:
a_dev_data = ... | if a_type & LSTM: |
Given the code snippet: <|code_start|> a_path=DFLT_MODEL_PATH, a_dev_data=None,
a_grid_search=False, a_w2v=False, a_lstsq=False):
"""Train specified model(s) on the provided data.
Args:
a_train_data (list or None):
training set
a_path (str):
... | if a_type & MJR: |
Based on the snippet: <|code_start|> """Train specified model(s) on the provided data.
Args:
a_train_data (list or None):
training set
a_path (str):
path for storing the model
a_type (str):
type of the model to be trained
a_dev_... | if a_type & WANG: |
Here is a snippet: <|code_start|> Args:
a_train_data (list or None):
training set
a_path (str):
path for storing the model
a_type (str):
type of the model to be trained
a_dev_data (list or None):
development set
a_g... | if a_type & XGBOOST: |
Here is a snippet: <|code_start|>
def _prune_data(self, a_rels, a_parses):
"""Remove unnecessary information from data.
Args:
a_rels (list):
list of input discourse relations
a_parses (dict):
parse trees
Returns:
2-tuple(list, dict):
ab... | isent.pop(PARSE_TREE) |
Continue the code snippet: <|code_start|> def _prune_data(self, a_rels, a_parses):
"""Remove unnecessary information from data.
Args:
a_rels (list):
list of input discourse relations
a_parses (dict):
parse trees
Returns:
2-tuple(list, dict):
... | isent.pop(DEPS) |
Using the snippet: <|code_start|> """Remove unnecessary information from data.
Args:
a_rels (list):
list of input discourse relations
a_parses (dict):
parse trees
Returns:
2-tuple(list, dict):
abridged input data
"""
arg = N... | for iword in isent[WORDS]: |
Predict the next line after this snippet: <|code_start|> return self.wbench
def _prune_data(self, a_rels, a_parses):
"""Remove unnecessary information from data.
Args:
a_rels (list):
list of input discourse relations
a_parses (dict):
parse trees
... | for isent in isentences[SENTENCES]: |
Given snippet: <|code_start|> raise RuntimeError("No model type specified.")
if a_dev_data is None:
a_dev_data = ([], {})
# initialize models
if a_type & MJR:
self.models.append(MajorSenser())
if a_type & WANG:
self.models.append(WangSenser(... | isense = SHORT2FULL.get(isense, isense) |
Using the snippet: <|code_start|> str: normalized connective
"""
a_conn = a_conn.strip().lower()
if a_conn:
return CHM.map_raw_connective(a_conn)[0]
return a_conn
def _get_toks_pos(self, a_parses, a_rel, a_arg):
"""Method for getting raw tokens with the... | ret.append((wrd[TOK_IDX].lower(), wrd[1].get(POS))) |
Predict the next line after this snippet: <|code_start|> relation argument to obtain senses for
Returns:
list: list of tokens and their parts of speech
"""
ret = []
snt = wrd = None
for s_id, w_ids in \
self._get_snt2tok(a_rel[a_arg][TOK_LIS... | snt_id = el[SNT_ID] |
Using the snippet: <|code_start|> str: normalized connective
"""
a_conn = a_conn.strip().lower()
if a_conn:
return CHM.map_raw_connective(a_conn)[0]
return a_conn
def _get_toks_pos(self, a_parses, a_rel, a_arg):
"""Method for getting raw tokens with the... | ret.append((wrd[TOK_IDX].lower(), wrd[1].get(POS))) |
Predict the next line after this snippet: <|code_start|>
Returns:
list: list of tokens and their parts of speech
"""
ret = []
snt = wrd = None
for s_id, w_ids in \
self._get_snt2tok(a_rel[a_arg][TOK_LIST]).iteritems():
snt = a_parses[s_id][W... | snt2tok_pos[snt_id].add(el[TOK_ID]) |
Given snippet: <|code_start|> a_conn (str):
connectve to be normalized
Returns:
str: normalized connective
"""
a_conn = a_conn.strip().lower()
if a_conn:
return CHM.map_raw_connective(a_conn)[0]
return a_conn
def _get_toks_pos(sel... | self._get_snt2tok(a_rel[a_arg][TOK_LIST]).iteritems(): |
Predict the next line for this snippet: <|code_start|> connectve to be normalized
Returns:
str: normalized connective
"""
a_conn = a_conn.strip().lower()
if a_conn:
return CHM.map_raw_connective(a_conn)[0]
return a_conn
def _get_toks_pos(se... | snt = a_parses[s_id][WORDS] |
Here is a snippet: <|code_start|> tuple:
trainings set with explicit and implicit connectives
"""
if not a_ds:
return (([], {}), ([], {}))
explicit_instances = []
implicit_instances = []
for i, irel in enumerate(a_ds[0]):
if is_explic... | return CHM.map_raw_connective(a_conn)[0] |
Using the snippet: <|code_start|> Returns:
void:
Note:
modifies ``a_ret`` in place
"""
for i, irel in enumerate(a_rels):
self.predict(irel, a_data, a_ret, i)
def predict(self, a_rel, a_data, a_ret, a_i):
"""Method for predicting sense of sing... | if is_explicit(a_rel): |
Next line prediction: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
"""Module providing class for SVD sense disambiguation.
Attributes:
SVDExplicitSenser (class):
class that predicts senses of explicit relations
"""
#################################################################... | class SVDExplicitSenser(SVDBaseSenser): |
Given the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
"""Module providing class for SVD sense disambiguation.
Attributes:
SVDExplicitSenser (class):
class that predicts senses of explicit relations
"""
###############################################################... | @timeit("Training explicit SVD classifier...") |
Next line prediction: <|code_start|>
Returns:
(void)
"""
return
# # divide training set into explicit and implicit relations
# exp_train, imp_train = self._divide_data(a_train)
# exp_dev, imp_dev = self._divide_data(a_dev)
# # train explicit judge
... | if is_explicit(a_rel): |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
####... | svd = SVDExplicitSenser() |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Constants
################... | xgb = XGBoostExplicitSenser() |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################... | scalar = floatX(0) |
Using the snippet: <|code_start|>MAX_I = 7
##################################################################
# Methods
def test_floatX_0():
scalar = floatX(0)
assert scalar.dtype == config.floatX
assert isinstance(scalar, np.ndarray)
def test_floatX_1():
scalar = floatX(range(5))
assert scalar.... | cost_func, update_func, rms_params = rmsprop(params, grads, |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Test Classes... | irels = [{CONNECTIVE: {RAW_TEXT: "SINCE"}, |
Based on the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Test Classes
class TestMajorSens... | irels = [{CONNECTIVE: {RAW_TEXT: "SINCE"}, |
Next line prediction: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Test Classes
class TestMajorSens... | SENSE: ["Contingency.Cause.Reason"]}, |
Based on the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
##################################################################
# Test Classes
class TestMajorSens... | self.ds = MajorSenser() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.