use smart combinator in geo-ip
parent
c97ed1fc37
commit
fe62bebb4b
|
@ -4,7 +4,7 @@ USING: kernel sequences io.files io.files.temp io.launcher
|
||||||
io.pathnames io.encodings.ascii io.streams.string http.client
|
io.pathnames io.encodings.ascii io.streams.string http.client
|
||||||
generalizations combinators math.parser math.vectors
|
generalizations combinators math.parser math.vectors
|
||||||
math.intervals interval-maps memoize csv accessors assocs
|
math.intervals interval-maps memoize csv accessors assocs
|
||||||
strings math splitting grouping arrays ;
|
strings math splitting grouping arrays combinators.smart ;
|
||||||
IN: geo-ip
|
IN: geo-ip
|
||||||
|
|
||||||
: db-path ( -- path ) "IpToCountry.csv" temp-file ;
|
: db-path ( -- path ) "IpToCountry.csv" temp-file ;
|
||||||
|
@ -20,15 +20,17 @@ IN: geo-ip
|
||||||
TUPLE: ip-entry from to registry assigned city cntry country ;
|
TUPLE: ip-entry from to registry assigned city cntry country ;
|
||||||
|
|
||||||
: parse-ip-entry ( row -- ip-entry )
|
: parse-ip-entry ( row -- ip-entry )
|
||||||
7 firstn {
|
[
|
||||||
[ string>number ]
|
{
|
||||||
[ string>number ]
|
[ string>number ]
|
||||||
[ ]
|
[ string>number ]
|
||||||
[ ]
|
[ ]
|
||||||
[ ]
|
[ ]
|
||||||
[ ]
|
[ ]
|
||||||
[ ]
|
[ ]
|
||||||
} spread ip-entry boa ;
|
[ ]
|
||||||
|
} spread
|
||||||
|
] input<sequence ip-entry boa ;
|
||||||
|
|
||||||
MEMO: ip-db ( -- seq )
|
MEMO: ip-db ( -- seq )
|
||||||
download-db ascii file-lines
|
download-db ascii file-lines
|
||||||
|
|
Loading…
Reference in New Issue