Page 1 of 1
Issues with extracting date from Amazon Web Services Invoice

Posted:
Thu Jun 20, 2013 5:59 pm
by inbloom
Recently I've updated Hazel to version 3.1. For the most part the new date extracting feature has worked well. However I have two issues. First, Hazel doesn't seem to recognize months in a other language than the system language. Can someone confirm this is the case?
I suspect this because the format of the AWS invoice is "TOTAL AMOUNT DUE ON March 3 , 2011"
In Swedish, March is "mars", and because my Macs system language is Swedish Hazel don't know that March is a month. When I run the same rule on an invoice with the due date of April or December, which are the same in Swedish, Hazel recognizes the month. I have both English and Swedish invoices and I would like to use the date extracting feature on all of them.
That was the first issue. My second issue is that even on the AWS invoices Hazel acts on, it always thinks the month is June. My rule is that I rename the file to aws-"due date".extension. It always renames it to aws-06.pdf, or aws-juni.pdf depending on the format chosen. I would like to know if there are any other AWS users who have this problem.
Re: Issues with extracting date from Amazon Web Services Inv

Posted:
Fri Jun 21, 2013 10:54 am
by Mr_Noodle
Hazel can only match the months in the current language of the system. To have it try months in every language would be a bit much.
As for the second issue, can you email your rule and a sample file to demonstrate the problem?
Re: Issues with extracting date from Amazon Web Services Inv

Posted:
Fri Jun 21, 2013 3:35 pm
by Mr_Noodle
Actually, another user emailed in a sample rule and file to demonstrate the second problem which I can replicate here. There should be a fix for that in the next patch.
Re: Issues with extracting date from Amazon Web Services Inv

Posted:
Thu Jul 25, 2013 1:14 pm
by inbloom
THANK YOU for fixing the Amazon issue, and for adding this feature in 3.1.3:
"If the region setting is not English, date tokens will match English months in addition to months in the current region setting"
Works great on my Amazon invoices

Re: Issues with extracting date from Amazon Web Services Inv

Posted:
Thu Jul 25, 2013 2:52 pm
by Mr_Noodle
Oh good. I got enough requests and it seemed in every case, it was english in addition to their native language. Will have to re-think things if someone wants it to be two non-english languages.
Re: Issues with extracting date from Amazon Web Services Inv

Posted:
Tue Oct 08, 2013 6:17 am
by ericwillems
This is how I've set up extracting dates that can be in a different language than the system language.
I'm Dutch, but live in New Zealand and have most of my documents in English. Occasionally I have a Dutch document and most of the month names in Dutch are different from English.
I've set up a folder to add the extracted date to the file name. This folder has several rules that check dates in various formats: dd/mm/yyyy, dd/mm/yy, d/m/yy, dd mon yyyy, etc. One of the last rules checks for the Dutch month names. It uses an "if any ..." with 12 "Contents contain match" conditions, one for each month.
Each condition uses a Date element with a hardcoded month name. It includes the day token (31) and the year token (1999), but not the month token. Instead, the month name is hardcoded. So, the pattern is "31 <month name in Dutch> 1999", for example, "31 mei 1999". I've named all these patterns after the month name they match.
At this stage I've got 12 variables that each match a date pattern with a month name in Dutch. If there is a match then only one variable will have a value (assuming that Hazel will stop searching after the first match because it is an "if any").
The rule then renames the file by including all 12 variables. Since only one variable will have a value, the output will be only one date.
When including these variables, I've edited the date pattern to include the month numbers. The date pattern includes the day token (31) and the year token (1999), and hardcoded the month number that corresponds with the month variable. For example, the "mei" variable gets the date pattern "1999-05-31".
That's it. It takes a while to set up, but it works. It's probably not the most efficient because Hazel needs to scan the document up to 12 times, but I didn't notice any performance degradation.
In theory, this technique could be used to set up rules for other languages as well.
If a language has only a few months different to the system language a fallback condition could be set up that does include the month token (December). Only the months that are different would then need a specific condition.
Re: Issues with extracting date from Amazon Web Services Inv

Posted:
Fri Nov 22, 2013 10:57 am
by jonaswouters
@ericwillems that seems like a lot of work to support an additional language.
My system is set to English but I get Dutch invoices ... so it would be great if date matching would work with any secondary languages setup in the system.
https://www.dropbox.com/s/3h8q8jxebhsv6 ... .53.52.PNG"If the region setting is not English, date tokens will match English months in addition to months in the current region setting" is a great addition already ...
Maybe having a setting where you can add additional matches for the month names?

Re: Issues with extracting date from Amazon Web Services Inv

Posted:
Fri Nov 22, 2013 12:38 pm
by Mr_Noodle
I'd like to avoid special UI for this type of thing. It also is not straightforwards, since (though I may be mis-remembering) the Apple APIs don't really give you access to the list of languages. The system either picks which language resource to use or it hands back things to use for the current language, whatever that happens to be.