Skip to content

Commit

Permalink
Add return_score option to evaluate
Browse files Browse the repository at this point in the history
  • Loading branch information
kowaalczyk committed Apr 3, 2019
1 parent b7c4a46 commit d17e055
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spacy/cli/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import plac
from timeit import default_timer as timer
from wasabi import Printer
import srsly

from ..gold import GoldCorpus
from .. import util
Expand All @@ -17,6 +18,7 @@
gpu_id=("Use GPU", "option", "g", int),
displacy_path=("Directory to output rendered parses as HTML", "option", "dp", str),
displacy_limit=("Limit of parses to render as HTML", "option", "dl", int),
return_scores=("Return dict containing model scores", "flag", "r", bool),
)
def evaluate(
model,
Expand All @@ -25,6 +27,7 @@ def evaluate(
gold_preproc=False,
displacy_path=None,
displacy_limit=25,
return_scores=False,
):
"""
Evaluate a model. To render a sample of parses in a HTML file, set an
Expand Down Expand Up @@ -75,6 +78,8 @@ def evaluate(
ents=render_ents,
)
msg.good("Generated {} parses as HTML".format(displacy_limit), displacy_path)
if return_scores:
return scorer.scores


def render_parses(docs, output_path, model_name="", limit=250, deps=True, ents=True):
Expand Down

0 comments on commit d17e055

Please sign in to comment.