Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'str' object has no attribute 'is_context_set' #2314

Closed
yananchen1989 opened this issue Jun 24, 2021 · 2 comments
Closed

AttributeError: 'str' object has no attribute 'is_context_set' #2314

yananchen1989 opened this issue Jun 24, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@yananchen1989
Copy link

content = "The video will start in 8 Cancel\nClick to play Tap to play\nGet daily updates directly to your inbox + Subscribe Thank you for subscribing! Could not subscribe, try again later Invalid Email\nSeveral schools will remain closed on Tuesday as a weather warning for ice continues into the morning.\nMore than 200 schools in North Wales were closed today after snow and ice caused chaos over the weekend.\nThe vast majority are expected to re-open but some closures are still expected.\nThis story will be updated as more information becomes available.\nTemperatures are not expected to be above 0C until midday.\n(Image: Robert Parry-Jones)\nAs of 7.55pm, the schools which will be closed on Tuesday in Wrexham are:\nSt Christopher's School, Wrexham, Ysgol y Waun, Chirk, Froncysyllte CP and Garth CP. All the others are expected to re-open although this information is subject to change.\nIn Denbighshire, Denbigh High School will be open tomorrow but Ysgol Plas Brondyffryn, Ysgol Carreg Emlyn and Ysgol Dinas Bran will be shut.\nYsgol Tir Morfa will be open but transport from Denbigh and further south will not operate.\nFor full details on school transport in Denbighshire click here.\nFlintshire Council currently say there are no planned closures tomorrow although that could change.\nColeg Cambria will be shut entirely on Tuesday.\nGlyndwr University will be open and lectures are expected to take place."

from flair.data import Sentence # ver: 0.8
from flair.models import SequenceTagger
tagger = SequenceTagger.load("ner-large")
tagger.predict(content)

error:

/usr/local/lib/python3.6/dist-packages/flair/models/sequence_tagger_model.py in predict(self, sentences, mini_batch_size, all_tag_prob, verbose, label_name, return_loss, embedding_storage_mode)
335 previous_sentence = None
336 for sentence in sentences:
--> 337 if sentence.is_context_set(): continue
338 sentence._previous_sentence = previous_sentence
339 sentence._next_sentence = None

AttributeError: 'str' object has no attribute 'is_context_set'

@yananchen1989 yananchen1989 added the bug Something isn't working label Jun 24, 2021
@Wapiti08
Copy link

I had the exactly same bug. Have you solved this problem?

@helpmefindaname
Copy link
Collaborator

It is simply not possible to pass a string instead of a sentence.

following this tutorial should help for clarification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants