Chess::FIDE - Perl extension for FIDE Rating List
use Chess::FIDE; my $fide = Chess::FIDE->new(-file=>'filename'); my @results = $fide->fideSearch("surname eq 'Kasparov'"); $fide->dumpPlayer($results);
Chess::FIDE - Perl extension for FIDE Rating List. FIDE is the International Chess Federation that releases a list of its rated members every month. The list contains about five hundred thousand entries. This module is designed to parse its contents and to search across it using perl expressions. A sample from an up-to-date FIDE list is provided in t/data/test-list-2.txt, while the older list sample is still available in t/data/test-list.txt
The following methods are available:
$fide = Chess::FIDE->new(-file => 'localfile'); $fide = Chess::FIDE->new(-www => 1, [ -proxy=>proxyaddress, -url => URL ]);
There are two types of constructors - one takes a local file and another one retrieves the up-to-date zip file from the FIDE site, unzips it on the fly and parses the output immediately. In case of the second constructor no files are created. Also usage of an optional proxy is possible in the second case. Also a specific URL may be specified to retrieve the file.
Each player entry in the file is scanned against a regexp and then there is a post-parsing as well which is implemented in function parseLine. The entry is then stored in an object defined by the module Chess::FIDE::Player (see its documentation). The whole list of players is stored in the players field of the Chess::FIDE object.
@result = $fide->fideSearch("perl conditional", [ @arrayref ]); Example: @result = $fide->fideSearch("surname eq 'Kasparov'");
Searches the fide object for entries satisfying the conditional specified as the argument. The conditional operator MUST be a PERL operator. The first operand must be a valid field of the FIDE rating list. The second operand must be a value within single quotes because the conditional is 'eval'ed against each entry. Any conditional operand including a regexp match that may be eval-ed is valid. For the fields to use in conditionals see Chess::FIDE::Player documentation. Only single condition is supported at this stage. Optionally, an list of Chess::FIDE::Player objects may be supplied to search against, for example you can feed the results of the previous query.
Dumps a ready to use header for a list of players to display.
my @results = $fide->fideSearch("surname eq 'Kasparov'"); $fide->dumpPlayer($results);
Dumps a player object in the format almost identical to the one it was read from and ready to be re-read if necessary.
Load the empty FIDE object with the content specified either in -www or -file switch.
Converts names from the headers of old FIDE files to the new ones, where required.
Parse the header of the FIDE file and assign string positions of the detected fields.
Parse additionally the name of the player and deduct surname and given name from it.
Parse a line from the file of FIDE ratings.
Parse the file of FIDE ratings.
The only unique entry is the id field. There are, for example, two "Sokolov, Andrei" entries, so a search by name might be ambiguous.
Please note that the files on FIDE website are available only for the year 2001 and later.
Roman M. Parparov, <firstname.lastname@example.org>
Copyright (C) 2004-2015 by Roman M. Parparov
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.
Fide Rating List is Copyright (C) by the International Chess Federation http://www.fide.com