Beispiel #1
0
    def __init__(self):
        SequenceSpec.__init__(self, "adv-adj")
        self.__compared_with = {}

        self.spec = template("spec")(
            [
                template("repeat")(
                    "$PARENT::adv",
                    repeatable=RepeatableSpecs().Once(),
                    body={
                        "id": "$PARENT::adv",
                        "repeatable": RepeatableSpecs().Once(),
                        "include": {"spec": "basic-adv"},
                        "master-slave": [LinkSpecs().IsSlave("$LOCAL_SPEC_ANCHOR", weight=LinkWeight("$SPECNAME"))],
                    },
                    separator={"always": False},
                ),
                {
                    "id": "$PARENT::adj",
                    "repeatable": RepeatableSpecs().Once(),
                    "include": {"spec": "basic-adj"},
                    "anchor": [AnchorSpecs().LocalSpecAnchor()],
                },
            ]
        )
Beispiel #2
0
    def __init__(self):
        SequenceSpec.__init__(self, 'entity-location')
        self.__compared_with = {}

        self.spec = template("subclass")(
            base=EntityListSpec,
            rewrite=[
                {
                    "find": {
                        "id": ".*::#pre#",
                    },
                    "extend": {
                        "id": "$PARENT::prepositions",
                        "anchor": AnchorSpecs().Tag("pre"),
                        "repeatable": RepeatableSpecs().Once(),
                        "uniq-items": template("foreach")(
                            prototype={
                                "repeatable": RepeatableSpecs().Once(),
                                "pos_type": [PosSpecs().IsPreposition(), ],
                                "dependency-of": template("dependency")(
                                    "location",
                                    "$TAG(object)"
                                ),
                            },
                            items=[
                                {"pos_type": [WordSpecs().IsWord([u'над']), ]},
                                {"pos_type": [WordSpecs().IsWord([u'под']), ]},
                                {"pos_type": [WordSpecs().IsWord([u'в']), ]},
                                {"pos_type": [WordSpecs().IsWord([u'на']), ]},
                            ]
                        )
                    }
                },
                {
                    "find": {
                        "id": ".*::#pre-internal#",
                    },
                    "extend": {
                        "id": "$PARENT::prepositions",
                        "repeatable": RepeatableSpecs().Once(),
                        "uniq-items": template("foreach")(
                            prototype={
                                "repeatable": RepeatableSpecs().Once(),
                                "pos_type": [PosSpecs().IsPreposition(), ],
                                "exclusive-with": AnchorSpecs().ExclusiveWith("$TAG(pre)"),
                            },
                            items=[
                                {"pos_type": [WordSpecs().IsWord([u'над']), ]},
                                {"pos_type": [WordSpecs().IsWord([u'под']), ]},
                                {"pos_type": [WordSpecs().IsWord([u'в']), ]},
                                {"pos_type": [WordSpecs().IsWord([u'на']), ]},
                            ]
                        )
                    }
                },
            ]
        )
Beispiel #3
0
    def __init__(self):
        SequenceSpec.__init__(self, 'entity-list-neg')
        self.__compared_with = {}

        self.spec = template("spec")([
            template("neg")(
                "$PARENT::entity-list-neg",
                "entity-list",
                repeatable=RepeatableSpecs().Once(),
                strict_neg=False,
                anchor=True
            )
        ])
Beispiel #4
0
    def __init__(self):
        SequenceSpec.__init__(self, 'sentence')
        self.__compared_with = {}

        self.spec = template("spec")([
            {
                "id": "$PARENT::subject-pre",
                "repeatable": RepeatableSpecs().LessOrEqualThan(1),
                "anchor": AnchorSpecs().LocalSpecAnchor(),
                "include": {
                    "spec": "subject-group"
                },
            },
            {
                "id": "$PARENT::predicate",
                "repeatable": RepeatableSpecs().EqualOrMoreThan(1),
                "include": {
                    "spec": "verb-group"
                },
                "master-slave": [LinkSpecs().IsSlave("$LOCAL_SPEC_ANCHOR"), ],
            },
            {
                "id": "$PARENT::subject-post",
                "repeatable": RepeatableSpecs().LessOrEqualThan(1),
                "anchor": AnchorSpecs().LocalSpecAnchor(),
                "include": {
                    "spec": "subject-group"
                },
            }
        ])
Beispiel #5
0
    def __init__(self):
        SequenceSpec.__init__(self, 'comma-and-or')
        self.__compared_with = {}

        self.spec = template("spec")(
            {
                "repeatable": RepeatableSpecs().Once(),
                "id": "$PARENT:or",
                "anchor": AnchorSpecs().LocalSpecAnchor(),
                "uniq-items": [
                    {
                        "id": "$PARENT::comma",
                        "repeatable": RepeatableSpecs().Once(),
                        "pos_type": [PosSpecs().IsComma(), ],
                        "merges-with": ["comma", ],
                    },
                    {
                        "id": "$PARENT::and",
                        "repeatable": RepeatableSpecs().Once(),
                        "pos_type": [WordSpecs().IsWord([u'и', ]), PosSpecs().IsUnion()],
                    },
                    {
                        "id": "$PARENT::or",
                        "repeatable": RepeatableSpecs().Once(),
                        "pos_type": [WordSpecs().IsWord([u'или', ]), ],
                    }
                ]
            }
        )
Beispiel #6
0
    def __init__(self):
        SequenceSpec.__init__(self, 'basic-subject')
        self.__compared_with = {}

        self.spec = template("spec")(
            {
                "repeatable": RepeatableSpecs().Once(),
                "id": "$PARENT:subject",
                "anchor": AnchorSpecs().LocalSpecAnchor(),
                "uniq-items": [
                    {
                        "id": "$PARENT::pronoun",
                        "repeatable": RepeatableSpecs().Once(),
                        "pos_type": [PosSpecs().IsPronoun(), ],
                        "case": [CaseSpecs().IsCase(["nominative", ]), ],
                    },
                    {
                        "id": "$PARENT::noun",
                        "repeatable": RepeatableSpecs().Once(),
                        "case": [CaseSpecs().IsCase(["nominative", ]), ],
                        "include": {
                            "spec": "noun-group"
                        },
                    },
                ],
            }
        )
Beispiel #7
0
    def __init__(self):
        SequenceSpec.__init__(self, "noun-ctrl-noun")
        self.__compared_with = {}

        self.spec = template("spec")(
            [
                {
                    "id": "$PARENT::noun",
                    "repeatable": RepeatableSpecs().Once(),
                    "anchor": AnchorSpecs().LocalSpecAnchor(),
                    "include": {"spec": "adj+-noun"},
                },
                {
                    "id": "$PARENT::ctrled-noun",
                    "repeatable": RepeatableSpecs().LessOrEqualThan(1),
                    "entries": [
                        {
                            "id": "$PARENT::noun",
                            "repeatable": RepeatableSpecs().Once(),
                            "master-slave": [LinkSpecs().IsSlave("$SPEC::noun")],
                            "case": [CaseSpecs().IsCase(["genitive"])],
                            "include": {"spec": "adj+-noun"},
                        },
                        {
                            "id": "$PARENT::ctrled-noun",
                            "repeatable": RepeatableSpecs().LessOrEqualThan(1),
                            "master-slave": [LinkSpecs().IsSlave("$SPEC::ctrled-noun::noun")],
                            "case": [CaseSpecs().IsCase(["genitive"])],
                            "include": {"spec": "adj+-noun"},
                        },
                    ],
                },
            ]
        )
Beispiel #8
0
    def __init__(self):
        SequenceSpec.__init__(self, 'mrg')
        self.__compared_with = {}

        self.spec = template("spec")([
            {
                "id": "$PARENT::s1",
                "repeatable": RepeatableSpecs().Once(),
                "pos_type": [PosSpecs().IsNoun(), ],
            },
            {
                "id": "$PARENT::s2",
                "repeatable": RepeatableSpecs().Once(),
                "anchor": AnchorSpecs().LocalSpecAnchor(),
                "include": {
                    "spec": "inc"
                },
            },
            {
                "id": "$PARENT::s3",
                "repeatable": RepeatableSpecs().Once(),
                "include": {
                    "spec": "comma-and-or"
                },
            },
            {
                "id": "$PARENT::s4",
                "pos_type": [PosSpecs().IsNoun(), ],
                "repeatable": RepeatableSpecs().Once(),
            }
        ])
Beispiel #9
0
    def __init__(self):
        SequenceSpec.__init__(self, "noun-group")
        self.__compared_with = {}

        self.spec = template("spec")(
            [
                {
                    "id": "$PARENT::preposition",
                    "repeatable": RepeatableSpecs().LessOrEqualThan(1),
                    "pos_type": [PosSpecs().IsPreposition()],
                },
                {
                    "id": "$PARENT::noun",
                    "repeatable": RepeatableSpecs().Once(),
                    "anchor": AnchorSpecs().LocalSpecAnchor(),
                    "include": {"spec": "noun-ctrl-noun"},
                    "master-slave": [LinkSpecs().IsSlave("$SPEC::preposition")],
                },
                {
                    "id": "$PARENT::noun-seq",
                    "repeatable": RepeatableSpecs().Any(),
                    "anchor": AnchorSpecs().LocalSpecAnchor(),
                    "same-as": [SameAsSpecs().SameCase("$PARENT::noun")],
                    "include": {"spec": "noun-group-aux"},
                    "master-slave": [LinkSpecs().IsSlave("$SPEC::preposition")],
                },
            ]
        )
Beispiel #10
0
    def __init__(self):
        SequenceSpec.__init__(self, 'entity-ownership')
        self.__compared_with = {}

        self.spec = template("subclass")(
            base=EntityListSpec,
            rewrite=[
                {
                    "find": {
                        "id": ".*::common-pre",
                    },
                    "extend": {
                        "repeatable": RepeatableSpecs().Never(),
                    }
                },
                {
                    "find": {
                        "id": ".*::#item#",
                    },
                    "extend": {
                        "case": [CaseSpecs().IsCase(["genitive", ]), ],
                    }
                },
            ]
        )
Beispiel #11
0
    def __init__(self):
        SequenceSpec.__init__(self, 'verb-group')
        self.__compared_with = {}

        self.spec = template("spec")([
            {
                "repeatable": RepeatableSpecs().Any(),
                "id": "$PARENT::noun-group-pre",
                "include": {
                    "spec": "noun-group"
                },
                "master-slave": [LinkSpecs().IsSlave("$LOCAL_SPEC_ANCHOR"), ],
            },
            {
                "repeatable": RepeatableSpecs().Once(),
                "id": "$PARENT::predicate",
                "include": {
                    "spec": "adv-verb"
                },
                "anchor": AnchorSpecs().LocalSpecAnchor(),
            },
            {
                "repeatable": RepeatableSpecs().Any(),
                "id": "$PARENT::noun-group-post",
                "include": {
                    "spec": "noun-group"
                },
                "master-slave": [LinkSpecs().IsSlave("$LOCAL_SPEC_ANCHOR"), ],
            }
        ])
Beispiel #12
0
    def __init__(self):
        SequenceSpec.__init__(self, 'entity-neg')
        self.__compared_with = {}

        self.spec = template("@", "spec")([
            template("neg")(
                "$PARENT::entity-neg",
                {
                    "id": "$PARENT::body",
                    "@inherit": ["once", "anchor"],
                    "anchor": AnchorSpecs().LocalSpecAnchor(),
                    "include": template("include")("entity", is_static=True),
                },
                repeatable=RepeatableSpecs().Once(),
                strict_neg=False
            )
        ])
Beispiel #13
0
    def __init__(self):
        SequenceSpec.__init__(self, 'entity')
        self.__compared_with = {}

        self.spec = template("@", "spec")([
            {
                "id": "$PARENT::definitive",
                "@inherit": ["any"],
                "dependency-of": template("dependency")(
                    "location"
                ),
                "include": template("include")("adjective"),
            },
            {
                "id": "$PARENT::core",
                "@inherit": ["once", "anchor"],
                "anchor": AnchorSpecs().LocalSpecAnchor(),
                "uniq-items": [
                    {
                        "id": "$PARENT::noun",
                        "@inherit": ["once"],
                        "include": template("include")("basic-noun", is_static=True),
                    },
                    # {
                    #     "id": "$PARENT::noun",
                    #     "repeatable": RepeatableSpecs().Once(),
                    #     "include": {
                    #         "spec": "basic-pronoun",
                    #     },
                    # },
                ],
            },
            {
                "id": "$PARENT::ownership",
                "@inherit": ["any"],
                "uniq-items": [
                    {
                        "id": "$PARENT::location",
                        "@inherit": ["once"],
                        "dependency-of": template("dependency")(
                            "location"
                        ),
                        "include": template("include")("entity-location"),
                    },
                    {
                        "id": "$PARENT::ownership",
                        "@inherit": ["once"],
                        "dependency-of": template("dependency")(
                            "location"
                        ),
                        "include": template("include")("entity-ownership"),
                    },
                ]
            }
        ])
Beispiel #14
0
    def __init__(self):
        SequenceSpec.__init__(self, 'basic-adv')
        self.__compared_with = {}

        self.spec = template("spec")(
            {
                "id": "$PARENT::adv",
                "repeatable": RepeatableSpecs().Once(),
                "pos_type": [PosSpecs().IsAdverb(), ],
                "anchor": AnchorSpecs().LocalSpecAnchor(),
            }
        )
Beispiel #15
0
    def __init__(self):
        SequenceSpec.__init__(self, 'noun-noun')
        self.__compared_with = {}

        self.spec = template("spec")(
            {
                "id": "$SPEC::noun",
                "repeatable": RepeatableSpecs().EqualOrMoreThan(2),
                "include": {
                    "spec": "adj+-noun"
                },
                "master-slave": [LinkSpecs().IsSlave("$SPEC::noun[$INDEX(0)-1]"), ],
            }
        )
Beispiel #16
0
    def __init__(self):
        SequenceSpec.__init__(self, "noun-group-aux")
        self.__compared_with = {}

        self.spec = template("spec")(
            [
                {
                    "id": "$PARENT::comma-and-or",
                    "repeatable": RepeatableSpecs().Once(),
                    "include": {"spec": "comma-and-or"},
                },
                {
                    "id": "$PARENT::noun",
                    "repeatable": RepeatableSpecs().Once(),
                    "anchor": AnchorSpecs().LocalSpecAnchor(),
                    "include": {"spec": "noun-ctrl-noun"},
                },
            ]
        )
Beispiel #17
0
    def __init__(self):
        SequenceSpec.__init__(self, 'inc')
        self.__compared_with = {}

        self.spec = template("spec")([
            {
                "id": "$PARENT::p1",
                "repeatable": RepeatableSpecs().Once(),
                "pos_type": [PosSpecs().IsNoun(), ],
                "anchor": AnchorSpecs().LocalSpecAnchor(),
            },
            {
                "id": "$PARENT::p2",
                "repeatable": RepeatableSpecs().Any(),
                "entries": [
                    {
                        "id": "$PARENT::n1",
                        "repeatable": RepeatableSpecs().Once(),
                        "include": {
                            "spec": "comma-and-or"
                        },
                    },
                    {
                        "id": "$PARENT::n2",
                        "pos_type": [PosSpecs().IsNoun(), ],
                        "repeatable": RepeatableSpecs().Once(),
                        "anchor": AnchorSpecs().LocalSpecAnchor(),
                    },
                    {
                        "id": "$PARENT::n3",
                        "repeatable": RepeatableSpecs().Once(),
                        "include": {
                            "spec": "comma-and-or"
                        },
                    },
                ]
            }
        ])
Beispiel #18
0
    def __init__(self):
        SequenceSpec.__init__(self, 'entity-list')
        self.__compared_with = {}

        self.spec = template("@", "spec")([
            template("aggregate")(
                "$PARENT::aggregate",
                attributes={
                    "anchor": AnchorSpecs().LocalSpecAnchor(),
                },
                body={
                    "id": "$PARENT::variants",
                    "@inherit": ["once"],
                    "uniq-items": [
                        {
                            "id": "$PARENT::common-pre",
                            "repeatable": RepeatableSpecs().Once(),
                            "entries": [
                                {
                                    "id": "$PARENT::#pre#",
                                    "repeatable": RepeatableSpecs().Never(),
                                },
                                template("repeat")(
                                    "$PARENT::entity-list",
                                    {
                                        "id": "$PARENT::entity-list",
                                        "repeatable": RepeatableSpecs().Once(),
                                        "entries": [
                                            {
                                                "id": "$PARENT::#item#",
                                                "@inherit": ["once"],
                                                "refers-to": template("refers-to")(),
                                                "anchor": AnchorSpecs().Tag("object"),
                                                "include": template("include")("entity-neg", is_static=True),
                                            }
                                        ]
                                    },
                                    repeatable=RepeatableSpecs().Once(),
                                    separator=None
                                ),
                            ]
                        },
                        template("repeat")(
                            "$PARENT::entity-list",
                            {
                                "id": "$PARENT::entity-list",
                                "@inherit": ["once"],
                                "entries": [
                                    {
                                        "id": "$PARENT::#pre-internal#",
                                        "repeatable": RepeatableSpecs().Never(),
                                        "dependency-of": template("dependency")(
                                            "location",
                                            "$PARENT::#item#"
                                        ),
                                    },
                                    {
                                        "id": "$PARENT::#item#",
                                        "@inherit": ["once"],
                                        "refers-to": template("refers-to")(),
                                        "anchor": AnchorSpecs().Tag("object-int"),
                                        "include": template("include")("entity-neg", is_static=True),
                                    }
                                ]
                            },
                            repeatable=RepeatableSpecs().Once(),
                            separator=None
                        ),
                    ]
                },
                as_dict=True
            )
        ])
Beispiel #19
0
    def __init__(self):
        SequenceSpec.__init__(self, 'adj+-noun')
        self.__compared_with = {}

        self.spec = template("spec")([
            {
                "id": "$PARENT::pronoun",
                "repeatable": RepeatableSpecs().LessOrEqualThan(1),
                "include": {
                    "spec": "pronoun-group",
                },
                "case": [CaseSpecs().IsCase(["genitive", ]), ],
                "master-slave": [LinkSpecs().IsSlave("$LOCAL_SPEC_ANCHOR"), ],
            },
            {
                "id": "$PARENT::participal",
                "repeatable": RepeatableSpecs().Any(),
                "include": {
                    "spec": "participal-group"
                },
                "master-slave": [LinkSpecs().IsSlave("$LOCAL_SPEC_ANCHOR"), ],
                "reliability": 1,
            },
            {
                "id": "$PARENT::adj-pre",
                "repeatable": RepeatableSpecs().Any(),
                "include": {
                    "spec": "adv-adj"
                },
                "master-slave": [LinkSpecs().IsSlave("$LOCAL_SPEC_ANCHOR"), ],
                "reliability": 1,
            },
            {
                "id": "$PARENT::pronoun-seq",
                "repeatable": RepeatableSpecs().LessOrEqualThan(1),
                "include": {
                    "spec": "pronoun-group"
                },
                "case": [CaseSpecs().IsCase(["genitive", ]), ],
                "master-slave": [LinkSpecs().IsSlave("$LOCAL_SPEC_ANCHOR"), ],
            },
            {
                "id": "$SPEC::noun",
                "repeatable": RepeatableSpecs().Once(),
                "pos_type": [PosSpecs().IsNoun(), ],
                "anchor": AnchorSpecs().LocalSpecAnchor(),
            },
            {
                "id": "$PARENT::adj-post",
                "repeatable": RepeatableSpecs().Any(),
                "include": {
                    "spec": "adv-adj"
                },
                "master-slave": [LinkSpecs().IsSlave("$LOCAL_SPEC_ANCHOR"), ],
                "reliability": 0.9,
            },
            template("wrap")(
                "$PARENT::participal-post",
                repeatable=RepeatableSpecs().Any(),
                body={
                    "id": "$PARENT::participal",
                    "repeatable": RepeatableSpecs().Once(),
                    "include": {
                        "spec": "participal-group"
                    },
                    "master-slave": [LinkSpecs().IsSlave("$LOCAL_SPEC_ANCHOR"), ],
                },
                attrs={
                    "reliability": 1.0,
                }
            ),
        ])