Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nltk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
nltk
Commits
c79bc6d7
Commit
c79bc6d7
authored
Jun 23, 2014
by
Steven Bird
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #683 from heatherleaf/develop
Added `parse` method to malt.py, fixes #682
parents
6015262a
b3e948d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletions
+13
-1
nltk/parse/dependencygraph.py
+1
-1
nltk/parse/malt.py
+12
-0
No files found.
nltk/parse/dependencygraph.py
View file @
c79bc6d7
...
@@ -284,7 +284,7 @@ class DependencyGraph(object):
...
@@ -284,7 +284,7 @@ class DependencyGraph(object):
elif
style
==
4
:
elif
style
==
4
:
lines
.
append
(
'
%
s
\t
%
s
\t
%
s
\t
%
s
\n
'
%
(
word
,
tag
,
head
,
rel
))
lines
.
append
(
'
%
s
\t
%
s
\t
%
s
\t
%
s
\n
'
%
(
word
,
tag
,
head
,
rel
))
elif
style
==
10
:
elif
style
==
10
:
lines
.
append
(
'
%
s
\t
%
s
\t
%
s
\t
%
s
\t
%
s
\
%
s
\t
%
s
\t
%
s
\t
_
\t
_
\n
'
%
(
i
+
1
,
word
,
lemma
,
ctag
,
tag
,
feats
,
head
,
rel
))
lines
.
append
(
'
%
s
\t
%
s
\t
%
s
\t
%
s
\t
%
s
\
t
%
s
\t
%
s
\t
%
s
\t
_
\t
_
\n
'
%
(
i
+
1
,
word
,
lemma
,
ctag
,
tag
,
feats
,
head
,
rel
))
else
:
else
:
raise
ValueError
(
'Number of tab-delimited fields (
%
d) not supported by CoNLL(10) or Malt-Tab(4) format'
%
(
style
))
raise
ValueError
(
'Number of tab-delimited fields (
%
d) not supported by CoNLL(10) or Malt-Tab(4) format'
%
(
style
))
return
''
.
join
(
lines
)
return
''
.
join
(
lines
)
...
...
nltk/parse/malt.py
View file @
c79bc6d7
...
@@ -113,6 +113,18 @@ class MaltParser(ParserI):
...
@@ -113,6 +113,18 @@ class MaltParser(ParserI):
tagged_sentences
=
[
self
.
tagger
.
tag
(
sentence
)
for
sentence
in
sentences
]
tagged_sentences
=
[
self
.
tagger
.
tag
(
sentence
)
for
sentence
in
sentences
]
return
self
.
tagged_parse_sents
(
tagged_sentences
,
verbose
)
return
self
.
tagged_parse_sents
(
tagged_sentences
,
verbose
)
def
parse
(
self
,
sentence
,
verbose
=
False
):
"""
Use MaltParser to parse a sentence. Takes a sentence as a list of words.
The sentence will be automatically tagged with this MaltParser instance's
tagger.
:param sentence: Input sentence to parse
:type sentence: list(str)
:return: ``DependencyGraph`` the dependency graph representation of the sentence
"""
return
self
.
parse_sents
([
sentence
],
verbose
)[
0
]
def
raw_parse
(
self
,
sentence
,
verbose
=
False
):
def
raw_parse
(
self
,
sentence
,
verbose
=
False
):
"""
"""
Use MaltParser to parse a sentence. Takes a sentence as a string;
Use MaltParser to parse a sentence. Takes a sentence as a string;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment