Results are printed rather than returned

#1
by ingerid - opened

Hi,

I've used the model as demonstrated with a list of texts, and wonder if it's possible to change the model.tag() method to return the results rather than just print them?

from transformers import AutoModel

humit_tagger = AutoModel.from_pretrained(
    "Humit-Oslo/humit-tagger-xs", trust_remote_code=True
)

postagged = humit_tagger.tag(df.text.tolist())
# printed output: 
# {"lang": "bm", "sent": [{"w": "Det", "t": ["pron", "3", "ent", "n\u00f8yt", "pers"], "l": "det"}, {"w": "var", "t": ["verb", "pret"], "l": "v\u00e6re"}, {"w": "umulig", "t": ["adj", "ent", "n\u00f8yt", "pos", "ub"], "l": "umulig"}, {"w": "\u00e5", "t": ["inf-merke"], "l": "\u00e5"}, {"w": "fortsette", "t": ["verb", "inf"], "l": "fortsette"}, {"w": ".", "t": ["<punkt>"], "l": "."}]}
# ... 

print(type(postagged))
# output: <class 'NoneType'>
Humit - Center for digital development at the University of Oslo org
edited 9 days ago

It must be possible through the write_output_to="list" parameter to the tag() function. Can you check if this works for you?

That worked, thanks!

ingerid changed discussion status to closed

Sign up or log in to comment