Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Issue with storing a parsetree

Aperta
#150 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
20/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python
Ambito
data

Direzione di ricerca

L’issue non indica file del repository né test. Inizia dalla chiamata parsetree(...) e dalle classi Text e Sentence, quindi verifica come sono rappresentati i loro contenuti e se è documentata un’interfaccia di esportazione esistente. Per considerarlo completato servirebbero un formato di output definito da un maintainer e una verifica corrispondente, che l’issue non specifica.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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,

Lingua principale
Python
Stelle
8.9k
Fork
1.6k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di clips/pattern

Tutte le issue di clips/pattern

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.