无法渲染Scattertext HTML输出

2024-06-02 13:40:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是Juypter笔记本,在尝试为scattertext包生成HTML输出时,继续出现错误404:notfound。你知道吗

import scattertext as st
from IPython.display import IFrame

convention_df = st.SampleCorpora.ConventionData2012.get_data()
convention_df["party"].iloc[3] = "liberal"
convention_df["party"].iloc[4] = "republican"
convention_df["party"].iloc[5] = "liberal"
convention_df["party"].iloc[6] = "republican"

empath_corpus = st.CorpusFromParsedDocuments(convention_df.iloc[:15],
                                             category_col="party",
                                             feats_from_spacy_doc=st.FeatsFromOnlyEmpath(),
                                             parsed_col="text").build()

html = st.produce_scattertext_explorer(empath_corpus,
    category = 'democrat',
    category_name = 'democrat',
    not_category_name = "Not democrat",
    width_in_pixels=1000,
    use_non_text_features=True,
    use_full_doc=True)

file_name = 'democrat.html'
rel_report_path = os.path.relpath(file_name)
from IPython.display import IFrame    
display(IFrame(filename, width=900, height=650))

Juypter返回404:未找到

从我所看到的HTML文件是生成的,但我不能让它显示出来。我用水蟒。你知道吗


Tags: namefromimportdfpartyhtmldisplayconvention