Пример #1
def getSentanceCombos(sentance):
  #Splitting up the sentance into different base sentances by splitting at
  #some spaces and not splitting at others. gives a list of sentances in the form
  #where each item in the list is a list of words

  #for now I will just assume every space is a seperator
  sentance_combinations = [sentance.split(" ")]

  #loop through all of the words and split each possible sentance into 
  #a list of combinations of possible parts of speach
  tag_combos = [[[], 1.0]]
  for sentance in sentance_combinations:
    for word in sentance:
      #getting a list of all the possible parts of speech for the given word
      tags = word_data.getSimpleWordData(word)
      #checking if the word returned with data
      #if not, then no data on the word, so we can quit the sentance
      if tags == False:
        return False 

      #list to store the new tag combos
      new_tag_combos = []

      #loop through possible tags
      for tag in tags:
        #for each of those, loop though all of the already existing tag combos
        tmp_tag_combos = tag_combos[:]
        for combo in tmp_tag_combos:
            a = [combo[0]+[tag[0]], combo[1]*tag[1]]

      tag_combos = new_tag_combos

  #Sort the list of tag_combos
  if(tag_combos != False): #checks if the tag combos are not false
    return sortTagCombos(tag_combos)

  return tag_combos
Пример #2
def testWords(wordList):
    for i in wordList:
        print i + " " + str(word_data.getSimpleWordData(i))