-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
FES: detect capitalization and spelling mistakes #4637
Comments
Sounds like a great idea to me. Implementation wise do you have an idea of how to do this? |
what about a spinoff of FAQ? like frequent code mistakes, super short?
|
@limzykenneth
I am not yet sure about the exact specifications of the word distance algorithm. I have been reading on various ways it can be implemented to find something which fits here. I can also set it up so that capitalization has a smaller distance as compared to letter differences.
@montoyamoraga Yes! We could also add this to the wiki I think. |
@akshay-99 that sounds awesome! yeah i have been thinking about ways to have less people post issues here when they are having trouble with their code, i am thinking this FAQ lisit could live both on p5.js website and be referenced when people open any new issue :) |
@akshay-99 I don't think I understand the second solution well but the first solution seems like a good enough avenue to start exploring. A good word distance algorithm can be rather complicated to setup as there are many many ways a typo can occur, what I would suggest is to start simple with just a |
So excited for this! This could be a very powerful improvement to FES. Just to echo @limzykenneth that a Also, this is less important and maybe outside of scope, but I wander if you could easily do this same comparison for undefined variables that are close to user-defined variables. |
Thanks for the suggestions everyone! I will try out these things and see the results.
@stalgiag Are you talking about variables which are defined by the user as a part of their sketch but may not be related to any p5 functionality? |
@akshay-99 yes, just curious if the same solution for p5 functions could be easily expanded to help with a sketch like this: let myX = 50, myY = 10;
function setup() {
createCanvas(100, 100);
rect(myx, myY, 10); // FES will say variable undefined, which is probably enough of a clue
} This becomes a bit more of a fuzzy discussion about the scope of the FES and I don't think this functionality needs to be addressed. This was more of a passing consideration that I just wanted to think about in parallel to the work done here. |
@stalgiag The FES does not currently have this much insight about the sketch. I think this specific case would need to involve parsing the user's sketch, basically having one script ( p5 library) read the code in another script ( the sketch ) . I had come up with some ideas about this a few months back, about how the FES could use the parsed sketch to build more context for its messages, and how this could be done. But it would be a much larger task. Also, when the sketch is run locally ( not on a server ), the execution environment in the browser will allow us to see read the code written inside functions in the sketch, but not the code at the top level in the sketch file. And since |
this is great. I will add that |
@akshay-99 right - hadn't considered where we were catching things currently. Thanks for the breakdown! |
Most appropriate sub-area of p5.js?
I have seen that new programmers often take time to register the several naming conventions used in programming such as camelCase for identifier names, ALL_CAPS for constants, etc. And so capitalization mistakes are very common among them but they can spend way more time trying to debug it. For example one may call try to call
createcanvas
instead ofcreateCanvas
,Color
instead ofcolor
and so on. These types of mistakes are easier to spot as the browser itself will show an error likecreatecanvas
doesn't exist.But mistakes in functions which are to be defined by the user such as
setup
,draw
,mouseClicked
, etc are harder to spot. For exampleThis code snippet won't run as
Setup
has been defined when we neededsetup
. But there will be no error message displayed here and so it can take longer for a beginner to figure it out. Similarlymouseclicked
will not work but there is no error message.Spelling mistakes can also be common for someone not that familiar with English, or there can be regional differences in spelling (
color
vscolour
)I am thinking of using the FES to display a message whenever the user has made a capitalization or spelling mistake and show the nearest match using word distance algorithms. Something like
🌸 p5.js says: It looks like you have used mouseclicked. Did you mean mouseClicked ?
This won't run every time, but only when a spelling/capitalization mistake occurs. So there should be no negative effects on the performance as such. It will function similarly to
helpForMisusedAtTopLevel
The text was updated successfully, but these errors were encountered: