diff --git a/src/sastadev/methods.py b/src/sastadev/methods.py index 4b5dd3c..4147551 100644 --- a/src/sastadev/methods.py +++ b/src/sastadev/methods.py @@ -129,7 +129,7 @@ def treatmethod(methodname: MethodName, methodfilename: FileName) -> Tuple[Metho else: resultmethodfilename = methodname resultmethodname = getmethodfromfile(methodname) - settings.warning( + settings.LOGGER.warning( 'Method derived from the method file name: {}'.format(resultmethodname)) elif methodname is not None and methodfilename is not None: if methodname.lower() in supported_methods: diff --git a/src/sastadev/sasta_explanation.py b/src/sastadev/sasta_explanation.py index d682a1a..26a48d1 100644 --- a/src/sastadev/sasta_explanation.py +++ b/src/sastadev/sasta_explanation.py @@ -5,15 +5,14 @@ import copy from typing import List, Optional -from auchann.align_words import align_words +from auchann.align_words import AlignmentSettings, align_words from lxml import etree # import find1, iswordnode, getattval import sastadev.stringfunctions as strf import sastadev.treebankfunctions as tbf -from auchannsettings import settings from sastadev.alpinoparsing import parse -from sastadev.auchannsettings import AlignmentSettings +from sastadev.auchannsettings import settings from sastadev.cleanCHILDEStokens import cleantext from sastadev.conf import settings as sdsettings from sastadev.lexicon import known_word diff --git a/src/sastadev/sastatypes.py b/src/sastadev/sastatypes.py index 7313cdc..5653413 100644 --- a/src/sastadev/sastatypes.py +++ b/src/sastadev/sastatypes.py @@ -3,7 +3,7 @@ ''' from collections import Counter -from typing import Callable, Dict, List, Optional, Tuple, TypeAlias, Union +from typing import Callable, Dict, List, Optional, Tuple, Union from lxml import etree @@ -24,69 +24,70 @@ Item_Level = Tuple[Item, Level] AltCodeDict = Dict[Item_Level, Item_Level] -AltId: TypeAlias = int +AltId = int AnalysedTrees = List[Tuple[UttId, SynTree]] -BackPlacement: TypeAlias = int -CapitalName: TypeAlias = str -CountryName: TypeAlias = str -ContinentName: TypeAlias = str -CELEXPosCode: TypeAlias = str -FirstName: TypeAlias = str -LocationName: TypeAlias = str -DCOIPt: TypeAlias = str -DeHet: TypeAlias = str -CELEX_INFL: TypeAlias = str -DCOITuple: TypeAlias = Tuple -Lemma: TypeAlias = str -CorrectionMode: TypeAlias = str # Literal['0','1','n'] -ErrorDict: TypeAlias = Dict[str, List[List[str]]] -Level: TypeAlias = str # in the future perhaps NewType('Level', str) -Item: TypeAlias = str # in the future perhaps NewType('Item', str) -Item_Level: TypeAlias = Tuple[Item, Level] -IntSpan: TypeAlias = Tuple[int, int] -AltCodeDict: TypeAlias = Dict[Item_Level, Item_Level] -QId: TypeAlias = str # in the futute perhaps NewType('QId', str) -UttId: TypeAlias = str # in the future perhaps NewType('UttId', str) -Position: TypeAlias = int # in the future perhapos NewType('Position', int) -PositionStr: TypeAlias = str -Stage: TypeAlias = int -SynTree: TypeAlias = etree._Element # type: ignore -GoldTuple: TypeAlias = Tuple[str, str, Counter] +BackPlacement = int +CapitalName = str +CountryName = str +ContinentName = str +CELEXPosCode = str +FirstName = str +LocationName = str +DCOIPt = str +DeHet = str +CELEX_INFL = str +DCOITuple = Tuple +Lemma = str +CorrectionMode = str # Literal['0','1','n'] +ErrorDict = Dict[str, List[List[str]]] +Level = str # in the future perhaps NewType('Level', str) +Item = str # in the future perhaps NewType('Item', str) +Item_Level = Tuple[Item, Level] +IntSpan = Tuple[int, int] +AltCodeDict = Dict[Item_Level, Item_Level] +QId = str # in the futute perhaps NewType('QId', str) +UttId = str # in the future perhaps NewType('UttId', str) +Position = int # in the future perhapos NewType('Position', int) +PositionStr = str +Stage = int +SynTree = etree._Element # type: ignore +GoldTuple = Tuple[str, str, Counter] GoldResults = Dict[QId, GoldTuple] -Item2LevelsDict: TypeAlias = Dict[Item, List[Level]] -Match: TypeAlias = Tuple[SynTree, SynTree] -Matches: TypeAlias = List[Match] -MatchesDict: TypeAlias = Dict[Tuple[QId, UttId], Matches] -MetaElement: TypeAlias = etree.Element -ExactResult: TypeAlias = Tuple[UttId, Position] -ExactResults: TypeAlias = List[ExactResult] -ExactResultsDict: TypeAlias = Dict[QId, ExactResults] # qid -Gender: TypeAlias = str -Penalty: TypeAlias = int -PhiTriple: TypeAlias = Tuple[str, str, str] -OptPhiTriple: TypeAlias = Optional[PhiTriple] -PositionMap: TypeAlias = Dict[Position, Position] -QueryDict: TypeAlias = Dict[QId, Query] -QIdCount: TypeAlias = Dict[QId, int] -MethodName: TypeAlias = str # perhaps in the future NewType('MethodName', str) -FileName: TypeAlias = str # perhaps in the future NewType('FileName', str) -ReplacementMode: TypeAlias = int -ResultsCounter: TypeAlias = Counter # Counter[UttId] # Dict[UttId, int] -ResultsDict: TypeAlias = Dict[QId, ResultsCounter] +Item2LevelsDict = Dict[Item, List[Level]] +Match = Tuple[SynTree, SynTree] +Matches = List[Match] +MatchesDict = Dict[Tuple[QId, UttId], Matches] +MetaElement = etree.Element +ExactResult = Tuple[UttId, Position] +ExactResults = List[ExactResult] +ExactResultsDict = Dict[QId, ExactResults] # qid +Gender = str +Penalty = int +PhiTriple = Tuple[str, str, str] +OptPhiTriple = Optional[PhiTriple] +PositionMap = Dict[Position, Position] +QueryDict = Dict[QId, Query] +QIdCount = Dict[QId, int] +MethodName = str # perhaps in the future NewType('MethodName', str) +FileName = str # perhaps in the future NewType('FileName', str) +ReplacementMode = int +ResultsCounter = Counter # Counter[UttId] # Dict[UttId, int] +ResultsDict = Dict[QId, ResultsCounter] SampleSizeTuple = Tuple[List[UttId], int, Optional[PositionStr]] -Span: TypeAlias = Tuple[PositionStr, PositionStr] -Item_Level2QIdDict: TypeAlias = Dict[Item_Level, QId] -Nort: TypeAlias = Union[SynTree, Token] -ExactResultsFilter: TypeAlias = Callable[[Query, ExactResultsDict, ExactResult], bool] -Targets: TypeAlias = int -Treebank: TypeAlias = etree.Element -TreePredicate: TypeAlias = Callable[[SynTree], bool] -TokenTreePredicate: TypeAlias = Callable[[Token, SynTree], bool] -URL: TypeAlias = str -UttTokenDict: TypeAlias = Dict[UttId, List[Token]] -UttWordDict: TypeAlias = Dict[UttId, List[str]] -WordInfo: TypeAlias = Tuple[Optional[CELEXPosCode], Optional[DeHet], Optional[CELEX_INFL], Optional[Lemma]] +Span = Tuple[PositionStr, PositionStr] +Item_Level2QIdDict = Dict[Item_Level, QId] +Nort = Union[SynTree, Token] +ExactResultsFilter = Callable[[Query, ExactResultsDict, ExactResult], bool] +Targets = int +Treebank = etree.Element +TreePredicate = Callable[[SynTree], bool] +TokenTreePredicate = Callable[[Token, SynTree], bool] +URL = str +UttTokenDict = Dict[UttId, List[Token]] +UttWordDict = Dict[UttId, List[str]] +WordInfo = Tuple[Optional[CELEXPosCode], Optional[DeHet], + Optional[CELEX_INFL], Optional[Lemma]] # moved the following to allresuls.py -#CoreQueryFunction: TypeAlias = Callable[[SynTree], List[SynTree]] -#PostQueryFunction: TypeAlias = Callable[[SynTree, allresults.AllResults], List[SynTree]] -#QueryFunction: TypeAlias = Union[CoreQueryFunction, PostQueryFunction] +# CoreQueryFunction = Callable[[SynTree], List[SynTree]] +# PostQueryFunction = Callable[[SynTree, allresults.AllResults], List[SynTree]] +# QueryFunction = Union[CoreQueryFunction, PostQueryFunction]