Merge pull request '#64-consolidate-validation' (#69) from #64-consolidate-validation into main
Reviewed-on: #69pull/72/head
commit
feb52bf7a8
|
|
@ -1,12 +1,46 @@
|
||||||
|
from typing import Dict, List
|
||||||
|
|
||||||
|
|
||||||
def validate_entities(entities):
|
def validate_entities(entities):
|
||||||
return entities
|
result = []
|
||||||
#todo
|
reduced_kpi: Dict[str, List[Dict[str, str | int]]] = {}
|
||||||
valid = []
|
for item in entities:
|
||||||
for entity in entities:
|
label = item["label"]
|
||||||
if entity["type"] == "PERSON":
|
if label not in reduced_kpi:
|
||||||
if entity["name"] == "John Doe":
|
reduced_kpi[label] = []
|
||||||
valid.append(entity)
|
reduced_kpi[label].append(item)
|
||||||
elif entity["type"] == "ORG":
|
|
||||||
if entity["name"] == "Exxeta":
|
for item in reduced_kpi.items():
|
||||||
valid.append(entity)
|
if item[0] == "FONDSNAME":
|
||||||
return valid
|
result.extend(item[1])
|
||||||
|
continue
|
||||||
|
elif item[0] == "DATUM":
|
||||||
|
result.extend(item[1])
|
||||||
|
continue
|
||||||
|
elif item[0] == "FONDSMANAGER":
|
||||||
|
result.extend(item[1])
|
||||||
|
continue
|
||||||
|
|
||||||
|
validated = False
|
||||||
|
for entity in item[1]:
|
||||||
|
if entity["status"] == "validated":
|
||||||
|
validated = True
|
||||||
|
|
||||||
|
if validated:
|
||||||
|
item_list = [x for x in item[1] if x["status"] == "validated"]
|
||||||
|
result.extend(item_list)
|
||||||
|
else:
|
||||||
|
result.extend(item[1])
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
entities = [
|
||||||
|
{"label": "PERSON", "entity": "John Doe", "status": "validated"},
|
||||||
|
{"label": "PERSON", "entity": "Exxeta", "status": "invalid"},
|
||||||
|
{"label": "ORG", "entity": "Google", "status": "invalid"},
|
||||||
|
{"label": "FONDSNAME", "entity": "Microsoft", "status": "validated"},
|
||||||
|
{"label": "FONDSNAME", "entity": "Amazon", "status": "invalid"},
|
||||||
|
{"label": "FONDSNAME", "entity": "Apple", "status": "invalid"}
|
||||||
|
]
|
||||||
|
print(validate_entities(entities))
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ function ExtractedResultsPage() {
|
||||||
} else {
|
} else {
|
||||||
const index = Number.parseInt(value);
|
const index = Number.parseInt(value);
|
||||||
setSelectedIndex(index);
|
setSelectedIndex(index);
|
||||||
|
setCurrentPage(kpiValues[index].page);
|
||||||
setCustomValue("");
|
setCustomValue("");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -104,6 +105,7 @@ function ExtractedResultsPage() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRowClick = (index: number) => {
|
const handleRowClick = (index: number) => {
|
||||||
|
setCurrentPage(kpiValues[index].page);
|
||||||
setSelectedIndex(index);
|
setSelectedIndex(index);
|
||||||
setCustomValue("");
|
setCustomValue("");
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue