Duboue Nlgen2 Corrected


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:

ScheduleI'd like to schedule a meeting with you
RescheduleI'll need to change my meeting for next week
CancelI can't make it next week, sorry

Subintents:

AcceptOK, that'll do
CounterWhat about on the afternoon?
RejectNo, I cannot do then
QueryWhat's available on the mornings next week?
OfferI can do Tuesday 10 AM

Example flows:

(PHP-NLGen answers are in bold)

  • TGreeting Hi, how can I help you?
  • Schedule I'd like to schedule a meeting with you
  • QWhen When do you want to schedule the meeting?
  • Query What's available on the mornings next week?
  • TAvailability Monday and Thursdays are taken. Wednesday is free after 10 AM. The rest are free.
  • Offer I can do Tuesday 10 AM
  • QConfirm Do you confirm then, meeting on Thursday the 15th (next week) at 10 AM?
  • Accept Yes, sounds great.
  • TClosing Thanks, it is set. Let me know as early as possible if you need to cancel or reschedule.

  • Cancel I can't make it next week, sorry
  • TCancelAccept Alright, the meeting is cancelled. QReschedule Do you want to reschedule?
  • Reject No, I'll contact you later about it.
  • TClosing Perfect, thanks!

  • Reschedule I'll need to change my meeting for next week
  • TOverall Next week by now is pretty packed, I have some availability on Thursday and Friday first thing in the morning. QOffer Would that work for you?
  • Counter What about on the afternoon?
  • TReject All taken. TAvailability Afternoons, we are looking into two weeks for now. TOffer What about Monday the 19th at 3 PM?
  • Counter Can it be earlier?
  • TOffer We have 2PM on Tuesday.
  • Accept I'll take that!
  • QConfirm Meeting on Tuesday the 20th (two weeks from now), 2 PM. Is that correct?
  • Accept Yes.
  • TClosingReschedule Your 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