Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about biaffine_ner_model.py #28

Open
BinLingNie opened this issue Jul 16, 2021 · 1 comment
Open

about biaffine_ner_model.py #28

BinLingNie opened this issue Jul 16, 2021 · 1 comment

Comments

@BinLingNie
Copy link

BinLingNie commented Jul 16, 2021

Hi, get_pred_ner() functions in your biaffine_ner_model.py

top_spans = [sorted(top_span,reverse=True,key=lambda x:x[3]) for top_span in top_spans]
sent_pred_mentions = [[] for _ in xrange(len(sentences))]
for sid, top_span in enumerate(top_spans):
  for ns,ne,t,_ in top_span:
    for ts,te,_ in sent_pred_mentions[sid]:
      if ns < ts <= ne < te or ts < ns <= te < ne:
        #for both nested and flat ner no clash is allowed
        break
      if is_flat_ner and (ns <= ts <= te <= ne or ts <= ns <= ne <= te):
        #for flat ner nested mentions are not allowed
        break
    else:
      sent_pred_mentions[sid].append((ns,ne,t))

According to the alignment of your codes,
"else:
sent_pred_mentions[sid].append((ns,ne,t))“ is aligned to "for ts,te,_ in sent_pred_mentions[sid]:". how to understand it ?
"

@juntaoy
Copy link
Owner

juntaoy commented Jul 16, 2021

The else here means the for loop finished without break. You can find more details about for/else in python here:
https://book.pythontips.com/en/latest/for_-_else.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants