Python 当我运行涉及stanfordnlp.Pipeline()的代码时,我得到一个断言错误

Python 当我运行涉及stanfordnlp.Pipeline()的代码时,我得到一个断言错误,python,pandas,stanford-nlp,assertion,batchsize,Python,Pandas,Stanford Nlp,Assertion,Batchsize,我得到了断言错误,我无法找出问题所在。同样的代码行用于另一个列表,但是当我尝试使用这个列表时,它抛出了断言错误。我正在使用standfordnp negative_list = negative_df['tweet'].to_list() negative_list new_list=[] for line in negative_list: txt_list = nltk.word_tokenize(line) taggedLis

我得到了断言错误,我无法找出问题所在。同样的代码行用于另一个列表,但是当我尝试使用这个列表时,它抛出了断言错误。我正在使用standfordnp

    negative_list = negative_df['tweet'].to_list()
    negative_list
    new_list=[]
    for line in negative_list:
        txt_list = nltk.word_tokenize(line)
        taggedList = nltk.pos_tag(txt_list)
        new_list.append(taggedList)
        #print(taggedList)
    new_list
    newwordList = []
    flag = 0
    for j in new_list:
      for i in range(0,len(j)-1):
        if(new_list[i][1]=="NN" and new_list[i+1][1]=="NN"):
            newwordList.append(new_list[i][0]+new_list[i+1][0])
            flag=1
        else:
            if (flag==1):
    
                flag=0
                continue
            newwordList.append(new_list[i][0])
            if (i==len(new_list)-2):
                newwordList.append(new_list[i+1][0])
    finaltxt = '\n '.join(' '.join(word) for word in newwordList) #print('\n'.join(''.join(elems) for elems in data))
    print(finaltxt)
    nlp = stanfordnlp.Pipeline()
    doc = nlp(finaltxt)
    dep_node = []
    for dep_edge in doc.sentences[0].dependencies:
        dep_node.append([dep_edge[2].text, dep_edge[0].index, dep_edge[1]])
    for i in range(0, len(dep_node)):
        if (int(dep_node[i][1]) != 0):
            dep_node[i][1] = newwordList[(int(dep_node[i][1]) - 1)]
    print(dep_node)
    
    **After this statement i am getting this error:**

    AssertionError                            Traceback (most recent call last)
<ipython-input-30-7f55b8388dd9> in <module>()
      1 nlp = stanfordnlp.Pipeline(pos_batch_size=4096)
----> 2 doc = nlp(finaltxt)
      3 dep_node = []
      4 for dep_edge in doc.sentences[0].dependencies:
      5     dep_node.append([dep_edge[2].text, dep_edge[0].index, dep_edge[1]])

4 frames
/usr/local/lib/python3.6/dist-packages/stanfordnlp/models/pos/data.py in __getitem__(self, key)
     89         batch_size = len(batch)
     90         batch = list(zip(*batch))
---> 91         assert len(batch) == 4096
     92 
     93         # sort sentences by lens for easy RNN operations

AssertionError: 
negative_list=negative_df['tweet'].to_list()
负面清单
新列表=[]
对于负面列表中的行:
txt\u list=nltk.word\u标记化(行)
taggedList=nltk.pos_标签(txt_列表)
新列表。追加(标记列表)
#打印(标记列表)
新名单
newwordList=[]
标志=0
对于新列表中的j:
对于范围(0,len(j)-1)内的i:
如果(新列表[i][1]=“NN”和新列表[i+1][1]=“NN”):
追加(新列表[i][0]+新列表[i+1][0])
标志=1
其他:
如果(标志==1):
标志=0
持续
newwordList.append(新列表[i][0])
如果(i==len(新列表)-2:
追加(新列表[i+1][0])
finalText='\n'.join(''.join(word)表示新单词列表中的单词)#print('\n'.join('.join(elems)表示数据中的元素))
打印(FinalText)
nlp=stanfordnlp.Pipeline()
doc=nlp(最终文本)
dep_节点=[]
对于文档语句[0]中的dep_edge,依赖项:
dep_节点。追加([dep_边缘[2]。文本,dep_边缘[0]。索引,dep_边缘[1])
对于范围(0,len(dep_节点))中的i:
如果(int(dep_节点[i][1])!=0:
dep_node[i][1]=newwordList[(int(dep_node[i][1])-1]
打印(dep_节点)
**在此语句之后,我得到以下错误:**
AssertionError回溯(上次最近的调用)
在()
1 nlp=斯坦福德nlp.管道(位置批次尺寸=4096)
---->2文件=nlp(最终文本)
3 dep_节点=[]
4用于文档语句[0]中的dep_edge。依赖项:
5 dep_节点。追加([dep_边缘[2]。文本,dep_边缘[0]。索引,dep_边缘[1])
4帧
/usr/local/lib/python3.6/dist-packages/stanfordnlp/models/pos/data.py in_uuu_ugetitem_uuu(self,key)
89批次尺寸=长度(批次)
90批次=列表(zip(*批次))
--->91断言长度(批次)=4096
92
93#按镜头对句子进行排序,便于RNN操作
断言者错误: