You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not uncommon for extractors to be conditional, i.e. they should return None unless some condition holds.
The extractor class supports a condition applicable which allows you to check a property in the metadata, but this is not very flexible. It only works on the document level, for one thing.
It would be nice to change this to a more general condition, where applicable instead takes an extractor.
For the old functionality, you can use the Metadata extractor:
#extract the foo tag if 'bar' is set to True in the metadataXML('foo', applicable=lambdametadata: metadata['bar'])
# becomes:XML('foo', applicable=Metadata('bar'))
However, other cases can now use the same syntax to be a lot more readable:
# extract the foo tag if a bar tag exists in the node & is truthyCombined(
XML('foo'),
XML('bar'),
transform=lambdavalues: value[0] ifvalue[1] elseNone
)
# becomes:XML('foo',
applicable=XML('bar')
)
The text was updated successfully, but these errors were encountered:
Note: the secondary_tag property on the XML extractor is also used to specify some kind of condition which could be captured by this as well, I think. -> this already covered by #18
lukavdplas
transferred this issue from CentreForDigitalHumanities/I-analyzer
Feb 16, 2024
It's not uncommon for extractors to be conditional, i.e. they should return
None
unless some condition holds.The extractor class supports a condition
applicable
which allows you to check a property in the metadata, but this is not very flexible. It only works on the document level, for one thing.It would be nice to change this to a more general condition, where
applicable
instead takes an extractor.For the old functionality, you can use the
Metadata
extractor:However, other cases can now use the same syntax to be a lot more readable:
The text was updated successfully, but these errors were encountered: