USe Quepy For Religion

56 views
Skip to first unread message

mani

unread,
Aug 19, 2016, 9:52:13 PM8/19/16
to Quepy
HI,

I need to have a query about religions in each country, I wrote this code in file religion.py

from refo import Plus, Question
from quepy.dsl import HasKeyword
from quepy.parsing import Lemma, Pos, QuestionTemplate, Token, Particle
from dsl import IsCountry, TypesOfReligion

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)


class TypesOfReligionQuestion(QuestionTemplate):
"""
Ex: "list of Religions"
"""

opening = (Pos("WP") + Lemma("religion") + Token("is"))
regex = opening + Question(Pos("DT")) + Country() + Question(Pos("."))

def interpret(self, match):
religion = TypesOfReligion(match.country)
return religion, "enum"



and add this part to dsl.py :

class TypesOfReligion(FixedRelation):
relation = "dbpprop:religion"
reverse = True


but when I checked e.g .

Which religion is in Iran?
--------------------------
Query not generated :(


could anyone help me?
Thanks in advance,

Rafael Carrascosa

unread,
Aug 20, 2016, 10:00:44 AM8/20/16
to qu...@googlegroups.com
Hi Mana,

Looks like some part-of-speech tag must be causing the question template not to match.
Try running your quepy app with the '-d' command line option to see more detailed information on the tagging of your query.

Another thing you can do to troubleshoot your question template is to change a few Pos (maybe Lemma too) expressions into Token expressions to find the place where the regex is not matching.

Regards!


Rafael


--
You received this message because you are subscribed to the Google Groups "Quepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quepy+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mana

unread,
Aug 23, 2016, 8:03:40 AM8/23/16
to Quepy

Thanks Rafael .

With your explanation everything is so clear. I post the answer here, maybe help others.

Regards!

from refo import Plus, Question
from quepy.dsl import HasKeyword
from quepy.parsing import Lemma, Pos, QuestionTemplate, Token, Particle, \
Lemmas
from dsl import IsCountry, ReligionOf, LabelOf

class Country(Particle):
regex = Plus(Pos("DT") | Pos("NN") | Pos("NNS") | Pos("NNP") | Pos("NNPS")) | Pos("IN")


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


class ReligionOfQuestion(QuestionTemplate):


"""
Ex: "list of Religions"
"""
regex = (Lemma("list")) + (Lemma("religion") | Lemma("religions")) + \
Pos("IN") + Country()

def interpret(self, match):
religion = ReligionOf(match.country)
label = LabelOf(religion)
return label, "enum"


Reply all
Reply to author
Forward
0 new messages