无法呈现Scattertext HTML输出

我正在使用Juypter笔记本,尝试生成scattertext包的HTML输出时,继续出现错误404:未找到。

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文件已生成,但无法显示它。我使用水蟒。

annzhang123456 回答:无法呈现Scattertext HTML输出

似乎您从未写入过文件。

file_name = 'democrat.html下,确保您包含以下内容:

with open(file_name,'w') as outf: outf.write(html)
本文链接:https://www.f2er.com/3169643.html

大家都在问