Changes between Version 21 and Version 22 of en/ProgrammingRobotsCourse/PepperApi


Ignore:
Timestamp:
Mar 30, 2020, 11:51:12 AM (3 years ago)
Author:
xrambous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • en/ProgrammingRobotsCourse/PepperApi

    v21 v22  
    108108https://nlp.fi.muni.cz/projekty/pepper/videos/pocitani.mp4
    109109
     110See `dialog_counting` app for details.
     111Concepts for arithmetic operators and numbers are created. Not every number is defined, but rather decimal places and their combination, eg.
     112
     113{{{
     114concept:(tens) [20 30 40 50 60 70 80 90]
     115concept:(number_hundreds) ["{[1 "jedno"]} sto" "dvě stě" "[3 4] sta" "[5 6 7 8 "osum" 9] set" dvěsta dvěstě pěcet šescet devěcet]
     116concept:(number) ["~number_hundreds {~number_tens} {~digits}" "~number_tens {~digits}" ~digits]
     117}}}
     118
     119This way, robot can understand numbers up to 999. Concepts are used in the dialogue, passed into counting function and output result is said in the dialogue:
     120
     121{{{
     122u:(["kolik [je jsou]" spočítej spočti] _"~number ~operator [~number ~number2]")
     123    $num_expression=$1
     124    ^call(ALDialogCounting.compute($num_expression))
     125    c1:(_* equals nan) $1 přece nejde spočítat!
     126    c1:(_* equals _*) $1 [je "by mohlo být"] {asi} {tak} $2
     127
     128}}}
     129
     130Computing function receive recognized words as parameters and have to convert the words to numbers before producing the result. `command` parameter contains recognized sentence, eg. "dvacet dva plus třináct".
     131
     132{{{
     133m = re.match('(.*) (' + '|'.join(OPERATOR_WORDS) + ') (.*)', command)
     134if m:
     135  number1 = self.convert_number(m.group(1))
     136  operator_word = m.group(2)
     137  operator = OPERATOR_WORDS[operator_word]
     138  number2 = self.convert_number(m.group(3))
     139  try:
     140    result = str(int(eval(str(number1) + operator + str(number2)))).replace('-','minus')
     141   except:
     142     result = 'nan'
     143}}}
     144
    110145==== Display subtitles for speech recognition/generation
    111146https://nlp.fi.muni.cz/projekty/pepper/videos/titulky.mp4