forked from AmitMY/chimera
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(experiments): add manaual evaluation
- Loading branch information
Showing
15 changed files
with
3,700 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/ | ||
libs/ | ||
!libs/__init__.py | ||
cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,20 @@ | ||
from itertools import chain | ||
from json import load | ||
|
||
from amt.manual.create import files, load_delex, ids, seen_limit, corpus | ||
import numpy as np | ||
|
||
samples = load(open("samples.json")) | ||
if __name__ == "__main__": | ||
samples = load(open("samples.json")) | ||
rdfs = list(chain.from_iterable([s["rdf"] for s in samples])) | ||
hal = np.sum([s["hal"] for s in samples]) | ||
|
||
mapper = {(s["id"], s["sen"]): s for s in samples} | ||
total = len(rdfs) | ||
exists = len([r for s, r, o, res in rdfs if res == "yes"]) | ||
doesnt = len([r for s, r, o, res in rdfs if res == "no"]) | ||
wrong = len([r for s, r, o, res in rdfs if res == "no-lex"]) | ||
wrong_reg = len([r for s, r, o, res in rdfs if res == "no-reg"]) | ||
|
||
# if __name__ == "__main__": | ||
# for f in files: | ||
# s = load_delex(f) | ||
# | ||
# scores = [] | ||
# | ||
# for id in ids: | ||
# if id <= seen_limit: | ||
# id = id - 1 | ||
# sen = s[id].lower().replace("ent_", "<b>ent_").replace("_ent", "_ent</b>") | ||
# | ||
# key = (id, relex(sen)) | ||
# if key in mapper: | ||
# scores.append(mapper[(id, relex(sen))]) | ||
# | ||
# rdfs = hal = exists = doesnt = wrong = 0 | ||
# for sc in scores: | ||
# hal += sc["hal"] | ||
# rdfs += len(sc["rdf"]) | ||
# exists += len([r for s, r, o, res in sc["rdf"] if res == "yes"]) | ||
# doesnt += len([r for s, r, o, res in sc["rdf"] if res == "no"]) | ||
# wrong += len([r for s, r, o, res in sc["rdf"] if res == "no-lex"]) | ||
# | ||
# print(f, "rdfs", rdfs, "hallucinations", hal, "exists", exists, "doesn't", doesnt, "wrong-lex", wrong) | ||
# print("verify", exists, "+", doesnt, "+", wrong, "=", exists+doesnt+wrong) | ||
print([(s,r,o) for s, r, o, res in rdfs if res == "no"]) | ||
|
||
print("rdfs", total, "hallucinations", hal, "exists", exists, "doesn't", doesnt, "wrong-lex", wrong, "wrong-reg", wrong_reg) | ||
print("verify", exists, "+", doesnt, "+", wrong, "+", wrong_reg, "=", total) |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.