Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
10f974e
add examples
karin0018 Aug 6, 2021
265a338
[examples] update formula,i2v,t2v,Tokenizer
karin0018 Aug 11, 2021
ee09181
[examples] update i2v
karin0018 Aug 11, 2021
460a852
[examples] update i2v
karin0018 Aug 11, 2021
71a77d4
[other] delete warnings
karin0018 Aug 15, 2021
f3d2fef
[examples] update formula
karin0018 Aug 15, 2021
affbf45
[examples] update Tokenizer
karin0018 Aug 15, 2021
ca6dfeb
[examples] add some detailed descriptions
karin0018 Aug 20, 2021
b6eb168
[examples] add some detailed descriptions
karin0018 Aug 20, 2021
5b08a4f
[examples] add some detailed descriptions
karin0018 Aug 20, 2021
289ed10
Merge pull request #44 from BAOOOOOM/master
BAOOOOOM Aug 21, 2021
d325d16
Merge pull request #47 from BAOOOOOM/master
BAOOOOOM Aug 22, 2021
71ed2ea
Merge branch 'bigdata-ustc:master' into master
karin0018 Aug 22, 2021
1efe364
[feat] add support to \textf{}
karin0018 Aug 22, 2021
b3dd6f5
add tests for \textf{}
karin0018 Aug 22, 2021
af1a924
Merge pull request #48 from BAOOOOOM/master
BAOOOOOM Aug 22, 2021
5f13e51
Merge pull request #49 from bigdata-ustc/docs_dev
BAOOOOOM Aug 22, 2021
641e383
Merge pull request #52 from BAOOOOOM/master
BAOOOOOM Aug 22, 2021
4603b9f
Merge pull request #53 from BAOOOOOM/master
BAOOOOOM Aug 22, 2021
ff2a8df
[fix] update some examples
karin0018 Aug 23, 2021
9382147
[fix] parser
karin0018 Aug 23, 2021
1d9c14a
[examples] add some detailed explain
karin0018 Aug 23, 2021
172c36a
[fix] table
karin0018 Aug 23, 2021
fd2c2af
Merge pull request #54 from BAOOOOOM/master
BAOOOOOM Aug 23, 2021
4e2e530
Merge pull request #1 from test2021413/dev
BAOOOOOM Aug 31, 2021
ee85070
[DOC]Update documents
BAOOOOOM Sep 1, 2021
cceb3cc
update document
BAOOOOOM Sep 1, 2021
8040c26
[DOC]Update documents
BAOOOOOM Sep 1, 2021
4344f5e
[DOC]update
BAOOOOOM Sep 1, 2021
63c4fbc
[DOC]Update documents
BAOOOOOM Sep 1, 2021
d82aaca
[DOC]Update document
BAOOOOOM Sep 1, 2021
4b5294e
[DOC]Update documents
BAOOOOOM Sep 1, 2021
35f3605
[DOC]Update document
BAOOOOOM Sep 1, 2021
508c3ee
[DOC]Update document
BAOOOOOM Sep 1, 2021
a10535a
[DOC]Update documents
BAOOOOOM Sep 1, 2021
c1a2ac6
Create i2v.py
BAOOOOOM Sep 1, 2021
1a6892d
Create t2v.py
BAOOOOOM Sep 1, 2021
5ab4854
Merge pull request #80 from test2021413/docs
BAOOOOOM Sep 1, 2021
90d2ca6
update some examples
karin0018 Sep 2, 2021
be8b833
merge docs
karin0018 Sep 3, 2021
ed4e3a1
update sif.py api
karin0018 Sep 5, 2021
259b7ca
update documents
BAOOOOOM Sep 5, 2021
d02608e
[DOC] update i2v,pretrained,sif,tokenizer,vector api documents
karin0018 Sep 5, 2021
82ca552
[DOC] update i2v,pretrained,sif,tokenizer,vector api documents 2.0
karin0018 Sep 5, 2021
3483c3a
[DOC]Update documents
BAOOOOOM Sep 5, 2021
62d34f2
fix merge conflict
karin0018 Sep 6, 2021
a7eb643
Merge pull request #84 from karin0018/docs
BAOOOOOM Sep 6, 2021
a00e15b
[DOC]Update documents
BAOOOOOM Sep 6, 2021
9e2bfff
Create sif.ipynb
BAOOOOOM Sep 6, 2021
976a912
Merge pull request #85 from test2021413/docs
BAOOOOOM Sep 6, 2021
7cdac61
Create i2v.py
BAOOOOOM Sep 6, 2021
db40230
Create i2v.py
BAOOOOOM Sep 6, 2021
afd70e7
Create i2v.py
BAOOOOOM Sep 7, 2021
05a8ef5
Create tokenize.rst
BAOOOOOM Sep 7, 2021
9c80f99
[DOC]Update documents
BAOOOOOM Sep 8, 2021
2a97a26
[DOC]Update document
BAOOOOOM Sep 8, 2021
7312972
update doc
BAOOOOOM Sep 8, 2021
20a1838
[DOC]Update documents
BAOOOOOM Sep 10, 2021
ddf3753
[DOC]Update i2v.py
BAOOOOOM Sep 10, 2021
6d24488
[DOC]Update documents
BAOOOOOM Sep 10, 2021
5093098
Update formula
BAOOOOOM Sep 10, 2021
f41f311
[DOC]Update documents
BAOOOOOM Sep 10, 2021
b7f4a81
[DOC]Update documents
BAOOOOOM Sep 10, 2021
ee5d77d
[DOC]Update documents
BAOOOOOM Sep 10, 2021
c36ca76
[DOC]update documents
BAOOOOOM Sep 10, 2021
7cdf974
[DOC]Update decoments
BAOOOOOM Sep 10, 2021
8661bd1
[DOC]fix pytest
BAOOOOOM Sep 10, 2021
7a1a659
fix pytext
BAOOOOOM Sep 10, 2021
d5aa55c
update pic
BAOOOOOM Sep 10, 2021
e32011a
fix pic
BAOOOOOM Sep 10, 2021
23a76ee
update pic width
BAOOOOOM Sep 10, 2021
263aebf
new pic
BAOOOOOM Sep 10, 2021
1ff0c80
new dic
BAOOOOOM Sep 11, 2021
08c0609
update flow chart
BAOOOOOM Sep 11, 2021
f7683f6
[DOC]Update documents
BAOOOOOM Sep 11, 2021
4299e0b
update flow chart
BAOOOOOM Sep 11, 2021
2c61156
[DOC]Update document
BAOOOOOM Sep 11, 2021
94e32b4
update flow chart
BAOOOOOM Sep 11, 2021
00b4a3a
update api
BAOOOOOM Sep 11, 2021
d3f6ae2
[DOC]Update documents
BAOOOOOM Sep 11, 2021
00129e3
update vector api
BAOOOOOM Sep 11, 2021
234ce56
[DOC]Update documents
BAOOOOOM Sep 11, 2021
289f1aa
fix pytest error
BAOOOOOM Sep 11, 2021
cf61733
delete api/index
BAOOOOOM Sep 12, 2021
ea06f03
Update doc
BAOOOOOM Sep 12, 2021
dd65658
[DOC]Update documents
BAOOOOOM Sep 12, 2021
0ffb17a
[DOC]update document
BAOOOOOM Sep 12, 2021
4a6673a
fix pytest error
BAOOOOOM Sep 12, 2021
3f1e59f
fix pytest error
BAOOOOOM Sep 12, 2021
ef008b6
[DOC]Update documents
BAOOOOOM Sep 12, 2021
edd982f
fix pytest error
BAOOOOOM Sep 12, 2021
4fc89ba
update api/sif
BAOOOOOM Sep 12, 2021
a8f9fa3
[DOC]update documents
BAOOOOOM Sep 13, 2021
7cbe63d
[DOC]Update documents
BAOOOOOM Sep 13, 2021
be85d71
[DOC]Update documents
BAOOOOOM Sep 13, 2021
40d7d93
[DOC]Update documnets
BAOOOOOM Sep 14, 2021
f48c842
[DOC]Update documents
BAOOOOOM Sep 16, 2021
2f3ed72
fix pytest error
BAOOOOOM Sep 16, 2021
98393f4
update total_vector.ipynb
BAOOOOOM Sep 18, 2021
23788ea
fix tokenize example
BAOOOOOM Sep 18, 2021
b6f491f
fix tokenize example
BAOOOOOM Sep 18, 2021
10f8196
try fix
BAOOOOOM Sep 18, 2021
2ff3185
fix tokenize example
BAOOOOOM Sep 18, 2021
025bc52
update index
BAOOOOOM Sep 18, 2021
565e718
update doc
BAOOOOOM Sep 18, 2021
b6a9117
update doc
BAOOOOOM Sep 18, 2021
77152bb
update doc
BAOOOOOM Sep 18, 2021
43f369b
update doc
BAOOOOOM Sep 18, 2021
4e7cbc7
update doc
BAOOOOOM Sep 18, 2021
7bb13cb
update doc
BAOOOOOM Sep 18, 2021
171b3f8
update doc
BAOOOOOM Sep 18, 2021
668dde7
update doc
BAOOOOOM Sep 18, 2021
f609df6
update doc
BAOOOOOM Sep 18, 2021
72788f1
update doc
BAOOOOOM Sep 18, 2021
fb9359d
update doc
BAOOOOOM Sep 18, 2021
0d80987
update doc
BAOOOOOM Sep 18, 2021
a487d58
update doc
BAOOOOOM Sep 18, 2021
d72bf5f
update doc
BAOOOOOM Sep 18, 2021
17f1b93
update doc
BAOOOOOM Sep 18, 2021
730e520
update doc
BAOOOOOM Sep 18, 2021
bbebaa1
update doc
BAOOOOOM Sep 18, 2021
41a99f7
update doc
BAOOOOOM Sep 18, 2021
7cab7d4
update doc
BAOOOOOM Sep 18, 2021
8fc156e
update doc
BAOOOOOM Sep 18, 2021
1d2b90d
update doc
BAOOOOOM Sep 18, 2021
bb9a8c3
update doc
BAOOOOOM Sep 19, 2021
6a01106
update doc
BAOOOOOM Sep 19, 2021
f786dbb
Delete examples/Tokenizer directory
BAOOOOOM Sep 20, 2021
9a5bec1
try fix bug
BAOOOOOM Sep 20, 2021
144f7b7
try fix bug
BAOOOOOM Sep 20, 2021
3f49879
update docs
BAOOOOOM Sep 20, 2021
1f583a5
update doc
BAOOOOOM Sep 20, 2021
1bb1b38
update doc
BAOOOOOM Sep 20, 2021
b86336f
update docs, now it follows the list of Attributes
BAOOOOOM Sep 22, 2021
ddccf29
update index
BAOOOOOM Sep 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 75 additions & 16 deletions EduNLP/Formula/Formula.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@

class Formula(object):
"""
The part transform a formula to the parsed abstracted syntax tree.

Parameters
----------
formula: str or List[Dict]
latex formula string or the parsed abstracted syntax tree
variable_standardization
const_mathord
init
args
kwargs

Examples
--------
>>> f = Formula("x")
Expand All @@ -29,22 +41,21 @@ class Formula(object):
<Formula: x>
>>> f.elements
[{'id': 0, 'type': 'mathord', 'text': 'x', 'role': None, 'var': 0}]
"""

Attributes
------------
ast
show all ast details
elements
just show elements' id, type, text and role
ast_graph
draw a ast graph
to_str
resetable
return bool
"""
def __init__(self, formula: (str, List[Dict]), variable_standardization=False, const_mathord=None,
init=True, *args, **kwargs):
"""

Parameters
----------
formula: str or List[Dict]
latex formula string or the parsed abstracted syntax tree
variable_standardization
const_mathord
init
args
kwargs
"""
self._formula = formula
self._ast = None
if init is True:
Expand All @@ -55,6 +66,15 @@ def __init__(self, formula: (str, List[Dict]), variable_standardization=False, c
)

def variable_standardization(self, inplace=False, const_mathord=None, variable_connect_dict=None):
"""
It makes same parmeters have the same number.

Parameters
----------
inplace
const_mathord
variable_connect_dict
"""
const_mathord = const_mathord if const_mathord is not None else CONST_MATHORD
ast_tree = self._ast if inplace else deepcopy(self._ast)
var_code = variable_connect_dict["var_code"] if variable_connect_dict is not None else {}
Expand Down Expand Up @@ -118,6 +138,26 @@ def resetable(self):

class FormulaGroup(object):
"""
The part transform a group of formula to the parsed abstracted syntax forest.

Attributes
------------
to_str
ast
show all ast details
elements
just show elements' id, type, text and role
ast_graph
draw a ast graph

Parameters
----------
formula: str or List[Dict] or List[Formula]
latex formula string or the parsed abstracted syntax tree or a group of parsed abstracted syntax tree
variable_standardization
const_mathord
detach

Examples
---------
>>> fg = FormulaGroup(["x + y", "y + x", "z + x"])
Expand All @@ -128,15 +168,16 @@ class FormulaGroup(object):
<FormulaGroup: <Formula: x + y>;<Formula: y + x>;<Formula: z + x>>
>>> fg = FormulaGroup(["x", Formula("y"), "x"])
>>> fg.elements
[{'id': 0, 'type': 'mathord', 'text': 'x', 'role': None}, {'id': 1, 'type': 'mathord', 'text': 'y', 'role': None},\
{'id': 2, 'type': 'mathord', 'text': 'x', 'role': None}]
[{'id': 0, 'type': 'mathord', 'text': 'x', 'role': None}, \
{'id': 1, 'type': 'mathord', 'text': 'y', 'role': None}, \
{'id': 2, 'type': 'mathord', 'text': 'x', 'role': None}]
>>> fg = FormulaGroup(["x", Formula("y"), "x"], variable_standardization=True)
>>> fg.elements
[{'id': 0, 'type': 'mathord', 'text': 'x', 'role': None, 'var': 0}, \
{'id': 1, 'type': 'mathord', 'text': 'y', 'role': None, 'var': 1}, \
{'id': 2, 'type': 'mathord', 'text': 'x', 'role': None, 'var': 0}]
"""

"""
def __init__(self,
formula_list: (list, List[str], List[Formula]),
variable_standardization=False,
Expand Down Expand Up @@ -186,6 +227,15 @@ def __contains__(self, item) -> bool:
return item in self._formulas

def variable_standardization(self, inplace=False, const_mathord=None, variable_connect_dict=None):
"""
It makes same parmeters have the same number.

Parameters
----------
inplace
const_mathord
variable_connect_dict
"""
ret = []
for formula in self._formulas:
ret.append(formula.variable_standardization(inplace=inplace, const_mathord=const_mathord,
Expand Down Expand Up @@ -220,6 +270,15 @@ def ast_graph(self) -> (nx.Graph, nx.DiGraph):


def link_formulas(*formula: Formula, link_vars=True, **kwargs):
"""

Parameters
----------
formula
the parsed abstracted syntax tree
link_vars
kwargs
"""
forest = []
for form in formula:
forest += form.reset_ast(
Expand Down
2 changes: 2 additions & 0 deletions EduNLP/Formula/ast/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@


def katex_parse(formula):
"""将公式传入katex进行语法解析"""
return katex.katex.__parse(formula,{'displayMode':True,'trust': True}).to_list()


def str2ast(formula: str, *args, **kwargs):
"""给字符串的接口"""
return ast(formula, is_str=True, *args, **kwargs)


Expand Down
2 changes: 1 addition & 1 deletion EduNLP/Formula/viz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# 2021/3/8 @ tongshiwei

import warnings
warnings.warn("Do not use this package")
# warnings.warn("Do not use this package")
from .tree_viz import TreePlotter, ForestPlotter
Loading