EduNLP.utils¶
- EduNLP.utils.dict2str4sif(obj: dict, key_as_tag=True, tag_mode='delimiter', add_list_no_tag=True, keys=None) str[source]¶
- Parameters
obj –
key_as_tag –
tag_mode – delimiter: add $SIFTag{key_begin}$ in the head and add $SIFTag{key_end}$ at the end head: add $SIFTag{key}$ in the head tail: add $SIFTag{key}$ at the end
add_list_no_tag –
keys –
Examples
>>> item = { ... "stem": r"若复数$z=1+2 i+i^{3}$,则$|z|=$", ... "options": ['0', '1', r'$\sqrt{2}$', '2'], ... } >>> item {'stem': '若复数$z=1+2 i+i^{3}$,则$|z|=$', 'options': ['0', '1', '$\\sqrt{2}$', '2']} >>> dict2str4sif(item) '$\\SIFTag{stem_begin}$...$\\SIFTag{stem_end}$$\\SIFTag{options_begin}$...$\\SIFTag{options_end}$' >>> dict2str4sif(item, add_list_no_tag=True) '...$\\SIFTag{options_begin}$$\\SIFTag{list_0}$0$\\SIFTag{list_1}$1...$\\SIFTag{options_end}$' >>> dict2str4sif(item, tag_mode="head") '$\\SIFTag{stem}$...$\\SIFTag{options}$...' >>> dict2str4sif(item, tag_mode="tail") '若复数$z=1+2 i+i^{3}$,则$|z|=$$\\SIFTag{stem}$...2$\\SIFTag{options}$' >>> dict2str4sif(item, add_list_no_tag=False) '...$\\SIFTag{options_begin}$0$\\SIFSep$1$\\SIFSep$...$\\SIFTag{options_end}$' >>> dict2str4sif(item, key_as_tag=False) '若复数$z=1+2 i+i^{3}$,则$|z|=$0$\\SIFSep$1$\\SIFSep$$\\sqrt{2}$$\\SIFSep$2'