Update agent to support new verification style. Update frontend to support new file format and remove redundant logic from old experiments.
This commit is contained in:
@@ -8,11 +8,9 @@ def render():
|
||||
for entry in st.session_state.data:
|
||||
st.subheader(entry.get("text"))
|
||||
|
||||
for o in entry.get("output", []):
|
||||
for c in o.get("content_parsed", []):
|
||||
st.markdown(f"**Event:** {c.get('event')}")
|
||||
st.markdown(f"**Reasoning:** {c.get('reasoningWhyRelevant')}")
|
||||
st.markdown(f"**Score:** {c.get('score')}")
|
||||
st.markdown(f"**Human Score:** {c.get('human_score')}")
|
||||
st.markdown(f"**Extra Info:** {c.get('extra_info', '')}")
|
||||
st.markdown("---")
|
||||
for c in entry.get("events", []):
|
||||
st.markdown(f"**Event:** {c.get('Event')}")
|
||||
st.markdown(f"**Reasoning:** {c.get('ReasoningWhyRelevant')}")
|
||||
st.markdown(f"**Score:** {c.get('score')}")
|
||||
st.markdown(f"**Extra Info:** {c.get('extra_info', '')}")
|
||||
st.markdown("---")
|
||||
@@ -1,7 +1,7 @@
|
||||
import random
|
||||
import streamlit as st
|
||||
from config import INPUT_FILE
|
||||
from data_utils import save_data
|
||||
from data_utils import save_data_clean
|
||||
|
||||
|
||||
def page_title() -> str:
|
||||
@@ -15,10 +15,10 @@ def render():
|
||||
for entry in st.session_state.data:
|
||||
claims = []
|
||||
|
||||
for o in entry.get("output", []):
|
||||
for c in o.get("content_parsed", []):
|
||||
if not c.get("ranked"):
|
||||
claims.append(c)
|
||||
|
||||
for c in entry.get("events", []):
|
||||
if not c.get("ranked"):
|
||||
claims.append(c)
|
||||
|
||||
if claims:
|
||||
unannotated.append({"entry": entry, "claims": claims})
|
||||
@@ -44,8 +44,8 @@ def render():
|
||||
|
||||
with st.container(border=True):
|
||||
|
||||
st.markdown(f"**Event:** {c.get('event')}")
|
||||
st.markdown(f"**Reasoning:** {c.get('reasoningWhyRelevant')}")
|
||||
st.markdown(f"**Event:** {c.get('Event')}")
|
||||
st.markdown(f"**Reasoning:** {c.get('ReasoningWhyRelevant')}")
|
||||
|
||||
cols = st.columns(7)
|
||||
temp = ""
|
||||
@@ -69,7 +69,7 @@ def render():
|
||||
c["ranked"] = True
|
||||
|
||||
if st.button("Save Annotation"):
|
||||
save_data(INPUT_FILE, st.session_state.data)
|
||||
save_data_clean(INPUT_FILE, st.session_state.data)
|
||||
st.session_state.current_claim = None
|
||||
print("Annotation saved")
|
||||
st.rerun()
|
||||
@@ -1,116 +0,0 @@
|
||||
import streamlit as st
|
||||
import copy
|
||||
import random
|
||||
from streamlit_sortables import sort_items
|
||||
from config import INPUT_FILE, OUTPUT_FILE
|
||||
from data_utils import save_data, save_data_clean
|
||||
|
||||
|
||||
def page_title() -> str:
|
||||
return "Rank"
|
||||
|
||||
def render():
|
||||
st.header("Rank Events")
|
||||
candidates = []
|
||||
|
||||
for entry in st.session_state.data:
|
||||
perfect = []
|
||||
|
||||
for o in entry.get("output", []):
|
||||
for c in o.get("content_parsed", []):
|
||||
if "PERFECT" in c.get("extra_info", "") and not c.get("rank_position"):
|
||||
perfect.append(c)
|
||||
|
||||
if perfect:
|
||||
candidates.append({"entry": entry, "claims": perfect})
|
||||
|
||||
if not candidates:
|
||||
st.info("No events available.")
|
||||
st.stop()
|
||||
|
||||
if "current_bundle" not in st.session_state:
|
||||
st.session_state.current_bundle = random.choice(candidates)
|
||||
|
||||
bundle = st.session_state.current_bundle
|
||||
entry = bundle["entry"]
|
||||
claims = bundle["claims"]
|
||||
|
||||
st.subheader(entry.get("text"))
|
||||
|
||||
# init
|
||||
if "perfect_order" not in st.session_state:
|
||||
st.session_state.perfect_order = list(range(len(claims)))
|
||||
|
||||
order = st.session_state.perfect_order
|
||||
|
||||
# labels shown in sortable UI
|
||||
labels = [
|
||||
f"{i+1}. {claims[idx].get('event')}"
|
||||
for i, idx in enumerate(order)
|
||||
]
|
||||
|
||||
st.markdown("### Drag to reorder:")
|
||||
|
||||
# -------------------------
|
||||
# Drag & drop UI
|
||||
# -------------------------
|
||||
new_labels = sort_items(labels)
|
||||
|
||||
# Convert reordered labels back → indices
|
||||
if new_labels != labels:
|
||||
new_order = []
|
||||
for lbl in new_labels:
|
||||
original_pos = labels.index(lbl)
|
||||
new_order.append(order[original_pos])
|
||||
|
||||
st.session_state.perfect_order = new_order
|
||||
order = new_order
|
||||
|
||||
st.markdown("---")
|
||||
for rank, idx in enumerate(order):
|
||||
c = claims[idx]
|
||||
st.markdown(f"**Rank {rank+1}: {c.get('event')}**")
|
||||
st.markdown(c.get("reasoningWhyRelevant"))
|
||||
st.markdown("---")
|
||||
|
||||
if st.button("Submit Ranking"):
|
||||
|
||||
n = len(order)
|
||||
|
||||
for rank_position, idx in enumerate(order):
|
||||
claim_obj = claims[idx]
|
||||
|
||||
# explicit stored rank
|
||||
claim_obj["rank_position"] = rank_position + 1
|
||||
|
||||
claim_obj["human_score"] = 1
|
||||
|
||||
# Auto-scoring
|
||||
for entry in st.session_state.data:
|
||||
for o in entry.get("output", []):
|
||||
for c in o.get("content_parsed", []):
|
||||
|
||||
if c.get("human_score") is not None:
|
||||
continue
|
||||
|
||||
extra = c.get("extra_info", "")
|
||||
|
||||
if "DUPLICATE" in extra:
|
||||
c["human_score"] = 0
|
||||
elif extra:
|
||||
c["human_score"] = round(
|
||||
c.get("score", 0) * 0.5, 3
|
||||
)
|
||||
|
||||
save_data(INPUT_FILE, st.session_state.data)
|
||||
save_data_clean(
|
||||
OUTPUT_FILE,
|
||||
copy.deepcopy(st.session_state.data)
|
||||
)
|
||||
|
||||
# reset state for next example
|
||||
del st.session_state.current_bundle
|
||||
del st.session_state.perfect_order
|
||||
|
||||
print("Ranking saved!")
|
||||
st.rerun()
|
||||
@@ -18,16 +18,14 @@ def render():
|
||||
|
||||
# ---- collect stats ----
|
||||
for entry in st.session_state.data:
|
||||
for o in entry.get("output", []):
|
||||
for c in o.get("content_parsed", []):
|
||||
for c in entry.get("events", []):
|
||||
# ---- extra_info word counts ----
|
||||
extra = c.get("extra_info", "")
|
||||
score = c.get("score", None)
|
||||
|
||||
# ---- extra_info word counts ----
|
||||
extra = c.get("extra_info", "")
|
||||
score = c.get("score", None)
|
||||
|
||||
if extra:
|
||||
words = extra.strip().split()
|
||||
word_counter.update(words)
|
||||
if extra:
|
||||
words = extra.strip().split()
|
||||
word_counter.update(words)
|
||||
|
||||
# --------------------------
|
||||
# Extra Info Word Counts
|
||||
|
||||
Reference in New Issue
Block a user