コード例 #1
0
# Copyright (c) 2012, Machinalis S.R.L.
# This file is part of quepy and is distributed under the Modified BSD License.
# You should have received a copy of license in the LICENSE file.
#
# Authors: Rafael Carrascosa <*****@*****.**>
#          Gonzalo Garcia Berrotaran <*****@*****.**>
"""
Writers related regex.
"""

from refo import Plus, Question
from quepy.dsl import HasKeyword
from quepy.parsing import Lemma, Lemmas, Pos, QuestionTemplate, Particle
from dsl import IsBook, HasAuthor, AuthorOf, IsPerson, NameOf

nouns = Pos("DT") | Pos("IN") | Pos("NN") | Pos("NNS") | Pos("NNP") | Pos(
    "NNPS")


class Book(Particle):
    regex = Plus(nouns)

    def interpret(self, match):
        name = match.words.tokens
        return IsBook() + HasKeyword(name)


class Author(Particle):
    regex = Plus(nouns | Lemma("."))

    def interpret(self, match):
コード例 #2
0
class Country(Particle):
    regex = Plus(Pos("DT") | Pos("NN") | Pos("NNS") | Pos("NNP") | Pos("NNPS"))

    def interpret(self, match):
        name = match.words.tokens.title()
        return IsCountry() + HasKeyword(name)
コード例 #3
0
class MilitaryConflict(Particle):
    regex = Question(Pos("DT")) + nouns

    def interpret(self, match):
        name = match.words.tokens
        return IsMilitaryConflict() + LabelOfFixedDataRelation(name)
コード例 #4
0
class Person(Particle):
    regex = Plus(Pos("NN") | Pos("NNS") | Pos("NNP") | Pos("NNPS"))

    def interpret(self, match):
        name = match.words.tokens
        return IsPerson() + HasKeyword(name)
コード例 #5
0
class SongsAboutStuffQuestion(QuestionTemplate):
    """
    Ex: "List songs about love"
        "Songs about love"
    """
    regex = (Question(Lemma("list")) + (Lemma("song") | Lemma("songs") | Lemma("track")) + Pos("IN") + Topic()) | (
        Topic() + Lemma("song"))

    def interpret(self, match):
        _song, i, j = match.topic
        return IsAlbum() + TrackList(_song + HasId()), ReturnValue(i, j)
コード例 #6
0
class EducationInstitution(Particle):
    regex = Plus(Pos("DT") | Pos("IN") | nouns)

    def interpret(self, match):
        name = match.words.tokens.title()
        return IsEducation() + InstitutionEducation(HasName(name) + HasId())
コード例 #7
0
class Location(Particle):
    regex = Plus(Pos("DT") | nouns)

    def interpret(self, match):
        name = match.words.tokens.title()
        return IsLocation() + HasKeyword(name)
コード例 #8
0
ファイル: movies.py プロジェクト: LayneIns/KBQA_basic_version
class Movie(Particle):
    regex = Question(Pos("DT")) + nouns

    def interpret(self, match):
        name = match.words.tokens
        return IsMovie() + HasName(name)
コード例 #9
0
class YearAf(Particle):
    regex = Pos("CD")

    def interpret(self, match):
        year = match.words.tokens
        return IsAfterYear(year)
コード例 #10
0
class SongLength(Particle):
    regex = Pos("CD")

    def interpret(self, match):
        length = match.words.tokens
        return TrackLengthHigh("\"" + length + "\"")
コード例 #11
0
class Topic(Particle):
    regex = Pos("IN") | Pos("JJ") | Pos("NN") | Pos("NNP") | Pos("NNS")

    def interpret(self, match):
        name = match.words.tokens.title()
        return NameApproximation(name + u"*")
コード例 #12
0
class BandName(Particle):
    regex = Plus(Pos("DT") | Pos("POS") | Pos("NN") | Pos("NNP") | Pos("NNS"))

    def interpret(self, match):
        name = match.words.tokens.title()
        return AlbumArtist(name)
コード例 #13
0
class SongsAboutStuffWrittenByPersonQuestion(QuestionTemplate):
    """
    Ex: "List songs about love"
        "Songs about love"
    """
    regex = Question(Lemma("list")) + (Lemma("song") | Lemma("songs") | Lemma("track")) + Pos("IN") + Topic() + (
        Lemma("write") + Lemma("by") | Lemma("by") | Lemma("from")) + BandName()

    def interpret(self, match):
        _song, i, j = match.topic
        _artist, i, j = match.bandname
        rezultat = _artist + PrimaryRelease(TrackList(HasId() + _song))
        return rezultat, ReturnValue(i, j)
コード例 #14
0
ファイル: music.py プロジェクト: francoguilherme/quepy-api
class Band(Particle):
    regex = Question(Pos("DT")) + Plus(Pos("NN") | Pos("NNP"))

    def interpret(self, match):
        name = match.words.tokens.title()
        return IsBand() + HasKeyword(name)
コード例 #15
0
class TvShow(Particle):
    regex = Plus(Question(Pos("DT")) + nouns)

    def interpret(self, match):
        name = match.words.tokens
        return IsTvShow() + HasName(name)
コード例 #16
0
ファイル: movies.py プロジェクト: LayneIns/KBQA_basic_version
# You should have received a copy of license in the LICENSE file.
#
# Authors: Rafael Carrascosa <*****@*****.**>
#          Gonzalo Garcia Berrotaran <*****@*****.**>
"""
Movie related regex.
"""

from refo import Plus, Question
from quepy.dsl import HasKeyword
from quepy.parsing import Lemma, Lemmas, Pos, QuestionTemplate, Particle
from dsl import IsMovie, NameOf, IsPerson, \
    DirectedBy, LabelOf, DurationOf, HasActor, HasName, ReleaseDateOf, \
    DirectorOf, StarsIn, DefinitionOf

nouns = Plus(Pos("NN") | Pos("NNS") | Pos("NNP") | Pos("NNPS"))


class Movie(Particle):
    regex = Question(Pos("DT")) + nouns

    def interpret(self, match):
        name = match.words.tokens
        return IsMovie() + HasName(name)


class Actor(Particle):
    regex = nouns

    def interpret(self, match):
        name = match.words.tokens
コード例 #17
0
class MilitaryConflict(Particle):
    regex = Question(Pos("DT")) + Plus(nouns | Pos("IN"))

    def interpret(self, match):
        name = match.words.tokens
        return IsMilitaryConflict() + HasName(name)
コード例 #18
0
ファイル: basic.py プロジェクト: papabalda/stibd
class Thing(Particle):
    regex = Question(Pos("JJ")) + (Pos("NN") | Pos("NNP") | Pos("NNS")) |\
            Pos("VBN")

    def interpret(self, match):
        return HasKeyword(match.words.tokens)
コード例 #19
0
class Album(Particle):
    regex = Plus(Pos("NN") | Pos("NNPS") | Pos("DT") | Pos("NNP"))

    def interpret(self, match):
        name = match.words.tokens.title()
        return IsAlbum() + HasName(name)