id
int64
0
328k
repository_name
stringlengths
7
58
file_path
stringlengths
9
302
class_name
stringlengths
5
256
human_written_code
stringlengths
16
2.16M
class_skeleton
stringlengths
18
1.49M
⌀
total_program_units
int64
1
1.76k
total_doc_str
int64
0
771
AvgCountLine
float64
0
7.89k
AvgCountLineBlank
float64
0
297
AvgCountLineCode
float64
0
7.89k
AvgCountLineComment
float64
0
7.89k
AvgCyclomatic
float64
0
130
CommentToCodeRatio
float64
0
168
CountClassBase
float64
0
40
CountClassCoupled
float64
0
583
CountClassCoupledModified
float64
0
575
CountClassDerived
float64
0
5.35k
CountDeclInstanceMethod
float64
0
529
CountDeclInstanceVariable
float64
0
296
CountDeclMethod
float64
0
599
CountDeclMethodAll
float64
0
1.12k
CountLine
float64
1
40.4k
CountLineBlank
float64
0
8.16k
CountLineCode
float64
1
25.7k
CountLineCodeDecl
float64
1
8.15k
CountLineCodeExe
float64
0
24.2k
CountLineComment
float64
0
16.5k
CountStmt
float64
1
9.71k
CountStmtDecl
float64
1
8.15k
CountStmtExe
float64
0
9.69k
MaxCyclomatic
float64
0
759
MaxInheritanceTree
float64
0
16
MaxNesting
float64
0
34
SumCyclomatic
float64
0
2.9k
13,300
explosion/spaCy
explosion_spaCy/spacy/pipeline/span_finder.py
spacy.pipeline.span_finder.SpanFinder
from ..tokens import Doc, Span from ..errors import Errors from thinc.api import Config, Model, Optimizer, set_dropout_rate from ..training import Example from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple from ..language import Language from thinc.types import Floats2d from .trainable_pipe import ...
class SpanFinder(TrainablePipe): '''Pipeline that learns span boundaries. DOCS: https://spacy.io/api/spanfinder ''' def __init__(self, nlp: Language, model: Model[Iterable[Doc], Floats2d], name: str='span_finder', *, spans_key: str=DEFAULT_SPANS_KEY, threshold: float=0.5, max_length: Optional[int]=Non...
8
8
28
2
19
8
4
0.45
1
9
2
0
7
5
7
7
209
19
131
68
100
59
88
45
80
9
1
4
27
13,301
explosion/spaCy
explosion_spaCy/spacy/pipeline/span_ruler.py
spacy.pipeline.span_ruler.SpanRuler
from ..language import Language from functools import partial from .. import util from ..matcher import Matcher, PhraseMatcher from ..matcher.levenshtein import levenshtein_compare from ..training import Example from pathlib import Path from ..tokens import Doc, Span from typing import Any, Callable, Dict, Iterable, Li...
class SpanRuler(Pipe): '''The SpanRuler lets you add spans to the `Doc.spans` using token-based rules or exact phrase matches. DOCS: https://spacy.io/api/spanruler USAGE: https://spacy.io/usage/rule-based-matching#spanruler ''' def __init__(self, nlp: Language, name: str='span_ruler', *, spans...
25
20
18
1
11
5
2
0.51
1
18
4
0
20
15
20
20
382
47
222
98
165
114
139
61
118
8
1
3
48
13,302
explosion/spaCy
explosion_spaCy/spacy/pipeline/spancat.py
spacy.pipeline.spancat.SpanCategorizer
from ..vocab import Vocab from .trainable_pipe import TrainablePipe import numpy from thinc.api import Config, Model, Ops, Optimizer, get_current_ops, set_dropout_rate from ..tokens import Doc, Span, SpanGroup from ..training import Example, validate_examples from thinc.types import Floats2d, Ints1d, Ints2d, Ragged fro...
class SpanCategorizer(TrainablePipe): '''Pipeline component to label spans of text. DOCS: https://spacy.io/api/spancategorizer ''' def __init__(self, vocab: Vocab, model: Model[Tuple[List[Doc], Ragged], Floats2d], suggester: Suggester, name: str='spancat', *, add_negative_label: bool=False, spans_key:...
26
18
22
1
15
7
4
0.45
1
14
4
0
19
7
19
19
456
44
292
140
224
131
210
92
190
10
1
4
70
13,303
explosion/spaCy
explosion_spaCy/spacy/pipeline/spancat.py
spacy.pipeline.spancat.Suggester
from thinc.types import Floats2d, Ints1d, Ints2d, Ragged from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union, cast from ..compat import Protocol, runtime_checkable from ..tokens import Doc, Span, SpanGroup from thinc.api import Config, Model, Ops, Optimizer, get_current_ops, set_dropout_rate ...
@runtime_checkable class Suggester(Protocol): def __call__(self, docs: Iterable[Doc], *, ops: Optional[Ops]=None) -> Ragged: pass
3
0
2
0
2
0
1
0
1
0
0
0
1
0
1
25
3
0
3
2
1
0
3
2
1
1
5
0
1
13,304
explosion/spaCy
explosion_spaCy/spacy/pipeline/spancat.py
spacy.pipeline.spancat._Intervals
from dataclasses import dataclass @dataclass class _Intervals: """ Helper class to avoid storing overlapping spans. """ def __init__(self): self.ranges = set() def add(self, i, j): for e in range(i, j): self.ranges.add(e) def __contains__(self, rang): i, j...
@dataclass class _Intervals: ''' Helper class to avoid storing overlapping spans. ''' def __init__(self): pass def add(self, i, j): pass def __contains__(self, rang): pass
5
1
4
0
4
0
2
0.25
0
2
0
0
3
1
3
3
18
3
12
8
8
3
12
8
8
3
0
2
6
13,305
explosion/spaCy
explosion_spaCy/spacy/pipeline/textcat.py
spacy.pipeline.textcat.TextCategorizer
from ..vocab import Vocab from ..training import Example, validate_examples, validate_get_examples from itertools import islice from ..errors import Errors from .trainable_pipe import TrainablePipe import numpy from thinc.api import Config, Model, Optimizer, get_array_module, set_dropout_rate from typing import Any, Ca...
class TextCategorizer(TrainablePipe): '''Pipeline component for single-label text classification. DOCS: https://spacy.io/api/textcategorizer ''' def __init__(self, vocab: Vocab, model: Model, name: str='textcat', *, threshold: float, scorer: Optional[Callable]=textcat_score) -> None: '''Initia...
17
12
20
1
13
7
3
0.53
1
12
2
1
13
6
13
13
284
32
169
84
121
89
129
50
115
9
1
3
43
13,306
explosion/spaCy
explosion_spaCy/spacy/pipeline/textcat_multilabel.py
spacy.pipeline.textcat_multilabel.MultiLabel_TextCategorizer
from .textcat import TextCategorizer from ..training import Example, validate_get_examples from ..errors import Errors from ..language import Language from ..vocab import Vocab from typing import Any, Callable, Dict, Iterable, List, Optional from itertools import islice from thinc.api import Config, Model class MultiL...
class MultiLabel_TextCategorizer(TextCategorizer): '''Pipeline component for multi-label text classification. DOCS: https://spacy.io/api/textcategorizer ''' def __init__(self, vocab: Vocab, model: Model, name: str='textcat_multilabel', *, threshold: float, scorer: Optional[Callable]=textcat_multilabel...
6
4
18
1
12
6
3
0.54
1
8
2
0
4
6
4
17
83
10
48
35
28
26
32
20
27
5
2
3
11
13,307
explosion/spaCy
explosion_spaCy/spacy/pipeline/tok2vec.py
spacy.pipeline.tok2vec.Tok2Vec
from thinc.api import Config, Model, Optimizer, set_dropout_rate from ..training import Example, validate_examples, validate_get_examples from .trainable_pipe import TrainablePipe from ..tokens import Doc from itertools import islice from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence from ..lang...
class Tok2Vec(TrainablePipe): '''Apply a "token-to-vector" model and set its outputs in the doc.tensor attribute. This is mostly useful to share a single subnetwork between multiple components, e.g. to have one embedding and CNN network shared between a parser, tagger and NER. In order to use the `...
17
13
13
1
7
4
2
0.77
1
12
3
0
12
5
12
12
188
27
91
50
61
70
77
35
61
4
1
3
29
13,308
explosion/spaCy
explosion_spaCy/spacy/pipeline/tok2vec.py
spacy.pipeline.tok2vec.Tok2VecListener
from thinc.api import Config, Model, Optimizer, set_dropout_rate from ..tokens import Doc from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence from ..errors import Errors class Tok2VecListener(Model): """A layer that gets fed its answers from an upstream connection, for instance from a co...
class Tok2VecListener(Model): '''A layer that gets fed its answers from an upstream connection, for instance from a component earlier in the pipeline. The Tok2VecListener layer is used as a sublayer within a component such as a parser, NER or text categorizer. Usually you'll have multiple listeners ...
6
5
10
0
5
5
2
1.17
1
5
1
0
3
4
4
4
58
6
24
12
18
28
21
11
16
3
1
2
6
13,309
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.ArgSchemaConfig
class ArgSchemaConfig: extra = 'forbid' arbitrary_types_allowed = True
class ArgSchemaConfig: pass
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
3
3
2
0
3
3
2
0
0
0
0
13,310
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.ArgSchemaConfigExtra
class ArgSchemaConfigExtra: extra = 'forbid' arbitrary_types_allowed = True
class ArgSchemaConfigExtra: pass
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
3
3
2
0
3
3
2
0
0
0
0
13,311
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.DocJSONSchema
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union class DocJSONSchema(BaseModel): """ JSON/dict format for JSON representation of Doc objects. """ cats: Optional[Dict[StrictStr, StrictFloat]] = Field(None, title='Categories with corresponding p...
class DocJSONSchema(BaseModel): ''' JSON/dict format for JSON representation of Doc objects. ''' pass
1
1
0
0
0
0
0
0.11
1
0
0
0
0
0
0
50
32
1
28
10
27
3
10
10
9
0
5
0
0
13,312
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.ModelMetaSchema
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union class ModelMetaSchema(BaseModel): lang: StrictStr = Field(..., title="Two-letter language code, e.g. 'en'") name: StrictStr = Field(..., title='Model name') version: StrictStr = Field(..., title='Mo...
class ModelMetaSchema(BaseModel): pass
1
0
0
0
0
0
0
0.06
1
0
0
0
0
0
0
50
19
0
18
18
17
1
18
18
17
0
5
0
0
13,313
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.RecommendationSchema
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union class RecommendationSchema(BaseModel): word_vectors: Optional[str] = None transformer: Optional[RecommendationTrf] = None has_letters: bool = True
class RecommendationSchema(BaseModel): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
50
4
0
4
4
3
0
4
4
3
0
5
0
0
13,314
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.RecommendationTrf
class RecommendationTrf(BaseModel): efficiency: RecommendationTrfItem accuracy: RecommendationTrfItem
class RecommendationTrf(BaseModel): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
50
3
0
3
1
2
0
3
1
2
0
5
0
0
13,315
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.RecommendationTrfItem
class RecommendationTrfItem(BaseModel): name: str size_factor: int
class RecommendationTrfItem(BaseModel): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
50
3
0
3
1
2
0
3
1
2
0
5
0
0
13,316
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.TokenPattern
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union class TokenPattern(BaseModel): orth: Optional[StringValue] = None text: Optional[StringValue] = None lower: Optional[StringValue] = None pos: Optional[StringValue] = None tag: Optional[Strin...
class TokenPattern(BaseModel): class Config: def alias_generator(value): pass @validator('*', pre=True, allow_reuse=True) def raise_for_none(cls, v): pass
5
0
4
0
4
0
2
0
1
1
0
0
1
0
1
51
49
2
47
44
43
0
46
43
43
2
5
1
2
13,317
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.TokenPatternNumber
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union class TokenPatternNumber(BaseModel): REGEX: Optional[StrictStr] = Field(None, alias='regex') IN: Optional[List[StrictInt]] = Field(None, alias='in') NOT_IN: Optional[List[StrictInt]] = Field(None, a...
class TokenPatternNumber(BaseModel): class Config: @validator('*', pre=True, each_item=True, allow_reuse=True) def raise_for_none(cls, v): pass
4
0
4
0
4
0
2
0.05
1
1
0
0
1
0
1
51
23
2
21
18
17
1
20
17
17
2
5
1
2
13,318
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.TokenPatternOperatorMinMax
import re class TokenPatternOperatorMinMax(ConstrainedStr): regex = re.compile('^({\\d+}|{\\d+,\\d*}|{\\d*,\\d+})$')
class TokenPatternOperatorMinMax(ConstrainedStr): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
70
2
0
2
2
1
0
2
2
1
0
3
0
0
13,319
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.TokenPatternOperatorSimple
from enum import Enum class TokenPatternOperatorSimple(str, Enum): plus: StrictStr = StrictStr('+') star: StrictStr = StrictStr('*') question: StrictStr = StrictStr('?') exclamation: StrictStr = StrictStr('!')
class TokenPatternOperatorSimple(str, Enum): pass
1
0
0
0
0
0
0
0
2
0
0
0
0
0
0
115
5
0
5
5
4
0
5
5
4
0
4
0
0
13,320
explosion/spaCy
explosion_spaCy/spacy/schemas.py
spacy.schemas.TokenPatternString
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union class TokenPatternString(BaseModel): REGEX: Optional[Union[StrictStr, 'TokenPatternString']] = Field(None, alias='regex') IN: Optional[List[StrictStr]] = Field(None, alias='in') NOT_IN: Optional[Lis...
class TokenPatternString(BaseModel): class Config: @validator('*', pre=True, each_item=True, allow_reuse=True) def raise_for_none(cls, v): pass
4
0
4
0
4
0
2
0.02
1
1
0
0
1
0
1
51
45
2
43
22
39
1
24
21
21
2
5
1
2
13,321
explosion/spaCy
explosion_spaCy/spacy/scorer.py
spacy.scorer.PRFScore
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Set, Tuple class PRFScore: """A precision / recall / F score.""" def __init__(self, *, tp: int=0, fp: int=0, fn: int=0) -> None: self.tp = tp self.fp = fp self.fn = fn def __len__(self) -> int: ...
class PRFScore: '''A precision / recall / F score.''' def __init__(self, *, tp: int=0, fp: int=0, fn: int=0) -> None: pass def __len__(self) -> int: pass def __iadd__(self, other): pass def __add__(self, other): pass def score_set(self, cand: set, gold: set)...
13
1
4
0
4
0
1
0.03
0
4
0
0
9
3
9
9
49
9
39
24
20
1
28
15
18
1
0
0
9
13,322
explosion/spaCy
explosion_spaCy/spacy/scorer.py
spacy.scorer.ROCAUCScore
from .errors import Errors import numpy as np from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Set, Tuple class ROCAUCScore: """An AUC ROC score. This is only defined for binary classification. Use the method is_binary before calculating the score, otherwise it may throw an ...
class ROCAUCScore: '''An AUC ROC score. This is only defined for binary classification. Use the method is_binary before calculating the score, otherwise it may throw an error.''' def __init__(self) -> None: pass def score_set(self, cand, gold) -> None: pass def is_binary(self...
6
1
5
0
5
0
2
0.15
0
4
1
0
4
4
4
4
27
4
20
10
14
3
19
9
14
3
0
1
6
13,323
explosion/spaCy
explosion_spaCy/spacy/scorer.py
spacy.scorer.Scorer
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Set, Tuple from .training import Example from .tokens import Doc, Span, Token from .util import SimpleFrozenList, get_lang_class from .morphology import Morphology class Scorer: """Compute evaluation scores.""" def __init__(self,...
class Scorer: '''Compute evaluation scores.''' def __init__(self, nlp: Optional['Language']=None, default_lang: str='xx', default_pipeline: Iterable[str]=DEFAULT_PIPELINE, **cfg) -> None: '''Initialize the Scorer. DOCS: https://spacy.io/api/scorer#init ''' pass def score(s...
17
10
70
2
52
16
13
0.3
0
9
2
0
2
2
9
9
647
27
480
173
410
145
320
113
310
24
0
7
115
13,324
explosion/spaCy
explosion_spaCy/spacy/tokens/_dict_proxies.py
spacy.tokens._dict_proxies.SpanGroups
from .span_group import SpanGroup import warnings import weakref import srsly from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Tuple, Union from ..errors import Errors, Warnings from collections import UserDict class SpanGroups(UserDict): """A dict-like proxy held by the Doc, to control access to ...
class SpanGroups(UserDict): '''A dict-like proxy held by the Doc, to control access to span groups.''' def __init__(self, doc: 'Doc', items: Iterable[Tuple[str, SpanGroup]]=tuple()) -> None: pass def __setitem__(self, key: str, value: Union[SpanGroup, Iterable['Span']]) -> None: pass ...
9
1
10
0
8
2
3
0.26
1
8
2
0
8
1
8
63
90
9
65
25
54
17
53
23
44
7
8
3
21
13,325
explosion/spaCy
explosion_spaCy/spacy/tokens/_serialize.py
spacy.tokens._serialize.DocBin
from ._dict_proxies import SpanGroups from .doc import DOCBIN_ALL_ATTRS as ALL_ATTRS from ..attrs import IDS, ORTH, SPACY, intify_attr from thinc.api import NumpyOps import srsly from numpy import ndarray from ..errors import Errors from pathlib import Path from ..util import SimpleFrozenList, ensure_path from .doc imp...
class DocBin: '''Pack Doc objects for binary serialization. The DocBin class lets you efficiently serialize the information from a collection of Doc objects. You can control which information is serialized by passing a list of attribute IDs, and optionally also specify whether the user data is seri...
10
10
24
2
17
6
4
0.48
0
13
2
0
9
10
9
9
258
30
158
54
143
76
131
46
121
8
0
3
33
13,326
explosion/spaCy
explosion_spaCy/spacy/tokens/underscore.py
spacy.tokens.underscore.Underscore
from ..errors import Errors import copy import functools from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union class Underscore: mutable_types = (dict, list, set) doc_extensions: Dict[Any, Any] = {} span_extensions: Dict[Any, Any] = {} token_extensions: Dict[Any, Any] = {} _exte...
class Underscore: def __init__(self, extensions: Dict[str, Any], obj: Union['Doc', 'Span', 'Token'], start: Optional[int]=None, end: Optional[int]=None): pass def __dir__(self) -> List[str]: pass def __getattr__(self, name: str) -> Any: pass def __setattr__(self, name: str, ...
13
0
7
0
6
1
2
0.13
0
9
1
0
8
0
10
10
91
10
72
33
51
9
55
23
44
6
0
2
17
13,327
explosion/spaCy
explosion_spaCy/spacy/training/Corpus.py
spacy.training.Corpus.Corpus
from ..vocab import Vocab from typing import TYPE_CHECKING, Callable, Iterable, Iterator, List, Optional, Union from .example import Example import random from .augment import dont_augment from .. import util from pathlib import Path from ..tokens import Doc, DocBin class Corpus: """Iterate Example objects from a ...
class Corpus: '''Iterate Example objects from a file or directory of DocBin (.spacy) formatted data files. path (Path): The directory or filename to read from. gold_preproc (bool): Whether to set up the Example object with gold-standard sentences and tokens for the predictions. Gold preprocessi...
7
3
15
1
14
2
5
0.33
0
6
1
0
6
6
6
6
119
11
84
45
60
28
54
28
47
8
0
5
28
13,328
explosion/spaCy
explosion_spaCy/spacy/training/Corpus.py
spacy.training.Corpus.JsonlCorpus
from pathlib import Path from ..tokens import Doc, DocBin from .example import Example from typing import TYPE_CHECKING, Callable, Iterable, Iterator, List, Optional, Union from .. import util import srsly class JsonlCorpus: """Iterate Example objects from a file or directory of jsonl formatted raw text files....
class JsonlCorpus: '''Iterate Example objects from a file or directory of jsonl formatted raw text files. path (Path): The directory or filename to read from. min_length (int): Minimum document length (in tokens). Shorter documents will be skipped. Defaults to 0, which indicates no limit. m...
3
2
17
1
13
4
3
0.67
0
4
0
0
2
4
2
2
53
8
27
21
17
18
18
14
15
5
0
3
6
13,329
explosion/spaCy
explosion_spaCy/spacy/training/Corpus.py
spacy.training.Corpus.PlainTextCorpus
from .. import util from pathlib import Path from .example import Example from typing import TYPE_CHECKING, Callable, Iterable, Iterator, List, Optional, Union class PlainTextCorpus: """Iterate Example objects from a file or directory of plain text UTF-8 files with one line per doc. path (Path): The direc...
class PlainTextCorpus: '''Iterate Example objects from a file or directory of plain text UTF-8 files with one line per doc. path (Path): The directory or filename to read from. min_length (int): Minimum document length (in tokens). Shorter documents will be skipped. Defaults to 0, which indicat...
3
2
16
1
11
4
4
0.67
0
3
0
0
2
3
2
2
47
7
24
17
15
16
17
10
14
6
0
5
7
13,330
explosion/spaCy
explosion_spaCy/spacy/training/alignment.py
spacy.training.alignment.Alignment
from typing import List from .alignment_array import AlignmentArray from dataclasses import dataclass from .align import get_alignments @dataclass class Alignment: x2y: AlignmentArray y2x: AlignmentArray @classmethod def from_indices(cls, x2y: List[List[int]], y2x: List[List[int]]) -> 'Alignment': ...
@dataclass class Alignment: @classmethod def from_indices(cls, x2y: List[List[int]], y2x: List[List[int]]) -> 'Alignment': pass @classmethod def from_strings(cls, A: List[str], B: List[str]) -> 'Alignment': pass
6
0
4
0
4
0
1
0
0
2
0
0
0
0
2
2
14
2
12
6
7
0
10
4
7
1
0
0
2
13,331
explosion/spaCy
explosion_spaCy/spacy/training/corpus.py
spacy.training.corpus.Corpus
from .augment import dont_augment from ..tokens import Doc, DocBin from ..vocab import Vocab import random from typing import TYPE_CHECKING, Callable, Iterable, Iterator, List, Optional, Union from .. import util from .example import Example from pathlib import Path class Corpus: """Iterate Example objects from a ...
class Corpus: '''Iterate Example objects from a file or directory of DocBin (.spacy) formatted data files. path (Path): The directory or filename to read from. gold_preproc (bool): Whether to set up the Example object with gold-standard sentences and tokens for the predictions. Gold preprocessi...
7
3
15
1
14
2
5
0.33
0
6
1
0
6
6
6
6
119
11
84
45
60
28
54
28
47
8
0
5
28
13,332
explosion/spaCy
explosion_spaCy/spacy/training/corpus.py
spacy.training.corpus.JsonlCorpus
from pathlib import Path import srsly from ..tokens import Doc, DocBin from .. import util from .example import Example from typing import TYPE_CHECKING, Callable, Iterable, Iterator, List, Optional, Union class JsonlCorpus: """Iterate Example objects from a file or directory of jsonl formatted raw text files....
class JsonlCorpus: '''Iterate Example objects from a file or directory of jsonl formatted raw text files. path (Path): The directory or filename to read from. min_length (int): Minimum document length (in tokens). Shorter documents will be skipped. Defaults to 0, which indicates no limit. m...
3
2
17
1
13
4
3
0.67
0
4
0
0
2
4
2
2
53
8
27
21
17
18
18
14
15
5
0
3
6
13,333
explosion/spaCy
explosion_spaCy/spacy/training/corpus.py
spacy.training.corpus.PlainTextCorpus
from .example import Example from typing import TYPE_CHECKING, Callable, Iterable, Iterator, List, Optional, Union from .. import util from pathlib import Path class PlainTextCorpus: """Iterate Example objects from a file or directory of plain text UTF-8 files with one line per doc. path (Path): The direc...
class PlainTextCorpus: '''Iterate Example objects from a file or directory of plain text UTF-8 files with one line per doc. path (Path): The directory or filename to read from. min_length (int): Minimum document length (in tokens). Shorter documents will be skipped. Defaults to 0, which indicat...
3
2
16
1
11
4
4
0.67
0
3
0
0
2
3
2
2
47
7
24
17
15
16
17
10
14
6
0
5
7
13,334
explosion/spaCy
explosion_spaCy/spacy/training/pretrain.py
spacy.training.pretrain.ProgressTracker
import time from collections import Counter class ProgressTracker: def __init__(self, frequency=1000000): self.loss = 0.0 self.prev_loss = 0.0 self.nr_word = 0 self.words_per_epoch = Counter() self.frequency = frequency self.last_time = time.time() self.last...
class ProgressTracker: def __init__(self, frequency=1000000): pass def update(self, epoch, loss, docs): pass
3
0
16
0
16
0
2
0
0
3
0
0
2
8
2
2
34
1
33
16
30
0
26
16
23
2
0
1
3
13,335
explosion/spaCy
explosion_spaCy/spacy/ty.py
spacy.ty.InitializableComponent
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Sequence from .compat import Protocol, runtime_checkable @runtime_checkable class InitializableComponent(Protocol): def initialize(self, get_examples: Callable[[], Iterable['Example']], nlp: 'Language', **kwargs: Any): ...
@runtime_checkable class InitializableComponent(Protocol): def initialize(self, get_examples: Callable[[], Iterable['Example']], nlp: 'Language', **kwargs: Any): pass
3
0
7
0
7
0
1
0
1
1
0
0
1
0
1
25
8
0
8
7
1
0
3
2
1
1
5
0
1
13,336
explosion/spaCy
explosion_spaCy/spacy/ty.py
spacy.ty.ListenedToComponent
from .compat import Protocol, runtime_checkable from thinc.api import Model, Optimizer from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Sequence @runtime_checkable class ListenedToComponent(Protocol): model: Any listeners: Sequence[Model] listener_map: Dict[str, Sequence[Mod...
@runtime_checkable class ListenedToComponent(Protocol): def add_listener(self, listener: Model, component_name: str) -> None: pass def remove_listener(self, listener: Model, component_name: str) -> bool: pass def find_listeners(self, component) -> None: pass
5
0
2
0
2
0
1
0
1
2
0
0
3
0
3
27
14
3
11
4
7
0
11
4
7
1
5
0
3
13,337
explosion/spaCy
explosion_spaCy/spacy/ty.py
spacy.ty.TrainableComponent
from thinc.api import Model, Optimizer from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Sequence from .compat import Protocol, runtime_checkable @runtime_checkable class TrainableComponent(Protocol): model: Any is_trainable: bool def update(self, examples: Iterable['Example...
@runtime_checkable class TrainableComponent(Protocol): def update(self, examples: Iterable['Example'], *, drop: float=0.0, sgd: Optional[Optimizer]=None, losses: Optional[Dict[str, float]]=None) -> Dict[str, float]: pass def finish_update(self, sgd: Optimizer) -> None: pass
4
0
6
0
6
0
1
0
1
2
0
0
2
0
2
26
16
2
14
10
4
0
7
3
4
1
5
0
2
13,338
explosion/spaCy
explosion_spaCy/spacy/util.py
spacy.util.DummyTokenizer
from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, Iterable, Iterator, List, Mapping, NoReturn, Optional, Pattern, Set, Tuple, Type, Union, cast from pathlib import Path class DummyTokenizer: def __call__(self, text): raise NotImplementedError def pipe(self, texts, **kwargs): f...
class DummyTokenizer: def __call__(self, text): pass def pipe(self, texts, **kwargs): pass def to_bytes(self, **kwargs): pass def from_bytes(self, data: bytes, **kwargs) -> 'DummyTokenizer': pass def to_disk(self, path: Union[str, Path], **kwargs) -> None: ...
7
0
2
0
2
0
1
0.14
0
4
0
5
6
0
6
6
21
5
14
8
7
2
14
8
7
2
0
1
7
13,339
explosion/spaCy
explosion_spaCy/spacy/util.py
spacy.util.ENV_VARS
class ENV_VARS: CONFIG_OVERRIDES = 'SPACY_CONFIG_OVERRIDES'
class ENV_VARS: pass
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
2
2
1
0
2
2
1
0
0
0
0
13,340
explosion/spaCy
explosion_spaCy/spacy/util.py
spacy.util.SimpleFrozenDict
from .errors import OLD_MODEL_SHORTCUTS, Errors, Warnings class SimpleFrozenDict(dict): """Simplified implementation of a frozen dict, mainly used as default function or method argument (for arguments that should default to empty dictionary). Will raise an error if user or spaCy attempts to add to dict. ...
class SimpleFrozenDict(dict): '''Simplified implementation of a frozen dict, mainly used as default function or method argument (for arguments that should default to empty dictionary). Will raise an error if user or spaCy attempts to add to dict. ''' def __init__(self, *args, error: str=Errors.E09...
5
2
4
0
2
1
1
0.8
1
4
1
0
4
1
4
31
23
5
10
6
5
8
10
6
5
1
2
0
4
13,341
explosion/spaCy
explosion_spaCy/spacy/util.py
spacy.util.SimpleFrozenList
from .errors import OLD_MODEL_SHORTCUTS, Errors, Warnings class SimpleFrozenList(list): """Wrapper class around a list that lets us raise custom errors if certain attributes/methods are accessed. Mostly used for properties like Language.pipeline that return an immutable list (and that we don't want to ...
class SimpleFrozenList(list): '''Wrapper class around a list that lets us raise custom errors if certain attributes/methods are accessed. Mostly used for properties like Language.pipeline that return an immutable list (and that we don't want to convert to a tuple to not break too much backwards compati...
10
2
3
0
2
0
1
0.45
1
4
1
0
9
1
9
42
39
10
20
11
10
9
20
11
10
1
2
0
9
13,342
explosion/spaCy
explosion_spaCy/spacy/util.py
spacy.util.registry
from .errors import OLD_MODEL_SHORTCUTS, Errors, Warnings import catalogue from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, Iterable, Iterator, List, Mapping, NoReturn, Optional, Pattern, Set, Tuple, Type, Union, cast import thinc from catalogue import Registry, RegistryError import inspect class regi...
class registry(thinc.registry): @classmethod def ensure_populated(cls) -> None: '''Ensure the registry is populated with all necessary components.''' pass @classmethod def get_registry_names(cls) -> List[str]: '''List all available registries.''' pass @classmethod ...
11
5
18
0
15
4
4
0.28
1
4
1
0
0
0
4
4
109
5
81
43
70
23
67
37
62
5
1
3
16
13,343
jbarlow83/OCRmyPDF
src/ocrmypdf/_concurrent.py
ocrmypdf._concurrent.Executor
from ocrmypdf._progressbar import NullProgressBar, ProgressBar import threading from abc import ABC, abstractmethod from collections.abc import Callable, Iterable class Executor(ABC): """Abstract concurrent executor.""" pool_lock = threading.Lock() pbar_class = NullProgressBar def __init__(self, *, pb...
class Executor(ABC): '''Abstract concurrent executor.''' def __init__(self, *, pbar_class=None): pass def __call__(self, *, use_threads: bool, max_workers: int, progress_kwargs: dict, worker_initializer: Callable | None=None, task: Callable[..., T] | None=None, task_arguments: Iterable | None=Non...
5
3
22
1
14
7
3
0.49
1
6
1
3
3
0
3
23
75
6
47
27
22
23
18
6
14
5
4
1
8
13,344
jbarlow83/OCRmyPDF
src/ocrmypdf/_concurrent.py
ocrmypdf._concurrent.SerialExecutor
from collections.abc import Callable, Iterable class SerialExecutor(Executor): """Implements a purely sequential executor using the parallel protocol. The current process/thread will be the worker that executes all tasks in order. As such, ``worker_initializer`` will never be called. """ def _exe...
class SerialExecutor(Executor): '''Implements a purely sequential executor using the parallel protocol. The current process/thread will be the worker that executes all tasks in order. As such, ``worker_initializer`` will never be called. ''' def _execute(self, *, use_threads: bool, max_workers: in...
2
1
15
0
15
1
2
0.31
1
5
0
0
1
0
1
24
22
2
16
15
4
5
6
4
4
2
5
2
2
13,345
jbarlow83/OCRmyPDF
src/ocrmypdf/_exec/ghostscript.py
ocrmypdf._exec.ghostscript.DuplicateFilter
from collections import deque import logging class DuplicateFilter(logging.Filter): """Filter out duplicate log messages. A context window of default 5 messages is used to determine if a message is a duplicate. This is because some Ghostscript messages are word wrapped. """ def __init__(self, log...
class DuplicateFilter(logging.Filter): '''Filter out duplicate log messages. A context window of default 5 messages is used to determine if a message is a duplicate. This is because some Ghostscript messages are word wrapped. ''' def __init__(self, logger: logging.Logger, context_window=5): ...
3
1
9
0
9
1
2
0.26
1
2
0
0
2
4
2
4
26
3
19
8
16
5
18
8
15
3
2
2
4
13,346
jbarlow83/OCRmyPDF
src/ocrmypdf/_exec/ghostscript.py
ocrmypdf._exec.ghostscript.GhostscriptFollower
import re class GhostscriptFollower: """Parses the output of Ghostscript and uses it to update the progress bar.""" re_process = re.compile('Processing pages \\d+ through (\\d+).') re_page = re.compile('Page (\\d+)') def __init__(self, progressbar_class): self.count = 0 self.progressba...
class GhostscriptFollower: '''Parses the output of Ghostscript and uses it to update the progress bar.''' def __init__(self, progressbar_class): pass def __enter__(self): pass def __exit__(self, exc_type, exc_value, traceback): pass def __call__(self, line): pass
5
1
7
0
6
1
2
0.19
0
1
0
0
4
3
4
4
37
5
27
11
22
5
24
11
19
5
0
2
9
13,347
jbarlow83/OCRmyPDF
src/ocrmypdf/_exec/tesseract.py
ocrmypdf._exec.tesseract.TesseractLoggerAdapter
import logging class TesseractLoggerAdapter(logging.LoggerAdapter): """Prepend [tesseract] to messages emitted from tesseract.""" def process(self, msg, kwargs): kwargs['extra'] = self.extra return (f'[tesseract] {msg}', kwargs)
class TesseractLoggerAdapter(logging.LoggerAdapter): '''Prepend [tesseract] to messages emitted from tesseract.''' def process(self, msg, kwargs): pass
2
1
3
0
3
0
1
0.25
1
0
0
0
1
0
1
20
6
1
4
2
2
1
4
2
2
1
2
0
1
13,348
jbarlow83/OCRmyPDF
src/ocrmypdf/_exec/tesseract.py
ocrmypdf._exec.tesseract.TesseractVersion
from packaging.version import Version import re class TesseractVersion(Version): """Modify standard packaging.Version regex to support Tesseract idiosyncrasies.""" _regex = re.compile('^\\s*' + TESSERACT_VERSION_PATTERN + '\\s*$', re.VERBOSE | re.IGNORECASE)
class TesseractVersion(Version): '''Modify standard packaging.Version regex to support Tesseract idiosyncrasies.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
24
6
1
4
2
3
1
2
2
1
0
2
0
0
13,349
jbarlow83/OCRmyPDF
src/ocrmypdf/_exec/unpaper.py
ocrmypdf._exec.unpaper.UnpaperImageTooLargeError
class UnpaperImageTooLargeError(Exception): """To capture details when an image is too large for unpaper.""" def __init__(self, w, h, message="Image with size {}x{} is too large for cleaning with 'unpaper'."): self.w = w self.h = h self.message = message.format(w, h) super().__i...
class UnpaperImageTooLargeError(Exception): '''To capture details when an image is too large for unpaper.''' def __init__(self, w, h, message="Image with size {}x{} is too large for cleaning with 'unpaper'."): pass
2
1
10
0
10
0
1
0.09
1
1
0
0
1
3
1
11
13
1
11
10
4
1
6
5
4
1
3
0
1
13,350
jbarlow83/OCRmyPDF
src/ocrmypdf/_graft.py
ocrmypdf._graft.OcrGrafter
from ocrmypdf._jobcontext import PdfContext from pathlib import Path from contextlib import suppress from pikepdf import Dictionary, Matrix, Name, Operator, Page, Pdf, PdfError, Stream, parse_content_stream, unparse_content_stream class OcrGrafter: """Manages grafting text-only PDFs onto regular PDFs.""" def ...
class OcrGrafter: '''Manages grafting text-only PDFs onto regular PDFs.''' def __init__(self, context: PdfContext): pass def graft_page(self, *, pageno: int, image: Path | None, textpdf: Path | None, autorotate_correction: int): pass def save_and_reload(self) -> None: '''Save...
7
4
39
4
28
7
4
0.24
0
12
2
0
6
10
6
6
239
30
170
73
147
40
130
54
123
8
0
4
25
13,351
jbarlow83/OCRmyPDF
src/ocrmypdf/_graft.py
ocrmypdf._graft.RenderMode
from enum import Enum class RenderMode(Enum): ON_TOP = 0 UNDERNEATH = 1
class RenderMode(Enum): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
49
3
0
3
3
2
0
3
3
2
0
4
0
0
13,352
jbarlow83/OCRmyPDF
src/ocrmypdf/_jobcontext.py
ocrmypdf._jobcontext.PageContext
from pathlib import Path from pluggy import PluginManager import os from argparse import Namespace from ocrmypdf.pdfinfo.info import PageInfo from copy import copy class PageContext: """Holds our context for a page. Must be pickle-able, so stores only intrinsic/simple data elements or those capable of the...
class PageContext: '''Holds our context for a page. Must be pickle-able, so stores only intrinsic/simple data elements or those capable of their serializing themselves via ``__getstate__``. ''' def __init__(self, pdf_context: PdfContext, pageno): pass def get_path(self, name: str) -> ...
4
2
8
1
6
1
2
0.57
0
5
1
0
3
1
3
3
38
7
23
6
19
13
23
6
19
3
0
1
5
13,353
jbarlow83/OCRmyPDF
src/ocrmypdf/_jobcontext.py
ocrmypdf._jobcontext.PdfContext
from pluggy import PluginManager from pathlib import Path from argparse import Namespace from ocrmypdf.pdfinfo import PdfInfo from collections.abc import Iterator class PdfContext: """Holds the context for a particular run of the pipeline.""" options: Namespace origin: Path pdfinfo: PdfInfo plugin_...
class PdfContext: '''Holds the context for a particular run of the pipeline.''' def __init__(self, options: Namespace, work_folder: Path, origin: Path, pdfinfo: PdfInfo, plugin_manager): pass def get_path(self, name: str) -> Path: '''Generate a ``Path`` for an intermediate file involved i...
5
4
8
0
6
2
2
0.39
0
8
2
0
4
2
4
4
41
6
28
18
16
11
21
11
16
2
0
1
6
13,354
jbarlow83/OCRmyPDF
src/ocrmypdf/_logging.py
ocrmypdf._logging.PageNumberFilter
import logging class PageNumberFilter(logging.Filter): """Insert PDF page number that emitted log message to log record.""" def filter(self, record): pageno = getattr(record, 'pageno', None) if isinstance(pageno, int): record.pageno = f'{pageno:5d} ' elif pageno is None: ...
class PageNumberFilter(logging.Filter): '''Insert PDF page number that emitted log message to log record.''' def filter(self, record): pass
2
1
7
0
7
0
3
0.13
1
1
0
0
1
0
1
3
10
1
8
3
6
1
7
3
5
3
2
1
3
13,355
jbarlow83/OCRmyPDF
src/ocrmypdf/_logging.py
ocrmypdf._logging.RichLoggingHandler
from rich.logging import RichHandler from rich.console import Console class RichLoggingHandler(RichHandler): def __init__(self, console: Console, **kwargs): super().__init__(console=console, show_level=False, show_time=False, markup=False, **kwargs)
class RichLoggingHandler(RichHandler): def __init__(self, console: Console, **kwargs): pass
2
0
4
0
4
0
1
0
1
1
0
0
1
0
1
1
5
0
5
2
3
0
3
2
1
1
1
0
1
13,356
jbarlow83/OCRmyPDF
src/ocrmypdf/_metadata.py
ocrmypdf._metadata.MetadataProgress
class MetadataProgress: def __init__(self, progressbar_class, enable: bool=True): self.progressbar_class = progressbar_class self.progressbar = self.progressbar_class(total=100, desc='Linearizing', unit='%', disable=not enable) def __enter__(self): self.progressbar.__enter__() ...
class MetadataProgress: def __init__(self, progressbar_class, enable: bool=True): pass def __enter__(self): pass def __exit__(self, exc_type, exc_value, traceback): pass def __call__(self, percent: int): pass
5
0
4
0
4
0
1
0
0
2
0
0
4
2
4
4
18
3
15
7
10
0
13
7
8
2
0
1
5
13,357
jbarlow83/OCRmyPDF
src/ocrmypdf/_pipelines/_common.py
ocrmypdf._pipelines._common.HOCRResult
from dataclasses import dataclass from pathlib import Path import json @dataclass class HOCRResult: """Result when hOCR is finished processing.""" pageno: int 'Page number, 0-based.' pdf_page_from_image: Path | None = None 'Single page PDF from image.' hocr: Path | None = None 'Single page ...
@dataclass class HOCRResult: '''Result when hOCR is finished processing.''' @classmethod def from_json(cls, json_str: str) -> HOCRResult: '''Create an instance from a dict.''' pass def to_json(self) -> str: '''Serialize to a JSON string.''' pass
5
3
3
0
2
1
1
0.73
0
3
2
0
1
1
2
2
26
7
11
9
7
8
10
7
7
1
0
0
2
13,358
jbarlow83/OCRmyPDF
src/ocrmypdf/_pipelines/_common.py
ocrmypdf._pipelines._common.HOCRResultDecoder
import json from pathlib import Path class HOCRResultDecoder(json.JSONDecoder): def __init__(self, *args, **kwargs): super().__init__(*args, object_hook=self.dict_to_object, **kwargs) def dict_to_object(self, d): if 'Path' in d: return Path(d['Path']) return d
class HOCRResultDecoder(json.JSONDecoder): def __init__(self, *args, **kwargs): pass def dict_to_object(self, d): pass
3
0
3
0
3
0
2
0
1
2
0
0
2
0
2
5
8
1
7
3
4
0
7
3
4
2
2
1
3
13,359
jbarlow83/OCRmyPDF
src/ocrmypdf/_pipelines/_common.py
ocrmypdf._pipelines._common.HOCRResultEncoder
import json from pathlib import Path class HOCRResultEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, Path): return {'Path': str(obj)} return super().default(obj)
class HOCRResultEncoder(json.JSONEncoder): def default(self, obj): pass
2
0
4
0
4
0
2
0
1
3
0
0
1
0
1
5
5
0
5
2
3
0
5
2
3
2
2
1
2
13,360
jbarlow83/OCRmyPDF
src/ocrmypdf/_pipelines/_common.py
ocrmypdf._pipelines._common.PageResult
from pathlib import Path from typing import NamedTuple, cast class PageResult(NamedTuple): """Result when a page is finished processing.""" pageno: int 'Page number, 0-based.' pdf_page_from_image: Path | None = None 'Single page PDF from image.' ocr: Path | None = None 'Single page OCR PDF....
class PageResult(NamedTuple): '''Result when a page is finished processing.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
0
17
5
6
5
5
6
6
5
5
0
1
0
0
13,361
jbarlow83/OCRmyPDF
src/ocrmypdf/_plugin_manager.py
ocrmypdf._plugin_manager.OcrmypdfPluginManager
import pkgutil from pathlib import Path import importlib import importlib.util from collections.abc import Sequence from ocrmypdf import pluginspec import sys import ocrmypdf.builtin_plugins import pluggy class OcrmypdfPluginManager(pluggy.PluginManager): """pluggy.PluginManager that can fork. Capable of reco...
class OcrmypdfPluginManager(pluggy.PluginManager): '''pluggy.PluginManager that can fork. Capable of reconstructing itself in child workers. Arguments: setup_func: callback that initializes the plugin manager with all standard plugins ''' def __init__(self, *args, plugins: Sequ...
5
1
16
1
13
2
2
0.24
1
7
0
0
4
4
4
4
78
11
54
21
42
13
35
15
29
6
1
2
9
13,362
jbarlow83/OCRmyPDF
src/ocrmypdf/_progressbar.py
ocrmypdf._progressbar.NullProgressBar
class NullProgressBar: """Progress bar API that takes no actions.""" def __init__(self, **kwargs): pass def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): return False def update(self, _arg=None, *, completed=None): return
class NullProgressBar: '''Progress bar API that takes no actions.''' def __init__(self, **kwargs): pass def __enter__(self): pass def __exit__(self, exc_type, exc_value, traceback): pass def update(self, _arg=None, *, completed=None): pass
5
1
2
0
2
0
1
0.11
0
0
0
1
4
0
4
4
14
4
9
5
4
1
9
5
4
1
0
0
4
13,363
jbarlow83/OCRmyPDF
src/ocrmypdf/_progressbar.py
ocrmypdf._progressbar.ProgressBar
from typing import Protocol class ProgressBar(Protocol): """The protocol that OCRmyPDF expects progress bar classes to be compatible with. In practice this could be used for any time of monitoring, not just a progress bar. Calling the class should return a new progress bar object, which is activated ...
class ProgressBar(Protocol): '''The protocol that OCRmyPDF expects progress bar classes to be compatible with. In practice this could be used for any time of monitoring, not just a progress bar. Calling the class should return a new progress bar object, which is activated with ``__enter__`` and termina...
5
5
15
2
3
10
1
8.38
1
4
0
0
4
0
4
28
147
25
13
13
0
109
5
5
0
1
5
0
4
13,364
jbarlow83/OCRmyPDF
src/ocrmypdf/_progressbar.py
ocrmypdf._progressbar.RichProgressBar
from rich.table import Column from rich.console import Console from rich.progress import BarColumn, MofNCompleteColumn, Progress, TaskProgressColumn, TextColumn, TimeRemainingColumn class RichProgressBar: """Display progress bar using rich.""" def __init__(self, *, console: Console, desc: str, total: float | ...
class RichProgressBar: '''Display progress bar using rich.''' def __init__(self, *, console: Console, desc: str, total: float | None=None, unit: str | None=None, unit_scale: float | None=1.0, disable: bool=False, **kwargs): pass def __enter__(self): pass def __exit__(self, exc_type, ...
5
1
13
0
13
0
2
0.02
0
3
0
0
4
4
4
4
57
4
52
20
37
1
20
10
15
3
0
1
7
13,365
jbarlow83/OCRmyPDF
src/ocrmypdf/api.py
ocrmypdf.api.Verbosity
from enum import IntEnum class Verbosity(IntEnum): """Verbosity level for configure_logging.""" quiet = -1 default = 0 debug = 1 debug_all = 2
class Verbosity(IntEnum): '''Verbosity level for configure_logging.''' pass
1
1
0
0
0
0
0
1.2
1
0
0
0
0
0
0
55
8
1
5
5
4
6
5
5
4
0
3
0
0
13,366
jbarlow83/OCRmyPDF
src/ocrmypdf/builtin_plugins/concurrency.py
ocrmypdf.builtin_plugins.concurrency.StandardExecutor
import logging import logging.handlers import os from ocrmypdf import Executor, hookimpl import threading from collections.abc import Callable, Iterable from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor, as_completed class StandardExecutor(Executor): """Standard OCRmyPDF concurrent task execut...
class StandardExecutor(Executor): '''Standard OCRmyPDF concurrent task executor.''' def _execute(self, *, use_threads: bool, max_workers: int, progress_kwargs: dict, worker_initializer: Callable, task: Callable, task_arguments: Iterable, task_finished: Callable): pass
2
1
64
3
44
17
6
0.4
1
9
0
0
1
0
1
24
67
4
45
21
33
18
26
9
24
6
5
3
6
13,367
jbarlow83/OCRmyPDF
src/ocrmypdf/builtin_plugins/tesseract_ocr.py
ocrmypdf.builtin_plugins.tesseract_ocr.TesseractOcrEngine
from ocrmypdf._exec import tesseract from ocrmypdf.pluginspec import OcrEngine class TesseractOcrEngine(OcrEngine): """Implements OCR with Tesseract.""" @staticmethod def version(): return str(tesseract.version()) @staticmethod def creator_tag(options): tag = '-PDF' if options.pdf...
class TesseractOcrEngine(OcrEngine): '''Implements OCR with Tesseract.''' @staticmethod def version(): pass @staticmethod def creator_tag(options): pass def __str__(self): pass @staticmethod def languages(options): pass @staticmethod def get_orie...
16
1
6
0
6
0
1
0.02
1
2
0
4
1
0
8
36
67
8
58
17
42
1
18
10
9
2
5
0
9
13,368
jbarlow83/OCRmyPDF
src/ocrmypdf/cli.py
ocrmypdf.cli.ArgumentParser
import argparse class ArgumentParser(argparse.ArgumentParser): """Override parser's default behavior of calling sys.exit(). https://stackoverflow.com/questions/5943249/python-argparse-and-controlling-overriding-the-exit-status-code OCRmyPDF began as a CLI but eventually acquired an API. The API works ins...
class ArgumentParser(argparse.ArgumentParser): '''Override parser's default behavior of calling sys.exit(). https://stackoverflow.com/questions/5943249/python-argparse-and-controlling-overriding-the-exit-status-code OCRmyPDF began as a CLI but eventually acquired an API. The API works inside out, by sy...
4
4
6
0
3
2
1
1.27
1
2
0
0
3
1
3
53
31
6
11
5
7
14
11
5
7
2
3
1
4
13,369
jbarlow83/OCRmyPDF
src/ocrmypdf/cli.py
ocrmypdf.cli.LanguageSetAction
import argparse class LanguageSetAction(argparse.Action): """Manages a list of languages.""" def __init__(self, option_strings, dest, default=None, **kwargs): """Initialize the action.""" if default is None: default = list() super().__init__(option_strings, dest, default=de...
class LanguageSetAction(argparse.Action): '''Manages a list of languages.''' def __init__(self, option_strings, dest, default=None, **kwargs): '''Initialize the action.''' pass def __call__(self, parser, namespace, values, option_string=None): '''Add a language to the set.''' ...
3
3
6
0
5
1
2
0.27
1
2
0
0
2
0
2
9
16
2
11
4
8
3
10
4
7
2
3
1
4
13,370
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.BadArgsError
class BadArgsError(ExitCodeException): """Invalid arguments on the command line or API.""" exit_code = ExitCode.bad_args
class BadArgsError(ExitCodeException): '''Invalid arguments on the command line or API.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
1
0
0
0
11
4
1
2
2
1
1
2
2
1
0
4
0
0
13,371
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.ColorConversionNeededError
from textwrap import dedent class ColorConversionNeededError(BadArgsError): """PDF needs color conversion.""" message = dedent(' The input PDF has an unusual color space. Use\n --color-conversion-strategy to convert to a common color space\n such as RGB, or use --output-type pdf to skip PD...
class ColorConversionNeededError(BadArgsError): '''PDF needs color conversion.''' pass
1
1
0
0
0
0
0
0.11
1
0
0
0
0
0
0
11
11
1
9
2
8
1
2
2
1
0
5
0
0
13,372
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.DigitalSignatureError
from textwrap import dedent class DigitalSignatureError(InputFileError): """PDF has a digital signature.""" message = dedent(' Input PDF has a digital signature. OCR would alter the document,\n invalidating the signature.\n ')
class DigitalSignatureError(InputFileError): '''PDF has a digital signature.''' pass
1
1
0
0
0
0
0
0.14
1
0
0
0
0
0
0
11
9
1
7
2
6
1
2
2
1
0
5
0
0
13,373
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.DpiError
class DpiError(ExitCodeException): """Missing information about input image DPI.""" exit_code = ExitCode.input_file
class DpiError(ExitCodeException): '''Missing information about input image DPI.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
11
4
1
2
2
1
1
2
2
1
0
4
0
0
13,374
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.EncryptedPdfError
from textwrap import dedent class EncryptedPdfError(ExitCodeException): """Input PDF is encrypted.""" exit_code = ExitCode.encrypted_pdf message = dedent(" Input PDF is encrypted. The encryption must be removed to\n perform OCR.\n\n For information about this PDF's security use\n ...
class EncryptedPdfError(ExitCodeException): '''Input PDF is encrypted.''' pass
1
1
0
0
0
0
0
0.08
1
0
0
0
0
0
0
11
16
3
12
3
11
1
3
3
2
0
4
0
0
13,375
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.ExitCode
from enum import IntEnum class ExitCode(IntEnum): """OCRmyPDF's exit codes.""" ok = 0 bad_args = 1 input_file = 2 missing_dependency = 3 invalid_output_pdf = 4 file_access_error = 5 already_done_ocr = 6 child_process_error = 7 encrypted_pdf = 8 invalid_config = 9 pdfa_co...
class ExitCode(IntEnum): '''OCRmyPDF's exit codes.''' pass
1
1
0
0
0
0
0
0.14
1
0
0
0
0
0
0
55
17
1
14
14
13
2
14
14
13
0
3
0
0
13,376
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.ExitCodeException
class ExitCodeException(Exception): """An exception which should return an exit code with sys.exit().""" exit_code = ExitCode.other_error message = '' def __str__(self): """Return a string representation of the exception.""" super_msg = super().__str__() if self.message: ...
class ExitCodeException(Exception): '''An exception which should return an exit code with sys.exit().''' def __str__(self): '''Return a string representation of the exception.''' pass
2
2
6
0
5
2
2
0.38
1
1
0
10
1
0
1
11
12
2
8
5
6
3
8
5
6
2
3
1
2
13,377
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.InputFileError
class InputFileError(ExitCodeException): """Something is wrong with the input file.""" exit_code = ExitCode.input_file
class InputFileError(ExitCodeException): '''Something is wrong with the input file.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
2
0
0
0
11
4
1
2
2
1
1
2
2
1
0
4
0
0
13,378
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.MissingDependencyError
class MissingDependencyError(ExitCodeException): """A third-party dependency is missing.""" exit_code = ExitCode.missing_dependency
class MissingDependencyError(ExitCodeException): '''A third-party dependency is missing.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
11
4
1
2
2
1
1
2
2
1
0
4
0
0
13,379
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.OutputFileAccessError
class OutputFileAccessError(ExitCodeException): """Cannot access the intended output file path.""" exit_code = ExitCode.file_access_error
class OutputFileAccessError(ExitCodeException): '''Cannot access the intended output file path.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
11
4
1
2
2
1
1
2
2
1
0
4
0
0
13,380
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.PriorOcrFoundError
class PriorOcrFoundError(ExitCodeException): """This file already has OCR.""" exit_code = ExitCode.already_done_ocr
class PriorOcrFoundError(ExitCodeException): '''This file already has OCR.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
11
4
1
2
2
1
1
2
2
1
0
4
0
0
13,381
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.SubprocessOutputError
class SubprocessOutputError(ExitCodeException): """A subprocess returned an unexpected error.""" exit_code = ExitCode.child_process_error
class SubprocessOutputError(ExitCodeException): '''A subprocess returned an unexpected error.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
11
4
1
2
2
1
1
2
2
1
0
4
0
0
13,382
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.TaggedPDFError
from textwrap import dedent class TaggedPDFError(InputFileError): """PDF is tagged.""" message = dedent(' This PDF is marked as a Tagged PDF. This often indicates\n that the PDF was generated from an office document and does\n not need OCR. Use --force-ocr, --skip-text or --redo-ocr to\n ...
class TaggedPDFError(InputFileError): '''PDF is tagged.''' pass
1
1
0
0
0
0
0
0.11
1
0
0
0
0
0
0
11
11
1
9
2
8
1
2
2
1
0
5
0
0
13,383
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.TesseractConfigError
class TesseractConfigError(ExitCodeException): """Tesseract config can't be parsed.""" exit_code = ExitCode.invalid_config message = 'Error occurred while parsing a Tesseract configuration file'
class TesseractConfigError(ExitCodeException): '''Tesseract config can't be parsed.''' pass
1
1
0
0
0
0
0
0.33
1
0
0
0
0
0
0
11
5
1
3
3
2
1
3
3
2
0
4
0
0
13,384
jbarlow83/OCRmyPDF
src/ocrmypdf/exceptions.py
ocrmypdf.exceptions.UnsupportedImageFormatError
class UnsupportedImageFormatError(ExitCodeException): """The image format is not supported.""" exit_code = ExitCode.input_file
class UnsupportedImageFormatError(ExitCodeException): '''The image format is not supported.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
11
4
1
2
2
1
1
2
2
1
0
4
0
0
13,385
jbarlow83/OCRmyPDF
src/ocrmypdf/extra_plugins/semfree.py
ocrmypdf.extra_plugins.semfree.ConnectionLogHandler
from multiprocessing.connection import Connection, wait import logging.handlers import logging class ConnectionLogHandler(logging.handlers.QueueHandler): """Handler used by child processes to forward log messages to parent.""" def __init__(self, conn: Connection) -> None: """Initialize the handler."""...
class ConnectionLogHandler(logging.handlers.QueueHandler): '''Handler used by child processes to forward log messages to parent.''' def __init__(self, conn: Connection) -> None: '''Initialize the handler.''' pass def enqueue(self, record): '''Enqueue a log message.''' pass
3
3
5
0
3
3
1
1
1
2
0
0
2
1
2
26
13
2
6
4
3
6
6
4
3
1
4
0
2
13,386
jbarlow83/OCRmyPDF
src/ocrmypdf/extra_plugins/semfree.py
ocrmypdf.extra_plugins.semfree.LambdaExecutor
from ocrmypdf import Executor, hookimpl from itertools import islice, repeat, takewhile, zip_longest import logging from multiprocessing import Pipe, Process from collections.abc import Callable, Iterable, Iterator import logging.handlers from multiprocessing.connection import Connection, wait class LambdaExecutor(Exe...
class LambdaExecutor(Executor): '''Executor for AWS Lambda or similar environments that lack semaphores.''' def _execute(self, *, use_threads: bool, max_workers: int, progress_kwargs: dict, worker_initializer: Callable, task: Callable, task_arguments: Iterable, task_finished: Callable): pass
2
1
74
7
67
0
16
0.01
1
10
1
0
1
0
1
24
77
8
68
25
56
1
44
14
42
16
5
5
16
13,387
jbarlow83/OCRmyPDF
src/ocrmypdf/extra_plugins/semfree.py
ocrmypdf.extra_plugins.semfree.MessageType
from enum import Enum, auto class MessageType(Enum): """Implement basic IPC messaging.""" exception = auto() result = auto() complete = auto()
class MessageType(Enum): '''Implement basic IPC messaging.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
49
6
1
4
4
3
4
4
4
3
0
4
0
0
13,388
jbarlow83/OCRmyPDF
src/ocrmypdf/helpers.py
ocrmypdf.helpers.NeverRaise
from deprecation import deprecated @deprecated(deprecated_in='15.4.0') class NeverRaise(Exception): """An exception that is never raised."""
@deprecated(deprecated_in='15.4.0') class NeverRaise(Exception): '''An exception that is never raised.''' pass
2
1
0
0
0
0
0
1
1
0
0
0
0
0
0
10
2
0
1
1
0
1
1
1
0
0
3
0
0
13,389
jbarlow83/OCRmyPDF
src/ocrmypdf/helpers.py
ocrmypdf.helpers.Resolution
from collections.abc import Callable, Iterable, Sequence from statistics import harmonic_mean from math import isclose, isfinite from typing import Any, Generic, TypeVar class Resolution(Generic[T]): """The number of pixels per inch in each 2D direction. Resolution objects are considered "equal" for == purpos...
class Resolution(Generic[T]): '''The number of pixels per inch in each 2D direction. Resolution objects are considered "equal" for == purposes if they are equal to a reasonable tolerance. ''' def __init__(self, x: T, y: T): '''Construct a Resolution object.''' pass def round(s...
19
15
4
0
3
1
1
0.45
1
8
0
0
14
0
15
17
99
20
55
29
30
25
46
20
30
3
1
1
19
13,390
jbarlow83/OCRmyPDF
src/ocrmypdf/hocrtransform/_font.py
ocrmypdf.hocrtransform._font.Courier
from pikepdf import Dictionary, Name, Pdf class Courier(EncodableFont): """Courier font.""" def text_width(self, text: str, fontsize: float) -> float: """Estimate the width of a text string when rendered with the given font.""" return len(text) * fontsize def text_encode(self, text: str) ...
class Courier(EncodableFont): '''Courier font.''' def text_width(self, text: str, fontsize: float) -> float: '''Estimate the width of a text string when rendered with the given font.''' pass def text_encode(self, text: str) -> bytes: pass def register(self, pdf: Pdf) -> Dicti...
4
3
5
0
4
1
1
0.23
1
3
0
0
3
0
3
4
19
3
13
4
9
3
7
4
3
1
2
0
3
13,391
jbarlow83/OCRmyPDF
src/ocrmypdf/hocrtransform/_font.py
ocrmypdf.hocrtransform._font.EncodableFont
from pikepdf.canvas import Font class EncodableFont(Font): def text_encode(self, text: str) -> bytes: raise NotImplementedError()
class EncodableFont(Font): def text_encode(self, text: str) -> bytes: pass
2
0
2
0
2
0
1
0
1
3
0
2
1
0
1
1
3
0
3
2
1
0
3
2
1
1
1
0
1
13,392
jbarlow83/OCRmyPDF
src/ocrmypdf/hocrtransform/_font.py
ocrmypdf.hocrtransform._font.GlyphlessFont
import zlib from pikepdf import Dictionary, Name, Pdf from importlib.resources import files as package_files import unicodedata class GlyphlessFont(EncodableFont): CID_TO_GID_DATA = zlib.compress(b'\x00\x01' * 65536) GLYPHLESS_FONT_NAME = 'pdf.ttf' GLYPHLESS_FONT = (package_files('ocrmypdf.data') / GLYPHLE...
class GlyphlessFont(EncodableFont): def __init__(self): pass def text_width(self, text: str, fontsize: float) -> float: '''Estimate the width of a text string when rendered with the given font.''' pass def text_encode(self, text: str) -> bytes: pass def register(self...
5
2
22
1
19
2
1
0.1
1
3
0
0
4
0
4
5
95
6
82
13
77
8
22
13
17
1
2
0
4
13,393
jbarlow83/OCRmyPDF
src/ocrmypdf/hocrtransform/_hocr.py
ocrmypdf.hocrtransform._hocr.HocrTransform
from pikepdf.canvas import BLACK, BLUE, CYAN, DARKGREEN, GREEN, MAGENTA, RED, Canvas, Text, TextDirection from xml.etree import ElementTree from itertools import pairwise from ocrmypdf.hocrtransform._font import EncodableFont as Font from math import atan, pi import unicodedata from ocrmypdf.hocrtransform._font import ...
class HocrTransform: '''A class for converting documents from the hOCR format. For details of the hOCR format, see: http://kba.github.io/hocr-spec/1.2/. ''' def __init__(self, *, hocr_filename: str | Path, dpi: float, debug: bool=False, fontname: Name=Name('/f-0-0'), font: '''Initialize th...
25
19
22
1
17
4
4
0.25
0
10
3
0
14
8
18
18
442
39
336
117
267
84
182
67
163
16
0
3
64
13,394
jbarlow83/OCRmyPDF
src/ocrmypdf/hocrtransform/_hocr.py
ocrmypdf.hocrtransform._hocr.HocrTransformError
class HocrTransformError(Exception): """Error while applying hOCR transform."""
class HocrTransformError(Exception): '''Error while applying hOCR transform.''' pass
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
10
2
0
1
1
0
1
1
1
0
0
3
0
0
13,395
jbarlow83/OCRmyPDF
src/ocrmypdf/languages.py
ocrmypdf.languages.ISOCodeData
from typing import NamedTuple class ISOCodeData(NamedTuple): """Data for a single ISO 639 code.""" alt: str alpha_2: str english: str french: str
class ISOCodeData(NamedTuple): '''Data for a single ISO 639 code.''' pass
1
1
0
0
0
0
0
0.2
1
0
0
0
0
0
0
0
7
1
5
1
4
1
5
1
4
0
1
0
0
13,396
jbarlow83/OCRmyPDF
src/ocrmypdf/optimize.py
ocrmypdf.optimize.XrefExt
from typing import Any, NamedTuple, NewType class XrefExt(NamedTuple): """A PDF xref and image extension pair.""" xref: Xref ext: str
class XrefExt(NamedTuple): '''A PDF xref and image extension pair.''' pass
1
1
0
0
0
0
0
0.33
1
0
0
0
0
0
0
0
5
1
3
1
2
1
3
1
2
0
1
0
0
13,397
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.Colorspace
from enum import Enum, auto class Colorspace(Enum): """Description of common image colorspaces in a PDF.""" gray = auto() rgb = auto() cmyk = auto() lab = auto() icc = auto() index = auto() sep = auto() devn = auto() pattern = auto() jpeg2000 = auto()
class Colorspace(Enum): '''Description of common image colorspaces in a PDF.''' pass
1
1
0
0
0
0
0
0.18
1
0
0
0
0
0
0
49
14
1
11
11
10
2
11
11
10
0
4
0
0
13,398
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.ContentsInfo
from typing import NamedTuple from collections.abc import Callable, Container, Iterable, Iterator, Mapping, Sequence class ContentsInfo(NamedTuple): """Info about various objects found in a PDF.""" xobject_settings: list[XobjectSettings] inline_images: list[InlineSettings] found_vector: bool found_...
class ContentsInfo(NamedTuple): '''Info about various objects found in a PDF.''' pass
1
1
0
0
0
0
0
0.17
1
0
0
0
0
0
0
0
8
1
6
1
5
1
6
1
5
0
1
0
0
13,399
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.Encoding
from enum import Enum, auto class Encoding(Enum): """Description of common image encodings in a PDF.""" ccitt = auto() jpeg = auto() jpeg2000 = auto() jbig2 = auto() asciihex = auto() ascii85 = auto() lzw = auto() flate = auto() runlength = auto()
class Encoding(Enum): '''Description of common image encodings in a PDF.''' pass
1
1
0
0
0
0
0
0.2
1
0
0
0
0
0
0
49
13
1
10
10
9
2
10
10
9
0
4
0
0