EgorBu / mathematics_dataset

This dataset code generates mathematical question and answer pairs, from a range of question types at roughly school-level difficulty.
Apache License 2.0
0 stars 0 forks source link

Problems with sign symbols #4

Open EgorBu opened 1 month ago

EgorBu commented 1 month ago

Main problem looks like this: 5 + - 3 Examples:

extrapolate/arithmetic__mixed_longer
 (2 + -8)/90*((-18400)/350 + 52)*(-14)/(-4) - 16970/150  -113
 Чему равно (-374 - -1)/((-181 + 161 +
  (-1089)/(-54))*(18/(-150)*-10)/(-1*(-3)/15))?  -373

extrapolate/arithmetic__add_sub_multiple_longer
 Чему равно -2 + 1 - (3 - 15 - (-4 - -3)) - (-68 + (-69 - (368 + 49 + -120)))?
  444

extrapolate/arithmetic__add_or_sub_big
 Вычислите -0.5 + -5442473341375804.  -5442473341375804.5

interpolate/arithmetic__simplify_surd
 Упростите ((sqrt(220) + -3*sqrt(220))/sqrt(4) -
  1*sqrt(55)*-3)/(sqrt(240)/(-2*(sqrt(192) + sqrt(12)))).  -5*sqrt(11)
EgorBu commented 1 month ago

After examination I think I found the problematic function that doesn't wrap variable in brackets when needed:

def bracketed(child, parent, bracket_if_same_precedence):
    """Returns string representation of `child`, possibly bracketed.

    Args:
      child: Instance of `Op` or a valid value for `ConstantOp`.
      parent: Instance of `Op`. Used to determine whether `child` needs to be
          bracketed first before appearing in the parent op's expression.
      bracket_if_same_precedence: Whether to bracket if the child has the same
          operator precedence as the parent.

    Returns:
      String representation of `child`.
    """
EgorBu commented 1 month ago
extrapolate/arithmetic__mixed_longer
17/((-1360)/25540) + (258/(-688))/(7/((-210)/9)) - -1*7
<class 'mathematics_dataset.sample.ops.Sub'>
 17/((-1360)/25540) + (258/(-688))/(7/((-210)/9)) - -1*7  -311
((137760/175)/(-12) - -24 - (12/9)/(1/(-1 + 4))) + 5 + 189/(-35)
<class 'mathematics_dataset.sample.ops.Add'>
 ((137760/175)/(-12) - -24 - (12/9)/(1/(-1 + 4))) + 5 + 189/(-35)  -46
(9/(324/(-66)) + -3*4/(-12))/(3553/(-17490) - ((-18)/(-10))/(-9))
<class 'mathematics_dataset.sample.ops.Div'>
extrapolate/arithmetic__add_sub_multiple_longer
4 + -39 - (-10 - (5 + -18) - (-6 - (9 - 16) - (-1 - -6))) - -6
<class 'mathematics_dataset.sample.ops.Sub'>
interpolate/numbers__round_number_composed
 Пусть f = 2 + -128.02. Округли f до десятков.  -130
 Пусть j = -0.18788 + 102.07788. Пусть y = -101 + j. Округли y до ближайшего
  целого.  1
 Пусть y = -11.467 + 0.167. Пусть s = y - -11.300167. Округли s до 5 десятичных
  знаков.  0.00017