Skip to content

Commit

Permalink
[example] update
Browse files Browse the repository at this point in the history
  • Loading branch information
tswsxk committed May 22, 2021
1 parent ec22eb0 commit b84ffab
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions examples/formula/formula.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
# coding: utf-8
# 2021/3/8 @ tongshiwei
#
from EduNLP.Formula import Formula, FormulaGroup, link_formulas
#
# f1 = Formula(r"x + y", variable_standardization=True)
# f2 = Formula(r"y + x", variable_standardization=True)
# f3 = Formula(r"z + y", variable_standardization=True)
#
# print(f1.element)
# print(f2.element)
# print(f3.element)
#
# print("-----------------------")
#
# link_formulas(f1, f2, f3)
#
# print("------------------------")
#
# print(f1.element)
# print(f2.element)
# print(f3.element)
#
# print("---------------------")
#
# fg = FormulaGroup(
# [r"x + y", r"y + x", r"y + z"]
# )
# for f in fg:
# print(f.element)

import matplotlib.pyplot as plt
from EduNLP.Formula import Formula
from EduNLP.Formula.viz import ForestPlotter
# fg = FormulaGroup(["x", "y", "x"])
# print(fg.elements)

f = Formula(r"\frac{\sqrt{x^2}}{\pi} + 1 = y", variable_standardization=True)

ForestPlotter().export(
f.ast, root_list=[node["val"]["id"] for node in f.element if node["structure"]["father"] is None],
)
plt.show()
fg = FormulaGroup(["x", Formula("y"), "x"])
print(fg.elements)

0 comments on commit b84ffab

Please sign in to comment.