Dynamic unit conversion

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic unit conversion

Petr Bena
.Hi,

There are many articles on wikipedia that contain different units.
Some use cm, that are common in europe, other use inches that are more
widely used in US, same with other unit types.

I think it would be cool if an extension was created which would allow
everyone to specify what units they prefer, and the values in articles
would be converted automatically based on preference.

For example you would say the object has width of {{unit|cm=20}} and
people who prefer cm would see 20 cm in article text, but people who
prefer inches would see 7.87 inch. This could be even based on
geolocation for IP users

What do you think?

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Petr Bena
there could be even some cool javascript based toolbar that would
allow people to switch the unit, or see unit hint when they roll over
the text

On Fri, Jan 17, 2014 at 9:58 AM, Petr Bena <[hidden email]> wrote:

> .Hi,
>
> There are many articles on wikipedia that contain different units.
> Some use cm, that are common in europe, other use inches that are more
> widely used in US, same with other unit types.
>
> I think it would be cool if an extension was created which would allow
> everyone to specify what units they prefer, and the values in articles
> would be converted automatically based on preference.
>
> For example you would say the object has width of {{unit|cm=20}} and
> people who prefer cm would see 20 cm in article text, but people who
> prefer inches would see 7.87 inch. This could be even based on
> geolocation for IP users
>
> What do you think?

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Gerard Meijssen-3
Hoi,
The best place for such an effort would be Wikidata.. There are many units
that could do with some TLC. Particularly with the arrival of values in
Wikidata it is expedient to do this.

One other area where attention would be relevant are dates.. Did you know
that some calendars (that are used) have cycles of sixty years ??
Thanks,
     Gerard


On 17 January 2014 09:59, Petr Bena <[hidden email]> wrote:

> there could be even some cool javascript based toolbar that would
> allow people to switch the unit, or see unit hint when they roll over
> the text
>
> On Fri, Jan 17, 2014 at 9:58 AM, Petr Bena <[hidden email]> wrote:
> > .Hi,
> >
> > There are many articles on wikipedia that contain different units.
> > Some use cm, that are common in europe, other use inches that are more
> > widely used in US, same with other unit types.
> >
> > I think it would be cool if an extension was created which would allow
> > everyone to specify what units they prefer, and the values in articles
> > would be converted automatically based on preference.
> >
> > For example you would say the object has width of {{unit|cm=20}} and
> > people who prefer cm would see 20 cm in article text, but people who
> > prefer inches would see 7.87 inch. This could be even based on
> > geolocation for IP users
> >
> > What do you think?
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Antoine Musso-3
In reply to this post by Petr Bena
Le 17/01/14 09:58, Petr Bena a écrit :

> There are many articles on wikipedia that contain different units.
> Some use cm, that are common in europe, other use inches that are more
> widely used in US, same with other unit types.
>
> I think it would be cool if an extension was created which would allow
> everyone to specify what units they prefer, and the values in articles
> would be converted automatically based on preference.
>
> For example you would say the object has width of {{unit|cm=20}} and
> people who prefer cm would see 20 cm in article text, but people who
> prefer inches would see 7.87 inch. This could be even based on
> geolocation for IP users

Hello,

I like the idea.  One thing to take in account is that the unit
conversion should be done on the client side to avoid fragmentation of
the parser cache.

A possibility would be for the template to output BOTH metrics and
imperial units, then use JS/CSS to hide the irrelevant one.  Hence
{{unit|cm=20}} would generate something like:

 <span class="mw-unitsystem-imperial">7,874 inches</span>
 <span class="mw-unitsystem-metric">20 cm</span>

Then using user preference to hide one of the class.


--
Antoine "hashar" Musso


_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Petr Bena
In reply to this post by Gerard Meijssen-3
Yes, but what I mean is the user interface for wikipedia readers so
that it's easier for them to understand what the value is. I think
this issue has 2 parts.

One is implementation in user interface for readers (probably some js
widget that pop up, when you roll over the unit, allowing you to
immediately convert it or change the default preferences) who are
reading articles on wikipedia or any other wmf project.

The other part is the implementation of this for editors. It could
either use wikidata as backend, which probably is a good solution
here, or just some magic word like {{DYNAMICUNIT|unit_type=value}} etc
etc.

I think that best would be combination of both wikidata and magic,
because most of wikipedia editors aren't familiar with wikidata at all
and may find it complicated to insert the values directly in there. If
wikidata was the only option, it would need to be EXTREMELY simple for
users to insert the value into article with a 0 need for any knowledge
of how wikidata works, otherwise nobody is going to use it.

On Fri, Jan 17, 2014 at 10:28 AM, Gerard Meijssen
<[hidden email]> wrote:

> Hoi,
> The best place for such an effort would be Wikidata.. There are many units
> that could do with some TLC. Particularly with the arrival of values in
> Wikidata it is expedient to do this.
>
> One other area where attention would be relevant are dates.. Did you know
> that some calendars (that are used) have cycles of sixty years ??
> Thanks,
>      Gerard
>
>
> On 17 January 2014 09:59, Petr Bena <[hidden email]> wrote:
>
>> there could be even some cool javascript based toolbar that would
>> allow people to switch the unit, or see unit hint when they roll over
>> the text
>>
>> On Fri, Jan 17, 2014 at 9:58 AM, Petr Bena <[hidden email]> wrote:
>> > .Hi,
>> >
>> > There are many articles on wikipedia that contain different units.
>> > Some use cm, that are common in europe, other use inches that are more
>> > widely used in US, same with other unit types.
>> >
>> > I think it would be cool if an extension was created which would allow
>> > everyone to specify what units they prefer, and the values in articles
>> > would be converted automatically based on preference.
>> >
>> > For example you would say the object has width of {{unit|cm=20}} and
>> > people who prefer cm would see 20 cm in article text, but people who
>> > prefer inches would see 7.87 inch. This could be even based on
>> > geolocation for IP users
>> >
>> > What do you think?
>>
>> _______________________________________________
>> Wikitech-l mailing list
>> [hidden email]
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Petr Bena
In reply to this post by Antoine Musso-3
Yes, this is precisely what I mean. It could be some js gadget that
does this, just like the google translate gadget makes it easy to
translate a word by rolling over the text, this would let users see
the value in different units the same way. However this gadget needs
to know what is supposed to be converted. So there is also some need
to alter the current articles as they are.

Maybe it would be possible for it to automagically recognize what is a
unit using some regex or something like it, but I am afraid it
wouldn't be very reliable if the unit and value wasn't clearly
specified in wikitext. There are some special values, for example
recently I was reading about hard drives and values like size per
square inch (for example Tib/sq. inch) and similar are pretty exotic
to be matched easily by some automatic algorithm without explicitly
specifying what kind of unit is that.

On Fri, Jan 17, 2014 at 10:38 AM, Antoine Musso <[hidden email]> wrote:

> Le 17/01/14 09:58, Petr Bena a écrit :
>> There are many articles on wikipedia that contain different units.
>> Some use cm, that are common in europe, other use inches that are more
>> widely used in US, same with other unit types.
>>
>> I think it would be cool if an extension was created which would allow
>> everyone to specify what units they prefer, and the values in articles
>> would be converted automatically based on preference.
>>
>> For example you would say the object has width of {{unit|cm=20}} and
>> people who prefer cm would see 20 cm in article text, but people who
>> prefer inches would see 7.87 inch. This could be even based on
>> geolocation for IP users
>
> Hello,
>
> I like the idea.  One thing to take in account is that the unit
> conversion should be done on the client side to avoid fragmentation of
> the parser cache.
>
> A possibility would be for the template to output BOTH metrics and
> imperial units, then use JS/CSS to hide the irrelevant one.  Hence
> {{unit|cm=20}} would generate something like:
>
>  <span class="mw-unitsystem-imperial">7,874 inches</span>
>  <span class="mw-unitsystem-metric">20 cm</span>
>
> Then using user preference to hide one of the class.
>
>
> --
> Antoine "hashar" Musso
>
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Marc Ordinas i Llopis
In reply to this post by Petr Bena
On Fri, Jan 17, 2014 at 9:58 AM, Petr Bena <[hidden email]> wrote:

> For example you would say the object has width of {{unit|cm=20}} and
> people who prefer cm would see 20 cm in article text, but people who
> prefer inches would see 7.87 inch.


This is a great idea! As proposed it'd be very helpful, but maybe it'd be
better if it showed the original text and a conversion on mouse-over (maybe
with a small icon to indicate it, like external links).


> This could be even based on
> geolocation for IP users
>
>
Oh, please, don't use IP geolocation for anything. It's terrible for people
travelling, using proxies, living abroad, living in places where more than
one languages are commonly spoken, learning new languages… If you want to
get an initial default, use Accept-Language (like, inches for en-US and cm
for anyone else :) and allow the user to modify it.

Thanks,
Marc
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Jasper Deng
I would like to ask, how are significant figures going to be dealt with?
300 could mean anything from one to three significant figures, for example.


On Fri, Jan 17, 2014 at 1:47 AM, Marc Ordinas i Llopis <
[hidden email]> wrote:

> On Fri, Jan 17, 2014 at 9:58 AM, Petr Bena <[hidden email]> wrote:
>
> > For example you would say the object has width of {{unit|cm=20}} and
> > people who prefer cm would see 20 cm in article text, but people who
> > prefer inches would see 7.87 inch.
>
>
> This is a great idea! As proposed it'd be very helpful, but maybe it'd be
> better if it showed the original text and a conversion on mouse-over (maybe
> with a small icon to indicate it, like external links).
>
>
> > This could be even based on
> > geolocation for IP users
> >
> >
> Oh, please, don't use IP geolocation for anything. It's terrible for people
> travelling, using proxies, living abroad, living in places where more than
> one languages are commonly spoken, learning new languages… If you want to
> get an initial default, use Accept-Language (like, inches for en-US and cm
> for anyone else :) and allow the user to modify it.
>
> Thanks,
> Marc
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Happy Melon-2
Enwiki's {{convert}} template is a behemoth of a structure which is
intended to do this.  I once made an attempt to write a PHP-side extension
to do it (look at the revision history of the ParserFunctions extension),
but it never took off [1].  I don't think there was ever any enthusiasm to
take the ability to "tinker" with the formatting and output ({{convert}}
has a million and one different stylistic variations and parameters) away
from wiki template editors.

--HM

[1] https://bugzilla.wikimedia.org/show_bug.cgi?id=40039


On 17 January 2014 10:56, Jasper Deng <[hidden email]> wrote:

> I would like to ask, how are significant figures going to be dealt with?
> 300 could mean anything from one to three significant figures, for example.
>
>
> On Fri, Jan 17, 2014 at 1:47 AM, Marc Ordinas i Llopis <
> [hidden email]> wrote:
>
> > On Fri, Jan 17, 2014 at 9:58 AM, Petr Bena <[hidden email]> wrote:
> >
> > > For example you would say the object has width of {{unit|cm=20}} and
> > > people who prefer cm would see 20 cm in article text, but people who
> > > prefer inches would see 7.87 inch.
> >
> >
> > This is a great idea! As proposed it'd be very helpful, but maybe it'd be
> > better if it showed the original text and a conversion on mouse-over
> (maybe
> > with a small icon to indicate it, like external links).
> >
> >
> > > This could be even based on
> > > geolocation for IP users
> > >
> > >
> > Oh, please, don't use IP geolocation for anything. It's terrible for
> people
> > travelling, using proxies, living abroad, living in places where more
> than
> > one languages are commonly spoken, learning new languages… If you want to
> > get an initial default, use Accept-Language (like, inches for en-US and
> cm
> > for anyone else :) and allow the user to modify it.
> >
> > Thanks,
> > Marc
> > _______________________________________________
> > Wikitech-l mailing list
> > [hidden email]
> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
> >
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Petr Bena
That's why I don't think this is a best job for a template. It
definitely should be done by some kind of extension or gadget instead.

On Fri, Jan 17, 2014 at 11:16 AM, Happy Melon
<[hidden email]> wrote:

> Enwiki's {{convert}} template is a behemoth of a structure which is
> intended to do this.  I once made an attempt to write a PHP-side extension
> to do it (look at the revision history of the ParserFunctions extension),
> but it never took off [1].  I don't think there was ever any enthusiasm to
> take the ability to "tinker" with the formatting and output ({{convert}}
> has a million and one different stylistic variations and parameters) away
> from wiki template editors.
>
> --HM
>
> [1] https://bugzilla.wikimedia.org/show_bug.cgi?id=40039
>
>
> On 17 January 2014 10:56, Jasper Deng <[hidden email]> wrote:
>
>> I would like to ask, how are significant figures going to be dealt with?
>> 300 could mean anything from one to three significant figures, for example.
>>
>>
>> On Fri, Jan 17, 2014 at 1:47 AM, Marc Ordinas i Llopis <
>> [hidden email]> wrote:
>>
>> > On Fri, Jan 17, 2014 at 9:58 AM, Petr Bena <[hidden email]> wrote:
>> >
>> > > For example you would say the object has width of {{unit|cm=20}} and
>> > > people who prefer cm would see 20 cm in article text, but people who
>> > > prefer inches would see 7.87 inch.
>> >
>> >
>> > This is a great idea! As proposed it'd be very helpful, but maybe it'd be
>> > better if it showed the original text and a conversion on mouse-over
>> (maybe
>> > with a small icon to indicate it, like external links).
>> >
>> >
>> > > This could be even based on
>> > > geolocation for IP users
>> > >
>> > >
>> > Oh, please, don't use IP geolocation for anything. It's terrible for
>> people
>> > travelling, using proxies, living abroad, living in places where more
>> than
>> > one languages are commonly spoken, learning new languages… If you want to
>> > get an initial default, use Accept-Language (like, inches for en-US and
>> cm
>> > for anyone else :) and allow the user to modify it.
>> >
>> > Thanks,
>> > Marc
>> > _______________________________________________
>> > Wikitech-l mailing list
>> > [hidden email]
>> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>> >
>> _______________________________________________
>> Wikitech-l mailing list
>> [hidden email]
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Gabriel Wicke-3
In reply to this post by Petr Bena
On 01/17/2014 12:58 AM, Petr Bena wrote:
> I think it would be cool if an extension was created which would allow
> everyone to specify what units they prefer, and the values in articles
> would be converted automatically based on preference.

Whatever you do, make it client-side. It would be great to expose type
information with an attribute in HTML, so that it can be used for
client-side unit conversions. Ideally the typed information comes
directly from wikidata (and can be fed to nice table/pie chart/whatever
widgets), but it should also not be too hard to mark up data that lives
on the wiki the same way.

Gabriel

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Tim Landscheidt
Gabriel Wicke <[hidden email]> wrote:

>> I think it would be cool if an extension was created which would allow
>> everyone to specify what units they prefer, and the values in articles
>> would be converted automatically based on preference.

> Whatever you do, make it client-side. It would be great to expose type
> information with an attribute in HTML, so that it can be used for
> client-side unit conversions. Ideally the typed information comes
> directly from wikidata (and can be fed to nice table/pie chart/whatever
> widgets), but it should also not be too hard to mark up data that lives
> on the wiki the same way.

There's also http://microformats.org/wiki/measure for a more
standardized solution that could work on other websites as
well.

Tim


_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Petr Bena
In reply to this post by Gabriel Wicke-3
it can't be done client side. It must be done on both sides, so that
user can save their preference into database without having to set it
everytime they get their cookies wiped (which in my case is like 10
times a day just by switching devices and browsers)

On Fri, Jan 17, 2014 at 7:15 PM, Gabriel Wicke <[hidden email]> wrote:

> On 01/17/2014 12:58 AM, Petr Bena wrote:
>> I think it would be cool if an extension was created which would allow
>> everyone to specify what units they prefer, and the values in articles
>> would be converted automatically based on preference.
>
> Whatever you do, make it client-side. It would be great to expose type
> information with an attribute in HTML, so that it can be used for
> client-side unit conversions. Ideally the typed information comes
> directly from wikidata (and can be fed to nice table/pie chart/whatever
> widgets), but it should also not be too hard to mark up data that lives
> on the wiki the same way.
>
> Gabriel
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Petr Bena
Also this is not anything I am going to do just myself. This is
something WE should do. I have like 0 knowledge of this kind of
things, I was just thinking it would be a nice thing to have. Some
interface developer who is master of JS and such is needed to make
this. I can help of course, but basically I am just proposing an idea
:-)

On Fri, Jan 17, 2014 at 11:11 PM, Petr Bena <[hidden email]> wrote:

> it can't be done client side. It must be done on both sides, so that
> user can save their preference into database without having to set it
> everytime they get their cookies wiped (which in my case is like 10
> times a day just by switching devices and browsers)
>
> On Fri, Jan 17, 2014 at 7:15 PM, Gabriel Wicke <[hidden email]> wrote:
>> On 01/17/2014 12:58 AM, Petr Bena wrote:
>>> I think it would be cool if an extension was created which would allow
>>> everyone to specify what units they prefer, and the values in articles
>>> would be converted automatically based on preference.
>>
>> Whatever you do, make it client-side. It would be great to expose type
>> information with an attribute in HTML, so that it can be used for
>> client-side unit conversions. Ideally the typed information comes
>> directly from wikidata (and can be fed to nice table/pie chart/whatever
>> widgets), but it should also not be too hard to mark up data that lives
>> on the wiki the same way.
>>
>> Gabriel
>>
>> _______________________________________________
>> Wikitech-l mailing list
>> [hidden email]
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Gabriel Wicke-3
In reply to this post by Petr Bena
On 01/17/2014 02:11 PM, Petr Bena wrote:
> it can't be done client side. It must be done on both sides, so that
> user can save their preference into database without having to set it
> everytime they get their cookies wiped (which in my case is like 10
> times a day just by switching devices and browsers)

Sorry if I wasn't clear; yes, saving the preference is fine. I am mainly
concerned about keeping the page content independent of the preference,
so that we can serve the same cached content to anonymous and logged-in
users. Currently that is not yet possible, but we are working on
eliminating the last preference dependencies so that logged-in users can
get the same performance as anonymous users.

Gabriel

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic unit conversion

Petr Bena
Yes that sounds pretty good to me, I also think it would be much
better for this to be handled on client side, I don't really see any
problem with caching, but what I am not sure is if this could be
implemented without having to update the articles with some magic
words etc. But even if we had to, it still would be just a one time
update.

On Fri, Jan 17, 2014 at 11:30 PM, Gabriel Wicke <[hidden email]> wrote:

> On 01/17/2014 02:11 PM, Petr Bena wrote:
>> it can't be done client side. It must be done on both sides, so that
>> user can save their preference into database without having to set it
>> everytime they get their cookies wiped (which in my case is like 10
>> times a day just by switching devices and browsers)
>
> Sorry if I wasn't clear; yes, saving the preference is fine. I am mainly
> concerned about keeping the page content independent of the preference,
> so that we can serve the same cached content to anonymous and logged-in
> users. Currently that is not yet possible, but we are working on
> eliminating the last preference dependencies so that logged-in users can
> get the same performance as anonymous users.
>
> Gabriel
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l