Advertisement
Guest User

Untitled

a guest
Sep 18th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.60 KB | None | 0 0
  1. # the sounds in the language
  2. vowels = ["a", "e", "i", "o", "u"]
  3. consonants = ["m", "p", "f","t","s","k"]
  4. sounds = vowels+consonants
  5.  
  6. #initial settings
  7. wordlength = 5
  8. line=1
  9. numberofsounds = len(sounds)
  10.  
  11. #imports
  12. from array  import *
  13. from numpy  import *
  14.  
  15. #initial array settings
  16. a = zeros([pow(numberofsounds,wordlength),wordlength])
  17.  
  18. #entire addition loop
  19. end = 0
  20. while line < pow(numberofsounds,wordlength):
  21.  
  22.     #var used for loop
  23.     n = 0
  24.     #print "n="+str(n)
  25.     while n <= wordlength-1:
  26.         a[line,n] = a[line-1,n]
  27.         n = n+1
  28.         #print "n="+str(n)
  29.         #print a
  30.  
  31.     #add 1 to the last
  32.     a[line,wordlength-1] = a[line,wordlength-1]+1
  33.  
  34.     #loop that detect if a the number is too large
  35.     m = wordlength-1
  36.     while m >= 0:
  37.         if a[line, m] > numberofsounds-1 and m != 0:
  38.             a[line,m] = 0
  39.             a[line,m-1] = a[line,m-1]+1
  40.  
  41.         m=m-1
  42.  
  43.     line=line+1
  44.     #print "line="+str(line)
  45.  
  46. #displaying the representation
  47. print "numerical representation is"
  48. print a
  49.  
  50. #remove non-possible words
  51. #code goes here
  52.  
  53. #generating the words from the representation
  54.  
  55. #converter
  56. def convert(input):
  57.     return sounds[input]
  58.  
  59. #fetcher
  60. def fetch(input1,input2):
  61.     return a[input1,input2]
  62.  
  63. #print words
  64. line = 0
  65.  
  66. while line < pow(numberofsounds,wordlength):
  67.     word = ""
  68.     n = 0
  69.     while n < wordlength:
  70.         word = word + convert(int(fetch(line,n)))
  71.         n=n+1
  72.         #print str(n)
  73.  
  74.     #print "line="+str(line)
  75.     print word
  76.  
  77.     line=line+1
  78.  
  79. print "number of different words is "+(str(pow(numberofsounds,wordlength)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement