brando90 / MathNet-large-scale-Mathematics-Dataset-for-Machine-Learning

1 stars 0 forks source link

Considering new potential syntax for making questions #11

Open brando90 opened 7 years ago

brando90 commented 7 years ago

Consider this example

def example5():
    x,y,a,b, X = symbols('x y a b X')
    e,f,g,h = symbols('e f g h')
    ## solve x,  a = b,  x = 2*b, a = 8, can you do it?
    #first possible syntax using + for seqg
    question = solve + x +  Eq(a,b)/Eq(x,2*b)/Eq(a,8) + 'can you do it?'
    #second possible syntax for using >
    question = solve > x >  Eq(a,b)/Eq(x,2*b)/Eq(a,8) >'can you do it?'
    #third possible syntax using + for seqg
    question = solve + x +  perg( Eq(a,b),Eq(x,2*b),Eq(a,8)) + 'can you do it?'

first Syntax just probably requires overriding the + for python or implementing our own addition for seqg class.

second might require bigger hacking of python...not sure how to do it (we want to avoid parsers, at least at the moment).

One comment for either implementation. The having multiple additions means the tree might have more levels than neccessary, so if we have . A+B+C+perg(D,E,F)+G we would want all the additions at the same level of the tree when visualizing in the call graph (http://pycallgraph.slowchop.com/en/master/) mention in https://github.com/brando90/eit_proj1/issues/10

brando90 commented 7 years ago

seems the realistic thing to aim for is:

question = solve + x +  perg( Eq(a,b),Eq(x,2*b),Eq(a,8)) + 'can you do it?'

by overriding some type of __add__ or __addition__(whatever the name is)

brando90 commented 7 years ago

the goal is that previous question should not break!

just sort of as an alternative syntactic sugar for people (easier/more intuitive to code)

hairuoguo commented 7 years ago

Implemented Q() and A() subclasses of DelayedExecution and '+' operator overload. New option for syntax:

question = Q() + 'solve' + x + perg( Eq(a,b),Eq(x,2*b),Eq(a,8)) + 'can you do it?'

or

question = Q() question += 'solve' + x + perg( Eq(a,b),Eq(x,2*b),Eq(a,8)) + 'can you do it?'

Possible next step: | or / for perg

brando90 commented 7 years ago

is this still relevant?