Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Tabeldaja
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Neeme Kahusk
Tabeldaja
Commits
348aae6d
Commit
348aae6d
authored
Dec 10, 2019
by
Neeme Kahusk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blokiga v.0.4.0
parent
c017ecfd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
444 additions
and
436 deletions
+444
-436
VERSION
VERSION
+1
-1
tabeldaja/configure_columns.py
tabeldaja/configure_columns.py
+2
-1
tabeldaja/tabeldaja.py
tabeldaja/tabeldaja.py
+15
-8
tabeldaja/tulbad.csv
tabeldaja/tulbad.csv
+426
-426
No files found.
VERSION
View file @
348aae6d
0.3.4
0.4.0
\ No newline at end of file
\ No newline at end of file
tabeldaja/configure_columns.py
View file @
348aae6d
SIMPLE
=
[
'ressursi nimed'
,
'doi'
]
SIMPLE
=
[
'ressursi nimed'
,
'doi'
]
NAMES
=
[
'eestikeelne ressursi nimi'
,
'ingliskeelne ressursi nimi'
,
'kontaktisiku asutus'
,
'doi'
]
#
NAMES = ['eestikeelne ressursi nimi','ingliskeelne ressursi nimi','kontaktisiku asutus','doi']
NAMES_ATA
=
[
'eestikeelne ressursi nimi'
,
'ingliskeelne ressursi nimi'
,
'kontaktisik asutuseta'
,
'doi'
]
NAMES_ATA
=
[
'eestikeelne ressursi nimi'
,
'ingliskeelne ressursi nimi'
,
'kontaktisik asutuseta'
,
'doi'
]
NAMES
=
[
'eestikeelne ressursi nimi'
,
'ingliskeelne ressursi nimi'
,
'kontaktisik asutuseta'
,
'kontaktisiku asutus'
,
'doi'
]
\ No newline at end of file
tabeldaja/tabeldaja.py
View file @
348aae6d
...
@@ -15,7 +15,8 @@ from lxml import etree
...
@@ -15,7 +15,8 @@ from lxml import etree
from
prepare
import
read_xml
from
prepare
import
read_xml
from
configure_columns
import
SIMPLE
,
NAMES
,
NAMES_ATA
from
configure_columns
import
SIMPLE
,
NAMES
,
NAMES_ATA
XPATHLIST
=
NAMES_ATA
#XPATHLIST = NAMES_ATA
XPATHLIST
=
NAMES
class
Name
(
object
):
class
Name
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -73,7 +74,7 @@ def make_filter(tabelifail: str = 'tulbad.csv') -> list:
...
@@ -73,7 +74,7 @@ def make_filter(tabelifail: str = 'tulbad.csv') -> list:
return
labels_et
return
labels_et
def
text_or_subtexts
(
element
:
etree
.
_Element
)
:
def
text_or_subtexts
(
element
:
etree
.
_Element
,
block
:
str
=
None
)
->
str
:
out
=
[]
out
=
[]
if
element
.
text
:
if
element
.
text
:
a
=
element
.
text
a
=
element
.
text
...
@@ -81,13 +82,19 @@ def text_or_subtexts(element: etree._Element):
...
@@ -81,13 +82,19 @@ def text_or_subtexts(element: etree._Element):
a
=
'http://doi.org/'
+
a
a
=
'http://doi.org/'
+
a
return
a
return
a
else
:
else
:
#for el in element.xpath('./descendant-or-self::*/text()'):
if
not
block
:
for
el
in
element
.
xpath
(
'./*[not(descendant::affiliation) and not(ancestor-or-self::affiliation)]/text()'
):
for
el
in
element
.
xpath
(
'./descendant-or-self::*/text()'
):
out
.
append
(
el
)
else
:
for
el
in
element
.
xpath
(
'./*[not(descendant::{block}) and not(ancestor-or-self::{block})]/text()'
.
format
(
block
=
block
)
):
out
.
append
(
el
)
out
.
append
(
el
)
return
', '
.
join
(
out
)
return
', '
.
join
(
out
)
def
get_xpath
(
root
:
etree
.
_ElementTree
,
xpath
:
str
)
->
str
:
def
get_xpath
(
root
:
etree
.
_ElementTree
,
xpath
:
str
,
block
:
str
)
->
str
:
"""Returns text attribute(s) of XML Elements returned by xpath query.
"""Returns text attribute(s) of XML Elements returned by xpath query.
:param root: etree._ElementTree xml root
:param root: etree._ElementTree xml root
...
@@ -96,7 +103,7 @@ def get_xpath(root: etree._ElementTree, xpath: str) -> str:
...
@@ -96,7 +103,7 @@ def get_xpath(root: etree._ElementTree, xpath: str) -> str:
"""
"""
namespaces
=
{
'x'
:
'http://www.ilsp.gr/META-XMLSchema'
}
namespaces
=
{
'x'
:
'http://www.ilsp.gr/META-XMLSchema'
}
elements
=
root
.
xpath
(
xpath
,
namespaces
=
namespaces
)
elements
=
root
.
xpath
(
xpath
,
namespaces
=
namespaces
)
texts
=
[
text_or_subtexts
(
x
)
for
x
in
elements
]
texts
=
[
text_or_subtexts
(
x
,
block
)
for
x
in
elements
]
#return texts
#return texts
return
', '
.
join
(
texts
)
return
', '
.
join
(
texts
)
...
@@ -129,7 +136,7 @@ def featured_rows(list_of_roots: list, labels: list) -> list:
...
@@ -129,7 +136,7 @@ def featured_rows(list_of_roots: list, labels: list) -> list:
for
i
in
list_of_roots
:
for
i
in
list_of_roots
:
rida
=
{}
rida
=
{}
for
t
in
labels
:
for
t
in
labels
:
rida
[
t
[
'label_et'
]]
=
get_xpath
(
i
,
t
[
'xpath'
])
rida
[
t
[
'label_et'
]]
=
get_xpath
(
i
,
t
[
'xpath'
]
,
t
[
'block'
]
)
out
.
append
(
rida
)
out
.
append
(
rida
)
rida
=
{}
rida
=
{}
return
out
return
out
...
...
tabeldaja/tulbad.csv
View file @
348aae6d
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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