1
   Unit tests for the miscellaneous sort functions.

 
>>> from copy import deepcopy
>>> from nltk.misc.sort import *

A (very) small list of unsorted integers.

 
>>> test_data = [12, 67, 7, 28, 92, 56, 53, 720, 91, 57, 20, 20]

Test each sorting method - each method returns the number of operations required to sort the data, and sorts in-place (desctructively - hence the need for multiple copies).

 
>>> sorted_data = deepcopy(test_data)
>>> selection(sorted_data)
66
 
>>> sorted_data
[7, 12, 20, 20, 28, 53, 56, 57, 67, 91, 92, 720]
 
>>> sorted_data = deepcopy(test_data)
>>> bubble(sorted_data)
30
 
>>> sorted_data
[7, 12, 20, 20, 28, 53, 56, 57, 67, 91, 92, 720]
 
>>> sorted_data = deepcopy(test_data)
>>> merge(sorted_data)
30
 
>>> sorted_data
[7, 12, 20, 20, 28, 53, 56, 57, 67, 91, 92, 720]
 
>>> sorted_data = deepcopy(test_data)
>>> quick(sorted_data)
13
 
>>> sorted_data
[7, 12, 20, 20, 28, 53, 56, 57, 67, 91, 92, 720]

2   Unit tests for Wordfinder class

 
>>> import random
>>> random.seed(12345)
 
>>> from nltk.misc import wordfinder
>>> wordfinder.demo()
Word Finder

B I M H P Z S E I T I L A R T U E N Q B
S G S S Y S D U D E Z I L A R T U E N I
R N D E J L H C O N T R A P T I O N P I
E I S X T L B S E C N E I N E V N O C N
K T P E T A N I M O N E D Q W S R A O T
N E A J S G R E S C O U T P O R F W S R
O R R C N S Y E K S G Y L H D E O X O I
Y P T G O R E A M G I A U N W L X D U C
M R I R I E K N Y O Y M E W A I F E D A
E E C A T T C Z T T L P R C M A L T E T
L T U N C A I J I I P G I E I M E A P E
O N L D E U H M U A O T G R P K A U O L
D I A S P N E S N Q E R M A L C V L S Y
R S T T S I W W I H G O D T X A E A I P
A T O A O S C T T M N P O A N L N V T L
M H R N R N M I N T K N D W K B W E O U
A G S D P I T N O O G E R O M E O N R N
S I S F R N P I C T O R I A L T R U Y G
S L O B A S C A R B O R O U G H T F F E
K F S S R E K A T R E D N U I M H M B R

1: AGGLOMERATES
2: BLACKMAILERS
3: PROSPECTIONS
4: NEUTRALITIES
5: INTERPRETING
6: ARTICULATORS
7: CONVENIENCES
8: ANTITHETICAL
9: LEAVENWORTH
10: INTRICATELY
11: SCARBOROUGH
12: CONTRAPTION
13: UNEVALUATED
14: PERMISSIBLY
15: UNDERTAKERS
16: NEUTRALIZED
17: ADROITNESS
18: GRANDSTAND
19: MELODRAMAS
20: DEPOSITORY
21: CONTINUITY
22: DENOMINATE
23: INSINUATE
24: PICTORIAL
25: PLAYTIME
26: FAIRMONT
27: YONKERS
28: FLIGHTS
29: PLUNGER
30: GEROME
31: APPEND
32: HICKEY
33: SCOUT
34: OARS
35: BRIM