Issue with storing a parsetree
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 20/100
Research direction
The issue names no repository files or tests. Start with the parsetree(...) call and the Text and Sentence classes, then inspect how their contents are represented and whether an existing export interface is documented. Done would require a maintainer-defined output format and corresponding verification, which the issue does not specify.
Written by the indexing model from the issue text.
Description
Hello !
Painful issue right here.
I have built a parse tree quite simply on a large volume of texts like :
s = parsetree(string, relations=True, lemmata=True)
with s being of the type : <class 'pattern.text.tree.Text'>
If I do a pprint(s) I get a very clean data structure like :
WORD TAG CHUNK ROLE ID PNP LEMMA
@MAP_Information NN NP - - - @map_information
et CC - - - - et
pendant IN PP - - PNP pendant
ce PRP NP SBJ 1 PNP ce
temps NN NP ^ SBJ 1 PNP temps
Which is want I want ! So I would like to store the exact same data structure to any file like a DataFrame, a CSV, plain text... for better readability and user-friendliness.
However this is not possible since it all the outputs belong to <class 'pattern.text.tree.Text'> or <class 'pattern.text.tree.Sentence'> etc... classes, which make them painful to use.
For example I cannot :
encode my object to utf-8 for exporting :
s = s.encode('utf8')
AttributeError: 'Text' object has no attribute 'encode'
Export my object as a text file :
with open("D:\\Testpprint4.txt", 'w') as export :
for sentence in s :
export.write(sentence)
TypeError: expected a string or other character buffer object
Put my object to a dataframe :
`pd = pandas.DataFrame(sentence)
PandasError : DataFrame constructor not properly called!`
Or use pprint.pformat to store it as a csv since it does not deal with utf-8.
Would you have a solution ?
Thanks,
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from clips/pattern
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Similar issues
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vllm-project/vllm-metal#822 ·
Maintainers usually reply within 1 day
-
vector-store
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
mem0ai/mem0#7461 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug]: chunk_span_bounds and _validated_chunk_spans reject Pydantic models ChunkSpan and AudioFileOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
BasedHardware/omi#19047 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day