Revision 102
Added by Aaron Marcuse-Kubitza about 13 years ago
scripts/lib/xml_func.py | ||
---|---|---|
26 | 26 |
items = dict(items) |
27 | 27 |
return ' '.join([items['first'], items['last']]) |
28 | 28 |
|
29 |
def namePart(items): |
|
30 |
items = dict(items) |
|
31 |
def to_parts(name): return items[name].split(' ') |
|
32 |
parts = [] |
|
33 |
if 'first' in items: parts += to_parts('first')[:1] |
|
34 |
if 'last' in items: parts += to_parts('last')[-1:] |
|
35 |
if 'middle' in items: parts += to_parts('middle')[1:-1] |
|
36 |
return ' '.join(parts) |
|
37 |
|
|
29 | 38 |
# Function names must start with _ to avoid collisions with real tags |
30 |
# Functions have take arguments (doc, node) |
|
31 |
funcs = {'_range': range_, '_avg': avg, '_date': date, '_name': name} |
|
39 |
# Function names must be lowercase because name_of() returns name lowercased |
|
40 |
# Functions take arguments (doc, node) |
|
41 |
funcs = {'_range': range_, '_avg': avg, '_date': date, '_name': name, |
|
42 |
'_namepart': namePart} |
|
32 | 43 |
|
33 | 44 |
def process(doc, node=None): |
34 | 45 |
if node == None: node = doc.documentElement |
scripts/util/NYSpecimenDataAmericas.xml | ||
---|---|---|
56 | 56 |
</party> |
57 | 57 |
<party id="1"> |
58 | 58 |
<individualName> |
59 |
<surName>R. B. Foster</surName>
|
|
60 |
<givenName>R. B. Foster</givenName>
|
|
59 |
<surName>Foster</surName> |
|
60 |
<givenName>R. B.</givenName> |
|
61 | 61 |
</individualName> |
62 | 62 |
</party> |
63 | 63 |
<party id="2"> |
... | ... | |
65 | 65 |
</party> |
66 | 66 |
<party id="3"> |
67 | 67 |
<individualName> |
68 |
<surName>J. B. Walker</surName>
|
|
69 |
<givenName>J. B. Walker</givenName>
|
|
68 |
<surName>Walker</surName> |
|
69 |
<givenName>J. B.</givenName> |
|
70 | 70 |
</individualName> |
71 | 71 |
</party> |
72 | 72 |
</parties> |
mappings/VegX-VegBank.organisms.csv | ||
---|---|---|
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" |
25 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=collector]/partyWithRole/*ID->/parties/party/individualName/{givenName,surName}","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/collector_ID/party/{givenName,middleName,surName}"
|
|
26 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/partyWithRole/*ID->/parties/party/individualName/{givenName,surName}","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]:[interpretationType=Author,originalInterpretation=false,currentInterpretation=true]/*_ID/party/{givenName,middleName,surName}"
|
|
25 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=collector]/partyWithRole/*ID->/parties/party/individualName/{givenName/_namePart/{first,middle},surName/_namePart/last}","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/collector_ID/party/{givenName/_namePart/first,middleName/_namePart/middle,surName/_namePart/last}"
|
|
26 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/partyWithRole/*ID->/parties/party/individualName/{givenName/_namePart/{first,middle},surName/_namePart/last}","/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}"
|
|
27 | 27 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept/authorCode","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/collectionNumber" |
28 | 28 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept/note/text","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/notes" |
29 | 29 |
"/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept/partyWithRole/*ID->/parties/party/organizationName/_name/first","/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/museum_ID/party/OrganizationName/_name/first" |
mappings/NYBG-VegX.organisms.csv | ||
---|---|---|
16 | 16 |
"Species","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonConcept[Rank/@code=sp])/Name" |
17 | 17 |
"Subspecies","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonConcept[Rank/@code=ssp])/Name" |
18 | 18 |
"ScientificNameAuthor","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/*s/taxonRelationshipAssertion(/assertion/*ID->/*s/taxonConcept[Rank/@code=sp])/AccordingTo/Simple" |
19 |
"IdentifiedBy","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/partyWithRole/*ID->/parties/party/individualName/{givenName,surName}"
|
|
19 |
"IdentifiedBy","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/partyWithRole/*ID->/parties/party/individualName/{givenName/_namePart/{first,middle},surName/_namePart/last}"
|
|
20 | 20 |
"YearIdentified","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/date/_date/year" |
21 | 21 |
"MonthIdentified","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/date/_date/month" |
22 | 22 |
"DayIdentified","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=identifier]/date/_date/day" |
23 | 23 |
"TypeStatus", |
24 | 24 |
"CollectorNumber", |
25 | 25 |
"FieldNumber","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept/authorCode" |
26 |
"Collector","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=collector]/partyWithRole/*ID->/parties/party/individualName/{givenName,surName}"
|
|
26 |
"Collector","/*ID->/*s/individualOrganism/*sID->/*s/taxonNameUsageConcept->/*s/taxonDetermination[*ID,partyWithRole/role=collector]/partyWithRole/*ID->/parties/party/individualName/{givenName/_namePart/{first,middle},surName/_namePart/last}"
|
|
27 | 27 |
"YearCollected","/*ID->/*s/plotObservation/obsStartDate/_date/year" |
28 | 28 |
"MonthCollected","/*ID->/*s/plotObservation/obsStartDate/_date/month" |
29 | 29 |
"DayCollected","/*ID->/*s/plotObservation/obsStartDate/_date/day" |
mappings/joins/NYBG-VegBank.organisms.csv | ||
---|---|---|
12 | 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" |
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 |
IdentifiedBy,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]:[interpretationType=Author,originalInterpretation=false,currentInterpretation=true]/*_ID/party/{givenName,middleName,surName}"
|
|
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}"
|
|
16 | 16 |
YearIdentified,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]/interpretationDate/_date/year" |
17 | 17 |
MonthIdentified,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]/interpretationDate/_date/month" |
18 | 18 |
DayIdentified,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=identifier,!*_ID/plantConcept/plantStatus]/interpretationDate/_date/day" |
19 | 19 |
FieldNumber,/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/collectionNumber |
20 |
Collector,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/collector_ID/party/{givenName,middleName,surName}"
|
|
20 |
Collector,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/collector_ID/party/{givenName/_namePart/first,middleName/_namePart/middle,surName/_namePart/last}"
|
|
21 | 21 |
YearCollected,/*_ID/observation/obsStartDate/_date/year |
22 | 22 |
MonthCollected,/*_ID/observation/obsStartDate/_date/month |
23 | 23 |
DayCollected,/*_ID/observation/obsStartDate/_date/day |
Also available in: Unified diff
xml_func.py: Added _namepart function for extracting parts of names