我希望能够检测一个字符串是否是数学的。
在数学上评估为真的字符串将是"2", "42000", "-10", "-55.22", "forty-two", "fifty six", "negative ninety nine", 和"negative one point seven".
而且由于它不是数字和数学的东西,所以像"negative two times seven", or "two plus two", or "3 plus two", or "two - 1", or这样复杂的东西"2 ^ 7"会通过。
基本上拼出数字,拼出所有格数(第一,十三,千)和单词"plus",,,,,,,,,,,,,,,,,,,,,,和"negative",,"positive""minus""subtracted""from""times""multiplied""by" "divided""over""point""to""the""power""of""and""raised"
如果函数与这些示例之一不同,则该函数将返回 false。
使用机器学习/NLP 来做到这一点是否合适?有没有比 NLP / 机器学习更好的方法来做到这一点?
是否有任何现有的脚本或功能可以做到这一点?
如果没有,我该如何使用NLPTools或PHP NLP 工具来做到这一点?