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
ec24896e
Commit
ec24896e
authored
Jun 11, 2014
by
Steven Bird
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #677 from jw2013/develop
Drop the string initialization of Tree
parents
ba171e83
3db8f2dc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
49 deletions
+43
-49
nltk/test/tree.doctest
+9
-10
nltk/tree.py
+34
-39
No files found.
nltk/test/tree.doctest
View file @
ec24896e
...
@@ -41,32 +41,32 @@ tree object to one of several standard tree encodings:
...
@@ -41,32 +41,32 @@ tree object to one of several standard tree encodings:
Trees can be initialized from treebank strings:
Trees can be initialized from treebank strings:
>>> tree2 = Tree('(S (NP I) (VP (V enjoyed) (NP my cookie)))')
>>> tree2 = Tree
.fromstring
('(S (NP I) (VP (V enjoyed) (NP my cookie)))')
>>> print(tree2)
>>> print(tree2)
(S (NP I) (VP (V enjoyed) (NP my cookie)))
(S (NP I) (VP (V enjoyed) (NP my cookie)))
Trees can be compared for equality:
Trees can be compared for equality:
>>> tree == Tree(str(tree))
>>> tree == Tree
.fromstring
(str(tree))
True
True
>>> tree2 == Tree(str(tree2))
>>> tree2 == Tree
.fromstring
(str(tree2))
True
True
>>> tree == tree2
>>> tree == tree2
False
False
>>> tree == Tree(str(tree2))
>>> tree == Tree
.fromstring
(str(tree2))
False
False
>>> tree2 == Tree(str(tree))
>>> tree2 == Tree
.fromstring
(str(tree))
False
False
>>> tree != Tree(str(tree))
>>> tree != Tree
.fromstring
(str(tree))
False
False
>>> tree2 != Tree(str(tree2))
>>> tree2 != Tree
.fromstring
(str(tree2))
False
False
>>> tree != tree2
>>> tree != tree2
True
True
>>> tree != Tree(str(tree2))
>>> tree != Tree
.fromstring
(str(tree2))
True
True
>>> tree2 != Tree(str(tree))
>>> tree2 != Tree
.fromstring
(str(tree))
True
True
>>> tree < tree2 or tree > tree2
>>> tree < tree2 or tree > tree2
...
@@ -1075,4 +1075,3 @@ This used to discard the ``(B b)`` subtree (fixed in svn 6270):
...
@@ -1075,4 +1075,3 @@ This used to discard the ``(B b)`` subtree (fixed in svn 6270):
>>> print(Tree.fromstring('((A a) (B b))'))
>>> print(Tree.fromstring('((A a) (B b))'))
( (A a) (B b))
( (A a) (B b))
nltk/tree.py
View file @
ec24896e
This diff is collapsed.
Click to expand it.
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