Parser error with part of Example 1.

Create issue
Issue #65 resolved
Former user created an issue

Hi ! I've taken just the part that is commented out of the Example 1, because it is the most interesting to me, so my categorize.cfg file is:

-- -*- mode: haskell; -*-
-- Comments in this file use the Haskell syntax:
-- A "--" comments the rest of the line.
-- A set of {- ... -} comments out a group of lines.



-- To be able to match on the time of day, I introduce tags for that as well.
-- $time evaluates to local time.
$time >=  2:00 && $time <  8:00 ==> tag time-of-day:night,
$time >=  8:00 && $time < 12:00 ==> tag time-of-day:morning,
$time >= 12:00 && $time < 14:00 ==> tag time-of-day:lunchtime,
$time >= 14:00 && $time < 18:00 ==> tag time-of-day:afternoon,
$time >= 18:00 && $time < 22:00 ==> tag time-of-day:evening,
$time >= 22:00 || $time <  2:00 ==> tag time-of-day:late-evening,

-- This tag always refers to the last 24h
$sampleage <= 24:00 ==> tag last-day,

-- To categorize by calendar periods (months, weeks, or arbitrary periods),
-- I use $date variable, and some auxiliary functions. All these functions
-- evaluate dates in local time. Set TZ environment variable if you need
-- statistics in a different time zone.

-- You can compare dates:
$date >= 2001-01-01 ==> tag this_century,
-- You have to write them in YYYY-MM-DD format, else they will not be recognized.

-- “format $date” produces a string with the date in ISO 8601 format
-- (YYYY-MM-DD), it may be compared with strings. For example, to match
-- everything on and after a particular date I can use
format $date =~ ".*-03-19"  ==> tag period:on_a_special_day,
-- but note that this is a rather expensive operation and will slow down your
-- data processing considerably.

-- “day of month $date” gives the day of month (1..31),
-- “day of week $date” gives a sequence number of the day of week
-- (1..7, Monday is 1):
(day of month $date == 13) && (day of week $date == 5) ==> tag day:friday_13,

-- “month $date” gives a month number (1..12), “year $date” gives a year:
month $date == 1 ==> tag month:January,
month $date == 2 ==> tag month:February,
year $date == 2010 ==> tag year:2010,

-- “$now” evaluates to the current time
day of month $now == day of month $date ==> tag current-day,
month $now == month $date ==> tag current-month,
year $now == year $date ==> tag current-year,

When I run arbtt-stats --dump-samples, I get the following error:

Parser error:
"/home/matthieu/.arbtt/categorize.cfg" (line 32, column 32):
unexpected '>'
expecting end of "=="

The line 32 is the line: format $date =~ ".*-03-19" ==> tag period:on_a_special_day,. When I comment it out, I still get a parser error on line 47: day of month $now == day of month $date ==> tag current-day,

I need to also comment ou the last 3 lines for it not to make a parser error. Could you tell me why such a simple example doesn't work ? I'm on version 0.9.0.7 on Ubuntu 18.04.

Thanks !

Comments (5)

  1. nomeata repo owner

    Sorry for the bad error message. The right syntax seems to be

    format $date =~ /.*-03-19/  ==> tag period:on_a_special_day,
    

    I.e. use / for regexes.

  2. Matthieu Heitz

    Hi !
    Thank you for correcting the first line.

    However, I still get a parser error with each of the last 3 lines:

    -- “$now” evaluates to the current time
    day of month $now == day of month $date ==> tag current-day,
    month $now == month $date ==> tag current-month,
    year $now == year $date ==> tag current-year,
    

    Do you know what could be the cause ?

  3. Log in to comment