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
e8ac4716
Commit
e8ac4716
authored
May 14, 2014
by
Steven Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed _lcs_by_depth(), see
https://github.com/nltk/nltk/pull/662
parent
24e257a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
59 deletions
+0
-59
nltk/corpus/reader/wordnet.py
+0
-59
No files found.
nltk/corpus/reader/wordnet.py
View file @
e8ac4716
...
@@ -1815,65 +1815,6 @@ def lin_similarity(synset1, synset2, ic, verbose=False):
...
@@ -1815,65 +1815,6 @@ def lin_similarity(synset1, synset2, ic, verbose=False):
lin_similarity
.
__doc__
=
Synset
.
lin_similarity
.
__doc__
lin_similarity
.
__doc__
=
Synset
.
lin_similarity
.
__doc__
def
_lcs_by_depth
(
synset1
,
synset2
,
verbose
=
False
):
"""
Finds the least common subsumer of two synsets in a WordNet taxonomy,
where the least common subsumer is defined as the ancestor node common
to both input synsets whose shortest path to the root node is the longest.
:type synset1: Synset
:param synset1: First input synset.
:type synset2: Synset
:param synset2: Second input synset.
:return: The ancestor synset common to both input synsets which is also the
LCS.
"""
subsumer
=
None
max_min_path_length
=
-
1
subsumers
=
synset1
.
common_hypernyms
(
synset2
)
if
verbose
:
print
(
"> Subsumers1:"
,
subsumers
)
# Eliminate those synsets which are ancestors of other synsets in the
# set of subsumers.
eliminated
=
set
()
hypernym_relation
=
lambda
s
:
s
.
hypernyms
()
+
s
.
instance_hypernyms
()
for
s1
in
subsumers
:
for
s2
in
subsumers
:
if
s2
in
s1
.
closure
(
hypernym_relation
):
eliminated
.
add
(
s2
)
if
verbose
:
print
(
"> Eliminated:"
,
eliminated
)
subsumers
=
[
s
for
s
in
subsumers
if
s
not
in
eliminated
]
if
verbose
:
print
(
"> Subsumers2:"
,
subsumers
)
# Calculate the length of the shortest path to the root for each
# subsumer. Select the subsumer with the longest of these.
for
candidate
in
subsumers
:
paths_to_root
=
candidate
.
hypernym_paths
()
min_path_length
=
-
1
for
path
in
paths_to_root
:
if
min_path_length
<
0
or
len
(
path
)
<
min_path_length
:
min_path_length
=
len
(
path
)
if
min_path_length
>
max_min_path_length
:
max_min_path_length
=
min_path_length
subsumer
=
candidate
if
verbose
:
print
(
"> LCS Subsumer by depth:"
,
subsumer
)
return
subsumer
def
_lcs_ic
(
synset1
,
synset2
,
ic
,
verbose
=
False
):
def
_lcs_ic
(
synset1
,
synset2
,
ic
,
verbose
=
False
):
"""
"""
Get the information content of the least common subsumer that has
Get the information content of the least common subsumer that has
...
...
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