Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MONAPipe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MONA
MONAPipe
Commits
94f30892
Commit
94f30892
authored
2 years ago
by
Your Name
Browse files
Options
Downloads
Patches
Plain Diff
Update SpeechTagger
parent
f11e5e5f
No related branches found
Branches containing commit
Tags
v1.1
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pipeline/components/speech_tagger.py
+20
-8
20 additions, 8 deletions
pipeline/components/speech_tagger.py
with
20 additions
and
8 deletions
pipeline/components/speech_tagger.py
+
20
−
8
View file @
94f30892
...
...
@@ -6,7 +6,7 @@ from ..global_wordlists import Q_MARKS_C, Q_MARKS_O
from
..utils_methods
import
add_extension
def
flair_speech_tagger
(
doc
,
sentence_level
=
Tru
e
):
def
flair_speech_tagger
(
doc
,
sentence_level
=
Fals
e
):
"""
Spacy pipeline component.
Tags tokens and clauses with speech tags.
Wrapper for the
"
Redewiedergabe
"
taggers from https://github.com/redewiedergabe/tagger.
...
...
@@ -14,7 +14,7 @@ def flair_speech_tagger(doc, sentence_level=True):
Args:
doc (`Doc`): A spacy document object.
sentence_level (boolean): If True, the taggers take each sentence separately as input;
if False, the taggers take
the whole document at once
as input.
if False, the taggers take
chunks of up to 100 tokens
as input.
Returns:
`Doc`: A spacy document object.
...
...
@@ -33,12 +33,24 @@ def flair_speech_tagger(doc, sentence_level=True):
add_speech_tags_to_tokens
(
sent
,
text
,
SPEECH_TAGGERS
.
_
,
"
direct
"
)
add_speech_tags_to_tokens
(
sent
,
text
,
SPEECH_TAGGERS
.
_
,
"
reported
"
)
else
:
text
=
"
"
.
join
([
token
.
text
for
token
in
doc
if
not
token
.
is_space
])
text
=
Sentence
(
text
,
use_tokenizer
=
False
)
add_speech_tags_to_tokens
(
doc
,
text
,
SPEECH_TAGGERS
.
_
,
"
indirect
"
)
add_speech_tags_to_tokens
(
doc
,
text
,
SPEECH_TAGGERS
.
_
,
"
free_indirect
"
)
add_speech_tags_to_tokens
(
doc
,
text
,
SPEECH_TAGGERS
.
_
,
"
direct
"
)
add_speech_tags_to_tokens
(
doc
,
text
,
SPEECH_TAGGERS
.
_
,
"
reported
"
)
chunks
=
[]
chunk
=
[]
for
sent
in
doc
.
sents
:
tokens
=
list
(
sent
)
if
len
(
chunk
)
+
len
(
tokens
)
<=
100
or
len
(
chunk
)
==
0
:
chunk
.
extend
(
tokens
)
else
:
chunks
.
append
(
chunk
)
chunk
=
tokens
if
len
(
chunk
)
>
0
:
chunks
.
append
(
chunk
)
for
chunk
in
chunks
:
text
=
"
"
.
join
([
token
.
text
for
token
in
chunk
if
not
token
.
is_space
])
text
=
Sentence
(
text
,
use_tokenizer
=
False
)
add_speech_tags_to_tokens
(
chunk
,
text
,
SPEECH_TAGGERS
.
_
,
"
indirect
"
)
add_speech_tags_to_tokens
(
chunk
,
text
,
SPEECH_TAGGERS
.
_
,
"
free_indirect
"
)
add_speech_tags_to_tokens
(
chunk
,
text
,
SPEECH_TAGGERS
.
_
,
"
direct
"
)
add_speech_tags_to_tokens
(
chunk
,
text
,
SPEECH_TAGGERS
.
_
,
"
reported
"
)
assign_speech_tags_to_clauses
(
doc
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment