-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_metadata.py
More file actions
43 lines (35 loc) · 1.06 KB
/
test_metadata.py
File metadata and controls
43 lines (35 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
import streamlit as st
from src.st_annotator import text_annotator
st.title("Metadata Test")
text = "This is a test sentence for metadata preservation."
# Initial labels with metadata
labels = {
"Test": [
{
"start": 0,
"end": 4,
"label": "This",
"metadata": {
"confidence": 0.95,
"source": "test",
"type": "important"
}
}
]
}
st.write("Input labels with metadata:")
st.json(labels)
# Use the annotator
result = text_annotator(text, labels, key="metadata_test")
st.write("Output labels (should preserve metadata):")
st.json(result)
if result:
# Check if metadata is preserved
for label_type, annotations in result.items():
for ann in annotations:
if 'metadata' in ann:
st.success(f"✅ Metadata preserved for annotation: {ann['label']}")
st.json(ann['metadata'])
else:
st.warning(f"⚠️ No metadata found for annotation: {ann['label']}")