Skip to content

Commit

Permalink
Ran black
Browse files Browse the repository at this point in the history
  • Loading branch information
elliott authored and elliott committed Jan 2, 2021
1 parent 286bbba commit ab69a88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 9 additions & 5 deletions lib/bankofparliament/graphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
class GraphDB:
"""Generates neo4j database"""

def __init__(
self, host, port, user, password, entities, relationships, logger
):
def __init__(self, host, port, user, password, entities, relationships, logger):
"""Initialise the neo4j graphdb class"""
self.logger = logger
self.host = host
Expand Down Expand Up @@ -104,7 +102,13 @@ def create_node(self, node):
if node_type in ["politician", "advisor"]:
node_type = ":".join([node_type, "person"])

elif node_type not in ["person", "politician", "advisor", "property", "profession"]:
elif node_type not in [
"person",
"politician",
"advisor",
"property",
"profession",
]:
node_type = ":".join([node_type, "organisation"])

del node["entity_type"]
Expand Down Expand Up @@ -184,7 +188,7 @@ def cypher_arguments_from_dict(self, data):
for key, value in data.items():
if key not in ["relationship_type", "entity_type", "aliases", "resolved"]:
if key == "amount":
node_string += '{}: {}, '.format(key, value)
node_string += "{}: {}, ".format(key, value)
else:
node_string += '{}: "{}", '.format(key, value)
return "{" + node_string[:-2] + "}"
10 changes: 5 additions & 5 deletions lib/bankofparliament/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def result_matches_query(name, query, logger, min_word_length=2):
and len(query.split()) >= min_word_length
):
logger.debug("Matched: {} ---> {}".format(query, name))
return name.upper().replace('"', '')
return name.upper().replace('"', "")

normalised_name = normalise_organisation_name(_name)
normalised_query = normalise_organisation_name(_query)
Expand All @@ -381,27 +381,27 @@ def result_matches_query(name, query, logger, min_word_length=2):
if normalised_name == normalised_query:
if len(query.split()) >= min_word_length:
logger.debug("Matched: {} ---> {}".format(query, name))
return name.upper().replace('"', '')
return name.upper().replace('"', "")
possibles.append(name)

if normalised_name in normalised_query:
if len(normalised_name.split()) > min_word_length:
logger.debug("Matched: {} ---> {}".format(query, name))
return name.upper().replace('"', '')
return name.upper().replace('"', "")
possibles.append(name)

elif normalised_query in normalised_name:
if len(normalised_query.split()) > min_word_length:
logger.debug("Matched: {} ---> {}".format(query, name))
return name.upper().replace('"', '')
return name.upper().replace('"', "")
possibles.append(name)

if strip_non_alphanumeric(normalised_name) == strip_non_alphanumeric(
normalised_query
):
if len(query.split()) >= min_word_length:
logger.debug("Matched: {} ---> {}".format(query, name))
return name.upper().replace('"', '')
return name.upper().replace('"', "")

if possibles:
for poss in possibles:
Expand Down

0 comments on commit ab69a88

Please sign in to comment.