Skip to content

Commit

Permalink
Merge branch 'release/0.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
JeltevanBoheemen committed Nov 14, 2023
2 parents 5e18857 + f829223 commit 80b4bb3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='sastadev',
version='0.1.3',
version='0.1.4',
description='Linguistic functions for SASTA tool',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
37 changes: 22 additions & 15 deletions src/sastadev/SAFreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@
levelheaders = ['level']
stagesheaders = ['fases', 'stages']
commentsheaders = ['comments', 'commentaar']
unalignedheaders = ['unaligned']
unalignedheaders = ['unaligned', 'hele zin', 'hele uiting']


def nested_dict(n: int, type: type): # I do not know how to characterize the result type Dict n times deep endin gwith values of type type
def nested_dict(n: int,
type: type): # I do not know how to characterize the result type Dict n times deep endin gwith values of type type
if n == 1:
return defaultdict(type)
else:
Expand Down Expand Up @@ -419,7 +420,8 @@ def getitem2levelmap(mapping: Dict[Tuple[Item, Level], Any]) -> Dict[Item, Level
resultmap: Dict[Item, Level] = {}
for (item, level) in mapping:
if item in resultmap:
settings.LOGGER.error('Duplicate level {} for item {} with level {} ignored'.format(level, item, resultmap[item]))
settings.LOGGER.error(
'Duplicate level {} for item {} with level {} ignored'.format(level, item, resultmap[item]))
else:
resultmap[item] = level
return resultmap
Expand All @@ -446,7 +448,8 @@ def mkpatterns(allcodes: List[str]) -> Tuple[Pattern, Pattern]:
return (re.compile(basepattern), re.compile(fullpattern))


def get_golddata(filename: FileName, mapping: Dict[Tuple[Item, Level], QId], altcodes: Dict[Tuple[Item, Level], Tuple[Item, Level]],
def get_golddata(filename: FileName, mapping: Dict[Tuple[Item, Level], QId],
altcodes: Dict[Tuple[Item, Level], Tuple[Item, Level]],
queries: QueryDict, includeimplies: bool = False) \
-> Tuple[UttWordDict, Dict[QId, Tuple[Level, Item, List[Tuple[UttId, Position]]]]]:
# item2levelmap = {}
Expand All @@ -461,12 +464,12 @@ def get_golddata(filename: FileName, mapping: Dict[Tuple[Item, Level], QId], alt
for thelevel, theitem in basicdata:
thecounter = basicdata[(thelevel, theitem)]
# unclear why this below here is needed
# if (theitem, thelevel) in mapping:
# mappingitem = theitem
# elif (varitem, thelevel) in mapping:
# mappingitem = varitem
# else:
# mappingitem = theitem
# if (theitem, thelevel) in mapping:
# mappingitem = theitem
# elif (varitem, thelevel) in mapping:
# mappingitem = varitem
# else:
# mappingitem = theitem
if thelevel in literallevels:
# we still have to determine how to deal with this
pass
Expand All @@ -480,7 +483,8 @@ def get_golddata(filename: FileName, mapping: Dict[Tuple[Item, Level], QId], alt
impliedqid = mapping[(implieditem, impliedlevel)]
update(results, impliedqid, (impliedlevel, implieditem, thecounter))
else:
settings.LOGGER.error('Implied Item ({},{}) not found in mapping'.format(implieditem, impliedlevel))
settings.LOGGER.error(
'Implied Item ({},{}) not found in mapping'.format(implieditem, impliedlevel))
elif (theitem, thelevel) in altcodes:
(altitem, altlevel) = altcodes[(theitem, thelevel)]
qid = mapping[(altitem, altlevel)]
Expand All @@ -494,8 +498,9 @@ def get_golddata(filename: FileName, mapping: Dict[Tuple[Item, Level], QId], alt
impliedqid = mapping[(implieditem, impliedlevel)]
update(results, impliedqid, (impliedlevel, implieditem, thecounter))
else:
settings.LOGGER.error('Implied Item ({},{}) not found in mapping'.format(implieditem, impliedlevel))
elif theitem in mappingitem2levelmap: # valid item but wrong level
settings.LOGGER.error(
'Implied Item ({},{}) not found in mapping'.format(implieditem, impliedlevel))
elif theitem in mappingitem2levelmap: # valid item but wrong level
thecorrectlevel = mappingitem2levelmap[theitem]
qid = mapping[(theitem, thecorrectlevel)]
update(results, qid, (thecorrectlevel, theitem, thecounter))
Expand All @@ -508,7 +513,8 @@ def get_golddata(filename: FileName, mapping: Dict[Tuple[Item, Level], QId], alt
impliedqid = mapping[(implieditem, impliedlevel)]
update(results, impliedqid, (impliedlevel, implieditem, thecounter))
else:
settings.LOGGER.error('Implied Item ({},{}) not found in mapping'.format(implieditem, impliedlevel))
settings.LOGGER.error(
'Implied Item ({},{}) not found in mapping'.format(implieditem, impliedlevel))
elif theitem in altcodesitem2levelmap: # valid alternative item but wrong level
theitemlevel = altcodesitem2levelmap[theitem]
(thecorrectitem, thecorrectlevel) = altcodes[(theitem, theitemlevel)]
Expand All @@ -525,7 +531,8 @@ def get_golddata(filename: FileName, mapping: Dict[Tuple[Item, Level], QId], alt
impliedqid = mapping[(implieditem, impliedlevel)]
update(results, impliedqid, (impliedlevel, implieditem, thecounter))
else:
settings.LOGGER.error('Implied Item ({},{}) not found in mapping'.format(implieditem, thecorrectlevel))
settings.LOGGER.error(
'Implied Item ({},{}) not found in mapping'.format(implieditem, thecorrectlevel))

else:
settings.LOGGER.error('{} of level {} not a valid coding'.format(theitem, thelevel))
Expand Down
Binary file removed src/sastadev/data/methods/ASTA Index Current.xlsx
Binary file not shown.
Binary file added src/sastadev/data/methods/ASTA_Index_Current.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion src/sastadev/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def treatmethod(methodname: MethodName, methodfilename: FileName) -> Tuple[Metho
supported_methods = {}
supported_methods[tarsp] = os.path.join(
methodspath, 'TARSP Index Current.xlsx')
supported_methods[asta] = os.path.join(methodspath, 'ASTA Index Current.xlsx')
supported_methods[asta] = os.path.join(methodspath, 'ASTA_Index_Current.xlsx')
supported_methods[stap] = os.path.join(methodspath, 'STAP_Index_Current.xlsx')


Expand Down

0 comments on commit 80b4bb3

Please sign in to comment.