Skip to content

Commit b84ffab

Browse files
committed
[example] update
1 parent ec22eb0 commit b84ffab

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

examples/formula/formula.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
# coding: utf-8
22
# 2021/3/8 @ tongshiwei
3+
#
4+
from EduNLP.Formula import Formula, FormulaGroup, link_formulas
5+
#
6+
# f1 = Formula(r"x + y", variable_standardization=True)
7+
# f2 = Formula(r"y + x", variable_standardization=True)
8+
# f3 = Formula(r"z + y", variable_standardization=True)
9+
#
10+
# print(f1.element)
11+
# print(f2.element)
12+
# print(f3.element)
13+
#
14+
# print("-----------------------")
15+
#
16+
# link_formulas(f1, f2, f3)
17+
#
18+
# print("------------------------")
19+
#
20+
# print(f1.element)
21+
# print(f2.element)
22+
# print(f3.element)
23+
#
24+
# print("---------------------")
25+
#
26+
# fg = FormulaGroup(
27+
# [r"x + y", r"y + x", r"y + z"]
28+
# )
29+
# for f in fg:
30+
# print(f.element)
331

4-
import matplotlib.pyplot as plt
5-
from EduNLP.Formula import Formula
6-
from EduNLP.Formula.viz import ForestPlotter
32+
# fg = FormulaGroup(["x", "y", "x"])
33+
# print(fg.elements)
734

8-
f = Formula(r"\frac{\sqrt{x^2}}{\pi} + 1 = y", variable_standardization=True)
9-
10-
ForestPlotter().export(
11-
f.ast, root_list=[node["val"]["id"] for node in f.element if node["structure"]["father"] is None],
12-
)
13-
plt.show()
35+
fg = FormulaGroup(["x", Formula("y"), "x"])
36+
print(fg.elements)

0 commit comments

Comments
 (0)