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
Add positional preference for units #1329
Conversation
@jongfeli Would you be so kind and test this (it is based on your comments in SemanticMediaWiki/SemanticResultFormats#135 (comment)) @SemanticMediaWiki/testers are invited as well |
@@ -66,7 +73,7 @@ class SMWNumberValue extends SMWDataValue { | |||
* @return integer 0 (no errors), 1 (no number found at all), 2 (number | |||
* too large for this platform) | |||
*/ | |||
static protected function parseNumberValue( $value, &$number, &$unit ) { | |||
static protected function parseNumberValue( $value, &$number, &$unit, &$asPrefix = false ) { |
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.
#naaaaw
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.
Well, the whole thing needs a general overhaul but I'm not in a mood to bite the bullet yet (for once I want to add some new things not re-factor legacy stuff).
My apologies for the delay @mwjames. I tested this with [0] and it works BUT @JeroenDeDauw's Al-tough it is great to be able to define the unit position for a value, the way it is now and for units in front of the value this only makes sense when used inline or with You asked me to write a RFC, I will do this (after the holidays). [0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/pos-unit |
@jongfeli my previous comment is a code quality nitpick. It is not about the soundness of the overall approach. |
Thanks
The overall quality of the DV classes are hard to extend hence my comment.
"Prefexial dependency" and output alignment are distinct issues that should not be mixed with each other. The alignment of numbers within a column table to display an ordered (in terms of space) position has to be done in a result printer which generates the HTML/wikitext. This PR is about "positional preference" which is part of the DV (DataValue) itself to determine the relative correctness (correct in terms of what a user has defined to be either right or left) and keeps the information of the definition close that what the user has specified. A single DV has no (and can not have) knowledge about a possible competing DV that may (or may not) appear in a printout and therefore cannot be made dependent on such at the time the DV is created. Of course, you could have language dependant positional preference [0] but that cannot be solved with the current way general purpose quantity properties are defined.You would need to extend the Quantity DV and account for language specific output with the help of the i18n system. [0] http://english.stackexchange.com/questions/11326/what-is-the-difference-between-20-and-20 |
The unit position declared in `[[Corresponds to::€ 1]]` / `[[Corresponds to::1.06 US, US$, $]]` determines the positional preference (prefix, suffix).
... and for the due diligence fraction, I added some extra tests to cover things like |
Add positional preference for units
@kghbln FYI |
The unit position declared in
[[Corresponds to::€ 1]]
vs[[Corresponds to::1.06 USD, US$, $]]
determines the positional preference (prefix, suffix).
SemanticMediaWiki/SemanticResultFormats#135 (comment)
http://sandbox.semantic-mediawiki.org/wiki/Issue/1329_%28Positional_unit_preference%29