Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParsedSampleRow -- to common, considering cols_providers (Base, Network) as an extra parameter for value parsing. #284

Closed
nicolay-r opened this issue Feb 20, 2022 · 0 comments
Assignees
Labels
critical enhancement New feature or request task

Comments

@nicolay-r
Copy link
Owner

nicolay-r commented Feb 20, 2022

Proceeds #275 for better BRAT adaptation
Idea: columns provider describes how the values should be formatted. The latter might be an additional parameter that goes alongside with the __init__ method.

In common we may move ParsedSampleRow class with __init__(columns_fmt) structure, passed as a parameters but remained to be placed in contrib part. The code below is a custom version for the schema of source->target relation extraction task.

parse_value = {
const.ID: lambda value: value,
const.S_IND: lambda value: int(value),
const.T_IND: lambda value: int(value),
network_input_const.FrameVariantIndices: lambda value:
__process_indices_list(value) if isinstance(value, str) else empty_list,
network_input_const.FrameConnotations: lambda value:
__process_indices_list(value) if isinstance(value, str) else empty_list,
network_input_const.SynonymObject: lambda value: __process_indices_list(value),
network_input_const.SynonymSubject: lambda value: __process_indices_list(value),
network_input_const.Entities: lambda value: __process_indices_list(value),
network_input_const.PosTags: lambda value: __process_int_values_list(value),
"text_a": lambda value: filter_whitespaces([term for term in split_by_whitespaces(value)])
}
class ParsedSampleRow(object):
"""
Provides a parsed information for a sample row.
TODO. Use this class as API
"""
def __init__(self, row):
assert(isinstance(row, pd.Series))
self.__uint_label = None
self.__params = {}
for key, value in row.items():
if key == const.LABEL:
self.__uint_label = int(value)
continue
if key not in parse_value:
continue
self.__params[key] = parse_value[key](value)

@nicolay-r nicolay-r added enhancement New feature or request task labels Feb 20, 2022
@nicolay-r nicolay-r self-assigned this Feb 20, 2022
nicolay-r added a commit that referenced this issue Feb 20, 2022
@nicolay-r nicolay-r changed the title ParsedSampleRow -- to common, considering cols_providers (Base, Network) as an extra parameter for value parsing. ParsedSampleRow -- to common, considering cols_providers (Base, Network) as an extra parameter for value parsing. Jun 6, 2022
@nicolay-r nicolay-r mentioned this issue Jun 19, 2023
24 tasks
@nicolay-r nicolay-r changed the title ParsedSampleRow -- to common, considering cols_providers (Base, Network) as an extra parameter for value parsing. ‼️ ParsedSampleRow -- to common, considering cols_providers (Base, Network) as an extra parameter for value parsing. Oct 1, 2023
@nicolay-r nicolay-r changed the title ‼️ ParsedSampleRow -- to common, considering cols_providers (Base, Network) as an extra parameter for value parsing. ParsedSampleRow -- to common, considering cols_providers (Base, Network) as an extra parameter for value parsing. Oct 1, 2023
nicolay-r added a commit that referenced this issue Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical enhancement New feature or request task
Projects
None yet
Development

No branches or pull requests

1 participant