-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Mark units that are aliases, and use alias string for uString comparisons so sameUnits will allow plurals, etc. (#1193) #1194
Open
dpvc
wants to merge
1
commit into
openwebwork:develop
Choose a base branch
from
dpvc:fix-unit-aliases
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these extras added here instead of to the
Units.pm
file? I am curious as to why this is done differently for liters than for all other units that use thealiases
key inUnits.pm
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had originally not wanted to mess with the
Units.pm
file, so I added them here, mostly as an illustration of how to do that. You can't usealiases
here, as theUnits.pm
file has already processed and removed thealiases
properties, so we have to do it by hand here after the fact.I think the
Units.pm
file does need a lot of work in terms of aliases, but that wasn't my priority here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
I didn't mean to say that you should handle the work on aliases in this pull request. I just wanted to point that out, and that we need to work on it.
Interestingly, I noticed that I get somewhat different behavior from trying to use
grams
with theparserNumberWithUnits.pl
versus with the newcontextUnits.pl
macro. With theparserNumberWithUnits.pl
macro the message is'gra' is not defined in this context
, while with thecontextUnits.pl
macro the message is'rams' is not defined in this context
. The legacy macro seesms
as a unit and has a problem withgra
, but the new macro seesg
as a unit and has a problem withrams
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the two worked very differently about how they determined the units. The old units context tried to remove units from the end of the student answer and parse the rest as a formula, so it was essentially right-to-left handling of the units. But the new contest integrates units into the parsing as actual MathObjects, so it is done left-to-right, as with all the parsing. When there is a run of characters like "grams", MathObjects will take the maximal substring that matches one of its defined values (constants, functions, etc.), so in this case, since "gr", "gra", "gram", and "grams" are not defined in
Units.pm
, theg
is the longest match.The units context currently defines
squared
andsquare
so that you can dosquare meters
orseconds squared
. I suppose one could addmilli
,centi
,deci
, etc., so that you could usemillimeters
,decilitres
and so on without having to add all the separate aliases.