Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix #173

Merged
merged 2 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/fonduer/features/feature_libs/tree_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def corenlp_to_xmltree(s, prune_root=True):
if not isinstance(s, dict):
try:
s = s.__dict__ if hasattr(s, "__dict__") else dict(s)
except Exception as e:
except Exception:
raise ValueError("Cannot convert input object to dict")

# Use the dep_parents array as a guide: ensure it is present and a list of
Expand All @@ -53,7 +53,7 @@ def corenlp_to_xmltree(s, prune_root=True):
)
try:
dep_parents = list(map(int, s["dep_parents"]))
except Exception as e:
except Exception:
raise ValueError("'dep_parents' attribute must be a list of ints")

# Also ensure that we are using CoreNLP-native indexing
Expand Down
4 changes: 2 additions & 2 deletions src/fonduer/learning/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def save_marginals(session, X, marginals, training=True):
# Make sure that we are working with a numpy array
try:
shape = marginals.shape
except Exception as e:
except Exception:
marginals = np.array(marginals)
shape = marginals.shape

Expand Down Expand Up @@ -82,7 +82,7 @@ def reshape_marginals(marginals):
# Make sure training marginals are a numpy array first
try:
shape = marginals.shape
except Exception as e:
except Exception:
marginals = np.array(marginals)
shape = marginals.shape

Expand Down
2 changes: 1 addition & 1 deletion src/fonduer/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def _parse_sentence(self, paragraph, node, state):
if styles is not None:
for x in list(context_node.attrib.items()):
if x[0] == "class":
exp = r"(." + x[1] + ")([\n\s\r]*)\{(.*?)\}"
exp = r"(." + x[1] + r")([\n\s\r]*)\{(.*?)\}"
r = re.compile(exp, re.DOTALL)
if r.search(styles.text) is not None:
if cur_style_index is not None:
Expand Down
2 changes: 1 addition & 1 deletion src/fonduer/parser/spacy_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from spacy.cli import download
from spacy import util
from spacy.tokens import Doc
except Exception as e:
except Exception:
raise Exception("spaCy not installed. Use `pip install spacy`.")


Expand Down
4 changes: 2 additions & 2 deletions src/fonduer/parser/visual_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, time=False, verbose=False):
self.links = None
self.pdf_dim = None
delimiters = (
u"([\(\)\,\?\u2212\u201C\u201D\u2018\u2019\u00B0\*']|(?<!http):|\.$|\.\.\.)"
r"([\(\)\,\?\u2212\u201C\u201D\u2018\u2019\u00B0\*']|(?<!http):|\.$|\.\.\.)"
)
self.separators = re.compile(delimiters)

Expand Down Expand Up @@ -289,7 +289,7 @@ def _calculate_offset(self, listA, listB, seedSize, maxOffset):
for i in range(seedSize):
try:
offsets.append(wordsB.index(wordsA[i]) - i)
except Exception as e:
except Exception:
pass
return int(np.median(offsets))

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def test_e2e(caplog):
assert L_train_gold[0].shape == (3684, 1)

gen_model = LabelModel(k=2)
gen_model.train(L_train[0], n_epochs=500, print_every=100)
gen_model.train_model(L_train[0], n_epochs=500, print_every=100)

train_marginals = gen_model.predict_proba(L_train[0])[:, 1]

Expand Down Expand Up @@ -537,7 +537,7 @@ def test_e2e(caplog):
assert L_train[0].shape == (3684, 16)

gen_model = LabelModel(k=2)
gen_model.train(L_train[0], n_epochs=500, print_every=100)
gen_model.train_model(L_train[0], n_epochs=500, print_every=100)

train_marginals = gen_model.predict_proba(L_train[0])[:, 1]

Expand Down
2 changes: 1 addition & 1 deletion tests/shared/hardware_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def part_file_name_conditions(attr):
)


add_rgx = "^[A-Z0-9\-]{5,15}$"
add_rgx = r"^[A-Z0-9\-]{5,15}$"

part_file_name_lambda_matcher = LambdaFunctionMatcher(func=part_file_name_conditions)
part_file_name_matcher = Intersect(
Expand Down
2 changes: 1 addition & 1 deletion tests/shared/hardware_spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def __init__(self, n_max=2, split_tokens=["-", "/"]):
def apply(self, session, context):
for ts in MentionNgrams.apply(self, session, context):
m = re.match(
u"^([\+\-\u2010\u2011\u2012\u2013\u2014\u2212\uf02d])?(\s*)(\d+)$",
r"^([\+\-\u2010\u2011\u2012\u2013\u2014\u2212\uf02d])?(\s*)(\d+)$",
ts.get_span(),
re.U,
)
Expand Down