Skip to main content

XML/TRXML Selector

Description

This package provides two scripts: mine-xml and mine-trxml.

mine-xml selects tags from xml/mxml files, and save the selected values to file.

mine-trxml selects fields from trxml/mtrxml files, and save the selected values to file.

Status

https://travis-ci.org/tilaboy/xml-miner.svg?branch=master Documentation Status Updates

Requirements

Python 3.6+

Installation

pip install xml-selector

Usage

Use xml selector script

The xml selector supports:

  • one or more tagnames:

  • selector could be one tagname name

  • or comma separated tagnames langskill,compskill,softskills

  • multiple sources:

  • e.g. select from xml dir, xml files, mxml file, or directly from annotation server

examples:

#select from xml directory
mine-xml --source tests/xmls/ --selector name --output_file name.tsv
mine-xml --source tests/xmls/ --selector langskill,compskill,softskill --output_file skill.tsv --with_field_name

#select from xml file or mxml file
mine-xml --source tests/sample.mxml --selector experience --output_file experience.tsv

#select directly from annotation server
mine-xml --source localhost:50249 --selector name --output_file name.tsv --query "set Data2018"

Use trxml selector script

The trxml selector supports:

  • one or more selectors:

  • selector can be one field: name.0.name

  • or comma separated fields: name.0.name,address.0.address

  • single or multi item:

  • can select field from one item, e.g. experienceitem.3.experience

  • or select field value of all item, e.g. experienceitem.experience (or experienceitem.*.experience)

  • multiple sources:

  • e.g. select from trxml dir, trxml files, or mtrxml file

examples:

# one selector, single item
mine-trxml --source tests/trxmls/ --selector name.0.name --output_file name.tsv

# one selector, multiple item
mine-trxml --source tests/sample.mxml --selector experienceitem.experience --output_file experience.tsv

# more selectors, single item
mine-trxml --source tests/trxmls/ --selector name.0.name,address.0.address,phone.0.phone --output_file personal.tsv

# more selectors, multiple item
mine-trxml --source tests/sample.mxml  --itemgroup experienceitem --fields experience,experiencedate --output_file experience.tsv
mine-trxml --source tests/sample.mxml  --selector experienceitem.*.experience,experienceitem.*.experiencedate --output_file experience.tsv
mine-trxml --source tests/sample.mxml  --selector experienceitem.experience,experienceitem.experiencedate --output_file experience.tsv

Development

To install package and its dependencies, run the following from project root directory:

python setup.py install

To work the code and develop the package, run the following from project root directory:

python setup.py develop

To run unit tests, execute the following from the project root directory:

python setup.py test

selector and output details:

  • mine-xml:

    input: documents, selector(s), output

    output:

    • default (parameter with_field_name not set): filename, field_value

    e.g. select all names with selector name

    filename

    value

    xxxx

    Chao Li

    • parameter with_field_name set: filename, field_value, field_name

    e.g. select skills with selector compskill,langskill,otherskill

    filename

    value

    field

    xxxx

    java

    compskill

    xxxx

    dutch

    langskill

  • mine-trxml

    • input:

    • documents, selector(s), output,

    • documents, itemgroup, fields, output

    • single selector:

    • single item (name.0.name): filename field

    filename

    name.0.name

    xxxx

    Chao Li

    • multi items (skill.*.skill): filename item_index field

    filename

    item_index

    field

    xxxx

    0

    java

    xxxx

    1

    dutch

    • multiple selectors

    • single item: filename, field1, field2 …

    each selector points to a field of a specific item with a digital index, e.g. name.0.lastname,name.0.firstname,address.0.country

    filename

    name.0.lastname

    name.0.firstname

    address.0.country

    xxxx

    Li

    Chao

    China

    xxxx

    Lee

    Richard

    USA

    • multi items: filename, item_index, field1, field2 …

    each selector points to a field from all items in an itemgroup, e.g. skill.skill,skill.type,skill.date

    filename

    skill

    skill

    type

    date

    xxxx

    0

    java

    compskill

    2001-2005

    xxxx

    1

    dutch

    langskill

    2002-

0.0.5 (2019-10-14)

  • bug fix: ElementTree xpath find will return a None if value is an empty string, restore to empty string

0.0.4 (2019-09-11)

  • bug fix: reading always use utf8, and not continue reading if failed on encoding of one document

0.0.3 (2019-08-11)

  • expand miner.py module to generate matched phrases per doc

0.0.2 (2019-08-09)

  • added support for CI

0.0.1 (2019-08-09)

  • make two script: mine-xml and mine-trxml

0.0.0 (2019-08-06)

  • Add the first version of the mine_xml and mine_trxml

Metadata

Release files for xml-miner 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xml-miner 0.0.5
File Size Uploaded Provenance Actions
xml_miner-0.0.5.tar.gz 23.7 kB Without provenance Details for xml_miner-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xml-miner 0.0.5
File Interpreter ABI Platform Actions
xml_miner-0.0.5-py2.py3-none-any.whl Python 3, Python 2 none any Details for xml_miner-0.0.5-py2.py3-none-any.whl

Total release size: 43.9 kB

Release files / xml_miner-0.0.5.tar.gz

Download URL xml_miner-0.0.5.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bdab76c295a8de22f8b6e78e4452fd70097d8e754e0c8b7252758672878636d2
BLAKE2b-256 checksum
How to use checksums
83715c6ce0b5835b6bdd6f68252c2f4afbe19b786f441f8c4ca6df4d9849b04e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

Release files / xml_miner-0.0.5-py2.py3-none-any.whl

Download URL xml_miner-0.0.5-py2.py3-none-any.whl
Size 20.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2a3ab1f6eca7df8e72a404de063ccb15d977e8e651fcf1978846049e37642d31
BLAKE2b-256 checksum
How to use checksums
f6eb2af8d8f0d9a154f4345f53a8326ab7848463147a46d9aa4a072b48cfe34a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

Security for xml-miner 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page