def title_block(wInfo, lang): issueDate = wInfo.get_issue_date() noSecond = {"second": False} if lang == "en": s1 = S( NP(N("forecast").n("p")), VP( V("issue").t("pp"), PP( P("by"), Q("jsRealB"), DT(issueDate).dOpt(noSecond), P("for"), CP( C("and"), N("today"), DT(issueDate + datetime.timedelta(days=1)).dOpt( {"rtime": issueDate}))))) s2 = S( NP(D("the"), D("next"), V("schedule").t("pp"), N("forecast").n("p")), VP( V("be").t("f"), V("issue").t("pp"), DT(wInfo.get_next_issue_date()).dOpt(noSecond))) else: s1 = S( NP(N("prévision").n("p")), VP( V("émettre").t("pp"), PP( P("par"), Q("jsRealB"), DT(issueDate).dOpt(noSecond), P("pour"), CP( C("et"), Adv("aujourd'hui"), DT(issueDate + datetime.timedelta(days=1)).dOpt( {"rtime": issueDate}))))) s2 = S( NP(D("le"), A("prochain").pos("pre"), N("prévision").n("p")), VP( V("être").t("f"), V("émettre").t("pp"), DT(wInfo.get_next_issue_date()).dOpt(noSecond))) return "\n".join([realize(s1, lang, False), realize(s2, lang, False)])
def locationRole(semR, env, opts): traceSyntR("locationRole", semR) concept = semR.get_concept() roles = semR.roles if concept == "amr-unknown": opts.add("typ", {"int": "whe"}) elif concept == "between" and ":op1" in roles and ":op2" in roles: env.push( CP(C("and"), PP(P("between"), makeSyntR(roles[":op1"])), makeSyntR(roles[":op2"]))) del roles[":op1"] del roles[":op2"] else: if isPreposition(concept) or isAdverb(concept): env.push(makeSyntR(semR)) else: env.push(PP(P("in"), makeSyntR(semR)))
def op16(conj): return LexSem(conj,"C",[":op1",":op2",":op3",":op4",":op5",":op6"], lambda op1,op2,op3,op4,op5,op6:CP(C(conj),op1,op2,op3,op4,op5,op6))
isTomorrow=hour>23 hour=hour%24 for (s,e,jsrExp) in dayPeriods: if hour in range(s,e): exp=jsrExp[lang]() if isTomorrow: return exp.add(N("tomorrow" if lang=="en" else "demain"),0) elif s!=18: return exp.add(D("this" if lang=="en" else "ce"),0) dayOnly={"day":True,"year": False, "month": False, "date": False,"hour":False,"minute":False, "second": False,"det":False} periodNames = { "today":{"en":lambda _:N("today"), "fr":lambda _:Adv("aujourd'hui")}, "tonight":{"en":lambda _:N("tonight"), "fr":lambda _:CP(C("et"),NP(D("ce"),N("soir")),NP(D("ce"),N("nuit")))}, "tomorrow":{"en":lambda d:DT(d).dOpt(dayOnly), "fr":lambda d:DT(d).dOpt(dayOnly)}, "tomorrow_night":{"en":lambda d:NP(DT(d).dOpt(dayOnly),N("night")), "fr":lambda d:CP(C("et"),NP(DT(d).dOpt(dayOnly),N("soir")),NP(N("nuit")))} } ### time generation def jsrHour(h,lang): if h in range(0,6): return PP(P("during"),NP(D("the"),N("night"))) if lang=="en" else \ PP(P("durant"),NP(D("le"),N("nuit"))) if h in range(6,11): return PP(P("in"),NP(D("the"),N("morning"))) if lang=="en" else \ NP(D("le"),N("matin"))
def pcpn(type,action,tense,moment,quantity=None,unit=None): return S(type, VP(V(action).t(tense), CP(PP(P("in"),NP(D("the"),N(moment))), None if quantity==None else NP(N("amount"),NP(NO(quantity),unit)))))
from jsRealBclass import N,A,Adv,V,D,P,C,DT,NO,Q, NP,AP,AdvP,VP,S,PP,CP from Realization.common import realize, jsrDayPeriod sky_condition_terminology = { ## types of sky conditions "c1":{"en":(AP(A("sunny")),AP(A("clear"))), "fr":(AP(A("ensoleillé")),AP(A("dégagé")))}, "c2":{"en":(AP(Adv("mainly"),A("sunny")),NP(Q("a"),D("few"),N("cloud").n("p"))), "fr":(AP(Adv("généralement"),A("ensoleillé")),NP(D("quelque"),N("nuage").n("p")))}, "c3":{"en":(NP(D("a"),N("mix"),PP(P("of"),CP(C("and"),N("sun"),N("cloud").n("p")))), AP(Adv("partly"),A("cloudy"))), "fr":(NP(N("alternance"),CP(C("et"),PP(P("de"),N("soleil")),PP(P("de"),N("nuage").n("p")))), AP(Adv("partiellement"),A("couvert")))}, "c4":{"en":(AP(Adv("mainly"),A("cloudy")),), "fr":(AP(Adv("généralement"),A("nuageux")),)}, "c5":{"en":(AP(A("cloudy")),), "fr":(AP(A("nuageux")),)}, "c6":{"en":(AP(A("overcast")),), "fr":(AP(A("couvert")),)}, "c7":{"en":(NP(V("increase").t("pr"),N("cloudiness")),), "fr":(NP(N("ennuagement")),)}, "c8":{"en":(NP(N("clearing")),), "fr":(NP(N("dégagement")),)}, } def sky_condition(mc,period,lang): previous_conditions=[] jsrExprs=[] def addNoRepeat(c,dn,period=None): # avoid generating same sentence twice if c not in previous_conditions: if len(sky_condition_terminology[c][lang])==1:dn=0