ilios / mesh-parser
PHP library for extracting MeSH descriptors from XML.
Installs: 146 513
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 14
Forks: 5
Open Issues: 1
Requires
- php: >=8.2
- ext-dom: *
- ext-xmlreader: *
Requires (Dev)
- fakerphp/faker: @stable
- mockery/mockery: @stable
- phpstan/phpstan: ^1.10
- phpunit/phpunit: @stable
- squizlabs/php_codesniffer: @stable
This package is auto-updated.
Last update: 2024-06-16 09:25:55 UTC
README
MeSH Parser
This PHP code library provides tools for extracting Medical Subject Headings (MeSH) descriptors and associated data from a given XML file into an object representation.
It expects its input to be compliant with the 2023 or 2024 MeSH DTDs.
Installation
Use composer to add this library to your project.
composer require ilios/mesh-parser
Usage
Instantiate \Ilios\MeSH\Parser
and invoke its parse()
method with a URI that points at valid MeSH descriptors
XML file.
This method call will return an instance of \Ilios\MeSH\Model\DescriptorSet
; this is the entry point into
the object representation of the descriptors data model.
Use getter methods on this object and its subcomponents to traverse and process this model.
Example
<?php require __DIR__ . '/vendor/autoload.php'; // provide a URL or a local file path. //$uri = 'https://nlmpubs.nlm.nih.gov/projects/mesh/MESH_FILES/xmlmesh/desc2024.xml'; $uri = __DIR__ . '/desc2024.xml'; // instantiate the parser and parse the input. $parser = new \Ilios\MeSH\Parser(); $set = $parser->parse($uri); // process parsed data, e.g. $descriptor = $set->findDescriptorByUi('D000001'); echo "Descriptor ID (Name): {$descriptor->getUi()} ({$descriptor->getName()})\n"; $concepts = $descriptor->getConcepts(); foreach($concepts as $concept) { echo "- Concept ID (Name): {$concept->getUi()} ({$concept->getName()})\n"; $terms = $concept->getTerms(); foreach ($terms as $term) { // ... } }