Giter Club home page Giter Club logo

mathparse's Introduction

Hi there πŸ‘‹

I'm a big fan of Digital Ocean's services (like their small $5/mo servers) for hosting projects and expiriments.

If you want to try them out I have a referral link:
https://m.do.co/c/c9a695f20505

Each person referred gets $200 in credit over 60 days.

mathparse's People

Contributors

dcandrade avatar griffincx avatar gunthercox avatar manoelrui avatar petasis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mathparse's Issues

"10 plus 2 squared times 3 = 2,985,984 " ?????

As I run the chatterbot with math logic and evaluate the following sentences:

β€œ10 plus 2 squared times 3”
β€œ10 plus (2 squared) times 3”

must have the same results with 22.

However, the previous answer is 2,985,984, and the latter one is 22.

I think it happens because of mathparse, especially to_postfix() (the precedence of ^ and others)

Order of Mathwords Dictionary

I am having issues with words like seventeen being evaluated as 7teen.

With python 3.6+, would it help to list the English numbers like so:

    'numbers': {
        'eleven': 11,
        'twelve': 12,
        'thirteen': 13,
        'fourteen': 14,
        'fifteen': 15,
        'sixteen': 16,
        'seventeen': 17,
        'eighteen': 18,
        'nineteen': 19,
        'twenty': 20,
        'thirty': 30,
        'forty': 40,
        'fifty': 50,
        'sixty': 60,
        'seventy': 70,
        'eighty': 80,
        'ninety': 90,
        'zero': 0,
        'one': 1,
        'two': 2,
        'three': 3,
        'four': 4,
        'five': 5,
        'six': 6,
        'seven': 7,
        'eight': 8,
        'nine': 9,
        'ten': 10
    },

fifty thousand => 5(0 * 1000)

Running mathparse.replace_word_tokens('fifty thousand + 1', language='ENG') return 5(0 * 1000). I can look into fixing this, but it appears that it was hardcoded somewhere that the number before a scale is always one digit long.

can't caculate 'one hundred times fifty four' correctly?

The following line doesn't get the right answer.
ret = mathparse.parse('one hundred times fifty four', language='ENG')
I found that function replace_word_tokens in mathparse.parse goes wrong.Take one hundred times fifty four for example,we expect get '(1 * 100) * (50 + 4)' but get '(1 * 100) * (50 4)'.There is always a '+' missing when it comes to situations like 'twenty two','thirty three' and etc.

Add support for integration and more complex functions

Love this library, could be very useful. Mathparse could also make a good alternative to the pricey Wolfram Alpha python API because of the natural language input that translates into mathematical functions, if you were to add support for Integration, summations, solving, graphing, etc.

Add support for numeric strings without spaces

The tokenizer currently splits math tokens based on whitespace.

In Mandarin 二加二 means "'two plus two" but no spaces are used between the characters.

The tokenizer needs to be modified so that it will split these values correctly.


I believe the optimal solution might be to have the tokenizer ignore whitespace and traverse the values in the string based on the type they get recognized as. So, in this case, the first value would be read 二 and added to the stack of numbers, then the next value would be read 加 and added to the binary operator stack, and so on. No need to split on whitespace.


Previously reported as gunthercox/ChatterBot#1115

Cannot run mathparse for any non-English language

Taken from the examples in the README, if we run

mathparse.parse('50 * (85 / 100)', language='FRE')

we get the error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mathparse/mathparse.py", line 246, in parse
    string = replace_word_tokens(string, language)
  File "mathparse/mathparse.py", line 88, in replace_word_tokens
    operators.update(words['unary_operators'])
KeyError: 'unary_operators'

It appears we just need to add unary operators to every language or check if the language has unary operators before calling

operators.update(words['unary_operators'])

Handle division by zero

If an input such as '42 / 0' is received, this should be handled cleanly without an exception.
Just returning the words 'undefined' should be a good way to handle this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.