Can't create char_span if length of char 1 #10946
Replies: 5 comments
-
Hi @Artem-Haholkin-deepsee, please provide a complete, minimal example so we can reproduce your issue. |
Beta Was this translation helpful? Give feedback.
-
@rmitsch |
Beta Was this translation helpful? Give feedback.
-
By default, import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("This is a sentence.")
print(doc.char_span(0, 4)) # "This"
print(doc.char_span(0, 3)) # None
print(doc.char_span(0, 3, alignment_mode="contract")) # None
print(doc.char_span(0, 3, alignment_mode="expand")) # "This"
print(doc.text[0:3]) # "Thi" Note that even other alignment modes considers |
Beta Was this translation helpful? Give feedback.
-
As I understood there is no way to get span from one char inside one token |
Beta Was this translation helpful? Give feedback.
-
You could also build a [Edit] Moving this to discussions 🙂 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When I'm creating Span from a doc I want to create a span of length 1. But it returns None instead of span
As I understand something wrong with tokens/chars
When I do
doc[start:end]
it throws an error not enough tokens to unpack. But I expect it won't be tokens but charsAccording to documentation getting one item gives a tokens. But i think it should work another way for char_span
Environment
OS: MacOS Monterey 12.4
Python: Anaconda 3.8.12
Spacy: 3.0.6
Beta Was this translation helpful? Give feedback.
All reactions