from flair.data import Sentence text = "I am working at Google in New York City." sentence = Sentence(text) spans = sentence.get_spans('ner') # extract named entities for span in spans: print(span.text, span.label) # Output: # Google ORG # New York City LOCIn this example, we create a Sentence object from a given text string. We then call the get_spans() method with a parameter `'ner'` to extract all named entities. We iterate over the list of Span objects and print the text and label associated with each span, which in this case are `'Google'` with label `'ORG'` and `'New York City'` with label `'LOC'`. The package library used here is flair.data.