Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html should show word in tooltip when hovering over a dot with a mouse #8

Closed
udibr opened this issue Mar 10, 2017 · 14 comments
Closed

Comments

@udibr
Copy link

udibr commented Mar 10, 2017

No description provided.

@JasonKessler
Copy link
Owner

Is it possible for you to post a screengrab of what's happening, let me know the browser/OS you're using? The tooltips work for me in Chrome, Safari and Firefox, although it looks like Firefox has some slight word-list positioning issues.

image

@udibr
Copy link
Author

udibr commented Mar 11, 2017

I'm using latest Chrom on Mac. My guess is that I'm using python 2.7

@udibr
Copy link
Author

udibr commented Mar 11, 2017

the tooltips on browser are working on https://jasonkessler.github.io/Conventions-Visualization.html

@JasonKessler
Copy link
Owner

There are stil some issues with Python 2.x-- the easiest thing may be to use python 3. If you'd still like to use 2, make sure you upload to the latest version of scattertext (0.0.2.4.2).

@udibr
Copy link
Author

udibr commented Mar 12, 2017

I tried re-running my code on py3 and continue to have same problems. Can you direct me to the code which generate the tool tips?

@JasonKessler
Copy link
Owner

That's odd. The code is in the showTooltip function of main.js. Could you please post (or email me) a copy of the HTML file that's being generated along with how your calling Scattertext?

I'm having trouble replicating the bug.

@udibr
Copy link
Author

udibr commented Mar 12, 2017

on python 3.6 I managed to get the tooltips when using produce_scattertext_explorer but not when using produce_scattertext_html

In python 2.7 I get an exception when calling produce_scattertext_explorer:

/Users/udi/anaconda2/lib/python2.7/site-packages/scattertext/init.pyc in produce_scattertext_explorer(corpus, category, category_name, not_category_name, protocol, pmi_filter_thresold, minimum_term_frequency, max_terms, filter_unigrams, height_in_pixels, width_in_pixels, max_snippets, max_docs_per_category, metadata, scores, singleScoreMode, sort_by_dist, reverse_sort_scores_for_not_category, use_full_doc, transform, jitter, grey_zero_scores, term_ranker, chinese_mode, use_non_text_features, show_characteristic, word_vec_use_p_vals, max_p_val, term_significance, save_svg_button)
226 max_p_val=max_p_val,
227 save_svg_button=save_svg_button)
--> 228 .to_html(protocol=protocol)
229
230

/Users/udi/anaconda2/lib/python2.7/site-packages/scattertext/viz/HTMLVisualizationAssembly.pyc in to_html(self, protocol)
80 javascript_to_insert = '\n'.join([
81 self._full_content_of_javascript_files(),
---> 82 self._visualization_data.to_javascript(),
83 self._call_build_visualization_in_javascript()
84 ])

/Users/udi/anaconda2/lib/python2.7/site-packages/scattertext/viz/VizDataAdapter.pyc in to_javascript(self)
35 def to_javascript(self):
36 starter = 'function getDataAndInfo() { return'
---> 37 word_dict_json = json.dumps(self.word_dict)
38 ender = '; }'
39 return starter + word_dict_json + ender

/Users/udi/anaconda2/lib/python2.7/json/init.pyc in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, encoding, default, sort_keys, **kw)
242 cls is None and indent is None and separators is None and
243 encoding == 'utf-8' and default is None and not sort_keys and not kw):
--> 244 return _default_encoder.encode(obj)
245 if cls is None:
246 cls = JSONEncoder

/Users/udi/anaconda2/lib/python2.7/json/encoder.pyc in encode(self, o)
205 # exceptions aren't as detailed. The list call should be roughly
206 # equivalent to the PySequence_Fast that ''.join() would do.
--> 207 chunks = self.iterencode(o, _one_shot=True)
208 if not isinstance(chunks, (list, tuple)):
209 chunks = list(chunks)

/Users/udi/anaconda2/lib/python2.7/json/encoder.pyc in iterencode(self, o, _one_shot)
268 self.key_separator, self.item_separator, self.sort_keys,
269 self.skipkeys, _one_shot)
--> 270 return _iterencode(o, 0)
271
272 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,

/Users/udi/anaconda2/lib/python2.7/json/encoder.pyc in default(self, o)
182
183 """
--> 184 raise TypeError(repr(o) + " is not JSON serializable")
185
186 def encode(self, o):

TypeError: MY_UNICODE_TEXT is not JSON serializable

@JasonKessler
Copy link
Owner

Thanks for finding the issue with produce_scattertext_html. I'll push out a fix in the next version.

Unfortunately, I can't replicate the exception you're seeing. If you can post how you called the function and the data you passed into it, then I'll be able to address the issue.

@udibr
Copy link
Author

udibr commented Mar 13, 2017

I re-run your notebook after changing the python engine from 3 to 2
and got the same exception on the imdb corpus

@JasonKessler
Copy link
Owner

I reran the notebook in Python 3.6, and I can't replicate your error.

Which cell are you seeing the error on? What is your environment? Have you made any changes to the notebook?

@udibr
Copy link
Author

udibr commented Mar 13, 2017

Sorry for not being clear enough on last post. I took your original notebook and modified it to work on python 2.7 and then run it on python 2.7 and then on the cell in which you do
html = st.produce_scattertext_explorer(... for the first time I got the same error:

TypeError: smart and alert , thirteen conversations about one thing is a small gem . is not JSON serializable

@JasonKessler
Copy link
Owner

Hmm. It looks like Pandas' JSON writer is having trouble decoding string format.

I really don't envision spending much time supporting Python 2. If you'd like, feel free to take a look at this in the code and submit a PR.

@JasonKessler
Copy link
Owner

Since the discussion has drifted to a separate issue and the original bug was fixed, I'm going to close this issue.

@JasonKessler
Copy link
Owner

I was able to replicate this in Python 2 last night and figured out the issue. There's a fix coming in the next few minutes, but again, there may be a lot of Python 2 functionality that's broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants