citeproc-rb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/README +93 -0
  2. data/Rakefile +73 -0
  3. data/TODO +25 -0
  4. data/VERSION +1 -0
  5. data/data/locales/locales_en.xml +89 -0
  6. data/data/locales/locales_nl.xml +96 -0
  7. data/data/styles/ama.csl +184 -0
  8. data/data/styles/apa.csl +230 -0
  9. data/data/styles/apsa.csl +175 -0
  10. data/data/styles/asa.csl +215 -0
  11. data/data/styles/chicago-author-date.csl +361 -0
  12. data/data/styles/chicago-fullnote-bibliography.csl +665 -0
  13. data/data/styles/chicago-note-bibliography.csl +437 -0
  14. data/data/styles/chicago-note.csl +383 -0
  15. data/data/styles/harvard.csl +185 -0
  16. data/data/styles/ieee.csl +111 -0
  17. data/data/styles/mhra.csl +317 -0
  18. data/data/styles/mla.csl +173 -0
  19. data/data/styles/nature.csl +87 -0
  20. data/data/styles/nlm.csl +118 -0
  21. data/examples/citeproc_driver.rb +174 -0
  22. data/lib/citeproc.rb +28 -0
  23. data/lib/citeproc/csl.rb +647 -0
  24. data/lib/citeproc/csl_parser.rb +479 -0
  25. data/lib/citeproc/csl_processor.rb +485 -0
  26. data/lib/citeproc/csl_reference.rb +228 -0
  27. data/lib/citeproc/filters/bibo/bibo.rb +635 -0
  28. data/lib/citeproc/filters/bibo/bibo_input_filter.rb +242 -0
  29. data/lib/citeproc/filters/bibo/bibo_utils.rb +75 -0
  30. data/lib/citeproc/filters/csl_citation/csl_citation.rb +137 -0
  31. data/lib/citeproc/filters/csl_citation/csl_citation_input_filter.rb +274 -0
  32. data/lib/citeproc/formatters/base_formatter.rb +115 -0
  33. data/lib/citeproc/formatters/xhtml_formatter.rb +144 -0
  34. data/lib/citeproc/input_filter.rb +97 -0
  35. data/test/fixtures/bibo_test_data.n3 +191 -0
  36. data/test/fixtures/bibo_test_data.yaml +96 -0
  37. data/test/fixtures/bibo_test_how_to_cook.n3 +63 -0
  38. data/test/fixtures/bibo_test_zotero.rdf +129 -0
  39. data/test/fixtures/csl_test_data.json +62 -0
  40. data/test/fixtures/csl_test_data.yaml +8 -0
  41. data/test/fixtures/locales/test_locale_en.xml +89 -0
  42. data/test/fixtures/styles/test_csl_parse.csl +230 -0
  43. data/test/fixtures/styles/test_groups.csl +32 -0
  44. data/test/fixtures/styles/test_names.csl +46 -0
  45. data/test/fixtures/styles/test_sort.csl +125 -0
  46. data/test/fixtures/styles/test_text_terms.csl +40 -0
  47. data/test/test_all.rb +14 -0
  48. data/test/test_bibo.rb +20 -0
  49. data/test/test_csl.rb +136 -0
  50. data/test/test_csl_parser.rb +222 -0
  51. data/test/test_sample_bibo.rb +82 -0
  52. metadata +101 -0
@@ -0,0 +1,97 @@
1
+ # == Synopsis
2
+ #
3
+ # The InputFilter is a generic class for converting some form of citation data into
4
+ # variables which can be used by the Citeproc system.
5
+ #
6
+ # NB: The 'canonical' input filter is the BiblioInputFilter, which takes an object model
7
+ # from the Bibliontology as input. As the Bibliontology is intended as an abstract
8
+ # 'core' ontology, designed to represent a large number of potential citation structures,
9
+ # it may make the InputFilter approach redundant. For example, rather than converting
10
+ # BibTeX directly to the internal variable structures of Citeproc, it may be preferrable
11
+ # to convert BibTeX to Bibliontology first. Hence, please subclass InputFilter with care...
12
+ #
13
+ # == Author
14
+ #
15
+ # Liam Magee
16
+ #
17
+ # == Copyright
18
+ #
19
+ # Copyright (c) 2007, Liam Magee.
20
+ # Licensed under the same terms as Ruby - see http://www.ruby-lang.org/en/LICENSE.txt.
21
+ #
22
+
23
+ require 'open-uri'
24
+
25
+ module Citeproc
26
+
27
+ # Base class, defining services expected of a particular input format.
28
+ # Typically, implementations will parse a citation source, and deliver a series of values
29
+ # required by the CSL Formatter.
30
+ # Note: this class should never be instantiated directly - it acts like an abstract class (should be a module?)
31
+ class InputFilter
32
+
33
+ attr_accessor :citations
34
+
35
+ def initialize
36
+ @citations = {}
37
+ end
38
+
39
+ # Parses the +source+, and calls the load_model method with the results and +params+.
40
+ def parse(source, params)
41
+ open(source, 'rb') do |f|
42
+ load_citations(f, params)
43
+ end
44
+ end
45
+
46
+ # Loads the model - needs to be implemented
47
+ def load_citations(source, params); end
48
+
49
+
50
+
51
+
52
+ # Citation iterator
53
+ def each_citation
54
+ @citations.values.each do |citation|
55
+ @current_citation = citation
56
+ yield citation
57
+ end
58
+ end
59
+
60
+ # Citation iterator
61
+ def each_sorted_citation(keyset)
62
+ sorted_citations(keyset).each do |citation|
63
+ @current_citation = citation
64
+ yield citation
65
+ end
66
+ end
67
+
68
+
69
+ def sorted_citations(keyset)
70
+ keyset.sort do |a, b|
71
+ result = 0
72
+ for i in (1..a.length - 1)
73
+ result = a[i] <=> b[i]
74
+ break if result != 0
75
+ end
76
+ result
77
+ end.collect {|keys| keys[0]}
78
+ end
79
+
80
+
81
+
82
+
83
+ def extract_contributor(role, sort_by = nil); end
84
+
85
+ # Tests the document class, and returns the corresponding CSL type
86
+ def resolve_type; end
87
+
88
+ def extract_date(variable); end
89
+
90
+ def extract_locator_label(label); end
91
+
92
+ def extract_page_label(label); end
93
+
94
+ def extract_variable(variable); end
95
+
96
+ end
97
+ end
@@ -0,0 +1,191 @@
1
+ @prefix address: <http://schemas.talis.com/2005/address/schema#>.
2
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
3
+ @prefix bibo: <http://purl.org/ontology/bibo/> .
4
+ @prefix bibo_degrees: <http://purl.org/ontology/bibo_degrees/> .
5
+ @prefix dc: <http://purl.org/dc/terms/> .
6
+ @prefix dcterms: <http://purl.org/dc/terms/> .
7
+ @prefix bibo: <http://purl.org/ontology/bibo/> .
8
+ @prefix cc: <http://creativecommons.org/ns#> .
9
+ @prefix event: <http://purl.org/NET/c4dm/event.owl#> .
10
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
11
+ @prefix tl: <http://purl.org/NET/c4dm/timeline.owl#> .
12
+ @prefix time: <http://purl.org/NET/c4dm/timeline.owl#> .
13
+ @prefix timeline: <http://purl.org/NET/c4dm/timeline.owl#> .
14
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
15
+
16
+
17
+
18
+ <http://examples.net/contributors/1>
19
+ a foaf:Person ;
20
+ foaf:givenname "Jane" ;
21
+ foaf:family_name "Doe" .
22
+
23
+ <http://examples.net/contributors/2>
24
+ a foaf:Person .
25
+
26
+ <http://examples.net/contributors/3>
27
+ a foaf:Person .
28
+
29
+ <http://examples.net/contributors/4>
30
+ a foaf:Organization ;
31
+ foaf:name "ABC Publishers" ;
32
+ address:localityName "New York" .
33
+
34
+ <http://examples.net/contributors/5>
35
+ a foaf:Organization ;
36
+ foaf:name "XYZ Archive, National University".
37
+
38
+
39
+
40
+ <urn:isbn:23983498> a bibo:Book ;
41
+ dc:creator <http://examples.net/contributors/2> ;
42
+ dc:title "Book Title"@en ;
43
+ dc:date "2000" ;
44
+ dc:publisher <http://ex.net/agents/1> .
45
+
46
+
47
+
48
+
49
+
50
+ <info:doi/10.1134/S0003683806040089> a bibo:Article ;
51
+ dc:title "Effect of argillaceous minerals on the growth of phosphate-mobilizing bacteria Bacillus subtilis"@en ;
52
+ dc:date "2006-01-01" ;
53
+ dcterms:isPartOf <urn:issn:23346587> ;
54
+ bibo:volume "42" ;
55
+ bibo:issue "4" ;
56
+ bibo:pageStart "388" ;
57
+ bibo:pageEnd "391" ;
58
+ dc:creator <http://examples.net/contributors/2> ;
59
+ dc:creator <http://examples.net/contributors/1> ;
60
+ bibo:authorList ( <http://examples.net/contributors/2> <http://examples.net/contributors/1>) .
61
+
62
+ <urn:issn:23346587> a bibo:Journal ;
63
+ dc:title "Applied Biochemistry and Microbiology"@en ;
64
+ bibo:shortTitle "App Biochem and Biol"@en .
65
+
66
+
67
+
68
+
69
+ <http://www.nytimes.com/2007/07/09/us/09cnd-penn.html> a bibo:Article;
70
+ dcterms:isPartOf <http://www.nytimes.com> ;
71
+ dc:date "2007-07-09" ;
72
+ bibo:uri "http://www.nytimes.com/2007/07/09/us/09cnd-penn.html" ;
73
+ dc:creator <http://examples.net/contributors/100> .
74
+
75
+ <http://www.nytimes.com> a bibo:Periodical ;
76
+ bibo:uri "http://www.nytimes.com" ;
77
+ dc:title "New York Times" .
78
+
79
+ <http://examples.net/contributors/100> a foaf:Person;
80
+ foaf:givenname "Anahad" ;
81
+ foaf:family_name "O'Connor" .
82
+
83
+
84
+
85
+
86
+ <http://examples.net/dissertation> a bibo:Thesis ;
87
+ dc:date "1998-01-01" ;
88
+ dc:title "Dissertation Title"@en ;
89
+ bibo:issuer <http://examples.net/things/6> ;
90
+ bibo:degree bibo_degrees:phd ;
91
+ dc:creator <http://examples.net/contributors/1> .
92
+
93
+ <http://examples.net/things/6> a foaf:Organization ;
94
+ foaf:name "National University" ;
95
+ address:localityName "Singapore" .
96
+
97
+
98
+
99
+
100
+ <http://examples.net/letter> a bibo:Letter ;
101
+ dc:date "2000-10-12" ;
102
+ dc:creator <http://examples.net/contributors/1> ;
103
+ bibo:recipient <http://examples.net/people/alice/me/> .
104
+
105
+
106
+
107
+
108
+ <http://ex.net/x1> a bibo:Article ;
109
+ dc:creator <http://examples.net/contributors/1> ;
110
+ dc:title "Conference Paper" ;
111
+ bibo:presentedAt <http://ex.net/conference> ;
112
+ bibo:reproducedIn <http://ex.net/x2> .
113
+
114
+ <http://ex.net/conference> a bibo:Conference ;
115
+ bibo:organizer <http://ex.net> ;
116
+ event:place <http://dbpedia.org/resource/> ;
117
+ event:time [ time:Interval [ timeline:beginsAtDateTime "2007-03-01" ; timeline:endsAtDateTime "2007-03-13"] ] .
118
+
119
+ <http://ex.net/x2> a bibo:Proceedings ;
120
+ dc:title "Proceedings of the ABC Conference"@en ;
121
+ dc:date "2000" ;
122
+ dc:publisher <http://ex.net/z1> .
123
+
124
+
125
+
126
+
127
+ <http://www.w3.org/2007/Talks/0619-Nancy-IH/> a cc:Work, bibo:Slideshow ;
128
+ cc:license <http://creativecommons.org/licenses/by-nd/3.0/> ;
129
+ dc:date "2008-06-18"^^xsd:dateTime ;
130
+ dc:hasFormat <http://www.w3.org/2008/Talks/0619-Nancy-IH/Slides.odp> ;
131
+ dc:subject <http://lcsh.info/sh2002000569#concept> ;
132
+ dc:title "State of the Semantic Web"@en,
133
+ "États des lieux du Web sémantique"@fr ;
134
+ bibo:authorList ( <http://www.ivan-herman.net/me> ) ;
135
+ bibo:presentedAt <http://ic2008.loria.fr/> .
136
+
137
+ <http://www.ivan-herman.net/me> a foaf:Person ;
138
+ rdfs:seeAlso <http://www.ivan-herman.net/foaf> ;
139
+ foaf:name "Ivan Herman" .
140
+
141
+ <http://ic2008.loria.fr/> a bibo:Conference ;
142
+ event:place <http://dbpedia.org/resource/Nancy> ;
143
+ event:time
144
+ [ a tl:Interval ;
145
+ tl:beginsAt "2008-06-18"^^xsd:dateTime ;
146
+ tl:endsAt "2008-06-20"^^xsd:dateTime
147
+ ];
148
+ dc:title "19th Francophone Knowledge Engineering Days"@en,
149
+ "19èmes Journées Francophones d’Ingénierie des Connaissances"@fr .
150
+
151
+ <http://www.w3.org/2008/Talks/0619-Nancy-IH/Slides.odp>
152
+ dc:format "application/vnd.oasis.opendocument.presentation" ;
153
+ dc:isFormatOf <http://www.w3.org/2007/Talks/0619-Nancy-IH/> .
154
+
155
+
156
+
157
+
158
+ <http://examples.net/case/1> a bibo:LegalDecision ;
159
+ dcterms:issued "2006-01-01" ;
160
+ bibo:argued "2005-10-12" ;
161
+ dc:title "Doe v. Smith"@en ;
162
+ bibo:number "123223" ;
163
+ bibo:court [ foaf:name "Some Court" ] ;
164
+ bibo:affirmedBy <http://examples.net/case/2> ;
165
+ bibo:affirmedBy <http://examples.net/case/3> ;
166
+ dcterms:isPartOf <http://examples.net/periodicals/1> .
167
+
168
+ <http://examples.net/periodicals/1> a bibo:CourtReporter ;
169
+ dc:title "Court Reporter Title"@en ;
170
+ bibo:shortTitle "CRT"@en .
171
+
172
+
173
+
174
+
175
+
176
+
177
+ <http://examples.net/manuscript> a bibo:Manuscript ;
178
+ dc:title "Manuscript Title"@en ;
179
+ dcterms:isPartOf <http://examples.net/collections/1> ;
180
+ bibo:locator "Box 12, Folder 3" ;
181
+ dc:creator <http://examples.net/contributors/1> .
182
+
183
+ <http://examples.net/collections/1> a bibo:Collection ;
184
+ dc:title "Manuscript Collection Title"@en ;
185
+ bibo:owner <http://examples.net/contributors/5> .
186
+
187
+ <http://examples.net/places/1> a foaf:Organization ;
188
+ foaf:name "XYZ Archive, National University" ;
189
+ address:localityName "London" ;
190
+ foaf:based_near <http://dbpedia.org/resource/London> .
191
+
@@ -0,0 +1,96 @@
1
+ a:
2
+ !ruby/object:Bibo::Document
3
+ date: 2007-11-21 16:20:37.402371 +11:00
4
+ accessed: 2007-11-21 16:20:37.402371 +11:00
5
+ uri: http://wiki.Bibo.com/index.php/Ontology_Working_Draft
6
+ locator: 1
7
+ locator_type: volume
8
+ pages: '1'
9
+ contributions:
10
+ - !ruby/object:Bibo::Contribution
11
+ contributor: !ruby/object:Bibo::FOAF::Person
12
+ family_name: Myself
13
+ given_name: Me
14
+ homepage: http://mydomain.com
15
+ mbox: me@mydomain.com
16
+ position: 1
17
+ role: !ruby/object:Bibo::ContributionRole
18
+ name: author
19
+ - !ruby/object:Bibo::Contribution
20
+ contributor: !ruby/object:Bibo::FOAF::Person
21
+ family_name: Myself2
22
+ given_name: Me2
23
+ homepage: http://mydomain.com
24
+ mbox: me@mydomain.com
25
+ position: 2
26
+ role: !ruby/object:Bibo::ContributionRole
27
+ name: author
28
+ - !ruby/object:Bibo::Contribution
29
+ contributor: !ruby/object:Bibo::FOAF::Person
30
+ family_name: Myself3
31
+ given_name: Me3
32
+ homepage: http://mydomain.com
33
+ mbox: me@mydomain.com
34
+ position: 3
35
+ role: !ruby/object:Bibo::ContributionRole
36
+ name: author
37
+ - !ruby/object:Bibo::Contribution
38
+ contributor: !ruby/object:Bibo::FOAF::Person
39
+ family_name: Myself4
40
+ given_name: Me4
41
+ homepage: http://mydomain.com
42
+ mbox: me@mydomain.com
43
+ position: 4
44
+ role: !ruby/object:Bibo::ContributionRole
45
+ name: author
46
+ - !ruby/object:Bibo::Contribution
47
+ contributor: !ruby/object:Bibo::FOAF::Person
48
+ family_name: Myself5
49
+ given_name: Me5
50
+ homepage: http://mydomain.com
51
+ mbox: me@mydomain.com
52
+ position: 5
53
+ role: !ruby/object:Bibo::ContributionRole
54
+ name: author
55
+ - !ruby/object:Bibo::Contribution
56
+ contributor: !ruby/object:Bibo::FOAF::Person
57
+ family_name: Myself6
58
+ given_name: Me6
59
+ homepage: http://mydomain.com
60
+ mbox: me@mydomain.com
61
+ position: 6
62
+ role: !ruby/object:Bibo::ContributionRole
63
+ name: author
64
+ - !ruby/object:Bibo::Contribution
65
+ contributor: !ruby/object:Bibo::FOAF::Person
66
+ family_name: Myself7
67
+ given_name: Me7
68
+ homepage: http://mydomain.com
69
+ mbox: me@mydomain.com
70
+ position: 7
71
+ role: !ruby/object:Bibo::ContributionRole
72
+ name: author
73
+ - !ruby/object:Bibo::Contribution
74
+ contributor: !ruby/object:Bibo::FOAF::Person
75
+ family_name: Yourself
76
+ given_name: You
77
+ homepage: http://yourdomain.com
78
+ mbox: you@yourdomain.com
79
+ position: 2
80
+ role: !ruby/object:Bibo::ContributionRole
81
+ name: editor
82
+
83
+ presented_at: !ruby/object:Bibo::Events::Event
84
+ agent: !ruby/object:Bibo::FOAF::Organisation
85
+ name: Conference Organiser
86
+ name: An Important Conference
87
+ place: !ruby/object:Bibo::Wgs84_pos::SpatialThing
88
+ name: London
89
+ product: Some textual product.
90
+ time: !ruby/object:Bibo::Times::Interval
91
+ end: 2007-11-17 17:15:32.433835 +11:00
92
+ start: 2007-11-17 14:28:52.433817 +11:00
93
+ title: My Document
94
+ translation_of: !ruby/object:Bibo::Document
95
+ contributions: []
96
+ title: Mon Document
@@ -0,0 +1,63 @@
1
+ <http://demo.openlibrary.org/b/How_to_Cook_Edition> a bibo:Book ;
2
+
3
+ dcterms:title "How to Cook Revised Edition - An Easy and Imaginative Guide for the Beginner" ;
4
+
5
+ dcterms:subject <http://purl.org/umbel/sc/CookingFood> ;
6
+ dcterms:subject <http://purl.org/umbel/sc/Chef> ;
7
+
8
+ bibo:language "eng" ;
9
+ bibo:upc "099455014953" ;
10
+ bibo:eanucc13 "9780060083915" ;
11
+ bibo:isbn13 "9780060083915" ;
12
+ bibo:isbn10 "0060083913" ;
13
+ dcterms:date "2004-05-01" ;
14
+ bibo:number_of_page "320" ;
15
+ bibo:status <http://purl.org/ontology/bibo/status/published> ;
16
+ foaf:depiction <http://demo.openlibrary.org/static/bookcovers/full/0/0/0060083913.jpg> ;
17
+
18
+ dcterms:creator <http://demo.openlibrary.org/b/Raymond_Sokolov> ;
19
+
20
+ dcterms:publisher <http://demo.openlibrary.org/b/HarperCollins> ;
21
+ dcterms:publisher <http://demo.openlibrary.org/b/Morrow_Cookbooks>
22
+
23
+ dcterms:description "<P><B>A fully revised and updated edition of Raymond
24
+ Sokolov's classic kitchen primer for beginning chefs of all ages,
25
+ filled with 150 simple, sophisticated recipes, easy-to-learn
26
+ techniques, and indispensable advice. </B></P> <P>First published in
27
+ 1986, Ray Sokolov's <I>How To Cook</I> is the ultimate book for
28
+ beginning cooks of all ages. Unlike most kitchen primers, How To Cook
29
+ does not assume any prior cooking instruction or skills, but rather
30
+ guides the reader through the entire cooking process with simple
31
+ explanations in ordinary language. There are no fancy cooking terms or
32
+ special gadget here, just easy, indispensable techniques and foolproof
33
+ recipes for every occasion. In this revised paperback edition, Sokolov
34
+ addresses the increased sophistication of even adamant non-cooks in
35
+ today's food-obsessed climate, while he sticks to the unfussy,
36
+ straightforward approach that made the original such a hit. Home cooks
37
+ will learn everything they need for years worth of fabulous meals,
38
+ from how to decipher recipe measurements, to how to fry an egg, to how
39
+ to steam a lobster. Even readers weaned on frozen pizza will find
40
+ recipes they can master, for last minute meals, special occasions and
41
+ entertaining, and even holidays-all made from scratch with fresh,
42
+ accessible ingredients. Experienced cooks will appreciate the simple
43
+ elegance of such flavorful dishes as Veal Scallopini or Pears Poached
44
+ in Red Wine. Written with Sokolov's trademark wit and wisdom, <I>How
45
+ To Cook</I> is an invaluable kitchen classic you'll turn to again and
46
+ again.</P>".
47
+
48
+
49
+ <http://demo.openlibrary.org/b/Raymond_Sokolov> a foaf:Person ;
50
+ bibo:givenName "Raymond" ;
51
+ bibo:familyName "Sokolov" .
52
+
53
+ <http://demo.openlibrary.org/b/HarperCollins> a foaf:Organization ;
54
+ foaf:name "Harper Collins" ;
55
+ foaf:homepage <http://www.harpercollins.com/> .
56
+
57
+
58
+ <http://demo.openlibrary.org/b/Morrow_Cookbooks> a foaf:Organization ;
59
+ foaf:name "Harper Collins" ;
60
+ foaf:homepage <http://www.harpercollins.com/imprints/index.aspx?imprintid=517982> ;
61
+ owl:sameAs <http://demo.openlibrary.org/b/HarperCollins>.
62
+
63
+