@uniweb/scholar 0.1.0 → 0.2.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.
@@ -1,339 +0,0 @@
1
- /**
2
- * Chicago Style (Author-Date) Reference Formatter
3
- *
4
- * Formats references according to Chicago Manual of Style 17th edition
5
- * author-date format.
6
- *
7
- * @module @uniweb/scholar/bibliography/formatters/chicago
8
- */
9
-
10
- import { formatChicagoAuthors, parseAuthorString } from '../utils/authors.js'
11
- import { formatChicagoDate, getYear } from '../utils/dates.js'
12
-
13
- /**
14
- * Format a journal article in Chicago style
15
- *
16
- * @param {Object} pub - Publication data
17
- * @returns {string}
18
- */
19
- function formatArticle(pub) {
20
- const parts = []
21
-
22
- // Authors
23
- const authors = Array.isArray(pub.authors)
24
- ? pub.authors
25
- : parseAuthorString(pub.authors || pub.author)
26
- if (authors.length) {
27
- parts.push(`${formatChicagoAuthors(authors)}.`)
28
- }
29
-
30
- // Year
31
- const year = getYear(pub.year || pub.date)
32
- if (year) {
33
- parts.push(`${year}.`)
34
- }
35
-
36
- // Title in quotes
37
- if (pub.title) {
38
- parts.push(`"${pub.title}."`)
39
- }
40
-
41
- // Journal (italicized)
42
- if (pub.journal) {
43
- let journalPart = pub.journal
44
- if (pub.volume) {
45
- journalPart += ` ${pub.volume}`
46
- if (pub.issue) {
47
- journalPart += `, no. ${pub.issue}`
48
- }
49
- }
50
- if (pub.pages) {
51
- journalPart += `: ${pub.pages}`
52
- }
53
- parts.push(`${journalPart}.`)
54
- }
55
-
56
- // DOI
57
- if (pub.doi) {
58
- const doi = pub.doi.startsWith('http')
59
- ? pub.doi
60
- : `https://doi.org/${pub.doi}`
61
- parts.push(doi)
62
- }
63
-
64
- return parts.join(' ')
65
- }
66
-
67
- /**
68
- * Format a book in Chicago style
69
- *
70
- * @param {Object} pub - Publication data
71
- * @returns {string}
72
- */
73
- function formatBook(pub) {
74
- const parts = []
75
-
76
- // Authors or editors
77
- const authors = Array.isArray(pub.authors)
78
- ? pub.authors
79
- : parseAuthorString(pub.authors || pub.author)
80
- const editors = Array.isArray(pub.editors)
81
- ? pub.editors
82
- : parseAuthorString(pub.editors || pub.editor)
83
-
84
- if (authors.length) {
85
- parts.push(`${formatChicagoAuthors(authors)}.`)
86
- } else if (editors.length) {
87
- parts.push(
88
- `${formatChicagoAuthors(editors)}, ed${editors.length > 1 ? 's' : ''}.`
89
- )
90
- }
91
-
92
- // Year
93
- const year = getYear(pub.year || pub.date)
94
- if (year) {
95
- parts.push(`${year}.`)
96
- }
97
-
98
- // Title (italicized)
99
- if (pub.title) {
100
- let title = pub.title
101
- if (pub.edition && pub.edition !== '1') {
102
- title += `. ${pub.edition} ed`
103
- }
104
- parts.push(`${title}.`)
105
- }
106
-
107
- // Place and publisher
108
- if (pub.address && pub.publisher) {
109
- parts.push(`${pub.address}: ${pub.publisher}.`)
110
- } else if (pub.publisher) {
111
- parts.push(`${pub.publisher}.`)
112
- }
113
-
114
- return parts.join(' ')
115
- }
116
-
117
- /**
118
- * Format a book chapter in Chicago style
119
- *
120
- * @param {Object} pub - Publication data
121
- * @returns {string}
122
- */
123
- function formatInBook(pub) {
124
- const parts = []
125
-
126
- // Chapter authors
127
- const authors = Array.isArray(pub.authors)
128
- ? pub.authors
129
- : parseAuthorString(pub.authors || pub.author)
130
- if (authors.length) {
131
- parts.push(`${formatChicagoAuthors(authors)}.`)
132
- }
133
-
134
- // Year
135
- const year = getYear(pub.year || pub.date)
136
- if (year) {
137
- parts.push(`${year}.`)
138
- }
139
-
140
- // Chapter title in quotes
141
- if (pub.title) {
142
- parts.push(`"${pub.title}."`)
143
- }
144
-
145
- // Book title and editors
146
- if (pub.bookTitle) {
147
- let bookPart = `In ${pub.bookTitle}`
148
- const editors = Array.isArray(pub.editors)
149
- ? pub.editors
150
- : parseAuthorString(pub.editors || pub.editor)
151
- if (editors.length) {
152
- bookPart += `, edited by ${formatChicagoAuthors(editors)}`
153
- }
154
- if (pub.pages) {
155
- bookPart += `, ${pub.pages}`
156
- }
157
- parts.push(`${bookPart}.`)
158
- }
159
-
160
- // Place and publisher
161
- if (pub.address && pub.publisher) {
162
- parts.push(`${pub.address}: ${pub.publisher}.`)
163
- } else if (pub.publisher) {
164
- parts.push(`${pub.publisher}.`)
165
- }
166
-
167
- return parts.join(' ')
168
- }
169
-
170
- /**
171
- * Format conference proceedings in Chicago style
172
- *
173
- * @param {Object} pub - Publication data
174
- * @returns {string}
175
- */
176
- function formatConference(pub) {
177
- const parts = []
178
-
179
- // Authors
180
- const authors = Array.isArray(pub.authors)
181
- ? pub.authors
182
- : parseAuthorString(pub.authors || pub.author)
183
- if (authors.length) {
184
- parts.push(`${formatChicagoAuthors(authors)}.`)
185
- }
186
-
187
- // Year
188
- const year = getYear(pub.year || pub.date)
189
- if (year) {
190
- parts.push(`${year}.`)
191
- }
192
-
193
- // Title in quotes
194
- if (pub.title) {
195
- parts.push(`"${pub.title}."`)
196
- }
197
-
198
- // Conference name
199
- if (pub.booktitle || pub.conference) {
200
- let confPart = `Paper presented at ${pub.booktitle || pub.conference}`
201
- if (pub.address || pub.location) {
202
- confPart += `, ${pub.address || pub.location}`
203
- }
204
- parts.push(`${confPart}.`)
205
- }
206
-
207
- // DOI
208
- if (pub.doi) {
209
- const doi = pub.doi.startsWith('http')
210
- ? pub.doi
211
- : `https://doi.org/${pub.doi}`
212
- parts.push(doi)
213
- }
214
-
215
- return parts.join(' ')
216
- }
217
-
218
- /**
219
- * Format a website/webpage in Chicago style
220
- *
221
- * @param {Object} pub - Publication data
222
- * @returns {string}
223
- */
224
- function formatWebsite(pub) {
225
- const parts = []
226
-
227
- // Authors or organization
228
- const authors = Array.isArray(pub.authors)
229
- ? pub.authors
230
- : parseAuthorString(pub.authors || pub.author)
231
- if (authors.length) {
232
- parts.push(`${formatChicagoAuthors(authors)}.`)
233
- } else if (pub.organization) {
234
- parts.push(`${pub.organization}.`)
235
- }
236
-
237
- // Year
238
- const year = getYear(pub.year || pub.date)
239
- if (year) {
240
- parts.push(`${year}.`)
241
- }
242
-
243
- // Title in quotes
244
- if (pub.title) {
245
- parts.push(`"${pub.title}."`)
246
- }
247
-
248
- // Site name
249
- if (pub.siteName) {
250
- parts.push(`${pub.siteName}.`)
251
- }
252
-
253
- // Access date and URL
254
- if (pub.accessDate) {
255
- parts.push(`Accessed ${formatChicagoDate(pub.accessDate)}.`)
256
- }
257
- if (pub.url) {
258
- parts.push(pub.url)
259
- }
260
-
261
- return parts.join(' ')
262
- }
263
-
264
- /**
265
- * Format a thesis/dissertation in Chicago style
266
- *
267
- * @param {Object} pub - Publication data
268
- * @returns {string}
269
- */
270
- function formatThesis(pub) {
271
- const parts = []
272
-
273
- // Author
274
- const authors = Array.isArray(pub.authors)
275
- ? pub.authors
276
- : parseAuthorString(pub.authors || pub.author)
277
- if (authors.length) {
278
- parts.push(`${formatChicagoAuthors(authors)}.`)
279
- }
280
-
281
- // Year
282
- const year = getYear(pub.year || pub.date)
283
- if (year) {
284
- parts.push(`${year}.`)
285
- }
286
-
287
- // Title in quotes
288
- if (pub.title) {
289
- parts.push(`"${pub.title}."`)
290
- }
291
-
292
- // Type and institution
293
- const type =
294
- pub.type === 'mastersthesis' ? 'Master\'s thesis' : 'PhD diss.'
295
- if (pub.school || pub.institution) {
296
- parts.push(`${type}, ${pub.school || pub.institution}.`)
297
- }
298
-
299
- return parts.join(' ')
300
- }
301
-
302
- /**
303
- * Format a reference in Chicago author-date style
304
- *
305
- * @param {Object} pub - Publication data
306
- * @param {Object} [options] - Formatting options
307
- * @returns {string}
308
- */
309
- export function formatChicago(pub, options = {}) {
310
- const type = (pub.type || pub.entryType || 'article').toLowerCase()
311
-
312
- switch (type) {
313
- case 'article':
314
- case 'journal':
315
- return formatArticle(pub)
316
- case 'book':
317
- return formatBook(pub)
318
- case 'inbook':
319
- case 'incollection':
320
- case 'chapter':
321
- return formatInBook(pub)
322
- case 'inproceedings':
323
- case 'conference':
324
- case 'proceedings':
325
- return formatConference(pub)
326
- case 'webpage':
327
- case 'website':
328
- case 'online':
329
- return formatWebsite(pub)
330
- case 'thesis':
331
- case 'phdthesis':
332
- case 'mastersthesis':
333
- return formatThesis(pub)
334
- default:
335
- return formatArticle(pub)
336
- }
337
- }
338
-
339
- export default formatChicago
@@ -1,332 +0,0 @@
1
- /**
2
- * IEEE Reference Formatter
3
- *
4
- * Formats references according to IEEE citation style.
5
- *
6
- * @module @uniweb/scholar/bibliography/formatters/ieee
7
- */
8
-
9
- import { formatIeeeAuthors, parseAuthorString } from '../utils/authors.js'
10
- import { formatIeeeDate, getYear } from '../utils/dates.js'
11
-
12
- /**
13
- * Format a journal article in IEEE style
14
- *
15
- * @param {Object} pub - Publication data
16
- * @returns {string}
17
- */
18
- function formatArticle(pub) {
19
- const parts = []
20
-
21
- // Authors
22
- const authors = Array.isArray(pub.authors)
23
- ? pub.authors
24
- : parseAuthorString(pub.authors || pub.author)
25
- if (authors.length) {
26
- parts.push(`${formatIeeeAuthors(authors)},`)
27
- }
28
-
29
- // Title in quotes
30
- if (pub.title) {
31
- parts.push(`"${pub.title},"`)
32
- }
33
-
34
- // Journal (italicized)
35
- if (pub.journal) {
36
- let journalPart = pub.journal
37
- if (pub.volume) {
38
- journalPart += `, vol. ${pub.volume}`
39
- }
40
- if (pub.issue) {
41
- journalPart += `, no. ${pub.issue}`
42
- }
43
- if (pub.pages) {
44
- journalPart += `, pp. ${pub.pages}`
45
- }
46
- // Date
47
- const date = formatIeeeDate(pub.date || pub.year)
48
- if (date) {
49
- journalPart += `, ${date}`
50
- }
51
- parts.push(`${journalPart}.`)
52
- }
53
-
54
- // DOI
55
- if (pub.doi) {
56
- parts.push(`doi: ${pub.doi.replace(/^https?:\/\/doi\.org\//, '')}.`)
57
- }
58
-
59
- return parts.join(' ')
60
- }
61
-
62
- /**
63
- * Format a book in IEEE style
64
- *
65
- * @param {Object} pub - Publication data
66
- * @returns {string}
67
- */
68
- function formatBook(pub) {
69
- const parts = []
70
-
71
- // Authors or editors
72
- const authors = Array.isArray(pub.authors)
73
- ? pub.authors
74
- : parseAuthorString(pub.authors || pub.author)
75
- const editors = Array.isArray(pub.editors)
76
- ? pub.editors
77
- : parseAuthorString(pub.editors || pub.editor)
78
-
79
- if (authors.length) {
80
- parts.push(`${formatIeeeAuthors(authors)},`)
81
- } else if (editors.length) {
82
- parts.push(`${formatIeeeAuthors(editors)}, Ed${editors.length > 1 ? 's' : ''}.,`)
83
- }
84
-
85
- // Title (italicized)
86
- if (pub.title) {
87
- let title = pub.title
88
- if (pub.edition && pub.edition !== '1') {
89
- title += `, ${pub.edition} ed`
90
- }
91
- parts.push(`${title}.`)
92
- }
93
-
94
- // Place and publisher
95
- if (pub.address && pub.publisher) {
96
- parts.push(`${pub.address}: ${pub.publisher},`)
97
- } else if (pub.publisher) {
98
- parts.push(`${pub.publisher},`)
99
- }
100
-
101
- // Year
102
- const year = getYear(pub.year || pub.date)
103
- if (year) {
104
- parts.push(`${year}.`)
105
- }
106
-
107
- return parts.join(' ')
108
- }
109
-
110
- /**
111
- * Format a book chapter in IEEE style
112
- *
113
- * @param {Object} pub - Publication data
114
- * @returns {string}
115
- */
116
- function formatInBook(pub) {
117
- const parts = []
118
-
119
- // Chapter authors
120
- const authors = Array.isArray(pub.authors)
121
- ? pub.authors
122
- : parseAuthorString(pub.authors || pub.author)
123
- if (authors.length) {
124
- parts.push(`${formatIeeeAuthors(authors)},`)
125
- }
126
-
127
- // Chapter title in quotes
128
- if (pub.title) {
129
- parts.push(`"${pub.title},"`)
130
- }
131
-
132
- // Book title
133
- if (pub.bookTitle) {
134
- let bookPart = `in ${pub.bookTitle}`
135
- const editors = Array.isArray(pub.editors)
136
- ? pub.editors
137
- : parseAuthorString(pub.editors || pub.editor)
138
- if (editors.length) {
139
- bookPart += `, ${formatIeeeAuthors(editors)}, Ed${editors.length > 1 ? 's' : ''}.`
140
- }
141
- parts.push(bookPart)
142
- }
143
-
144
- // Place and publisher
145
- if (pub.address && pub.publisher) {
146
- parts.push(`${pub.address}: ${pub.publisher},`)
147
- } else if (pub.publisher) {
148
- parts.push(`${pub.publisher},`)
149
- }
150
-
151
- // Year and pages
152
- const year = getYear(pub.year || pub.date)
153
- if (year) {
154
- if (pub.pages) {
155
- parts.push(`${year}, pp. ${pub.pages}.`)
156
- } else {
157
- parts.push(`${year}.`)
158
- }
159
- }
160
-
161
- return parts.join(' ')
162
- }
163
-
164
- /**
165
- * Format conference proceedings in IEEE style
166
- *
167
- * @param {Object} pub - Publication data
168
- * @returns {string}
169
- */
170
- function formatConference(pub) {
171
- const parts = []
172
-
173
- // Authors
174
- const authors = Array.isArray(pub.authors)
175
- ? pub.authors
176
- : parseAuthorString(pub.authors || pub.author)
177
- if (authors.length) {
178
- parts.push(`${formatIeeeAuthors(authors)},`)
179
- }
180
-
181
- // Title in quotes
182
- if (pub.title) {
183
- parts.push(`"${pub.title},"`)
184
- }
185
-
186
- // Conference
187
- if (pub.booktitle || pub.conference) {
188
- let confPart = `in ${pub.booktitle || pub.conference}`
189
- if (pub.address || pub.location) {
190
- confPart += `, ${pub.address || pub.location}`
191
- }
192
- // Year
193
- const year = getYear(pub.year || pub.date)
194
- if (year) {
195
- confPart += `, ${year}`
196
- }
197
- if (pub.pages) {
198
- confPart += `, pp. ${pub.pages}`
199
- }
200
- parts.push(`${confPart}.`)
201
- }
202
-
203
- // DOI
204
- if (pub.doi) {
205
- parts.push(`doi: ${pub.doi.replace(/^https?:\/\/doi\.org\//, '')}.`)
206
- }
207
-
208
- return parts.join(' ')
209
- }
210
-
211
- /**
212
- * Format a website/webpage in IEEE style
213
- *
214
- * @param {Object} pub - Publication data
215
- * @returns {string}
216
- */
217
- function formatWebsite(pub) {
218
- const parts = []
219
-
220
- // Authors or organization
221
- const authors = Array.isArray(pub.authors)
222
- ? pub.authors
223
- : parseAuthorString(pub.authors || pub.author)
224
- if (authors.length) {
225
- parts.push(`${formatIeeeAuthors(authors)}.`)
226
- } else if (pub.organization) {
227
- parts.push(`${pub.organization}.`)
228
- }
229
-
230
- // Title in quotes
231
- if (pub.title) {
232
- parts.push(`"${pub.title}."`)
233
- }
234
-
235
- // Site name (italicized)
236
- if (pub.siteName) {
237
- parts.push(`${pub.siteName}.`)
238
- }
239
-
240
- // URL and access date
241
- if (pub.url) {
242
- let urlPart = pub.url
243
- if (pub.accessDate) {
244
- urlPart += ` (accessed ${formatIeeeDate(pub.accessDate)})`
245
- }
246
- parts.push(`${urlPart}.`)
247
- }
248
-
249
- return parts.join(' ')
250
- }
251
-
252
- /**
253
- * Format a thesis/dissertation in IEEE style
254
- *
255
- * @param {Object} pub - Publication data
256
- * @returns {string}
257
- */
258
- function formatThesis(pub) {
259
- const parts = []
260
-
261
- // Author
262
- const authors = Array.isArray(pub.authors)
263
- ? pub.authors
264
- : parseAuthorString(pub.authors || pub.author)
265
- if (authors.length) {
266
- parts.push(`${formatIeeeAuthors(authors)},`)
267
- }
268
-
269
- // Title in quotes
270
- if (pub.title) {
271
- parts.push(`"${pub.title},"`)
272
- }
273
-
274
- // Type
275
- const type = pub.type === 'mastersthesis' ? 'M.S. thesis' : 'Ph.D. dissertation'
276
- parts.push(type + ',')
277
-
278
- // Institution
279
- if (pub.school || pub.institution) {
280
- parts.push(`${pub.school || pub.institution},`)
281
- }
282
-
283
- // Location and year
284
- if (pub.address) {
285
- parts.push(`${pub.address},`)
286
- }
287
- const year = getYear(pub.year || pub.date)
288
- if (year) {
289
- parts.push(`${year}.`)
290
- }
291
-
292
- return parts.join(' ')
293
- }
294
-
295
- /**
296
- * Format a reference in IEEE style
297
- *
298
- * @param {Object} pub - Publication data
299
- * @param {Object} [options] - Formatting options
300
- * @returns {string}
301
- */
302
- export function formatIeee(pub, options = {}) {
303
- const type = (pub.type || pub.entryType || 'article').toLowerCase()
304
-
305
- switch (type) {
306
- case 'article':
307
- case 'journal':
308
- return formatArticle(pub)
309
- case 'book':
310
- return formatBook(pub)
311
- case 'inbook':
312
- case 'incollection':
313
- case 'chapter':
314
- return formatInBook(pub)
315
- case 'inproceedings':
316
- case 'conference':
317
- case 'proceedings':
318
- return formatConference(pub)
319
- case 'webpage':
320
- case 'website':
321
- case 'online':
322
- return formatWebsite(pub)
323
- case 'thesis':
324
- case 'phdthesis':
325
- case 'mastersthesis':
326
- return formatThesis(pub)
327
- default:
328
- return formatArticle(pub)
329
- }
330
- }
331
-
332
- export default formatIeee