J'utilise un ordinateur portable Jupyter et continue d'obtenir l'erreur 404: Introuvable lorsque j'essaie de générer une sortie HTML pour le package scattertext.
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))
Jupyter retourne 404: Introuvable
D'après ce que je peux voir, le fichier HTML a été généré, mais je n'arrive pas à l'afficher. J'utilise Anaconda.
0
Jennifer Schleicher
4 nov. 2019 à 03:22
1 réponse
Meilleure réponse
Il semble que vous n'écriviez jamais le fichier.
Sous file_name = 'democrat.html
, assurez-vous d'inclure quelque chose comme:
with open(file_name, 'w') as outf: outf.write(html)
1
Jason Kessler
4 nov. 2019 à 21:42