<commit_before># MeSH Parser

This PHP code library provides tools for extracting [Medical Subject Headings](https://www.nlm.nih.gov/mesh/) 
(MeSH) descriptors and associated data from a given XML file into an object representation.

It expects its input to be compliant with the 2016 or 2017 [MeSH DTDs](https://www.nlm.nih.gov/databases/dtd/).

## Installation

Use composer to add this library to your project.

```bash
composer require ilios/mesh-parser
```

## Usage

Instantiate `\Ilios\MeSH\Parser()` and invoke its `parse()` method with an URI that points a a valid MeSH descriptors 
XML file as its sole argument.  
This method call will return an instance of  `\Ilios\MeSH\Model\DescriptorSet`; this is the top-level entry point into
object representation of the descriptors data model.  
Use getter methods on this object and its sub-components to traverse and process this model.

### Example

```php
<?php

require __DIR__ . '/vendor/autoload.php';

// provide an URL or a local file path.
//$uri = 'ftp://nlmpubs.nlm.nih.gov/online/mesh/.xmlmesh/desc2016.xml';
$uri = __DIR__ . '/desc2016.xml';

// instantiate the parser and parse the input.
$parser = new \Ilios\MeSH\Parser();<commit_msg>updated code example with link to 2019 mesh xml.<commit_after># MeSH Parser

This PHP code library provides tools for extracting [Medical Subject Headings](https://www.nlm.nih.gov/mesh/) 
(MeSH) descriptors and associated data from a given XML file into an object representation.

It expects its input to be compliant with the 2016 or 2017 [MeSH DTDs](https://www.nlm.nih.gov/databases/dtd/).

## Installation

Use composer to add this library to your project.

```bash
composer require ilios/mesh-parser
```

## Usage

Instantiate `\Ilios\MeSH\Parser()` and invoke its `parse()` method with an URI that points a a valid MeSH descriptors 
XML file as its sole argument.  
This method call will return an instance of  `\Ilios\MeSH\Model\DescriptorSet`; this is the top-level entry point into
object representation of the descriptors data model.  
Use getter methods on this object and its sub-components to traverse and process this model.

### Example

```php
<?php

require __DIR__ . '/vendor/autoload.php';

// provide an URL or a local file path.
//$uri = 'ftp://nlmpubs.nlm.nih.gov/online/mesh/MESH_FILES/xmlmesh/desc2019.xml';
$uri = __DIR__ . '/desc2019.xml';

// instantiate the parser and parse the input.
$parser = new \Ilios\MeSH\Parser();
{'fraction_non_alphanumeric': 0.10232368528332654, 'fraction_numerical': 0.014675907052588666, 'mean_word_length': 4.070247933884297, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 7}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2381854', 'n_tokens_mistral': 795, 'n_tokens_neox': 719, 'n_words': 301}