Esempio n. 1
0
def nounPhrase(person=None, gender=None, number=None, function='S',
               kind=None, S=None):

    if person is None:
        if S and verify_semantics(S, 'PESSOA'):
            person = aleatory('person')
        else:
            person = '3'
    if kind is None:
        if person != '3' or percent(15):
            kind = 'personal_pronoun'
        else:
            kind = 'noun'

    L = []
    next = None
    if kind == 'noun':
        det = determiner(person, gender, number, function, kind, S)
        L.append(det)
        next = det.info['next']
    n = nounBar(person, gender, number, function, kind, S)

    if not next:
        next = n.info['next']

    L.append(n)
    return Tree('noun phrase', L, {'head': n.info['head'], 'next': next})
Esempio n. 2
0
    def set_semantics(self, src, *dsts):
        # type: (Union[Def, Apply], *SemDefCase) -> None
        """Set our semantics."""
        from semantics import verify_semantics
        from .xform import XForm, Rtl

        sem = []  # type: List[XForm]
        for dst in dsts:
            if isinstance(dst, Rtl):
                sem.append(XForm(Rtl(src).copy({}), dst))
            elif isinstance(dst, XForm):
                sem.append(
                    XForm(dst.src.copy({}), dst.dst.copy({}), dst.constraints))
            else:
                assert isinstance(dst, tuple)
                sem.append(XForm(Rtl(src).copy({}), dst[0],
                                 constraints=dst[1]))

        verify_semantics(self, Rtl(src), sem)

        self.semantics = sem
Esempio n. 3
0
    def set_semantics(self, src, *dsts):
        # type: (Union[Def, Apply], *SemDefCase) -> None
        """Set our semantics."""
        from semantics import verify_semantics
        from .xform import XForm, Rtl

        sem = []  # type: List[XForm]
        for dst in dsts:
            if isinstance(dst, Rtl):
                sem.append(XForm(Rtl(src).copy({}), dst))
            elif isinstance(dst, XForm):
                sem.append(XForm(
                    dst.src.copy({}),
                    dst.dst.copy({}),
                    dst.constraints))
            else:
                assert isinstance(dst, tuple)
                sem.append(XForm(Rtl(src).copy({}), dst[0],
                                 constraints=dst[1]))

        verify_semantics(self, Rtl(src), sem)

        self.semantics = sem
Esempio n. 4
0
def prepositionalPhrase(preposition=None, person=None, gender=None,
                        number=None, function='S', kind=None, S=None):

    if person is None:
        if S and verify_semantics(S, 'PESSOA'):
            person = aleatory('person')
        else:
            person = '3'
    if kind is None:
        if person != '3' or percent(15):
            kind = 'personal_pronoun'
        else:
            kind = 'noun'

    np = nounPhrase(person, gender, number, function, kind, S)
    next = np.info['next']
    L = [np]

    p = wf.getPreposition(preposition, gender, number, next)

    L = [Tree("preposition", [p])] + L

    return Tree('prepositional phrase', L, {'head': np.info['head']})
Esempio n. 5
0
 def belongs(self, s, kind='base'):
     if kind not in self.concept.keys():
         return False
     return semantics.verify_semantics(s, self.concept[kind])
Esempio n. 6
0
 def includes(self, s, kind='base'):
     if kind not in self.concept.keys():
         return False
     return semantics.verify_semantics(self.concept[kind], s)