AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Sample Spanish Chatscript: ¿qué hora es?
 
 

Here is my attempt at a Spanish topic for the question:  ¿qué hora es? (What time is it?)

When I started I did not know about the ^timeinfofromseconds function but there it was in the system function manual.  I tried to add a ¿ to the systemessentials.txt but it did not work so for now the following works if you just use the ending question mark. 

If it does not work then check to see if you saved your text file as UTF-8.  You can place it in a file named hora.top in /RAWDATA/HARRY folder or in your chatbot folder.  I am learning Spanish as I create these chatbot samples so please feel free to point out corrections. 

In Spanish the minutes are stated in terms of “minus minutes” from the next hour if the minutes are greater than 30 minutes.  The following could be expanded to answer questions like “What day is it?” “What day of the week is it?” and “What month is it?”


concept: ~números_de_tiempo ( cero uno dos tres cuatro cinco seis siete ocho nueve diez once doce trece catorce cuarto dieciséis diecisiete dieciocho diecinueve veinte ventiuno ventidos veintitrés veinticuatro veinticinco veintiséis veintisiete veintiocho veintinueve media)

topic: ~hora ( hora )

?: ( me puede decir la hora {por favor} ) ^keep() ^repeat() ^reuse(QUE_HORA_ES)

?: QUE_HORA_ES ( qué hora es ) ^keep() ^repeat()
_1 = ^timeinfofromseconds(%fulltime)
$$segundos = _1
$$minutos = _2
$$hora = _3
$$día_del_mes = _4
$$nombre_del_mes = _5
$$año = _6
$$nombre_del_día_de_la_semana = _7

if ( $$hora > 12 ) {$$hora = $$hora - 12}
if ( $$hora = 1 ) { $$respuesta = ^join( AUTOSPACE Es la ) }
  else { $$respuesta = ^join( AUTOSPACE Son las ) }
if ( $$minutos > 30 ) {
$$siguiente_hora = $$hora + 1
$$nombre_de_horas = ^nth( ~números_de_tiempo $$siguiente_hora )
$$menos_minutos = 60 - $$minutos
$$nombre_del_minuto = ^nth( ~números_de_tiempo $$menos_minutos )
$$respuesta = ^join( AUTOSPACE $$respuesta $$nombre_de_horas menos $$nombre_del_minuto )
}
  else
  {
$$nombre_de_horas = ^nth( ~números_de_tiempo $$hora )
$$nombre_del_minuto = ^nth( ~números_de_tiempo $$minutos )
$$respuesta = ^join( AUTOSPACE $$respuesta $$nombre_de_horas y $$nombre_del_minuto )
}
^join($$respuesta .)


Sample Output:
(at 9:17pm)
  >me puede decir la hora, por favor?
Son las nueve y veintiséis.

(at 9:34pm)
  >qué hora es?
Son las diez menos veintiséis.

 

 

 
  [ # 1 ]

For a topic which answers questions about time, I expect you will have no gambits, no conversation about it. It merely answers questions. You might as well mark the topic as system repeat and then not bother marking specific rules.

Also, while you don’t need to move the match variable data onto temporary user variables, it does make code clearer.
The EQUIVALENT of that is to use rename:  to add appropriate alternate names to the match variables so then there is no incentive to move them to temps.

if ( $$hora > 12 ) {$$hora = $$hora - 12}
is more tersely expressed as
if ( $$hora > 12 ) {$$hora -= 12}

 

 
  login or register to react