Skip to content

Commit

Permalink
fix: complete document
Browse files Browse the repository at this point in the history
  • Loading branch information
arachez committed Mar 7, 2025
1 parent abf8cb6 commit 4606317
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
43 changes: 22 additions & 21 deletions wsd/annotate/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,13 @@ def on_load(e):
width='100%',
text_align='center',
justify_content='center',
padding=me.Padding.all(24)
padding=me.Padding.all(24),
)


@me.page(
path="/",
on_load=on_load,
security_policy=me.SecurityPolicy(
allowed_script_srcs=[
'://',
]
),
on_load=on_load
)
def app():
"""Japanese Word Sense Disambiguation UI"""
Expand Down Expand Up @@ -152,7 +147,6 @@ def app():
label,
on_click=_next,
type="flat",
disabled=state.selected is None
)


Expand Down Expand Up @@ -184,19 +178,26 @@ def _on_chosen(event):
linhub.annotations[state.cur] = annotation


def _complete_document(event=None):
linhub.create_annotations(linhub.annotations.values())
linhub.annotation = {}
linhub.complete_document(linhub.document, linhub.task)
state = me.state(State)
try:
linhub.document = linhub.get_next_document(linhub.task.id)
state.cur = 0
state.selected = None
state.tokens = get_tokens()
except Exception as e:
print(e)
state.done = True


def _next(event):
state = me.state(State)
state.cur += 1
if state.cur < len(state.tokens):
state.entries = get_entries()
if state.cur == len(state.tokens) - 1:
_complete_document()
else:
linhub.create_annotations(linhub.annotations.values())
linhub.complete_document(linhub.document, linhub.task)
try:
linhub.document = linhub.get_next_document(linhub.task)
state.tokens = get_tokens()
state.cur = 0
state.selected = None
state.entries = get_entries()
except:
state.done = True
state.cur += 1
state.selected = None
state.entries = get_entries()
7 changes: 5 additions & 2 deletions wsd/annotate/lit/pop.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ class LinEntryElement extends LitElement {
box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.selected {
box-shadow: 0 4px 8px rgb(192, 203, 249);
background-color: lightgrey;
box-shadow: 0 4px 8px rgb(124, 149, 249);
background-color: rgb(124, 149, 249);
}
.entry:hover {
box-shadow: 0 4px 8px rgb(192, 203, 249);
cursor: pointer;
background-color: lightgrey;
&.selected {
background-color: rgb(124, 149, 249);
}
}
.kanjis {
display: flex;
Expand Down

0 comments on commit 4606317

Please sign in to comment.