Examples.py 749 Bytes
#! /usr/bin/python
# -*- coding: utf-8 -*-

from importer.Example import Example


class Examples:

    def __init__(self, examples):
        self._examples = examples

    @classmethod
    def fromTree(cls, examples_layer_tree, syntax, semantics, base, meanings, in_data, out_file, misconnected):
        examples = []
        for example_subtree in examples_layer_tree._children[0]._children[0]._children:
            example = Example.fromTree(example_subtree, syntax._phrases, semantics, base, meanings, in_data, out_file, misconnected)
            examples.append(example)
        
        return cls(examples)

    def store(self, entry, meanings):
        for example in self._examples:
            example.store(entry, meanings)