Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 试图同时处理所有Python函数_Php_Python - Fatal编程技术网

Php 试图同时处理所有Python函数

Php 试图同时处理所有Python函数,php,python,Php,Python,我试图处理一个文本文件和它的句子。我将文本拆分为句子,并通过一些python函数处理各个句子 with io.open ("articles.html", encoding="utf-8") as myfile: data = myfile.read() data = data.split('\n') myfile.close() 基本上,我根据句子的长度和一些正则表达式过滤器来处理每个句子。我已经将我的python函数(即process_movie_1、proces

我试图处理一个文本文件和它的句子。我将文本拆分为句子,并通过一些python函数处理各个句子

with io.open ("articles.html", encoding="utf-8") as myfile:
    data = myfile.read()
    data = data.split('\n')
    myfile.close() 
基本上,我根据句子的长度和一些正则表达式过滤器来处理每个句子。我已经将我的python函数(即process_movie_1、process_movie_2、process_movie_3)存储在其他文件中,并导入到主脚本中

我用for循环调用每个句子。在当前结构中,我的脚本在for循环中一次处理一个句子/一个函数。我需要修改脚本,以便我可以同时处理每个句子。我需要你的想法,我可能想从主脚本调用所有这些函数,或者用fork。我想你们中的一些人可能会想出一个更好的主意。好的,现在我使用IDE调用我的主脚本,但我已经准备好使用命令提示符同时处理所有的句子。我也可以使用任何开源软件来帮助我考虑我的情况

from clip1 import *
from clip2 import *
from clip3 import *
from clip4 import *

for idx, sentence in enumerate(data):

    serial = str(idx) 
    folder = str(idx)

    string = str(sentence)
    tokens = TextBlob(string)
    wordcounts = len(tokens.words)


    sep = re.split('; |\*|\n|--', string)


    if len(sep) == 2:

        a, b = [str(e) for e in sep]
        a = TextBlob(a)
        b = TextBlob(b)
        idx, len(tokens.words), len(sep), len(a.words), len(b.words), sep

        if (0 <= wordcounts <= 4):

            len(tokens.words), sentence, sep
            a, b = [str(e) for e in sep]
            a = TextBlob(a)
            b = TextBlob(b)
            len(a.words), len(b.words), sep, sentence

            process_movie_1(folder, gradient, fontface,
                             fontface_italic, highlight,
                             highlight_color, font_color, key_color, 
                             first_key, second_key, third_key, string, 
                             stroke_color, stroke_width, txt_under_color, 
                             serial)        



        elif (5 <= wordcounts <= 6):

            len(tokens.words), sentence, sep
            a, b = [str(e) for e in sep]
            a = TextBlob(a)
            b = TextBlob(b)
            len(a.words), len(b.words), sep, sentence


            process_movie_2(folder, gradient, fontface, fontface_italic, highlight, 
                             highlight_color, font_color, key_color, 
                             first_key, second_key, third_key, string, 
                             stroke_color, stroke_width, txt_under_color, 
                             serial)



        elif (7 <= wordcounts <= 15):

            len(tokens.words), sentence, sep
            a, b = [str(e) for e in sep]
            a = TextBlob(a)
            b = TextBlob(b)
            len(a.words), len(b.words), sep, sentence

            if (1 <= len(a.words) <= 3): 
                print idx, "(clip29 -- done)", len(tokens.words), sep


                process_movie_3(folder, gradient, fontface, fontface_italic, highlight, 
                                 highlight_color, font_color, key_color, 
                                 first_key, second_key, third_key, string, 
                                 stroke_color, stroke_width, txt_under_color, 
                                 serial)
从clip1导入*
从clip2导入*
从clip3导入*
从clip4导入*
对于idx,枚举中的句子(数据):
串行=str(idx)
folder=str(idx)
string=str(句子)
令牌=TextBlob(字符串)
wordcounts=len(标记。单词)
sep=re.split(“;| \*\n|--”,字符串)
如果len(sep)==2:
a、 b=[str(e)表示九月的e]
a=TextBlob(a)
b=TextBlob(b)
idx,len(代币词),len(sep),len(a.words),len(b.words),sep

如果(0 hi@anay bose,你想过并行吗?嗨,Andy K,还没有关于并行吗?你是不是在试图同时处理每两个句子而不是一个句子?嗨,Direprobs,没有,每个句子都是并行的。