It is currently November 14th, 2019, 7:44 am

logical error in Tips & Tricks

Discussion about the documentation, main Rainmeter site and forums.
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

logical error in Tips & Tricks

moshi » August 9th, 2014, 5:13 am

the "WebParser: Weather Skin Translations" trick here:
http://docs.rainmeter.net/tips/webparser-weather-skin-translations
has an error. it tells you to do:

Code: Select all

Substitute="Cloudy":"Bewölkt","Partly Cloudy":"Teilweise Bewölkt"
this can never work. because the "Cloudy" part of "Partly Cloudy" will be substituted before you substitute the complete string. you will get "Partly Bewölkt".


it would make more sense to substitute the longer strings before the shorter ones:

Code: Select all

Substitute="Partly Cloudy":"Teilweise Bewölkt","Cloudy":"Bewölkt"

that still has flaws. better:

Code: Select all

RegExpSubstitute=1
Substitute="^Cloudy$":"Bewölkt","^Partly Cloudy$":"Teilweise Bewölkt"

best though to use the numbers:

Code: Select all

RegExpSubstitute=1
Substitute="^26$":"Bewölkt","^30$":"Teilweise Bewölkt"
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: logical error in Tips & Tricks

moshi » May 9th, 2015, 1:37 pm

moshi wrote:best though to use the numbers:

Code: Select all

Select all
RegExpSubstitute=1
Substitute="^26$":"Bewölkt","^30$":"Teilweise Bewölkt"
because right now my Yahoo! Weather skin displays: "Showers in the Vicinity" :)
User avatar
jsmorley
Developer
Posts: 19706
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: logical error in Tips & Tricks

jsmorley » May 10th, 2015, 1:38 pm

I'm not sure I follow...

In the version I get in my browser, it has:

Substitute="(?i)^Cloudy$":"Bewölkt","^Partly Cloudy$":"Teilweise Bewölkt"

Which since it is using the ^ and $ characters to indicate the start and end of the string, should deal with any issues of "order".
1.png
What am I missing here?

P.S. The numbers probably are the better way to go, but in that tutorial I really wanted to focus more on Substitute in the pure "translation" sense, and not have that get lost in what is in effect a "lookup" rather than a "translation".

You are exactly right though. Yahoo Weather doesn't really have an entirely consistent description for any given weather code, and in a sense creating your own, with a single description tied to the code number, is more reliable. I might need to re-think this. I'm hesitant to suggest losing the subtleties of their descriptions by having "11" just always be "Showers", but I'm not sure you can reliably translate it any other way.
You do not have the required permissions to view the files attached to this post.
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: logical error in Tips & Tricks

moshi » May 10th, 2015, 3:30 pm

jsmorley wrote:I'm not sure I follow...

In the version I get in my browser, it has:

Substitute="(?i)^Cloudy$":"Bewölkt","^Partly Cloudy$":"Teilweise Bewölkt"

Which since it is using the ^ and $ characters to indicate the start and end of the string, should deal with any issues of "order".

What am I missing here?
i am pretty sure it has been changed since the time i made the first post (August 2014).


jsmorley wrote:You are exactly right though. Yahoo Weather doesn't really have an entirely consistent description for any given weather code, and in a sense creating your own, with a single description tied to the code number, is more reliable. I might need to re-think this. I'm hesitant to suggest losing the subtleties of their descriptions by having "11" just always be "Showers", but I'm not sure you can reliably translate it any other way.
can't use a translation api, because without context a "shower" is this:
euphoria-system-shower-system-with-diverter-for-wall-mounting.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 19706
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: logical error in Tips & Tricks

jsmorley » May 10th, 2015, 3:39 pm

moshi wrote: i am pretty sure it has been changed since the time i made the first post (August 2014).
Ah, my bad, I didn't look at the dates of the posts, and assumed they were all just now. Never mind. I did fix that quite a while ago, probably based on your original post.
User avatar
jsmorley
Developer
Posts: 19706
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: logical error in Tips & Tricks

jsmorley » May 10th, 2015, 3:47 pm

moshi wrote: can't use a translation api, because without context a "shower" is this:
Probably need to set up some kind of "learning" system, where it somehow flags "phrases" it doesn't already know, so you can go in and translate them manually. Then over time, you could probably get close. I suspect that Yahoo has some "finite" number of ways to express the conditions, even if is a large number. Surely every 10 minutes it isn't some human saying "let's call this 'hot and sticky' this time".
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: logical error in Tips & Tricks

moshi » May 10th, 2015, 4:07 pm

- a local file with known expressions (separated by commas or whatever)
- a skin that parses a few locations (probably best if one after another), preferably locations with extreme weather conditions
- FinishAction launches a dynamic webparser measure that parses the local file for the current expression
- IfNotMatchAction append current expression to local file
after a longer period of time there should be a nice list.

but there has to be a better way.
User avatar
jsmorley
Developer
Posts: 19706
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: logical error in Tips & Tricks

jsmorley » May 10th, 2015, 4:17 pm

moshi wrote:- a local file with known expressions (separated by commas or whatever)
- a skin that parses a few locations (probably best if one after another), preferably locations with extreme weather conditions
- FinishAction launches a dynamic webparser measure that parses the local file for the current expression
- IfNotMatchAction append current expression to local file
after a longer period of time there should be a nice list.

but there has to be a better way.
The better way is probably for Yahoo to allow a "langID" parm on the feed URL, and get with the fact that the internet isn't just about English speakers.
User avatar
jsmorley
Developer
Posts: 19706
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: logical error in Tips & Tricks

jsmorley » May 10th, 2015, 4:25 pm

Although another approach is to "roll your own". By that I mean ignore the description from Yahoo. Create your own based on a weighted combination of the "season / weather code / temperature / humidity / dew point / wind / gusts", where you could drive a description where a relative "importance" could be given to these factors, and "weight" that with how far out of some defined "norm" any of the values are.

So you could end up with "Hot and sticky" or "Windy and clear" or even "Chilly, breezy and party cloudy". If you did it right, there might be a subtle but real difference between "Windy and clear" and "Clear and windy".

Almost certainly require Lua, and there are factors like "partly" that might be hard to determine, but feels like there should be some formulaic way to get to a description that is as good, maybe better, than you get as raw text in the feed.

Be a fair to middling big project... ;-)
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: logical error in Tips & Tricks

moshi » May 10th, 2015, 6:03 pm

you'll end up using the description from Yahoo again. there's no precipitation data elsewhere in the feed.