Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
d19c6877
Commit
d19c6877
authored
May 10, 2016
by
c24b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Referencing the Parser
parent
0950a1ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
1 deletion
+57
-1
Cern.py
gargantext/util/parsers/Cern.py
+56
-0
__init__.py
gargantext/util/parsers/__init__.py
+1
-1
No files found.
gargantext/util/parsers/Cern.py
0 → 100644
View file @
d19c6877
from
._Parser
import
Parser
from
datetime
import
datetime
from
io
import
BytesIO
import
json
class
CernParser
(
Parser
):
self
.
MARC21
=
{
"100"
:{
"a"
:
"author_name"
,
"v"
:
"author_affiliation"
,
"w"
:
"author_country"
,
"m"
:
"author_mail"
,
},
"700"
:
{
"a"
:
"coauthor_name"
,
"v"
:
"coauthor_affiliation"
,
"w"
:
"coauthor_country"
,
},
"773"
:{
"c"
:
"pages"
,
"n"
:
"issue"
,
"p"
:
"journal"
,
"v"
:
"volume"
,
"y"
:
"year"
},
"024"
:
{
"a"
:
"DOI"
},
"037"
:
{
"a"
:
"ArXiv"
},
"022"
:
{
"a"
:
"ISSN"
},
"245"
:
{
"a"
:
"Title"
},
"520"
:
{
"a"
:
"Abstract"
},
"260"
:
{
"b"
:
"Publisher"
,
"c"
:
"Pubdate"
},
"024"
:
{
"t"
:
"Date"
},
"540"
:
{
"a"
:
"Licence"
},
"653"
:
{
"a"
:
"keywords"
},
"856"
:
{
"u"
:
"pdf_source"
},
}
def
parse
(
self
,
filebuf
):
tree
=
etree
.
tostring
(
filebuf
)
#root = tree.getroot()
soup
=
BeautifulSoup
(
tree
,
"lxml"
)
for
record
in
soupr
.
find_all
(
"record"
):
r
=
{
v
:[]
for
v
in
self
.
MARC21
[
"700"
]
.
values
()}
r
[
"uid"
]
=
soup
.
find
(
"controlfield"
)
.
text
for
data
in
soup
.
find_all
(
"datafield"
):
tag
=
data
.
get
(
"tag"
)
if
tag
in
self
.
MARC21
.
keys
():
for
sub
in
data
.
find_all
(
"subfield"
):
code
=
sub
.
get
(
"code"
)
if
code
in
self
.
MARC21
[
tag
]
.
keys
():
if
tag
==
"700"
:
r
[
self
.
MARC21
[
tag
][
code
]]
.
append
(
sub
.
text
)
else
:
r
[
self
.
MARC21
[
tag
][
code
]]
=
sub
.
text
records
.
append
(
r
.
decode
(
'utf-8'
))
gargantext/util/parsers/__init__.py
View file @
d19c6877
...
@@ -9,4 +9,4 @@ from .Europress import EuropressParser
...
@@ -9,4 +9,4 @@ from .Europress import EuropressParser
from
.ISTex
import
ISTexParser
from
.ISTex
import
ISTexParser
from
.CSV
import
CSVParser
from
.CSV
import
CSVParser
from
.C
ERN
import
CernParser
from
.C
ern
import
CernParser
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment