// TODO: use mention-specific data
for entity in response.get("entities", []):
mentions = []
entity_data = {}
for k, v in entity.items():
if k == "mentions":
mentions = [self._get_span(m) for m in v]
elif k == "sentiment":
entity_data.update(self._prefix_keys(v, "sentiment"))
elif k != "name": // avoid redundancy with "text" field
entity_data["entity_%s" % k] = v
for m in mentions:
After Change
// Entity-level features
// TODO: use mention-specific data
for entity in response.get("entities", []):
entity_copy = entity.copy()
mentions = entity_copy.pop("mentions", [])
entity_copy.pop("name", None)
for m in mentions: