コード例 #1
0
    def run(self):
        data = self.data

        read_module_pipes = [self.pipe_read_clean]
        read_module = ReadModule(read_module_pipes,
                                 self.file_path + self.file_name,
                                 self.encoding, data)

        clean_module_pipes = [self.pipe_read_clean, self.pipe_clean_sound]
        clean_module = CleanModule(clean_module_pipes, data)

        phonotype_module_pipes = [self.pipe_clean_sound, self.pipe_sound_syll]
        phonotype_module = PhonotypeModule(phonotype_module_pipes, data)

        syllabify_module_pipes = [self.pipe_sound_syll, self.pipe_syll_count]
        syllabify_module = SyllabifyModule(syllabify_module_pipes)

        count_module_pipes = [self.pipe_syll_count, self.pipe_count_txt]
        count_module = CountModule(count_module_pipes, data, self.file_path)

        write_module_pipes = [self.pipe_count_txt]
        write_module = WriteModule(write_module_pipes, self.file_path)

        clean_module.start()
        phonotype_module.start()
        syllabify_module.start()
        count_module.start()
        write_module.start()

        read_module.run()

        phonotype_module.join()
        syllabify_module.join()
        count_module.join()
        write_module.join()
コード例 #2
0
def run_through_module(words):
    module = CleanModule([pipe_in, pipe_out], data)
    module.start()
    result = []

    for word in words:
        pipe_in.acquire()
        pipe_in.put(word)
        pipe_in.notify()
        pipe_in.release()

    while True:
        pipe_out.acquire()
        if pipe_out.empty():
            pipe_out.wait()
        cleaned_word = pipe_out.get()
        result.append(cleaned_word)
        pipe_out.release()

        if isinstance(cleaned_word, End):
            break

    module.join()
    return result
コード例 #3
0
def run_through_module(words):
    clean_module = CleanModule([read_clean_pipe, clean_out_pipe], data)
    clean_module.start()
    result = []

    for word in words:
        read_clean_pipe.acquire()
        read_clean_pipe.put(word)
        read_clean_pipe.notify()
        read_clean_pipe.release()

    while True:
        clean_out_pipe.acquire()
        if clean_out_pipe.empty():
            clean_out_pipe.wait()
        cleaned_word = clean_out_pipe.get()
        result.append(cleaned_word)
        clean_out_pipe.release()

        if isinstance(cleaned_word, End):
            break

    clean_module.join()
    return result