PHP-NLGen started as a reaction to my 2011 introduction to NLG graduate course which featured very impopular codes in Lisp.
The intention is to bring NLG ideas into the language powering some of the most popular CMS out there (such the one used in this site, Tiki).
It allows to write grammars for recursive-descent generation using PHP methods.
The project has enjoyed a warm reception by the PHP community.
Learn more about PHP-NLGen in its GitHub repo.
Scheduling grammar
Intents:
Schedule — I'd like to schedule a meeting with you
Reschedule — I'll need to change my meeting for next week
Cancel — I can't make it next week, sorry
Subintents:
Accept — OK, that'll do
Counter — What about on the afternoon?
Reject — No, I cannot do then
Query — What's available on the mornings next week?
Offer — I can do Tuesday 10 AM
Example flows:
(PHP-NLGen answers are in bold)
-
TGreetingHi, how can I help you? -
ScheduleI'd like to schedule a meeting with you -
QWhenWhen do you want to schedule the meeting? -
QueryWhat's available on the mornings next week? -
TAvailabilityMonday and Thursdays are taken. Wednesday is free after 10 AM. The rest are free. -
OfferI can do Tuesday 10 AM -
QConfirmDo you confirm then, meeting on Thursday the 15th (next week) at 10 AM? -
AcceptYes, sounds great. -
TClosingThanks, it is set. Let me know as early as possible if you need to cancel or reschedule.
-
CancelI can't make it next week, sorry -
TCancelAcceptAlright, the meeting is cancelled.QRescheduleDo you want to reschedule? -
RejectNo, I'll contact you later about it. -
TClosingPerfect, thanks!
-
RescheduleI'll need to change my meeting for next week -
TOverallNext week by now is pretty packed, I have some availability on Thursday and Friday first thing in the morning.QOfferWould that work for you? -
CounterWhat about on the afternoon? -
TRejectAll taken.TAvailabilityAfternoons, we are looking into two weeks for now.TOfferWhat about Monday the 19th at 3 PM? -
CounterCan it be earlier? -
TOfferWe have 2PM on Tuesday. -
AcceptI'll take that! -
QConfirmMeeting on Tuesday the 20th (two weeks from now), 2 PM. Is that correct? -
AcceptYes. -
TClosingRescheduleYour meeting is rescheduled. Let me know as early as possible if you need to cancel or reschedule it again.
Availability Grammar
Input:
- busy-list (triples <dow, start time, end time>
- ranges: map dow=> tuple start-time (earliest time for scheduling), end-time (latest time for scheduling ending time). Any dow missing is assumed not scheduled
- natural language: iso two letter code, defaults to EN
Types:
- dow: day of week, int. 0=Monday, 4=Friday
- times: tuple of integers hour, minute