Debian Codegraph @

docs/ascii/citeparser.txt

raw
1 ==============================================================================
2 Biblio::Citation::Parser 1.10 Documentation
3 ==============================================================================
4
5 Contents:
6 - Introduction
7 - Required Software
8 - How to Install Biblio::Citation::Parser
9 - Reference Parsing
10 - ParaCite Web Service
11 - Troubleshooting
12 - How-To Guides
13 - Problems, Questions and Feedback
14
15 ==============================================================================
16 Introduction
17 ==============================================================================
18
19 What is ParaTools?
20 ParaTools, short for ParaCite Toolkit, is a collection of Perl modules for
21 reference parsing that is designed to be easily expanded and yet simple to
22 use. The parsing modules make up the core of the package, but there are
23 also useful modules to assist with OpenURL creation and the extraction of
24 references from documents. The toolkit is released under the GNU Public
25 License, so can be used freely as long as the source code is provided (see
26 the COPYING file in the root directory of the distribution for more
27 information).
28
29 The toolkit came about as a result of the ParaCite resource, a reference
30 search engine located at http://paracite.eprints.org, which uses a
31 template-based reference parser to extract metadata from provided
32 references and then provides search results based on this metadata. The
33 ParaCite parser is provided directly as the
34 Biblio::Citation::Parser::Standard module, with a separate Templates
35 module that can be replaced as new reference templates are located.
36
37 As well as providing examples for the provided parsing modules, ParaTools
38 also includes examples for using the ParaCite web service. This is an
39 alternate interface which provides access to ParaCite's search and parsing
40 functionality for any language that supports the Web Services Description
41 Language (WSDL).
42
43 Who should use ParaTools?
44 The ParaTools package has many applications, including:
45
46 * Converting reference lists into valid OpenURLs
47
48 * Converting existing metadata into valid OpenURLs
49
50 * Collecting metadata from references to carry out internal searches
51
52 * Extracting reference lists from documents
53
54 * Carrying out searches using ParaCite
55
56 The modularity of ParaTools means that it is very easy to add new
57 techniques (and we would be very pleased to hear of new ones!).
58
59 What will it run on?
60 ParaTools should work on any platform that supports Perl 5.6.0 or higher,
61 although testing was primarily carried out using Red Hat Linux 7.3 with
62 Perl 5.6. Where possible platform-agnostic modules have been used for file
63 functionality, so temporary files should be placed in the correct place
64 for the operating system. Memory requirements for ParaTools are minimal,
65 although the template parser and document parser will require more memory
66 as the number of templates and sizes of documents increase.
67
68 This Documentation
69 This documentation is written in perl POD format and converted into
70 Postscript (which is 2 pages to a sheet for printing), ASCII, PDF, and
71 HTML.
72
73 The latest version of this documentation can be obtained from
74 http://paracite.eprints.org/files/docs/
75
76
77 ==============================================================================
78 Required Software
79 ==============================================================================
80
81 What software does Biblio::Citation::Parser need?
82 Perl Modules
83 URI URI is required for the OpenURL encoding functions in
84 Biblio::Citation::Parser::Utils.
85
86 Text::Unidecode
87 Used by Biblio::Citation::Parser::Citebase to allow for matching
88 on unicode strings.
89
90 URI::OpenURL (Optional)
91 If you wish to create valid OpenURLs, URI::OpenURL provides a set
92 of functions for this purpose. The metadata produced by
93 Biblio::Citation::Parser can be used with this module.
94
95 SOAP::Lite (Optional)
96 This module is required if you wish to use the ParaCite web
97 services, but optional otherwise. This requires several other
98 modules, which are available in the soap subdirectory of
99 http://paracite.eprints.org/files/perlmods/.
100
101 There are also some dependencies for the above modules, including
102 MIME::Base64, HTML::TagSet, and Digest::MD5. The latest versions of these
103 can be obtained from http://www.cpan.org/
104
105 Installing Perl Modules
106 This describes the way to install a simple perl module, some require a bit
107 more effort. We will use the non-existent FOO module as an example.
108
109 Unpack the archive:
110 % tar xfvz FOO-5.2.34.tar.gz
111
112 Enter the directory this creates:
113 % cd FOO-5.2.34
114
115 Run the following commands:
116 % perl ./Build.PL
117 % ./Build
118 % ./Build test
119 % ./Build install
120
121
122 ==============================================================================
123 How to Install Biblio::Citation::Parser
124 ==============================================================================
125
126 Installation
127 First unpack the Biblio::Citation::Parser archive:
128
129 % tar xfvz <packagename>.tar.gz
130
131 Move into the unpacked folder, and then do the following:
132
133 % perl Build.PL
134 % ./Build
135
136 You can optionally run
137
138 % ./Build test
139
140 which will carry out a few checks to ensure everything is working
141 correctly.
142
143 Finally, become root and do:
144
145 % ./Build install
146
147 This will install the modules and man pages into the correct locations.
148
149 Examples
150 The examples directory contains two categories of examples - parsing
151 examples and web service examples. Note that the web service examples
152 require the SOAP::Lite module (see Required Software for more
153 information). To try out these samples after installation, simply cd into
154 the directory and execute the example. More information about the examples
155 is in the README file inside the examples directory.
156
157
158 ==============================================================================
159 Reference Parsing
160 ==============================================================================
161
162 Parsing References
163 Biblio::Citation::Parser is designed for parsing citations, and this can
164 be done very simply:
165
166 use Biblio::Citation::Parser::Standard;
167 my $parser = new Biblio::Citation::Parser::Standard();
168 my $metadata = $parser->parse("Jewell, M (2002) Parsing Examples");
169
170 The $metadata variable is a hash containing the information extracted from
171 the reference.
172
173 If you'd prefer to use another parser, simply substitute the 'Standard'
174 for the appropriate module. Biblio::Citation::Parser is distributed with
175 the Jiao module, which is a slightly modified version of a module created
176 by Zhuoan Jiao. To use this instead of the Standard module, you would do
177 the following:
178
179 use Biblio::Citation::Parser::Jiao;
180 my $parser = new Biblio::Citation::Parser::Jiao();
181 my $metadata = $parser->parse("Jewell, M (2002) Parsing Examples");
182
183 The Standard module provides slightly richer metadata than the Jiao
184 module, but it does rely on templates (see
185 Biblio::Citation::Parser::Templates) so requires updating as new citation
186 formats are found.
187
188 Creating an OpenURL
189 Once you have the metadata from the reference, it is easy to create an
190 OpenURL from it:
191
192 use Biblio::Citation::Parser::Standard;
193 use Biblio::Citation::Parser::Utils;
194 my $parser = new Biblio::Citation::Parser::Standard();
195 my $metadata = $parser->parse("Jewell, M (2002) Parsing Examples");
196 my $openurl = create_openurl($metadata);
197
198 The OpenURLs created by Biblio::Citation::Parser do not have a Base URL
199 prefixed, so this should be carried out before they are used (the ParaCite
200 base URL is http://paracite.eprints.org/cgi-bin/openurl.cgi).
201
202 If you would like to try to extract more information from the metadata,
203 you can use the "decompose_openurl" function:
204
205 my ($enriched_metadata, @errors) = decompose_openurl($metadata);
206
207 This tries to extract information from SICIs, page ranges, etc, and also
208 checks the fields for validity (the @errors array contains any mistakes).
209
210 Note that the create_openurl has been superceded by URI::OpenURL, but the
211 metadata returned by "trim_openurl" is in the correct format to be passed
212 to this module.
213
214 Metadata Structure
215 Biblio::Citation::Parser supports all of the fields specified in Table 1
216 of the OpenURL specification (http://www.sfxit.com/openurl/openurl.html).
217 Specific parsers can add their own fields, but these are not exported when
218 OpenURLs are created. Biblio::Citation::Parser::Standard provides the
219 following extra fields:
220
221 marked A marked-up version of the reference. e.g. <author>Jewell,
222 M</author> (<year>2002</year>) <title>A title</title>.
223
224 match The template matched by Biblio::Citation::Parser::Standard
225
226 ref The original reference
227
228
229 ==============================================================================
230 ParaCite Web Service
231 ==============================================================================
232
233 The ParaCite Web Service
234 The Biblio::Citation::Parser package includes several examples that
235 demonstrate the ParaCite web service, as well as the WSDL definition file.
236 This section explains the web service, and gives an introduction to using
237 it.
238
239 As ParaCite is written entirely in Perl, there are obvious issues if you
240 wish to use Java, PHP, or another language. The ParaCite web services
241 provides an interface into the reference parsing features of ParaCite,
242 while remaining language agnostic.
243
244 Using the Web Service from Perl
245 To access the web service from Perl requires the SOAP::Lite module (see
246 Required Software). Once this is present, this is all that is required to
247 connect to the web service:
248
249 my $service = SOAP::Lite
250 -> service("http://paracite.eprints.org/paracite.wsdl");
251
252 Three functions are now available from the $service variable:
253
254 doOpenURLConstruct($reference, $baseurl)
255 This returns an OpenURL, prefixed by the base URL if one is
256 provided.
257
258 doReferenceParse($reference, $baseurl)
259 This returns a hash containing the metadata in the reference, and
260 an OpenURL formed using the metadata and the base URL.
261
262 doParaciteSearch($reference, $baseurl)
263 This returns an hash containing 'resultElements' (an array of
264 search results), and 'metadata' (a hash of metadata).
265
266 Web Service Examples
267 The following code parses a reference, and stores the metadata in
268 $metadata and the OpenURL in $openurl:
269
270 use SOAP::Lite;
271 my $service = SOAP::Lite
272 -> service("http://paracite.eprints.org/paracite.wsdl");
273 my $base_url = "http://paracite.eprints.org/cgi-bin/openurl.cgi?";
274 my $result = $service
275 -> doReferenceParse("Jewell, M (2002) Example", $base_url);
276 my $metadata = $result->{metadata};
277 my $openurl = $result->{openURL};
278
279 If you do not want the metadata, and just want a link to an OpenURL
280 resolver, the following will do that:
281
282 use SOAP::Lite;
283 my $service = SOAP::Lite
284 -> service("http://paracite.eprints.org/paracite.wsdl");
285 my $base_url = "http://paracite.eprints.org/cgi-bin/openurl.cgi?";
286 my $open_url = $service
287 -> doOpenURLConstruct("Jewell, M (2002) Example", $base_url);
288
289 Finally, this example uses the doParaciteSearch method to get the first
290 match on a reference:
291
292 use SOAP::Lite;
293 my $service = SOAP::Lite
294 -> service("http://paracite.eprints.org/paracite.wsdl");
295 my $base_url = "http://paracite.eprints.org/cgi-bin/openurl.cgi?";
296 my $query = "Harnad, Stevan (1995) The PostGutenberg Galaxy.";
297 my $result = $service
298 -> doParaciteSearch($query, $base_url);
299 my $first_result = $result->{resultElements}->[0];
300 print "First result is: ".$first_result->{URL}."\n";
301
302 The web service automatically adds Google, Scirus, and Vivissimo as
303 resources to the search request, so if no resources match the publication
304 or subject these will be used as fall-backs.
305
306 Web Service Structures
307 Most of the Paracite structures have been modelled very closely on the
308 Google web service structures to allow some degree of standardisation.
309 Some additions have been made, and some fields are not yet used, but these
310 may change in future versions.
311
312 ParaciteSearchResult
313 resultElements
314 This is an array of resources, along with the search URLs
315 associated with them. See the ResultElement description later in
316 this section.
317
318 estimatedTotalResultsCount
319 This returns the number of items in the resultElements array.
320
321 estimateIsExact
322 This currently always returns 1.
323
324 searchQuery
325 This contains the original reference.
326
327 openURL This contains the OpenURL represented by the reference metadata
328 (prefixed by base URL if one is supplied).
329
330 metadata
331 This is a Metadata object (see later in this section).
332
333 ResultElement
334 URL This is a URL that searches the current resource for the
335 reference.
336
337 template
338 This contains the template of the matching resource interface that
339 was used to generate the search URL.
340
341 name The name of the resource (e.g. Google).
342
343 description
344 Some more information about the resource.
345
346 tollfree
347 A boolean value that is true if the results can be viewed without
348 cost.
349
350 fulltext
351 A boolean value that is true if a resulting article from this
352 resource will have the full text available.
353
354 stratum An integer representing the stratum in which this resource lies. A
355 complete list of the strata is available at
356 http://paracite.eprints.org/cgi-bin/views/viewstrata.cgi
357
358 Metadata
359 All of the fields in Metadata are valid fields in OpenURL metadata. See
360 Table 1 at http://www.sfxit.com/openurl/openurl.html for a complete list.
361
362
363 ==============================================================================
364 Troubleshooting
365 ==============================================================================
366
367 Troubleshooting
368 If you cannot find a solution to your problem here, make sure you are
369 using the latest version of the toolkit and ask on the ParaTools mailing
370 list (see http://paracite.eprints.org/developers/).
371
372 Reference Parsing
373 Reference does not parse correctly
374 If you are using the Standard parsing module, make sure that a template
375 for the reference exists in the package. See the HOWTO for more
376 information on how to do this. If you are using a contributed module,
377 please email your query to the author of the module.
378
379
380 ==============================================================================
381 How-To Guides
382 ==============================================================================
383
384 HOW TO: Modify Templates in Biblio::Citation::Parser::Standard
385 Adding new templates to the Standard parser is relatively easy:
386
387 * Locate where your Templates.pm file has been installed.
388
389 On Linux systems this should just involve doing 'locate
390 Templates.pm', otherwise 'find / -name Templates.pm' should work.
391 Alternatively, you can edit the Templates.pm in the
392 Biblio/Citation/Parser/ directory of an unpacked distribution, and
393 install it once you have finished.
394
395 * Add the template to the list.
396
397 If you are editing an already installed Templates.pm file you will
398 probably have to be root to do this. If you are editing the
399 Templates.pm inside an unpacked distribution, you will have to
400 reinstall the modules once you are finished (see the Installation
401 section).
402
403 The Templates.pm file should contain a structure similar to this:
404
405 $Biblio::Citation::Parser::Templates::templates = [
406 '_AUTHORS_, _PUBLICATION_, _YEAR_, _ISSUE_, _SPAGE_-_EPAGE_',
407 ...
408 ];
409
410 Each template is a string containing a set of placeholders. For example,
411 '_AUTHORS_ (_YEAR_) _TITLE_' can match 'Jewell, M (2002) Title'. The
412 following are valid field names:
413
414 _ANY_ Matches anything.
415
416 _AUFIRST_
417 Matches the first name of an author.
418
419 _AULAST_
420 Matches the last name of an author.
421
422 _AUTHORS_
423 Matches a list of authors.
424
425 _CAPPUBLICATION_
426 Matches a capitalised publication title (e.g. "Journal of
427 Lemurs").
428
429 _CAPTITLE_
430 Matches a capitalised title.
431
432 _CHAPTER_
433 Matches a chapter number.
434
435 _DATE_ Matches a date in nn/nn/nn form.
436
437 _EDITOR_
438 Matches an editor's name.
439
440 _EPAGE_ Matches the last page in a page range.
441
442 _ISBN_ Matches an ISBN number.
443
444 _ISSN_ Matches an ISSN number.
445
446 _ISSUE_ Matches an issue number.
447
448 _PAGES_ Matches a page range in nn-nn form.
449
450 _PUBLICATION_
451 Matches a publication name.
452
453 _PUBLISHER_
454 Matches a publisher name.
455
456 _PUBLOC_
457 Matches the location of a publisher.
458
459 _SPAGE_ Matches the start page.
460
461 _SUBTITLE_
462 Matches a subtitle.
463
464 _TITLE_ Matches an article title.
465
466 _UCPUBLICATION_
467 Matches a publication in entirely upper-case (e.g. JOURNAL OF
468 LEMURS).
469
470 _UCTITLE_
471 Matches a title in entirely upper-case.
472
473 _URL_ Matches a URL.
474
475 _VOLUME_
476 Matches a volume.
477
478 _YEAR_ Matches a year (4 digits).
479
480 HOW TO: Integrate ParaTools with EPrints 2
481 EPrints already contains ParaCite support, but using a specially built
482 version of the module before it was part of ParaTools. To alter your
483 cgi/paracite script to use ParaTools, you need to do the following:
484
485 First replace
486
487 use Citation::Parser::Simple;
488
489 with
490
491 use Biblio::Citation::Parser::Standard;
492
493 Next, replace this line:
494
495 my $parser = new Citation::Parser::Simple();
496
497 with this line:
498
499 my $parser = new Biblio::Citation::Parser::Standard();
500
501 This should work fine, although you can obviously integrate ParaCite more
502 if you wish.
503
504 HOW TO: Create a New Parser
505 Creating a Citation Parser
506 All new citation parsers should be named
507 Biblio::Citation::Parser::SomeName, where SomeName is replaced with a
508 unique name (ideally the author's surname). The parser should extend the
509 Biblio::Citation::Parser module like so:
510
511 package Biblio::Citation::Parser::SomeName;
512 require Exporter;
513 @ISA = ("Exporter", "Biblio::Citation::Parser");
514 our @EXPORT_OK = ( 'new', 'parse' );
515
516 You should then override the 'new' and 'parse' methods:
517
518 e.g.
519
520 sub new
521 {
522 my($class) = @_;
523 my $self = {};
524 return bless($self, $class);
525 }
526
527 sub parse
528 {
529 my($self, $ref) = @_;
530 my $hashout = $self->extract_metadata($ref);
531 return $hashout;
532 }
533
534 This makes it easy for users to swap out one reference parser for another.
535
536
537 ==============================================================================
538 Problems, Questions and Feedback
539 ==============================================================================
540
541 Bug Report Policy
542 There is currently no online bug tracking system. Known bugs are listed in
543 the BUGLIST file in the distribution and a list will be kept on the
544 http://paracite.eprints.org/developers/ site.
545
546 If you identify a bug or "issue" (issues are not bugs, but are things
547 which could be clearer or better), and it's not already listed on the
548 site, please let us know at [email protected] - include all the
549 information you can: what version of Biblio::Citation::Parser (see VERSION
550 if you're not sure), what operating system etc.
551
552 Where to go with Questions and Suggestions
553 There is a mailing list for ParaTools (encompassing
554 Biblio::Citation::Parser) which may be the right place to ask general
555 questions and start discussions on broad design issues.
556
557 To subscribe send an email to [email protected] containing the
558 text
559
560 subscribe paratools
561