mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-08 06:04:57 +03:00
Reverting unnecessary changes. Removing unused default values. Renaming variables in find-cli tests.
This commit is contained in:
parent
9c00b287c1
commit
65e41a52dd
|
@ -13,7 +13,6 @@ from ._util import app, Arg, Opt, import_code, setup_gpu
|
||||||
from .. import util
|
from .. import util
|
||||||
|
|
||||||
_DEFAULTS = {
|
_DEFAULTS = {
|
||||||
"average": "micro",
|
|
||||||
"n_trials": 10,
|
"n_trials": 10,
|
||||||
"use_gpu": -1,
|
"use_gpu": -1,
|
||||||
"gold_preproc": False,
|
"gold_preproc": False,
|
||||||
|
|
|
@ -21,7 +21,13 @@ MISSING_VALUES = frozenset([None, 0, ""])
|
||||||
class PRFScore:
|
class PRFScore:
|
||||||
"""A precision / recall / F score."""
|
"""A precision / recall / F score."""
|
||||||
|
|
||||||
def __init__(self, *, tp: int = 0, fp: int = 0, fn: int = 0) -> None:
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
tp: int = 0,
|
||||||
|
fp: int = 0,
|
||||||
|
fn: int = 0
|
||||||
|
) -> None:
|
||||||
self.tp = tp
|
self.tp = tp
|
||||||
self.fp = fp
|
self.fp = fp
|
||||||
self.fn = fn
|
self.fn = fn
|
||||||
|
@ -37,9 +43,7 @@ class PRFScore:
|
||||||
|
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
return PRFScore(
|
return PRFScore(
|
||||||
tp=self.tp + other.tp,
|
tp=self.tp + other.tp, fp=self.fp + other.fp, fn=self.fn + other.fn,
|
||||||
fp=self.fp + other.fp,
|
|
||||||
fn=self.fn + other.fn,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def score_set(self, cand: set, gold: set) -> None:
|
def score_set(self, cand: set, gold: set) -> None:
|
||||||
|
|
|
@ -889,8 +889,8 @@ def test_cli_find_threshold(capsys):
|
||||||
def init_nlp(
|
def init_nlp(
|
||||||
components: Tuple[Tuple[str, Dict[str, Any]], ...] = ()
|
components: Tuple[Tuple[str, Dict[str, Any]], ...] = ()
|
||||||
) -> Tuple[Language, List[Example]]:
|
) -> Tuple[Language, List[Example]]:
|
||||||
_nlp = English()
|
new_nlp = English()
|
||||||
textcat: TextCategorizer = _nlp.add_pipe( # type: ignore
|
textcat: TextCategorizer = new_nlp.add_pipe( # type: ignore
|
||||||
factory_name="textcat_multilabel",
|
factory_name="textcat_multilabel",
|
||||||
name="tc_multi",
|
name="tc_multi",
|
||||||
config={"threshold": 0.9},
|
config={"threshold": 0.9},
|
||||||
|
@ -901,17 +901,17 @@ def test_cli_find_threshold(capsys):
|
||||||
|
|
||||||
# Append additional components to pipeline.
|
# Append additional components to pipeline.
|
||||||
for cfn, comp_config in components:
|
for cfn, comp_config in components:
|
||||||
comp = _nlp.add_pipe(cfn, config=comp_config)
|
comp = new_nlp.add_pipe(cfn, config=comp_config)
|
||||||
if isinstance(comp, TextCategorizer):
|
if isinstance(comp, TextCategorizer):
|
||||||
for label in textcat_labels:
|
for label in textcat_labels:
|
||||||
comp.add_label(label)
|
comp.add_label(label)
|
||||||
|
|
||||||
_examples = make_examples(_nlp)
|
new_examples = make_examples(new_nlp)
|
||||||
_nlp.initialize(get_examples=lambda: _examples)
|
new_nlp.initialize(get_examples=lambda: new_examples)
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
_nlp.update(_examples)
|
new_nlp.update(new_examples)
|
||||||
|
|
||||||
return _nlp, _examples
|
return new_nlp, new_examples
|
||||||
|
|
||||||
with make_tempdir() as docs_dir:
|
with make_tempdir() as docs_dir:
|
||||||
# Check whether find_threshold() identifies lowest threshold above 0 as (first) ideal threshold, as this matches
|
# Check whether find_threshold() identifies lowest threshold above 0 as (first) ideal threshold, as this matches
|
||||||
|
|
Loading…
Reference in New Issue
Block a user