Skip to content

Instantly share code, notes, and snippets.

@jorotenev
Created January 14, 2017 07:39
Show Gist options
  • Save jorotenev/4f46b4d5a17298534ffb9eddad3450f6 to your computer and use it in GitHub Desktop.
Save jorotenev/4f46b4d5a17298534ffb9eddad3450f6 to your computer and use it in GitHub Desktop.
Small snippet to print the coordinates used in the Cocke–Younger–Kasami CKY algorithm for parsing. The same variable names as in 'Speech and Language Processing by Daniel Jurafsky and James Martin' are used.
j = 8
for j in range(1, j+1): # [1..j] # from 1 to j, including j
for i in range(j-2, 0-1, -1): # from j-2 "downto" 0; including 0
for k in range(i+1, j-1+1): # [i .. j-1] from i to j-1, including j-1
print("(j=%s,i=%i,k=%s)"%(j,i,k))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment