Revision 113
Added by Aaron Marcuse-Kubitza about 13 years ago
scripts/lib/xml_func.py | ||
---|---|---|
7 | 7 |
def map_items(func, items): |
8 | 8 |
return [(name, func(value)) for name, value in items] |
9 | 9 |
|
10 |
def alt(items): |
|
11 |
items = list(items) |
|
12 |
items.sort() |
|
13 |
return items[0][1] # value of lowest-numbered item |
|
14 |
|
|
10 | 15 |
def range_(items): |
11 | 16 |
items = dict(map_items(float, items)) |
12 | 17 |
return str(items['to'] - items['from']) |
... | ... | |
42 | 47 |
# Function names must start with _ to avoid collisions with real tags |
43 | 48 |
# Function names must be lowercase because name_of() returns name lowercased |
44 | 49 |
# Functions take arguments (doc, node) |
45 |
funcs = {'_range': range_, '_avg': avg, '_date': date, '_name': name,
|
|
46 |
'_namepart': namePart} |
|
50 |
funcs = {'_alt': alt, '_range': range_, '_avg': avg, '_date': date,
|
|
51 |
'_name': name, '_namepart': namePart}
|
|
47 | 52 |
|
48 | 53 |
def process(doc, node=None): |
49 | 54 |
if node == None: node = doc.documentElement |
mappings/VegX-VegBank.organisms.csv | ||
---|---|---|
16 | 16 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonConcept[Rank/@code=phyl_div])/Name","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Subkingdom]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
17 | 17 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonConcept[Rank/@code=reg])/Name","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Kingdom]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
18 | 18 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonConcept[Rank/@code=sp])/AccordingTo/Simple","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Species]/*_ID/plantConcept/*_ID/reference/referenceContributor/*_ID/referenceParty/{givenName,surname}" |
19 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonConcept[Rank/@code=sp])/Name","/taxonImportance/stemCount/stemLocation/{taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Species]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName,taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/*_ID/plantConcept/*_ID/*/plantName}" |
|
19 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonConcept[Rank/@code=sp])/Name","/taxonImportance/stemCount/stemLocation/{taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Species]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName,taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/*_ID/plantConcept/*_ID/*/plantName/_alt/2}"
|
|
20 | 20 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonConcept[Rank/@code=ssp])/Name","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Subspecies]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
21 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonName)/Simple","/taxonImportance/stemCount/stemLocation/{taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[*_ID/reference]/*_ID/*/plantName,taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/*_ID/plantConcept:[*_ID/reference]/*_ID/*/plantName}" |
|
21 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonName)/Simple","/taxonImportance/stemCount/stemLocation/{taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[*_ID/reference]/*_ID/*/plantName,taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/*_ID/plantConcept:[*_ID/reference]/*_ID/*/plantName/_alt/1}"
|
|
22 | 22 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/date/_date/day","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]/interpretationDate/_date/day" |
23 | 23 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/date/_date/month","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]/interpretationDate/_date/month" |
24 | 24 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/date/_date/year","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]/interpretationDate/_date/year" |
mappings/NYBG-VegBank.organisms.csv | ||
---|---|---|
2 | 2 |
:1,/taxonImportance/*/stemCount |
3 | 3 |
InstitutionCode,/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/museum_ID/party/OrganizationName/_name/first |
4 | 4 |
CollectionCode,/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/museum_ID/party/OrganizationName/_name/last |
5 |
ScientificName,"/taxonImportance/stemCount/stemLocation/{taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[*_ID/reference]/*_ID/*/plantName,taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/*_ID/plantConcept:[*_ID/reference]/*_ID/*/plantName}" |
|
5 |
ScientificName,"/taxonImportance/stemCount/stemLocation/{taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[*_ID/reference]/*_ID/*/plantName,taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/*_ID/plantConcept:[*_ID/reference]/*_ID/*/plantName/_alt/1}"
|
|
6 | 6 |
Kingdom,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Kingdom]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
7 | 7 |
Phylum,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Subkingdom]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
8 | 8 |
Class,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Class]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
9 | 9 |
Order,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Order]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
10 | 10 |
Family,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Family]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
11 | 11 |
Genus,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Genus]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
12 |
Species,"/taxonImportance/stemCount/stemLocation/{taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Species]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName,taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/*_ID/plantConcept/*_ID/*/plantName}" |
|
12 |
Species,"/taxonImportance/stemCount/stemLocation/{taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Species]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName,taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/*_ID/plantConcept/*_ID/*/plantName/_alt/2}"
|
|
13 | 13 |
Subspecies,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Subspecies]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
14 | 14 |
ScientificNameAuthor,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Species]/*_ID/plantConcept/*_ID/reference/referenceContributor/*_ID/referenceParty/{givenName,surname}" |
15 | 15 |
IdentifiedBy,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]:[interpretationType=Author,originalInterpretation=false,currentInterpretation=true]/*_ID/party/{givenName/_namePart/first,middleName/_namePart/middle,surName/_namePart/last}" |
mappings/SALVIAS-VegBank.organisms.csv | ||
---|---|---|
37 | 37 |
stem_liana_infestation,"/taxonImportance/stemCount/stemLocation/definedValue[*_ID/userDefined[tableName=stemLocation,userDefinedName=stemLianaInfestation]:[userDefinedType=varchar]]:[@fkey=tableRecord_ID]/definedValue" |
38 | 38 |
notes,/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/notes |
39 | 39 |
orig_family,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Family]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName" |
40 |
orig_species,"/taxonImportance/stemCount/stemLocation/{taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Species]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName,taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/*_ID/plantConcept/*_ID/*/plantName}" |
|
40 |
orig_species,"/taxonImportance/stemCount/stemLocation/{taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,*_ID/plantConcept/plantStatus/plantLevel=Species]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=true,interpretationDate=epoch,*_ID/party]/*_ID/plantConcept:[plantStatus:[plantConceptStatus=accepted,startDate=epoch,*_ID/party],*_ID/reference]/*_ID/*/plantName,taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/*_ID/plantConcept/*_ID/*/plantName/_alt/2}" |
Also available in: Unified diff
xml_func.py: Added _alt function to choose between alternative values and used it for the collector plantName mapping