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

fix: #265 and #261 (/js/ldavis.v3.0.0.js) #266

Merged
merged 4 commits into from
Apr 29, 2024
Merged

Conversation

ed9w2in6
Copy link
Contributor

@ed9w2in6 ed9w2in6 commented Apr 18, 2024

fixes #265 and #261

There does not seems to be any testing mechanism for the javascript code so no test are added.
Tested locally myself, matches my own expectation as described in #265.

@bmabey Please check.

@ed9w2in6
Copy link
Contributor Author

@msusol

@ed9w2in6 ed9w2in6 mentioned this pull request Apr 18, 2024
@ed9w2in6 ed9w2in6 changed the title fix: #265 (/js/ldavis.v3.0.0.js) fix: #265 and #261 (/js/ldavis.v3.0.0.js) Apr 18, 2024
@ed9w2in6
Copy link
Contributor Author

Also fixes #261, which just changes the formula written in the footnote of the visualisation.
For details please refer to #261.

@ed9w2in6
Copy link
Contributor Author

@msusol @bmabey Hi, I would love to see this being merged since apparently in modern browsers Javascript files cannot be served without a server. This means I cannot use this fix myself.

Let me know if you would need any help.

Of course, in the long run we should decouple the numbering from labels such that feature request like #92 can be implemented. Decoupling should also remove the need of sort_topics, and start_index.

Copy link
Collaborator

@msusol msusol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address these comments to pull in the changes.

@@ -178,7 +182,7 @@ var LDAvis = function(to_select, data_or_file_name, color1, color2) {
if (termElem !== undefined) term_off(termElem);
vis_state.term = "";
var value_old = document.getElementById(topicID).value;
var value_new = Math.min(K, +value_old + 1).toFixed(0);
var value_new = Math.min(K - 1 + startIndex, +value_old + 1).toFixed(0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

K - 1 + startIndex -> K + startIndex - 1

Just to be consistent everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added commit 0a96505

value_new = Math.min(K, Math.max(1, value_new));
// older versions check for value_new !== "" too, why?
if (!isNaN(value_new) && value_new > startIndex - 1) {
value_new = Math.min(K + startIndex - 1, Math.max(startIndex, value_new));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above, match this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added commit 0a96505

@@ -512,7 +517,7 @@ var LDAvis = function(to_select, data_or_file_name, color1, color2) {
.attr("x", 0)
.attr("y", mdsheight + 10 + (8/2)*barguide.height + 5)
.style("dominant-baseline", "middle")
.text("2. relevance(term w | topic t) = \u03BB * p(w | t) + (1 - \u03BB) * p(w | t)/p(w); see Sievert & Shirley (2014)");
.text("2. relevance(term w | topic t; \u03BB) = \u03BB * log(p(w | t)) + (1 - \u03BB) * log(p(w | t)/p(w)); see Sievert & Shirley (2014)");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#261 (comment)

You don't mention this formula change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it at line 511. I am not sure what you mean.

@@ -512,7 +517,7 @@ var LDAvis = function(to_select, data_or_file_name, color1, color2) {
.attr("x", 0)
.attr("y", mdsheight + 10 + (8/2)*barguide.height + 5)
.style("dominant-baseline", "middle")
.text("2. relevance(term w | topic t) = \u03BB * p(w | t) + (1 - \u03BB) * p(w | t)/p(w); see Sievert & Shirley (2014)");
.text("2. relevance(term w | topic t; \u03BB) = \u03BB * log(p(w | t)) + (1 - \u03BB) * log(p(w | t)/p(w)); see Sievert & Shirley (2014)");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change here?

relevance(term w | topic t; \u03BB)

Copy link
Contributor Author

@ed9w2in6 ed9w2in6 Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The notation is to indicate that \lambda is a parameter of the metric, such that the formula aligns better to the one shown in the linked paper:
image

@msusol msusol merged commit 728a360 into bmabey:master Apr 29, 2024
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

Successfully merging this pull request may close these issues.

major LDAviz UI topic index bug (e.g. term, topic, etc.)
2 participants