Esempio n. 1
0
def test_constellation_add():

    topic_query = format_cqp_query(TOPIC_ITEMS,
                                   p_query=P_QUERY,
                                   s_query=S_QUERY,
                                   flags="%cd",
                                   escape=False)

    # init constellation
    topic_dump = CORPUS.query(topic_query,
                              context=None,
                              context_break=S_CONTEXT)

    const = Constellation(topic_dump)

    # add discourseme
    disc1_query = format_cqp_query(DISC1_ITEMS,
                                   p_query=P_QUERY,
                                   s_query=S_QUERY,
                                   flags="%cd",
                                   escape=False)

    disc1_dump = CORPUS.query(disc1_query,
                              context=None,
                              context_break=S_CONTEXT)

    const.add_discourseme(disc1_dump)

    print(const.df)
    print(const.discoursemes.keys())
Esempio n. 2
0
def test_constellation_add(germaparl, discoursemes):

    corpus = get_corpus(germaparl)

    # init constellation
    topic_query = format_cqp_query(
        discoursemes['topic'],
        p_query=discoursemes['parameters']['p_query'],
        s_query=discoursemes['parameters']['s_query'],
        flags=discoursemes['parameters']['flags_query'],
        escape=discoursemes['parameters']['escape_query'])
    topic_dump = corpus.query(
        topic_query,
        context=None,
        context_break=discoursemes['parameters']['s_context'])
    const = Constellation(topic_dump)

    # add discourseme
    disc1_query = format_cqp_query(
        discoursemes['disc1'],
        p_query=discoursemes['parameters']['p_query'],
        s_query=discoursemes['parameters']['s_query'],
        flags=discoursemes['parameters']['flags_query'],
        escape=discoursemes['parameters']['escape_query'])
    disc1_dump = corpus.query(
        disc1_query,
        context=None,
        context_break=discoursemes['parameters']['s_context'])
    const.add_discourseme(disc1_dump)

    assert len(const.df) == 1599
    assert 'topic' in const.discoursemes
    assert len(const.discoursemes) == 2
Esempio n. 3
0
def test_constellation_coll(germaparl, discoursemes):

    corpus = get_corpus(germaparl)

    # init constellation
    topic_query = format_cqp_query(
        discoursemes['topic'],
        p_query=discoursemes['parameters']['p_query'],
        s_query=discoursemes['parameters']['s_query'],
        flags=discoursemes['parameters']['flags_query'],
        escape=discoursemes['parameters']['escape_query'])
    topic_dump = corpus.query(
        topic_query,
        context=None,
        context_break=discoursemes['parameters']['s_context'])
    const = Constellation(topic_dump)

    # add discourseme 1
    disc1_query = format_cqp_query(
        discoursemes['disc1'],
        p_query=discoursemes['parameters']['p_query'],
        s_query=discoursemes['parameters']['s_query'],
        flags=discoursemes['parameters']['flags_query'],
        escape=discoursemes['parameters']['escape_query'])
    disc1_dump = corpus.query(
        disc1_query,
        context=None,
        context_break=discoursemes['parameters']['s_context'])
    const.add_discourseme(disc1_dump, name='disc1')

    # add discourseme 2
    disc2_query = format_cqp_query(
        discoursemes['disc2'],
        p_query=discoursemes['parameters']['p_query'],
        s_query=discoursemes['parameters']['s_query'],
        flags=discoursemes['parameters']['flags_query'],
        escape=discoursemes['parameters']['escape_query'])
    disc2_dump = corpus.query(
        disc2_query,
        context=None,
        context_break=discoursemes['parameters']['s_context'])
    const.add_discourseme(disc2_dump, name='disc2')

    dfs = const.collocates(windows=list(range(1, 21)))
    assert len(dfs) == 20
    assert len(dfs[1]) == 2
    assert len(dfs[20]) == 5
Esempio n. 4
0
def test_constellation_conc():

    topic_query = format_cqp_query(TOPIC_ITEMS,
                                   p_query=P_QUERY,
                                   s_query=S_QUERY,
                                   flags="%cd",
                                   escape=False)

    # init constellation
    topic_dump = CORPUS.query(topic_query,
                              context=None,
                              context_break=S_CONTEXT)

    const = Constellation(topic_dump)

    # add discourseme 1
    disc1_query = format_cqp_query(DISC1_ITEMS,
                                   p_query=P_QUERY,
                                   s_query=S_QUERY,
                                   flags="%cd",
                                   escape=False)
    disc1_dump = CORPUS.query(disc1_query,
                              context=None,
                              context_break=S_CONTEXT)

    const.add_discourseme(disc1_dump, name='disc1')

    # add discourseme 2
    disc2_query = format_cqp_query(DISC2_ITEMS,
                                   p_query=P_QUERY,
                                   s_query=S_QUERY,
                                   flags="%cd",
                                   escape=False)
    disc2_dump = CORPUS.query(disc2_query,
                              context=None,
                              context_break=S_CONTEXT)

    const.add_discourseme(disc2_dump, name='disc2')

    lines = const.concordance(s_show=['text_id'])
    print(lines)
Esempio n. 5
0
def test_constellation_coll():

    topic_query = format_cqp_query(TOPIC_ITEMS,
                                   p_query=P_QUERY,
                                   s_query=S_QUERY,
                                   flags="%cd",
                                   escape=False)

    # init constellation
    topic_dump = CORPUS.query(topic_query,
                              context=None,
                              context_break=S_CONTEXT)
    const = Constellation(topic_dump)

    # add discourseme 1
    disc1_query = format_cqp_query(DISC1_ITEMS,
                                   p_query=P_QUERY,
                                   s_query=S_QUERY,
                                   flags="%cd",
                                   escape=False)
    disc1_dump = CORPUS.query(disc1_query,
                              context=None,
                              context_break=S_CONTEXT)

    const.add_discourseme(disc1_dump, name='disc1')

    # add discourseme 2
    disc2_query = format_cqp_query(DISC2_ITEMS,
                                   p_query=P_QUERY,
                                   s_query=S_QUERY,
                                   flags="%cd",
                                   escape=False)
    disc2_dump = CORPUS.query(disc2_query,
                              context=None,
                              context_break=S_CONTEXT)

    const.add_discourseme(disc2_dump, name='disc2')

    lines = const.collocates(windows=list(range(1, 20)))
    print(lines)