Пример #1
0
def to_sdp(passage, test=False, tree=False, mark_aux=False, *args, **kwargs):
    """ Convert from a Passage object to a string in SemEval 2015 SDP format (sdp)

    :param passage: the Passage object to convert
    :param test: whether to omit the top, head, frame, etc. columns. Defaults to False
    :param tree: whether to omit columns for non-primary parents. Defaults to False
    :param mark_aux: omit edges with labels with a preceding #

    :return list of lines representing the semantic dependencies in the passage
    """
    del args, kwargs
    from semstr.conversion.sdp import SdpConverter
    return SdpConverter(mark_aux=mark_aux).to_format(passage, test, tree)
Пример #2
0
def to_sdp(passage, test=False, tree=False, mark_aux=False, preprocess=True, **kwargs):
    """ Convert from a Passage object to a string in SemEval 2015 SDP format (sdp)

    :param passage: the Passage object to convert
    :param test: whether to omit the top, head, frame, etc. columns. Defaults to False
    :param tree: whether to omit columns for non-primary parents. Defaults to False
    :param mark_aux: omit edges with labels with a preceding #
    :param preprocess: preprocess the converted dependency graph before returning it?

    :return list of lines representing the semantic dependencies in the passage
    """
    from semstr.conversion.sdp import SdpConverter
    return SdpConverter(mark_aux=mark_aux, tree=tree).to_format(passage, test=test, preprocess=preprocess,
                                                                format=kwargs.get("format"))
Пример #3
0
def from_sdp(lines, passage_id, mark_aux=False, return_original=False, dep=False, preprocess=True, **kwargs):
    """Converts from parsed text in SemEval 2015 SDP format to a Passage object.

    :param lines: iterable of lines in SDP format, describing a single passage.
    :param passage_id: ID to set for passage
    :param mark_aux: add a preceding # for labels of auxiliary edges added
    :param return_original: return triple of (UCCA passage, SDP string, sentence ID)
    :param dep: return dependency graph rather than converted UCCA passage
    :param preprocess: preprocess the dependency graph before converting to UCCA (or returning it)?

    :return generator of Passage objects
    """
    from semstr.conversion.sdp import SdpConverter
    return SdpConverter(mark_aux=mark_aux).from_format(lines, passage_id=passage_id, return_original=return_original,
                                                       dep=dep, preprocess=preprocess, format=kwargs.get("format"))
Пример #4
0
def from_sdp(lines,
             passage_id,
             split=True,
             mark_aux=False,
             return_original=False,
             *args,
             **kwargs):
    """Converts from parsed text in SemEval 2015 SDP format to a Passage object.

    :param lines: iterable of lines in SDP format, describing a single passage.
    :param passage_id: ID to set for passage
    :param split: split each sentence to its own passage?
    :param mark_aux: add a preceding # for labels of auxiliary edges added
    :param return_original: return triple of (UCCA passage, SDP string, sentence ID)

    :return generator of Passage objects
    """
    del args, kwargs
    from semstr.conversion.sdp import SdpConverter
    return SdpConverter(mark_aux=mark_aux).from_format(
        lines, passage_id, split, return_original=return_original)