как показать длинный длинный результат в python? - PullRequest
0 голосов
/ 17 февраля 2020

Я хочу напечатать вектор (длина 148 КБ) в python (Юпитер). но только 8-10 символов этого показали. вот так: [0 0 0 ... 0 0 0] я хочу увидеть результат полностью.

import re
import nltk 
import numpy
import pandas
from nltk.corpus import stopwords
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"

vocab=numpy.array(pandas.read_excel('E:\\for_bow.xlsx'))

def word_extraction(sentence):
    ignore = set(stopwords.words('english'))    
    words = re.sub("[^\w]", " ",  sentence).split()   
    cleaned_text = [w.lower() for w in words
                    if w not in ignore]
    return cleaned_text

def generate_bow(allsentences):          
    for sentence in allsentences:        
        words = word_extraction(sentence)        
        bag_vector = numpy.zeros(len(vocab),int)        
        for w in words:            
            for i,word in enumerate(vocab):                
                if word == w:                     
                    bag_vector[i] += 1
        print("{0}\n{1}\n".format(sentence,numpy.array(bag_vector)))


input_text=["text1", "text2", "text3"]
generate_bow(input_text)

Я прочитал в другом посте здесь, что я должен использовать этот код:

from IPython.core.interactiveshell import InteractiveShell
    InteractiveShell.ast_node_interactivity = "all"

Я попробовал это, но не сработало.

...