Example #1
0
def createWordPhraseList(lines):
    ### each line has 1) word or phraseID, 2) POS and 3)mother node ID
    ### itemID, word or phrase, POS, motherID
    def isLinePhrase((num, item, POS, motherID)):
        return isPhrase(item)
    ### make lists of words and phrases
    phrases, wordList = partition(isLinePhrase, lines)
    phraseList = [[item.strip("#"), POS, motherID]
                  for [num, item, POS, motherID] in phrases]
    return wordList, phraseList
Example #2
0
def multirun(n, tasks, files):
    processes = [subprocess.Popen(tasks[i], stdout=open(files[i],'w'))
                 for i in range(n)]
    i = n
    while processes != []:
        subprocess.Popen(['sleep', '0.25']).wait()
        processes, dones = partition(lambda p:p.poll() is None, processes)
        for _ in dones:
            if i < len(tasks):
                print("Starting", ' '.join(tasks[i]))
                processes.append(subprocess.Popen(tasks[i],
                                                  stdout=open(files[i], 'w')))
                i += 1