Skip to content

Commit

Permalink
update differentiator
Browse files Browse the repository at this point in the history
  • Loading branch information
raju2592 committed Oct 8, 2020
1 parent 021fa54 commit bb8d93b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/differentiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def get_story(derivative):
+ rule_application.to_asciimath()
)
)

answer = add_quote(derivative_expression.to_asciimath() + " = " + derivative.result.to_asciimath()) + "."

if derivative.child_derivatives is not None:
child_derivatives = derivative.child_derivatives
if (len(child_derivatives) == 2
Expand All @@ -54,18 +57,17 @@ def get_story(derivative):
if len(derivative.applied_rules) == 2:
ending_texts = [
"So, by the rules, " + add_quote(derivative.applied_rules[0]) + ","
"and" + add_quote(derivative.applied_rules[1]) + ","
+ " and " + add_quote(derivative.applied_rules[1]) + ","
]
else:
ending_texts = [
"So, by the rules, " + add_quote(derivative.applied_rules[0]) + ","
"So, by the rule, " + add_quote(derivative.applied_rules[0]) + ","
]
ending_texts.append(
add_quote(derivative_expression.to_asciimath() + " = " + derivative.result.to_asciimath()) + "."
)

ending_texts.append(answer)
story.extend(ending_texts)

return Result(True, derivative.result.to_asciimath(), story)
return Result(True, answer, story)

def differentiate(str):
tokenizationResult = tokenize(str)
Expand Down

0 comments on commit bb8d93b

Please sign in to comment.