@manuscripts/transform 1.0.0 → 1.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.
- package/dist/cjs/jats/importer/jats-parser-utils.js +2 -2
- package/dist/cjs/jats/jats-exporter.js +16 -16
- package/dist/cjs/schema/nodes/blockquote_element.js +2 -2
- package/dist/cjs/schema/nodes/equation.js +3 -3
- package/dist/cjs/schema/nodes/inline_equation.js +3 -3
- package/dist/cjs/schema/nodes/list.js +3 -3
- package/dist/cjs/schema/nodes/listing.js +3 -3
- package/dist/cjs/schema/nodes/paragraph.js +2 -2
- package/dist/cjs/schema/nodes/pullquote_element.js +2 -2
- package/dist/cjs/transformer/builders.js +73 -73
- package/dist/cjs/transformer/decode.js +25 -25
- package/dist/cjs/transformer/document-object-types.js +11 -11
- package/dist/cjs/transformer/html.js +2 -2
- package/dist/cjs/transformer/index.js +0 -1
- package/dist/cjs/transformer/labels.js +1 -2
- package/dist/cjs/transformer/manuscript-dependencies.js +3 -3
- package/dist/cjs/transformer/node-types.js +33 -33
- package/dist/cjs/transformer/object-types.js +23 -23
- package/dist/cjs/transformer/project-bundle.js +4 -4
- package/dist/cjs/transformer/section-category.js +5 -5
- package/dist/es/jats/importer/jats-parser-utils.js +1 -1
- package/dist/es/jats/jats-exporter.js +1 -1
- package/dist/es/schema/nodes/blockquote_element.js +1 -1
- package/dist/es/schema/nodes/equation.js +1 -1
- package/dist/es/schema/nodes/inline_equation.js +1 -1
- package/dist/es/schema/nodes/list.js +1 -1
- package/dist/es/schema/nodes/listing.js +1 -1
- package/dist/es/schema/nodes/paragraph.js +1 -1
- package/dist/es/schema/nodes/pullquote_element.js +1 -1
- package/dist/es/transformer/builders.js +1 -1
- package/dist/es/transformer/decode.js +1 -1
- package/dist/es/transformer/document-object-types.js +1 -1
- package/dist/es/transformer/html.js +1 -1
- package/dist/es/transformer/index.js +0 -1
- package/dist/es/transformer/labels.js +1 -2
- package/dist/es/transformer/manuscript-dependencies.js +1 -1
- package/dist/es/transformer/node-types.js +1 -1
- package/dist/es/transformer/object-types.js +1 -1
- package/dist/es/transformer/project-bundle.js +1 -1
- package/dist/es/transformer/section-category.js +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -1
- package/dist/types/jats/importer/jats-comments.d.ts +1 -1
- package/dist/types/jats/importer/jats-front-parser.d.ts +6 -6
- package/dist/types/jats/importer/jats-parser-utils.d.ts +1 -1
- package/dist/types/jats/importer/jats-reference-parser.d.ts +2 -2
- package/dist/types/jats/importer/parse-jats-article.d.ts +2 -2
- package/dist/types/jats/jats-exporter.d.ts +1 -1
- package/dist/types/lib/styled-content.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +1 -1
- package/dist/types/transformer/bundles-data.d.ts +1 -1
- package/dist/types/transformer/bundles.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +1 -1
- package/dist/types/transformer/document-object-types.d.ts +1 -1
- package/dist/types/transformer/encode.d.ts +1 -1
- package/dist/types/transformer/footnotes-order.d.ts +1 -1
- package/dist/types/transformer/highlight-markers.d.ts +1 -1
- package/dist/types/transformer/html.d.ts +1 -1
- package/dist/types/transformer/id.d.ts +1 -1
- package/dist/types/transformer/index.d.ts +0 -1
- package/dist/types/transformer/labels.d.ts +1 -1
- package/dist/types/transformer/manuscript-dependencies.d.ts +1 -1
- package/dist/types/transformer/model-map.d.ts +1 -1
- package/dist/types/transformer/models.d.ts +1 -1
- package/dist/types/transformer/node-types.d.ts +1 -1
- package/dist/types/transformer/object-types.d.ts +1 -1
- package/dist/types/transformer/project-bundle.d.ts +1 -1
- package/dist/types/transformer/section-category.d.ts +1 -1
- package/dist/types/transformer/shared-data.d.ts +1 -1
- package/dist/types/transformer/update-identifiers.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/transformer/tei-grobid-importer.js +0 -121
- package/dist/es/transformer/tei-grobid-importer.js +0 -115
- package/dist/types/transformer/tei-grobid-importer.d.ts +0 -20
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { buildAffiliation, buildBibliographicDate, buildBibliographicName, buildBibliographyItem, buildContributor, buildManuscript, } from './builders';
|
|
17
|
-
import { addModelToMap } from './model-map';
|
|
18
|
-
const iterateSnapshot = function* (snapshot) {
|
|
19
|
-
for (let i = 0; i < snapshot.snapshotLength; i++) {
|
|
20
|
-
yield snapshot.snapshotItem(i);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const namespaces = new Map([
|
|
24
|
-
[null, 'http://www.tei-c.org/ns/1.0'],
|
|
25
|
-
]);
|
|
26
|
-
const namespaceResolver = (prefix) => namespaces.get(prefix) || null;
|
|
27
|
-
export const parseFront = (doc, addModel) => {
|
|
28
|
-
const headerNode = doc.evaluate('/TEI/teiHeader', doc, namespaceResolver, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue;
|
|
29
|
-
if (!headerNode) {
|
|
30
|
-
throw new Error('No header element found!');
|
|
31
|
-
}
|
|
32
|
-
const title = doc.evaluate('fileDesc/titleStmt/title', headerNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
33
|
-
const manuscript = buildManuscript(title);
|
|
34
|
-
addModel(manuscript);
|
|
35
|
-
const affiliationsMap = new Map();
|
|
36
|
-
const authorNodes = doc.evaluate('fileDesc/sourceDesc/biblStruct/analytic/author', headerNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
37
|
-
for (const authorNode of iterateSnapshot(authorNodes)) {
|
|
38
|
-
const name = buildBibliographicName({});
|
|
39
|
-
name.given = doc.evaluate('persName/forename', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
40
|
-
name.family = doc.evaluate('persName/surname', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
41
|
-
const contributor = buildContributor(name, 'author', 1);
|
|
42
|
-
contributor.affiliations = [];
|
|
43
|
-
const affiliationNodes = doc.evaluate('affiliation', authorNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
44
|
-
for (const affiliationNode of iterateSnapshot(affiliationNodes)) {
|
|
45
|
-
const key = affiliationNode.getAttribute('key');
|
|
46
|
-
if (key) {
|
|
47
|
-
const affiliation = affiliationsMap.get(key);
|
|
48
|
-
if (affiliation) {
|
|
49
|
-
contributor.affiliations.push(affiliation._id);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const affiliation = buildAffiliation('', 1);
|
|
53
|
-
affiliation.institution = doc.evaluate('orgName[@type="institution"]', affiliationNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
54
|
-
affiliation.department = doc.evaluate('orgName[@type="department"]', affiliationNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
55
|
-
addModel(affiliation);
|
|
56
|
-
affiliationsMap.set(key, affiliation);
|
|
57
|
-
contributor.affiliations.push(affiliation._id);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
addModel(contributor);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const chooseBibliographyItemType = (publicationType) => {
|
|
65
|
-
switch (publicationType) {
|
|
66
|
-
case 'book':
|
|
67
|
-
case 'thesis':
|
|
68
|
-
return publicationType;
|
|
69
|
-
case 'journal':
|
|
70
|
-
default:
|
|
71
|
-
return 'article-journal';
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
export const parseBack = (doc, addModel) => {
|
|
75
|
-
const backNode = doc.evaluate('/TEI/text/back', doc, namespaceResolver, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue;
|
|
76
|
-
if (!backNode) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const referenceNodes = doc.evaluate('div[@type="references"]/listBibl/biblStruct', backNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
80
|
-
for (const referenceNode of iterateSnapshot(referenceNodes)) {
|
|
81
|
-
const bibliographyItem = buildBibliographyItem({
|
|
82
|
-
type: chooseBibliographyItemType(null),
|
|
83
|
-
});
|
|
84
|
-
bibliographyItem.title = doc.evaluate('analytic/title', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
85
|
-
bibliographyItem.source = doc.evaluate('monogr/title', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
86
|
-
bibliographyItem.volume = doc.evaluate('monogr/imprint/biblScope[unit="volume"]', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
87
|
-
const fpage = doc.evaluate('monogr/imprint/biblScope[unit="page"]/@from', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
88
|
-
const lpage = doc.evaluate('monogr/imprint/biblScope[unit="page"]/@to', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
89
|
-
if (fpage) {
|
|
90
|
-
bibliographyItem.page = lpage ? `${fpage}-${lpage}` : fpage;
|
|
91
|
-
}
|
|
92
|
-
const date = doc.evaluate('monogr/imprint/date[type="published"]/@when', referenceNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
93
|
-
if (date) {
|
|
94
|
-
bibliographyItem.issued = buildBibliographicDate({
|
|
95
|
-
'date-parts': [date.split(/-/)],
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
const authorNodes = doc.evaluate('analytic/author', referenceNode, namespaceResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
|
|
99
|
-
bibliographyItem.author = [];
|
|
100
|
-
for (const authorNode of iterateSnapshot(authorNodes)) {
|
|
101
|
-
const name = buildBibliographicName({});
|
|
102
|
-
name.given = doc.evaluate('persName/forename', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
103
|
-
name.family = doc.evaluate('persName/surname', authorNode, namespaceResolver, XPathResult.STRING_TYPE).stringValue;
|
|
104
|
-
bibliographyItem.author.push(name);
|
|
105
|
-
}
|
|
106
|
-
addModel(bibliographyItem);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
export const parseTEIGROBIDArticle = (doc) => {
|
|
110
|
-
const modelMap = new Map();
|
|
111
|
-
const addModel = addModelToMap(modelMap);
|
|
112
|
-
parseFront(doc, addModel);
|
|
113
|
-
parseBack(doc, addModel);
|
|
114
|
-
return [...modelMap.values()];
|
|
115
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Model } from '@manuscripts/manuscripts-json-schema';
|
|
17
|
-
import { AddModel } from './model-map';
|
|
18
|
-
export declare const parseFront: (doc: Document, addModel: AddModel) => void;
|
|
19
|
-
export declare const parseBack: (doc: Document, addModel: AddModel) => void;
|
|
20
|
-
export declare const parseTEIGROBIDArticle: (doc: Document) => Model[];
|