Ejemplo n.º 1
0
from collections import defaultdict
import load_utils

stats_utils = load_utils.load_python_module(module_path='../resources/FN_Reader',
                                            module_name='stats_utils',
                                            verbose=1)

def load_frame2rbn_objs_via_subsumes_relation(fn, mapping, rbn_objs, verbose=0):
    """
    load the mapping from rbn to framenet as a relationship between

    frame -> every rbn lexical entry that is linked via a feature set match
    with a frame in fn
    """
    g = stats_utils.load_frame_relations_as_directed_graph(fn, subset_of_relations={'Inheritance'})

    # load mapping feature set to all fn frames that are under top frame
    rbn_featureset2all_frames = dict()
    for feature_set, top_frames in mapping.items():
        all_frames = set()
        for top_frame in top_frames:

            all_frames.add(top_frame)
            level2children = stats_utils.get_all_successors_of_all_successors(g,
                                                                              starting_node=top_frame,
                                                                              verbose=verbose)
            for depth, frames in level2children.items():
                all_frames.update(frames)

        rbn_featureset2all_frames[feature_set] = all_frames
Ejemplo n.º 2
0
import pickle
import load_utils
import random

load_utils.load_python_module(module_path='../resources/ODWN_Reader',
                              module_name='odwn_classes',
                              verbose=0)


def preprocess_dfn(fn_object_path):
    """
    Extract information from Dutch FrameNet
    for the computation of descriptive statistics.

    :param str fn_object_path: path to the version of Dutch FrameNet

    :rtype: tuple
    :return:    (fn_lu_id_pos2rbn_senseids,     dict for (FN LU id, POS) -> RBN LU id(s)
                rbn_senseid_pos2fn_lu_ids,      dict for (RBN LU id, POS) -> FN LU id(s)
                pos_set_fn,                     set for encountered POS in FN
                pos_set_rbn,                    set for encountered POS in RBN
                frame_label_pos2fn_lu_ids,      dict for (frame, None) -> FN LU id(s)
                frame_label_pos2rbn_senseids)   dict for (frame, None) -> RBN LU id(s)
    """
    with open(fn_object_path, 'rb') as infile:
        fn_obj = pickle.load(infile)

    pos_set_fn = set()
    pos_set_rbn = set()
    fn_lu_id_pos2rbn_senseids = dict()
    rbn_senseid_pos2fn_lu_ids = dict()
Ejemplo n.º 3
0
import sys
import os
import pickle
from dfn_classes import Lexeme, Lemma
from collections import defaultdict

import load_utils
sonar_classes = load_utils.load_python_module(
    module_path='../resources/FrameNet_annotations_on_SoNaR/scripts',
    module_name='sonar_classes',
    verbose=1)


def load_sonar_annotations(configuration, verbose=0):
    """
    load sonar annotations to
    frame_label -> list of Lexeme objects

    :param dict configuration: configuration (see config_files folder)

    :rtype: tuple
    :return: (mapping of frame_label -> lexeme objects,
              stats)
    """
    # load annotator information
    assert os.path.exists((configuration['path_sonar_annotator_1']))
    with open(configuration['path_sonar_annotator_1'], 'rb') as infile:
        annotator_1 = pickle.load(infile)

    assert os.path.exists((configuration['path_sonar_annotator_2']))
    with open(configuration['path_sonar_annotator_2'], 'rb') as infile: