MCPcopy
hub / github.com/explosion/spaCy / annotate

Function annotate

spacy/cli/benchmark_speed.py:107–122  ·  view source on GitHub ↗
(
    nlp: Language, docs: List[Doc], batch_size: Optional[int]
)

Source from the content-addressed store, hash-verified

105
106
107def annotate(
108 nlp: Language, docs: List[Doc], batch_size: Optional[int]
109) -> numpy.ndarray:
110 docs = nlp.pipe(tqdm(docs, unit="doc", disable=None), batch_size=batch_size)
111 wps = []
112 while True:
113 with time_context() as elapsed:
114 batch_docs = list(
115 islice(docs, batch_size if batch_size else nlp.batch_size)
116 )
117 if len(batch_docs) == 0:
118 break
119 n_tokens = count_tokens(batch_docs)
120 wps.append(n_tokens / elapsed.elapsed)
121
122 return numpy.array(wps)
123
124
125def benchmark(

Callers 2

benchmarkFunction · 0.85
warmupFunction · 0.85

Calls 4

time_contextClass · 0.85
count_tokensFunction · 0.85
appendMethod · 0.80
pipeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…