Skip to content

Commit

Permalink
Merge pull request nltk#1456 from alvations/develop
Browse files Browse the repository at this point in the history
Enable unordered comparison for gaac clustering
  • Loading branch information
stevenbird committed Aug 25, 2016
2 parents 9ba7ac5 + 2ebb5f2 commit 6b55702
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,4 @@
- Heguang Miao
- George Berry
- Adam Nelson
- J Richard Snape
10 changes: 7 additions & 3 deletions nltk/cluster/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Copyright (C) 2001-2016 NLTK Project
# Author: Trevor Cohn <tacohn@cs.mu.oz.au>
# Contributor: J Richard Snape
# URL: <http://nltk.org/>
# For license information, see LICENSE.TXT
from __future__ import print_function, unicode_literals
Expand Down Expand Up @@ -163,7 +164,10 @@ def groups(self, n):
for priority, node in queue:
groups.append(node.leaves())
return groups


def __lt__(self, comparator):
return cosine_distance(self._value, comparator._value) < 0


@python_2_unicode_compatible
class Dendrogram(object):
Expand Down Expand Up @@ -235,8 +239,8 @@ def show(self, leaf_labels=[]):

# find the bottom row and the best cell width
width = max(map(len, last_row)) + 1
lhalf = width / 2
rhalf = width - lhalf - 1
lhalf = int(width / 2)
rhalf = int(width - lhalf - 1)

# display functions
def format(centre, left=' ', right=' '):
Expand Down

0 comments on commit 6b55702

Please sign in to comment.