mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Merge pull request #883 from ericzhao28/master
Add `lower_` and `upper_` properties to `Span` class
This commit is contained in:
commit
28bb546939
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -105,3 +105,7 @@ website/package.json
|
||||||
website/announcement.jade
|
website/announcement.jade
|
||||||
website/www/
|
website/www/
|
||||||
website/.gitignore
|
website/.gitignore
|
||||||
|
|
||||||
|
# Python virtualenv
|
||||||
|
venv
|
||||||
|
venv/*
|
||||||
|
|
|
@ -31,6 +31,12 @@ def test_spans_root(doc):
|
||||||
assert span.root.text == 'sentence'
|
assert span.root.text == 'sentence'
|
||||||
assert span.root.head.text == 'is'
|
assert span.root.head.text == 'is'
|
||||||
|
|
||||||
|
def test_spans_string_fn(doc):
|
||||||
|
span = doc[0:4]
|
||||||
|
assert len(span) == 4
|
||||||
|
assert span.text == 'This is a sentence'
|
||||||
|
assert span.upper_ == 'THIS IS A SENTENCE'
|
||||||
|
assert span.lower_ == 'this is a sentence'
|
||||||
|
|
||||||
def test_spans_root2(en_tokenizer):
|
def test_spans_root2(en_tokenizer):
|
||||||
text = "through North and South Carolina"
|
text = "through North and South Carolina"
|
||||||
|
|
|
@ -365,6 +365,14 @@ cdef class Span:
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
return ' '.join([t.lemma_ for t in self]).strip()
|
return ' '.join([t.lemma_ for t in self]).strip()
|
||||||
|
|
||||||
|
property upper_:
|
||||||
|
def __get__(self):
|
||||||
|
return ''.join([t.string.upper() for t in self]).strip()
|
||||||
|
|
||||||
|
property lower_:
|
||||||
|
def __get__(self):
|
||||||
|
return ''.join([t.string.lower() for t in self]).strip()
|
||||||
|
|
||||||
property string:
|
property string:
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
return ''.join([t.string for t in self])
|
return ''.join([t.string for t in self])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user