当前位置: 动力学知识库 > 问答 > 编程问答 >

artificial intelligence - Calling functions from plain text descriptions

问题描述:

I have an app which has common maths functions behind the scenes:

  • add(x, y)
  • multiply(x, y)
  • square(x)

The interface is a simple google- style text field. I want the user to be able to enter a plain text description -

  • '2*3'
  • '2 times 3'
  • 'multiply 2 and 3'
  • 'take the product of 2 and 3'

and get a answer mathematical answer

Question is, how should I map the text descriptions to the functions ? I'm guessing I need to

  • tokenise the text
  • identify key tokens (function names, arguments)
  • try and map token combinations to function signatures

However I'm guessing this is already a 'solved problem' in the machine learning space. Should I be using Natural Language Processing ? Plain text search ? Something else ?

All ideas gratefully received, plus implementation suggestions [I'm using Python/AppEngine; I know about NLTK and Whoosh]

[PS I understand Google does this already, at least for the first two queries on the list. I'm guessing they also go it statistically, having a very large amount of search data. I don't have a large amount of data available, so will need an alternative approach].

网友答案:

After you tokenise the text, you need parsing to get a syntax tree of your natural language phrase. Once you have this, you can map the parse tree to a mathematical expression, and then evaluate the expression. I do not think this is a solved problem. I would start with several templates, say the first two, and experiment. The larger the domain of possible descriptions, the harder the task is.

网友答案:

I would recommend some tool for provide grammar/patterns on text like SimpleParse for python http://www.ibm.com/developerworks/linux/library/l-simple.html. As java programmer I would prefer GATE or graph-expression.

分享给朋友:
您可能感兴趣的文章:
随机阅读: