├── .github
└── workflows
│ ├── python-package.yml
│ └── python-publish.yml
├── .gitignore
├── LICENSE
├── MANIFEST
├── README.md
├── doc
├── Example_federated_shapes.ipynb
├── Rdf_config_files_from_local_content.ipynb
├── input_types.ipynb
├── outputs.ipynb
├── shape_maps_to_define_target_nodes_and_shapes.ipynb
├── shexer4wikipathways.ipynb
├── shexer_wikidata_tutorial.ipynb
└── tunning_extraction_several_parameters.ipynb
├── experiments
├── dbpedia
│ ├── README.md
│ └── shex_dbo.shex
└── wikidata
│ ├── celestial_bodies
│ ├── README.md
│ ├── celestial_classes_depth_1.tsv
│ └── wikidata_celestial.shex
│ └── countries_and_cities
│ ├── README.md
│ └── wikidata_country_capital.shex
├── requirements.txt
├── setup.cfg
├── setup.py
├── shexer
├── __init__.py
├── consts.py
├── core
│ ├── __init__.py
│ ├── instances
│ │ ├── __init__.py
│ │ ├── abstract_instance_tracker.py
│ │ ├── annotators
│ │ │ ├── __init__.py
│ │ │ ├── annotator_func.py
│ │ │ ├── annotator_tracking_instances.py
│ │ │ ├── base_annotator.py
│ │ │ └── strategy_mode
│ │ │ │ ├── __init__.py
│ │ │ │ ├── all_classes_mode.py
│ │ │ │ ├── base_strategy_mode.py
│ │ │ │ ├── compound_strategy_mode.py
│ │ │ │ ├── instance_cap_mode.py
│ │ │ │ ├── instances_cap_exception.py
│ │ │ │ ├── shape_qualifiers_mode.py
│ │ │ │ └── target_classes_mode.py
│ │ ├── endpoint_instance_tracker.py
│ │ ├── federated_source_instance_tracker.py
│ │ ├── instance_tracker.py
│ │ ├── mappings
│ │ │ ├── __init__.py
│ │ │ └── shape_map_instance_tracker.py
│ │ ├── mix
│ │ │ ├── __init__.py
│ │ │ └── mixed_instance_tracker.py
│ │ └── pconsts.py
│ ├── profiling
│ │ ├── __init__.py
│ │ ├── class_profiler.py
│ │ ├── consts.py
│ │ ├── federated_source_class_profiler.py
│ │ └── strategy
│ │ │ ├── __init__.py
│ │ │ ├── abstract_feature_direction_strategy.py
│ │ │ ├── direct_features_strategy.py
│ │ │ └── include_reverse_features_strategy.py
│ └── shexing
│ │ ├── __init__.py
│ │ ├── class_shexer.py
│ │ ├── class_shexer_fed_sources.py
│ │ └── strategy
│ │ ├── __init__.py
│ │ ├── abstract_shexing_strategy.py
│ │ ├── direct_and_inverse_shexing_strategy.py
│ │ ├── direct_shexing_strategy.py
│ │ └── minimal_iri_strategy
│ │ ├── __init__.py
│ │ ├── abstract_min_iri_strategy.py
│ │ ├── annotate_min_iri_strategy.py
│ │ └── ignore_min_iri_strategy.py
├── io
│ ├── __init__.py
│ ├── file.py
│ ├── graph
│ │ ├── __init__.py
│ │ └── yielder
│ │ │ ├── __init__.py
│ │ │ ├── base_triples_yielder.py
│ │ │ ├── big_ttl_triples_yielder.py
│ │ │ ├── filter
│ │ │ ├── __init__.py
│ │ │ └── filter_namespaces_triple_yielder.py
│ │ │ ├── multi_big_ttl_files_triple_yielder.py
│ │ │ ├── multi_nt_triples_yielder.py
│ │ │ ├── multi_rdflib_triple_yielder.py
│ │ │ ├── multi_tsv_nt_triples_yielder.py
│ │ │ ├── multi_zip_triples_yielder.py
│ │ │ ├── multifile_base_triples_yielder.py
│ │ │ ├── nt_triples_yielder.py
│ │ │ ├── rdflib_triple_yielder.py
│ │ │ ├── remote
│ │ │ ├── __init__.py
│ │ │ └── sgraph_from_selectors_triple_yielder.py
│ │ │ └── tsv_nt_triples_yielder.py
│ ├── json
│ │ ├── __init__.py
│ │ └── json_loader.py
│ ├── line_reader
│ │ ├── __init__.py
│ │ ├── file_line_reader.py
│ │ ├── gz_line_reader.py
│ │ ├── raw_string_line_reader.py
│ │ ├── xz_line_reader.py
│ │ └── zip_file_line_reader.py
│ ├── profile
│ │ ├── __init__.py
│ │ └── formater
│ │ │ ├── __init__.py
│ │ │ └── abstract_profile_serializer.py
│ ├── rdfconfig
│ │ ├── __init__.py
│ │ └── formater
│ │ │ ├── __init__.py
│ │ │ └── rdfconfig_serializer.py
│ ├── shacl
│ │ ├── __init__.py
│ │ └── formater
│ │ │ ├── __init__.py
│ │ │ └── shacl_serializer.py
│ ├── shape_map
│ │ ├── __init__.py
│ │ ├── label
│ │ │ ├── __init__.py
│ │ │ └── shape_map_label_parser.py
│ │ ├── node_selector
│ │ │ ├── __init__.py
│ │ │ └── node_selector_parser.py
│ │ └── shape_map_parser.py
│ ├── shex
│ │ ├── __init__.py
│ │ └── formater
│ │ │ ├── __init__.py
│ │ │ ├── consts.py
│ │ │ ├── shex_serializer.py
│ │ │ └── statement_serializers
│ │ │ ├── __init__.py
│ │ │ ├── base_statement_serializer.py
│ │ │ ├── fixed_prop_choice_statement_serializer.py
│ │ │ ├── frequency_strategy
│ │ │ ├── __init__.py
│ │ │ ├── abs_freq_serializer.py
│ │ │ ├── base_frequency_strategy.py
│ │ │ ├── mixed_frequency_strategy.py
│ │ │ └── ratio_freq_serializer.py
│ │ │ ├── inverse_statement_serializer.py
│ │ │ └── st_serializers_factory.py
│ ├── sparql
│ │ ├── __init__.py
│ │ └── query.py
│ ├── uml
│ │ ├── __init__.py
│ │ └── uml_serializer.py
│ └── wikidata.py
├── model
│ ├── IRI.py
│ ├── Literal.py
│ ├── Macro.py
│ ├── __init__.py
│ ├── bnode.py
│ ├── const_elem_types.py
│ ├── federated_source.py
│ ├── fixed_prop_choice_statement.py
│ ├── graph
│ │ ├── __init__.py
│ │ ├── abstract_sgraph.py
│ │ ├── endpoint_sgraph.py
│ │ └── rdflib_sgraph.py
│ ├── hierarchy_tree.py
│ ├── node_selector.py
│ ├── property.py
│ ├── shape.py
│ ├── shape_map.py
│ └── statement.py
├── shaper.py
└── utils
│ ├── __init__.py
│ ├── compression.py
│ ├── dict.py
│ ├── factories
│ ├── __init__.py
│ ├── class_profiler_factory.py
│ ├── class_shexer_factory.py
│ ├── h_tree.py
│ ├── instance_tracker_factory.py
│ ├── iri_factory.py
│ ├── remote_graph_factory.py
│ ├── shape_map_factory.py
│ ├── shape_map_parser_factory.py
│ ├── shape_serializer_factory.py
│ └── triple_yielders_factory.py
│ ├── file.py
│ ├── literal.py
│ ├── log.py
│ ├── namespaces.py
│ ├── obj_references.py
│ ├── shapes.py
│ ├── structures
│ ├── __init__.py
│ └── dicts.py
│ ├── target_elements.py
│ ├── translators
│ ├── __init__.py
│ └── list_of_classes_to_shape_map.py
│ ├── triple_yielders.py
│ └── uri.py
├── test
├── __init__.py
├── const.py
├── t_files
│ ├── bnodes
│ │ ├── bnode_people.nt
│ │ ├── bnode_people.ttl
│ │ ├── or_with_redundant_bnodes_and_shapes.shex
│ │ ├── or_with_redundant_bnodes_iris_and_shapes.shex
│ │ ├── people_some_bnodes_dont_have_shape.ttl
│ │ ├── people_target_mixes_bnodes_and_iris.ttl
│ │ ├── people_target_mixes_bnodes_iris_and_no_shapes.ttl
│ │ ├── schema_bnode_people.shex
│ │ ├── schema_people_some_bnodes_dont_have_shape.shex
│ │ └── schema_people_target_mixes_bnodes_iris_and_no_shapes.shex
│ ├── compression
│ │ ├── t1_graph_partials_1_2_3__3.nt.zip
│ │ ├── t1_graph_partials_1_2__3.nt.zip
│ │ ├── t1_graph_partials_3__3.nt.zip
│ │ ├── t1_partial_1_3.nt
│ │ ├── t1_partial_2_3.nt
│ │ ├── t1_partial_3_3.nt
│ │ ├── t_graph_1.json.gz
│ │ ├── t_graph_1.json.xz
│ │ ├── t_graph_1.json.zip
│ │ ├── t_graph_1.n3.gz
│ │ ├── t_graph_1.n3.xz
│ │ ├── t_graph_1.n3.zip
│ │ ├── t_graph_1.nt.gz
│ │ ├── t_graph_1.nt.xz
│ │ ├── t_graph_1.nt.zip
│ │ ├── t_graph_1.tsv.gz
│ │ ├── t_graph_1.tsv.xz
│ │ ├── t_graph_1.tsv.zip
│ │ ├── t_graph_1.ttl.gz
│ │ ├── t_graph_1.ttl.xz
│ │ ├── t_graph_1.ttl.zip
│ │ ├── t_graph_1.xml.gz
│ │ ├── t_graph_1.xml.xz
│ │ └── t_graph_1.xml.zip
│ ├── disable_comments
│ │ ├── g2.ttl
│ │ ├── g2_disable.shex
│ │ └── g2_enable.shex
│ ├── disable_or
│ │ ├── g3_or_example.ttl
│ │ ├── g_or_example_expandable_IRI.ttl
│ │ ├── or_disabled.shex
│ │ ├── or_enabled.shex
│ │ └── redundant_enabled_useful_IRI.shex
│ ├── discard_and_compliant
│ │ ├── compliant_no_discard.shex
│ │ ├── no_compliant_discard.shex
│ │ └── no_compliant_no_discard.shex
│ ├── empty_shapes
│ │ ├── one_empty_not_remove.shex
│ │ └── some_empty_not_remove.shex
│ ├── exact_cardinality
│ │ ├── g6_exact_cardinality.ttl
│ │ ├── g6_exact_disabled.shex
│ │ └── g6_exact_enabled.shex
│ ├── example_features
│ │ ├── determ_constraint_examples_no_inverse.shex
│ │ ├── determ_constraint_examples_with_inverse.shex
│ │ ├── determ_no_examples_no_inverse.shex
│ │ ├── determ_single_instance_single_prop_only_shape_examples_no_count.shex
│ │ ├── determ_single_instance_single_prop_only_shape_examples_with_count.shex
│ │ ├── single_class_deterministic_order.ttl
│ │ ├── single_instance_2_prop.ttl
│ │ └── single_instance_single_prop.ttl
│ ├── freq_reports
│ │ ├── g_person_0_decimals.shex
│ │ ├── g_person_2_decimals.shex
│ │ ├── g_person_absolute_instances.shex
│ │ ├── g_person_comments_disabled.shex
│ │ ├── g_person_every_decimal.shex
│ │ ├── g_person_infinite_frequencies.ttl
│ │ ├── g_person_mixed_2_dec.shex
│ │ └── g_person_mixed_unbound_dec.shex
│ ├── general
│ │ └── g1_all_classes_no_comments.shex
│ ├── graph_list_of_files_input
│ │ ├── g1_p1.nt
│ │ ├── g1_p1.ttl
│ │ ├── g1_p2.nt
│ │ └── g1_p2.ttl
│ ├── https
│ │ ├── https.ttl
│ │ └── https_shacl.ttl
│ ├── instances_cap
│ │ ├── all_classes_cap_1.shex
│ │ ├── all_classes_cap_3.shex
│ │ ├── target_person_cap_1.shex
│ │ └── target_person_cap_5.shex
│ ├── instances_file_input
│ │ ├── all_classes_some_instances.shex
│ │ ├── g1_all_instances.nt
│ │ ├── g1_some_instances.nt
│ │ ├── some_classes_all_instances.shex
│ │ └── some_classes_some_instances.shex
│ ├── instantiation_prop
│ │ ├── G1_ex_a.shex
│ │ ├── G1_ex_a.ttl
│ │ ├── G1_ex_a_some_rdftype.shex
│ │ └── G1_ex_a_some_rdftype.ttl
│ ├── inverse_paths
│ │ └── g1_inverse.shex
│ ├── keep_less_specific
│ │ ├── g1_several_names.ttl
│ │ ├── keep_less_compliant.shex
│ │ ├── keep_less_no_compliant.shex
│ │ ├── no_keep_less_compliant.shex
│ │ └── no_keep_less_no_compliant.shex
│ ├── literals
│ │ ├── different_literals.ttl
│ │ ├── different_literals_shacl.ttl
│ │ ├── literals_no_xsd.ttl
│ │ └── literals_no_xsd_shacl.ttl
│ ├── min_iri
│ │ ├── g1_all_classes_no_comments_min_iri.shex
│ │ ├── g1_different_base_per_instance_no_sep_char.ttl
│ │ ├── g1_different_namespaces_per_class.shex
│ │ ├── g1_different_namespaces_per_class.ttl
│ │ ├── g1_different_namespaces_per_instance.shex
│ │ ├── g1_different_namespaces_per_instance.ttl
│ │ ├── shacl_g1_all_classes_no_comments_min_iri.ttl
│ │ ├── shacl_g1_different_namespaces_per_class.ttl
│ │ └── shacl_g1_different_namespaces_per_instance.ttl
│ ├── namespaces_dict
│ │ ├── no_foaf.shex
│ │ ├── overwrite.shex
│ │ └── overwrite_empty.shex
│ ├── namespaces_to_ignore
│ │ ├── g1_namespaces.ttl
│ │ ├── g1_namespaces_indirect.ttl
│ │ ├── g1_other_namespace.shex
│ │ └── g1_other_namespace_indirect.shex
│ ├── no_sharp
│ │ └── sharp_chances.ttl
│ ├── no_slash_prefixed
│ │ └── g1_no_prefix_except_shapes.shex
│ ├── node_types
│ │ ├── property_to_IRI_and_literal.shex
│ │ └── property_to_IRI_and_literal.ttl
│ ├── opt_cardinality
│ │ ├── g4_opt_cardinality.ttl
│ │ ├── g4_opt_disabled.shex
│ │ └── g4_opt_enabled.shex
│ ├── qualifiers
│ │ ├── virus_qualifiers.shex
│ │ └── virus_wikidata_depth2.ttl
│ ├── shacl
│ │ ├── g1_all_classes.ttl
│ │ └── g1_person.ttl
│ ├── shape_map
│ │ ├── a_node.shex
│ │ ├── focus.sm
│ │ ├── focus_and_wildcard.shex
│ │ ├── focus_and_wildcard.sm
│ │ ├── focus_nodes.shex
│ │ ├── node_selector.sm
│ │ ├── prefixed_node_selector.sm
│ │ ├── several_shm_items.shex
│ │ ├── several_shm_items.sm
│ │ └── sparql_selector.sm
│ ├── shapes_namespace
│ │ ├── different_namespace.shex
│ │ ├── empty_prefix_used.shex
│ │ └── empty_prefix_used_and_no_def.shex
│ ├── sort
│ │ ├── g_sort.shex
│ │ ├── g_sort.ttl
│ │ ├── g_sort_incoming.shex
│ │ ├── g_sort_incoming.ttl
│ │ ├── g_sort_mixed.shex
│ │ └── g_sort_mixed.ttl
│ ├── t_graph_1.json
│ ├── t_graph_1.n3
│ ├── t_graph_1.nt
│ ├── t_graph_1.tsv
│ ├── t_graph_1.ttl
│ ├── t_graph_1.xml
│ ├── t_graph_1_absolutes.ttl
│ ├── t_graph_1_base.ttl
│ ├── t_graph_1_bnode.ttl
│ ├── t_graph_1_multiline_str.ttl
│ ├── t_graph_1_scaped_quotes.ttl
│ ├── t_graph_1_scaped_quotes_and_multiline.ttl
│ ├── target_classes
│ │ ├── input_classes_one_target.tsv
│ │ ├── input_classes_one_target_prefixed.tsv
│ │ ├── input_classes_two_targets.tsv
│ │ ├── one_target.shex
│ │ └── two_targets.shex
│ ├── threshold
│ │ ├── g1_t05.shex
│ │ ├── g1_t051.shex
│ │ └── g1_t1.shex
│ ├── uml
│ │ └── a.txt
│ ├── untyped_numbers
│ │ ├── g1_untyped_age.nt
│ │ └── g1_untyped_weight.nt
│ └── wikidata_annotation
│ │ ├── wiki_example.ttl
│ │ ├── wiki_example_noanot.shex
│ │ └── wiki_example_noanot_shacl.ttl
├── t_utils.py
├── test_all_classes_mode.py
├── test_allow_opt_cardinality.py
├── test_allow_redundant_or.py
├── test_bnode_handling.py
├── test_bugs
│ ├── __init__.py
│ ├── test_no_sharp_in_auto_shape_names.py
│ └── test_no_sharp_nor_slash_due_to_prefixing.py
├── test_compression_mode.py
├── test_decimals.py
├── test_depth_for_building_subgraph.py
├── test_detect_minimal_iri.py
├── test_disable_comments.py
├── test_disable_endpoint_cache.py
├── test_disable_exact_cardinality.py
├── test_disable_or_statements.py
├── test_discard_and_compliant.py
├── test_examples_mode.py
├── test_file_target_classes.py
├── test_graph_file_input.py
├── test_graph_list_of_file_inputs.py
├── test_infer_numeric_types_for_untyped_literals.py
├── test_input_format.py
├── test_instances_cap.py
├── test_instances_file_input.py
├── test_instances_report.py
├── test_instantiation_property.py
├── test_inverse_paths.py
├── test_keep_less_specific.py
├── test_list_of_url_input.py
├── test_namespaces_dict.py
├── test_namespaces_to_ignore.py
├── test_node_types.py
├── test_raw_graph.py
├── test_raw_shape_map.py
├── test_rdflib_graph.py
├── test_remove_empty_sahpes.py
├── test_shacl
│ ├── __init__.py
│ ├── test_annotation.py
│ ├── test_class_selection.py
│ ├── test_detect_minimal_iri.py
│ ├── test_https.py
│ ├── test_literal_types.py
│ └── test_shape_map_compatibility.py
├── test_shape_map_file.py
├── test_shape_map_format.py
├── test_shape_qualifiers_mode.py
├── test_shapes_namespaces.py
├── test_sort.py
├── test_target_classes.py
├── test_threshold.py
├── test_uml_gen.py
├── test_url_endpoint.py
├── test_url_graph.py
└── test_wikidata_annotation.py
└── ws
├── __init__.py
├── docker
└── Dockerfile
├── shexer_rest.py
└── wsgi.py
/.github/workflows/python-package.yml:
--------------------------------------------------------------------------------
1 | # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3 |
4 | name: Python package
5 |
6 | on:
7 | push:
8 | branches: [ "master" ]
9 | pull_request:
10 | branches: [ "master" ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 | strategy:
17 | fail-fast: false
18 | matrix:
19 | python-version: ["3.8","3.9", "3.10", "3.11"]
20 |
21 | steps:
22 | - uses: actions/checkout@v4
23 | - name: Set up Python ${{ matrix.python-version }}
24 | uses: actions/setup-python@v3
25 | with:
26 | python-version: ${{ matrix.python-version }}
27 | - name: Install dependencies
28 | run: |
29 | python -m pip install --upgrade pip
30 | python -m pip install flake8 pytest
31 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
32 | - name: Lint with flake8
33 | run: |
34 | # stop the build if there are Python syntax errors or undefined names
35 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
36 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38 | - name: Test with pytest
39 | run: |
40 | pytest
41 |
--------------------------------------------------------------------------------
/.github/workflows/python-publish.yml:
--------------------------------------------------------------------------------
1 | # This workflow will upload a Python Package using Twine when a release is created
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3 |
4 | # This workflow uses actions that are not certified by GitHub.
5 | # They are provided by a third-party and are governed by
6 | # separate terms of service, privacy policy, and support
7 | # documentation.
8 |
9 | name: Upload Python Package
10 |
11 | on:
12 | release:
13 | types: [published]
14 |
15 | permissions:
16 | contents: read
17 |
18 | jobs:
19 | deploy:
20 |
21 | runs-on: ubuntu-latest
22 |
23 | steps:
24 | - uses: actions/checkout@v4
25 | - name: Set up Python
26 | uses: actions/setup-python@v3
27 | with:
28 | python-version: '3.x'
29 | - name: Install dependencies
30 | run: |
31 | python -m pip install --upgrade pip
32 | pip install build
33 | - name: Build package
34 | run: python -m build
35 | - name: Publish package
36 | uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37 | with:
38 | user: __token__
39 | password: ${{ secrets.PYPI_API_TOKEN }}
40 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | env/
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 |
49 | # Translations
50 | *.mo
51 | *.pot
52 |
53 | # Django stuff:
54 | *.log
55 | local_settings.py
56 |
57 | # Flask stuff:
58 | instance/
59 | .webassets-cache
60 |
61 | # Scrapy stuff:
62 | .scrapy
63 |
64 | # Sphinx documentation
65 | docs/_build/
66 |
67 | # PyBuilder
68 | target/
69 |
70 | # Jupyter Notebook
71 | .ipynb_checkpoints
72 |
73 | # pyenv
74 | .python-version
75 |
76 | # celery beat schedule file
77 | celerybeat-schedule
78 |
79 | # SageMath parsed files
80 | *.sage.py
81 |
82 | # dotenv
83 | .env
84 |
85 | # virtualenv
86 | .venv
87 | venv/
88 | ENV/
89 |
90 | # Spyder project settings
91 | .spyderproject
92 | .spyproject
93 |
94 | # Rope project settings
95 | .ropeproject
96 |
97 | # mkdocs documentation
98 | /site
99 |
100 | # mypy
101 | .mypy_cache/
102 |
103 | # pycharm
104 |
105 | .idea/
106 |
107 | # local tests
108 |
109 | dbshx/local_code/
110 | local_code/
111 | shexer/local_code/
112 |
113 | # data
114 | files/
115 | logs/
116 |
--------------------------------------------------------------------------------
/MANIFEST:
--------------------------------------------------------------------------------
1 | # file GENERATED by distutils, do NOT edit
2 | setup.cfg
3 | setup.py
4 | shexer\__init__.py
5 | shexer\consts.py
6 | shexer\shaper.py
7 |
--------------------------------------------------------------------------------
/experiments/dbpedia/README.md:
--------------------------------------------------------------------------------
1 | The file shex_dbo.shex contains the shapes inferred for each class in dbpedia ontology with some instance in DBpedia.
2 |
3 | * Ontology: http://mappings.dbpedia.org/server/ontology/dbpedia.owl
4 | * Aceptance threshold: 0.5
5 | * Knowlegde graph: composition of the following list of files:
6 | * http://downloads.dbpedia.org/2016-10/core/geonames_links_en.ttl.bz2
7 | * http://downloads.dbpedia.org/2016-10/core/article_categories_en.ttl.bz2
8 | * http://downloads.dbpedia.org/2016-10/core/freebase_links_en.ttl.bz2
9 | * http://downloads.dbpedia.org/2016-10/core/geo_coordinates_en.ttl.bz2
10 | * http://downloads.dbpedia.org/2016-10/core/infobox_properties_en.ttl.bz2
11 | * http://downloads.dbpedia.org/2016-10/core/infobox_property_definitions_en.ttl.bz2
12 | * http://downloads.dbpedia.org/2016-10/core/instance_types_en.ttl.bz2
13 | * http://downloads.dbpedia.org/2016-10/core/interlanguage_links_chapters_en.ttl.bz2
14 | * http://downloads.dbpedia.org/2016-10/core/mappingbased_objects_en.ttl.bz2
15 | * http://downloads.dbpedia.org/2016-10/core/persondata_en.ttl.bz2
16 | * http://downloads.dbpedia.org/2016-10/core/skos_categories_en.ttl.bz2
17 | * http://downloads.dbpedia.org/2016-10/core/specific_mappingbased_properties_en.ttl.bz2
18 | * http://downloads.dbpedia.org/2016-10/core/uri_same_as_iri_en.ttl.bz2
19 | * http://downloads.dbpedia.org/2016-10/core/category_labels_en.ttl.bz2
20 | * http://downloads.dbpedia.org/2016-10/core/homepages_en.ttl.bz2
21 | * http://downloads.dbpedia.org/2016-10/core/labels_en.ttl.bz2
22 | * http://downloads.dbpedia.org/2016-10/core/mappingbased_literals_en.ttl.bz2
23 | * http://downloads.dbpedia.org/2016-10/core/page_ids_en.ttl.bz2
24 |
--------------------------------------------------------------------------------
/experiments/wikidata/celestial_bodies/README.md:
--------------------------------------------------------------------------------
1 | Shapes of different celestial bodies
2 |
3 | These shapes have been produced using all the triples in Wikidata whose sucject is an instance of planet (Q634), star (Q523), comet (Q3559), or any of their subclasses. The following configuration has been used:
4 |
5 | * Target classes: the ones listed in the file [celestial_classes_depth_1](https://github.com/DaniFdezAlvarez/shexer/blob/develop/experiments/wikidata/celestial_bodies/celestial_classes_depth_1.tsv).
6 | * Aceptance threshold: 0.2
7 | * Namespaces ignored : and (most of the properties considered belong to the namespace ).
8 | * inference_of_unlabelled_numeric_tipes active. This means that if there is some triple whose object is an untyped number (ex: 56 instead of "56"^^xsd:int), it will consider it a integer if does not have decimals or a float if it does.
9 | * all_instances_are_compliant_mode active. This means that every instance of a class will conform with the shape associated to that classs using kleene closure for cardinalities when needed.
10 | * discard_useless_constraints active. This means that if in case that there are a couple of constraints sharing property and object but with different cardinality, and one of those cardinalities is '+', with exactly the same compliance rate, the constraint with '+' will be discarded.
11 |
--------------------------------------------------------------------------------
/experiments/wikidata/countries_and_cities/README.md:
--------------------------------------------------------------------------------
1 | Shapes of Country and Capital
2 | These shapes have been produced using all the triples in Wikidata which sucject is an instance of country (Q6256) or capital (Q5119) using the following configuration:
3 |
4 | * Target classes: and .
5 | * Aceptance threshold: 0.7
6 | * Namespaces ignored : and (most of the properties considered belong to the namespace ).
7 | * inference_of_unlabelled_numeric_tipes active. This means that if there is some triple whose object is an untyped number (ex: 56 instead of "56"^^xsd:int), it will consider it a integer if does not have decimals or a float if it does.
8 | * all_instances_are_compliant_mode active. This means that every instance of a class will conform with the shape associated to that classs using kleene closure for cardinalities when needed.
9 | * discard_useless_constraints active. This means that if in case that there are a couple of constraints sharing property and object but with different cardinality, and one of those cardinalities is '+', with exactly the same compliance rate, the constraint with '+' will be discarded.
10 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | Flask==2.3.2
2 | Flask-Cors==5.0.0
3 | rdflib==6.0.2
4 | SPARQLWrapper==1.8.4
5 | wlighter==1.0.1
6 | plantuml==0.3.0
7 | python-xz==0.5.0
8 | six==1.16.0
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [metadata]
2 | description-file = README.md
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from distutils.core import setup
2 | from setuptools import find_packages
3 |
4 | def read(file_path):
5 | with open(file_path, "r") as in_stream:
6 | return in_stream.read()
7 |
8 | setup(
9 | name = 'shexer',
10 | packages = find_packages(exclude=["*.local_code.*"]), # this must be the same as the name above
11 | version = '2.6.3',
12 | description = 'Automatic schema extraction for RDF graphs',
13 | author = 'Daniel Fernandez-Alvarez',
14 | author_email = 'danifdezalvarez@gmail.com',
15 | url = 'https://github.com/DaniFdezAlvarez/shexer',
16 | download_url = 'https://github.com/DaniFdezAlvarez/shexer/archive/2.6.3.tar.gz',
17 | keywords = ['testing', 'shexer', 'shexerp3', "rdf", "shex", "shacl", "schema"],
18 | long_description = read('README.md'),
19 | long_description_content_type='text/markdown',
20 | classifiers=[
21 | "Programming Language :: Python :: 3.7",
22 | "Programming Language :: Python :: 3.8",
23 | "Programming Language :: Python :: 3.9",
24 | "Programming Language :: Python :: 3.10",
25 | "Programming Language :: Python :: 3.11",
26 | "Intended Audience :: Science/Research",
27 | "Intended Audience :: Information Technology",
28 | "Topic :: Software Development :: Libraries :: Python Modules"
29 | ],
30 | install_requires=[
31 | 'Flask',
32 | 'Flask-Cors',
33 | 'rdflib',
34 | 'SPARQLWrapper',
35 | 'wlighter',
36 | 'plantuml',
37 | 'python-xz'
38 | ],
39 | )
40 |
--------------------------------------------------------------------------------
/shexer/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/__init__.py
--------------------------------------------------------------------------------
/shexer/consts.py:
--------------------------------------------------------------------------------
1 | #OUTPUTS
2 | SHEXC = "ShEx"
3 | SHACL_TURTLE = "Shacl"
4 |
5 | #INPUT FORMATS
6 | NT = "nt"
7 | TSV_SPO = "tsv_spo"
8 | TURTLE = "turtle"
9 | TURTLE_ITER = "turtle_iter"
10 | RDF_XML = "xml"
11 | N3 = "n3"
12 | JSON_LD = "json-ld"
13 |
14 | #SHAPE MAP FORMATS
15 | JSON = "json"
16 | FIXED_SHAPE_MAP = "fsm"
17 |
18 | #FREQUENT INSTATIATION PROPERTIES
19 | RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
20 | WIKIDATA_INSTACE_OF = "http://www.wikidata.org/prop/direct/P31"
21 |
22 | #NAMESPACES
23 | SHAPES_DEFAULT_NAMESPACE = "http://weso.es/shapes/"
24 |
25 | #COMPRESSION FORMATS
26 | ZIP = "zip"
27 | GZ = "gz"
28 | XZ = "xz"
29 |
30 | # FREQUENCY MODES
31 |
32 | RATIO_INSTANCES = "ratio"
33 | ABSOLUTE_INSTANCES = "abs"
34 | MIXED_INSTANCES = "mixed"
35 |
36 |
37 | # EXAMPLES
38 | SHAPE_EXAMPLES = "shape"
39 | CONSTRAINT_EXAMPLES = "cons"
40 | ALL_EXAMPLES = "all"
41 |
42 | # UML
43 | UML_PLANT_SERVER = "http://www.plantuml.com/plantuml/img/"
44 |
--------------------------------------------------------------------------------
/shexer/core/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/__init__.py
--------------------------------------------------------------------------------
/shexer/core/instances/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/instances/__init__.py
--------------------------------------------------------------------------------
/shexer/core/instances/annotators/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/instances/annotators/__init__.py
--------------------------------------------------------------------------------
/shexer/core/instances/annotators/annotator_func.py:
--------------------------------------------------------------------------------
1 | from shexer.core.instances.annotators.base_annotator import BaseAnnotator
2 | from shexer.core.instances.annotators.annotator_tracking_instances import AnnotatorTrackingInstances
3 |
4 | def get_proper_annotator(track_hierarchies, instance_tracker_ref):
5 | return BaseAnnotator(instance_tracker_ref) if not track_hierarchies \
6 | else AnnotatorTrackingInstances(instance_tracker_ref)
--------------------------------------------------------------------------------
/shexer/core/instances/annotators/strategy_mode/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/instances/annotators/strategy_mode/__init__.py
--------------------------------------------------------------------------------
/shexer/core/instances/annotators/strategy_mode/all_classes_mode.py:
--------------------------------------------------------------------------------
1 | from shexer.core.instances.annotators.strategy_mode.base_strategy_mode import BaseStrategyMode
2 | from shexer.core.instances.pconsts import _P
3 |
4 | class AllClasesMode(BaseStrategyMode):
5 |
6 | def __init__(self, annotator_ref):
7 | super().__init__(annotator_ref)
8 |
9 |
10 |
11 | def is_relevant_triple(self, a_triple):
12 | if a_triple[_P] != self._instantiation_property:
13 | return False
14 | return True
15 |
16 |
17 | def annotate_triple(self, a_triple):
18 | if self._instance_tracker.is_an_instantiation_prop(a_triple[_P]):
19 | self._annotator_ref.add_instance_to_instances_dict(a_triple)
20 | self.annotate_class(a_triple)
21 |
22 |
23 |
--------------------------------------------------------------------------------
/shexer/core/instances/annotators/strategy_mode/base_strategy_mode.py:
--------------------------------------------------------------------------------
1 | from shexer.core.instances.pconsts import _S, _O
2 |
3 | class BaseStrategyMode(object):
4 |
5 | def __init__(self, annotator_ref):
6 | self._annotator_ref = annotator_ref
7 | self._instantiation_property = self._annotator_ref._instantiation_property
8 | self._instances_dict = self._annotator_ref._instances_dict
9 | self._instance_tracker = self._annotator_ref._instance_tracker
10 |
11 | def is_relevant_triple(self, a_triple):
12 | raise NotImplementedError()
13 |
14 | def annotate_triple(self, a_triple):
15 | raise NotImplementedError()
16 |
17 | def annotate_class(self, a_triple):
18 | self._instances_dict[a_triple[_S].iri].append(a_triple[_O].iri)
19 |
20 | def annotation_post_parsing(self):
21 | pass # By default, do nothing.
22 |
--------------------------------------------------------------------------------
/shexer/core/instances/annotators/strategy_mode/compound_strategy_mode.py:
--------------------------------------------------------------------------------
1 | from shexer.core.instances.annotators.strategy_mode.base_strategy_mode import BaseStrategyMode
2 |
3 |
4 | class CompoundStrategyMode(BaseStrategyMode):
5 |
6 | def __init__(self, annotator_ref, list_of_strategies):
7 | super().__init__(annotator_ref)
8 | self._list_of_strategies = list_of_strategies
9 |
10 |
11 | def is_relevant_triple(self, a_triple):
12 | for a_strategy in self._list_of_strategies:
13 | if a_strategy.is_relevant_triple(a_triple):
14 | return True
15 | return False
16 |
17 | def annotate_triple(self, a_triple):
18 | for a_strategy in self._list_of_strategies:
19 | a_strategy.annotate_triple(a_triple)
20 |
21 | def annotation_post_parsing(self):
22 | for a_strategy in self._list_of_strategies:
23 | a_strategy.annotation_post_parsing()
24 |
--------------------------------------------------------------------------------
/shexer/core/instances/annotators/strategy_mode/instances_cap_exception.py:
--------------------------------------------------------------------------------
1 |
2 | class InstancesCapException(BaseException):
3 |
4 | def __init__(self):
5 | pass
--------------------------------------------------------------------------------
/shexer/core/instances/annotators/strategy_mode/shape_qualifiers_mode.py:
--------------------------------------------------------------------------------
1 | from shexer.core.instances.annotators.strategy_mode.base_strategy_mode import BaseStrategyMode
2 | from shexer.utils.triple_yielders import check_if_property_belongs_to_namespace_list
3 | from shexer.utils.shapes import build_shape_name_for_qualifier_prop_uri
4 | from shexer.core.instances.pconsts import _P, _O
5 |
6 | class ShapeQualifiersMode(BaseStrategyMode):
7 |
8 | def __init__(self, annotator_ref, namespaces_for_qualifiers_props, shapes_namespace):
9 | super().__init__(annotator_ref)
10 | self._namespaces_for_qualifiers_props = namespaces_for_qualifiers_props
11 | self._dict_of_qualifier_properties = {}
12 | self._shapes_namespace = shapes_namespace
13 |
14 |
15 | def is_relevant_triple(self, a_triple):
16 | if check_if_property_belongs_to_namespace_list(str_prop=a_triple[_P].iri,
17 | namespaces=self._namespaces_for_qualifiers_props):
18 | return True
19 | return False
20 |
21 |
22 | def annotate_triple(self, a_triple):
23 | self._annotate_qualifier_shape(a_triple[_P])
24 | self._annotate_instance_of_a_qualifier(a_triple)
25 |
26 |
27 | def _annotate_instance_of_a_qualifier(self, a_triple):
28 | if a_triple[_O].iri not in self._instances_dict:
29 | self._instances_dict[a_triple[_O].iri] = []
30 | self._instances_dict[a_triple[_O].iri].append(self._dict_of_qualifier_properties[a_triple[_P].iri])
31 |
32 |
33 | def _annotate_qualifier_shape(self, a_property):
34 | str_prop = a_property.iri
35 | if str_prop not in self._dict_of_qualifier_properties:
36 | self._dict_of_qualifier_properties[str_prop] = \
37 | build_shape_name_for_qualifier_prop_uri(prop_uri=str_prop,
38 | shapes_namespace=self._shapes_namespace)
39 |
--------------------------------------------------------------------------------
/shexer/core/instances/annotators/strategy_mode/target_classes_mode.py:
--------------------------------------------------------------------------------
1 |
2 | from shexer.core.instances.annotators.strategy_mode.base_strategy_mode import BaseStrategyMode
3 | from shexer.core.instances.pconsts import _P, _O
4 |
5 | class TargetClassesMode(BaseStrategyMode):
6 |
7 | def __init__(self, annotator_ref):
8 | super().__init__(annotator_ref)
9 | self._target_classes = self._annotator_ref._target_classes
10 |
11 | def is_relevant_triple(self, a_triple):
12 | if a_triple[_P] != self._instantiation_property:
13 | return False
14 | if a_triple[_O] not in self._target_classes:
15 | return False
16 | return True
17 |
18 | def annotate_triple(self, a_triple):
19 | if self._instance_tracker.is_an_instantiation_prop(a_triple[_P]):
20 | self._annotator_ref.add_instance_to_instances_dict(a_triple)
21 | self.annotate_class(a_triple)
22 |
23 |
--------------------------------------------------------------------------------
/shexer/core/instances/endpoint_instance_tracker.py:
--------------------------------------------------------------------------------
1 | from shexer.core.instances.abstract_instance_tracker import _RDF_TYPE, _RDFS_SUBCLASS_OF
2 | from shexer.core.instances.instance_tracker import InstanceTracker
3 | from shexer.consts import SHAPES_DEFAULT_NAMESPACE
4 | from shexer.model.bnode import BNode
5 | from shexer.core.instances.pconsts import _S
6 |
7 |
8 | class EndpointInstanceTracker(InstanceTracker):
9 |
10 | def __init__(self, target_classes, triples_yielder, instantiation_property=_RDF_TYPE, all_classes_mode=False,
11 | subclass_property=_RDFS_SUBCLASS_OF, track_hierarchies=True, shape_qualifiers_mode=False,
12 | namespaces_for_qualifier_props=None, shapes_namespace=SHAPES_DEFAULT_NAMESPACE, instances_cap=-1):
13 | super().__init__(target_classes=target_classes,
14 | triples_yielder=triples_yielder,
15 | instantiation_property=instantiation_property,
16 | all_classes_mode=all_classes_mode,
17 | subclass_property=subclass_property,
18 | track_hierarchies=track_hierarchies,
19 | shape_qualifiers_mode=shape_qualifiers_mode,
20 | namespaces_for_qualifier_props=namespaces_for_qualifier_props,
21 | shapes_namespace=shapes_namespace,
22 | instances_cap=instances_cap)
23 |
24 | def _yield_relevant_triples(self):
25 | for a_triple in self._triples_yielder.yield_triples():
26 | if self._annotator.is_relevant_triple(a_triple) and self._subject_is_not_bnode(a_triple):
27 | self._relevant_triples += 1
28 | yield a_triple
29 | else:
30 | self._not_relevant_triples += 1
31 |
32 | def _subject_is_not_bnode(self, a_triple):
33 | return not isinstance(a_triple[_S], BNode)
34 |
--------------------------------------------------------------------------------
/shexer/core/instances/mappings/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/instances/mappings/__init__.py
--------------------------------------------------------------------------------
/shexer/core/instances/mappings/shape_map_instance_tracker.py:
--------------------------------------------------------------------------------
1 | from shexer.core.instances.abstract_instance_tracker import AbstractInstanceTracker
2 | from shexer.utils.log import log_msg
3 |
4 |
5 | class ShapeMapInstanceTracker(AbstractInstanceTracker):
6 |
7 | def __init__(self, shape_map):
8 | self._shape_map = shape_map
9 | self._instances_dict = {}
10 |
11 | def track_instances(self, verbose=False):
12 | log_msg(verbose=verbose,
13 | msg="Starting instance tracker...")
14 | for an_item in self._shape_map.yield_items():
15 | self._solve_targets_of_an_item(an_item)
16 | log_msg(verbose=verbose,
17 | msg="Instance tracker finished. {} instances located".format(len(self._instances_dict)))
18 | return self._instances_dict
19 |
20 | @property
21 | def shape_map(self):
22 | return self._shape_map
23 |
24 | def _solve_targets_of_an_item(self, an_item):
25 | for a_node in an_item.node_selector.get_target_nodes():
26 | if a_node not in self._instances_dict:
27 | self._instances_dict[a_node] = []
28 | self._instances_dict[a_node].append(an_item.shape_label)
29 |
30 | def _specific_disambiguator_prefix(self):
31 | return "custom_"
32 |
--------------------------------------------------------------------------------
/shexer/core/instances/mix/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/instances/mix/__init__.py
--------------------------------------------------------------------------------
/shexer/core/instances/pconsts.py:
--------------------------------------------------------------------------------
1 | _S = 0
2 | _P = 1
3 | _O = 2
4 |
5 | FEDERATION_TAG_MARK = "_fed_"
--------------------------------------------------------------------------------
/shexer/core/profiling/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/profiling/__init__.py
--------------------------------------------------------------------------------
/shexer/core/profiling/consts.py:
--------------------------------------------------------------------------------
1 | _S = 0
2 | _P = 1
3 | _O = 2
4 |
5 | POS_CLASSES = 0
6 | POS_FEATURES_DIRECT = 1
7 | POS_FEATURES_INVERSE = 2
8 |
9 | _ONE_TO_MANY = "+"
10 |
11 | RDF_TYPE_STR = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
--------------------------------------------------------------------------------
/shexer/core/profiling/strategy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/profiling/strategy/__init__.py
--------------------------------------------------------------------------------
/shexer/core/shexing/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/shexing/__init__.py
--------------------------------------------------------------------------------
/shexer/core/shexing/strategy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/shexing/strategy/__init__.py
--------------------------------------------------------------------------------
/shexer/core/shexing/strategy/minimal_iri_strategy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/core/shexing/strategy/minimal_iri_strategy/__init__.py
--------------------------------------------------------------------------------
/shexer/core/shexing/strategy/minimal_iri_strategy/abstract_min_iri_strategy.py:
--------------------------------------------------------------------------------
1 | class AbstractMinIriStrategy(object):
2 |
3 | def annotate_shape_iri(self, shape):
4 | raise NotImplementedError()
--------------------------------------------------------------------------------
/shexer/core/shexing/strategy/minimal_iri_strategy/ignore_min_iri_strategy.py:
--------------------------------------------------------------------------------
1 | from shexer.core.shexing.strategy.minimal_iri_strategy.abstract_min_iri_strategy import AbstractMinIriStrategy
2 |
3 |
4 | class IgnoreMinIriStrategy(AbstractMinIriStrategy):
5 |
6 | def __init__(self):
7 | pass
8 |
9 | def annotate_shape_iri(self, shape):
10 | """
11 | Just skip this, no need to do anything
12 |
13 | :param shape:
14 | :param class_key:
15 | :return:
16 | """
17 | pass
18 |
--------------------------------------------------------------------------------
/shexer/io/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/__init__.py
--------------------------------------------------------------------------------
/shexer/io/file.py:
--------------------------------------------------------------------------------
1 | def read_file(file_path):
2 | with open(file_path, "r") as in_stream:
3 | return in_stream.read()
--------------------------------------------------------------------------------
/shexer/io/graph/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/graph/__init__.py
--------------------------------------------------------------------------------
/shexer/io/graph/yielder/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/graph/yielder/__init__.py
--------------------------------------------------------------------------------
/shexer/io/graph/yielder/base_triples_yielder.py:
--------------------------------------------------------------------------------
1 |
2 | from shexer.io.line_reader.file_line_reader import FileLineReader
3 | from shexer.io.line_reader.raw_string_line_reader import RawStringLineReader
4 | from shexer.io.line_reader.gz_line_reader import GzFileLineReader
5 | from shexer.io.line_reader.zip_file_line_reader import ZipFileLineReader
6 | from shexer.io.line_reader.xz_line_reader import XzFileLineReader
7 | from shexer.utils.obj_references import check_just_one_not_none
8 | from shexer.consts import ZIP, GZ, XZ
9 |
10 | class BaseTriplesYielder(object):
11 |
12 | def __init__(self):
13 | pass
14 |
15 | def _decide_line_reader(self, raw_graph, source_file,
16 | compression_mode=None,
17 | zip_base_archive=None):
18 | check_just_one_not_none((source_file, "source_file"),
19 | (raw_graph, "raw_graph"))
20 | if raw_graph is not None:
21 | return RawStringLineReader(raw_string=raw_graph)
22 | elif compression_mode is None:
23 | return FileLineReader(source_file=source_file)
24 | elif compression_mode == GZ:
25 | return GzFileLineReader(gz_file=source_file)
26 | elif compression_mode == ZIP:
27 | return ZipFileLineReader(zip_archive=zip_base_archive,
28 | zip_target=source_file)
29 | elif compression_mode == XZ:
30 | return XzFileLineReader(xz_file=source_file)
31 | else:
32 | raise ValueError("Unsupported compression mode: {}".format(compression_mode))
33 |
34 | def yield_triples(self):
35 | raise NotImplementedError("Implement this method in derived classes")
--------------------------------------------------------------------------------
/shexer/io/graph/yielder/filter/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/graph/yielder/filter/__init__.py
--------------------------------------------------------------------------------
/shexer/io/graph/yielder/filter/filter_namespaces_triple_yielder.py:
--------------------------------------------------------------------------------
1 | from shexer.io.graph.yielder.base_triples_yielder import BaseTriplesYielder
2 | from shexer.utils.triple_yielders import check_if_property_belongs_to_namespace_list
3 |
4 | class FilterNamespacesTriplesYielder(BaseTriplesYielder):
5 |
6 | def __init__(self, actual_triple_yielder, namespaces_to_ignore):
7 | super().__init__()
8 | self._actual_triple_yielder = actual_triple_yielder
9 | self._namespaces_to_ignore = namespaces_to_ignore
10 |
11 |
12 | def yield_triples(self):
13 | for a_triple in self._actual_triple_yielder.yield_triples():
14 | if self._pass_filters(a_triple):
15 | yield a_triple
16 |
17 | def _pass_filters(self, a_triple):
18 | return not check_if_property_belongs_to_namespace_list(str_prop=str(a_triple[1]),
19 | namespaces=self._namespaces_to_ignore)
20 |
--------------------------------------------------------------------------------
/shexer/io/graph/yielder/multi_big_ttl_files_triple_yielder.py:
--------------------------------------------------------------------------------
1 |
2 | from shexer.io.graph.yielder.big_ttl_triples_yielder import BigTtlTriplesYielder
3 | from shexer.io.graph.yielder.multifile_base_triples_yielder import MultifileBaseTripleYielder
4 |
5 |
6 | class MultiBigTtlTriplesYielder(MultifileBaseTripleYielder):
7 |
8 | def __init__(self, list_of_files, allow_untyped_numbers=False, compression_mode=None, zip_base_archive=None):
9 | super(MultiBigTtlTriplesYielder, self).__init__(list_of_files=list_of_files,
10 | allow_untyped_numbers=allow_untyped_numbers,
11 | zip_base_archive=zip_base_archive,
12 | compression_mode=compression_mode)
13 |
14 | def _constructor_file_yielder(self, a_source_file, parse_namespaces=False):
15 | return BigTtlTriplesYielder(source_file=a_source_file,
16 | allow_untyped_numbers=self._allow_untyped_numbers,
17 | compression_mode=self._compression_mode,
18 | zip_base_archive=self._zip_base_archive)
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/shexer/io/graph/yielder/multi_nt_triples_yielder.py:
--------------------------------------------------------------------------------
1 | from shexer.io.graph.yielder.nt_triples_yielder import NtTriplesYielder
2 | from shexer.io.graph.yielder.multifile_base_triples_yielder import MultifileBaseTripleYielder
3 |
4 |
5 | class MultiNtTriplesYielder(MultifileBaseTripleYielder):
6 |
7 | def __init__(self, list_of_files,
8 | allow_untyped_numbers=False,
9 | compression_mode=None,
10 | zip_base_archive=None):
11 | super(MultiNtTriplesYielder, self).__init__(list_of_files=list_of_files,
12 | allow_untyped_numbers=allow_untyped_numbers,
13 | compression_mode=compression_mode,
14 | zip_base_archive=zip_base_archive)
15 |
16 | def _constructor_file_yielder(self, a_source_file, parse_namespaces=False):
17 | return NtTriplesYielder(source_file=a_source_file,
18 | allow_untyped_numbers=self._allow_untyped_numbers,
19 | compression_mode=self._compression_mode,
20 | zip_base_archive=self._zip_base_archive)
21 |
--------------------------------------------------------------------------------
/shexer/io/graph/yielder/multi_rdflib_triple_yielder.py:
--------------------------------------------------------------------------------
1 | from shexer.io.graph.yielder.multifile_base_triples_yielder import MultifileBaseTripleYielder
2 | from shexer.io.graph.yielder.rdflib_triple_yielder import RdflibParserTripleYielder
3 | from shexer.consts import TURTLE
4 |
5 |
6 | class MultiRdfLibTripleYielder(MultifileBaseTripleYielder):
7 |
8 | def __init__(self, list_of_files, input_format=TURTLE, allow_untyped_numbers=False,
9 | namespaces_dict=None, compression_mode=None, zip_archive_file=None):
10 | super(MultiRdfLibTripleYielder, self).__init__(list_of_files=list_of_files,
11 | allow_untyped_numbers=allow_untyped_numbers)
12 |
13 | self._input_format = input_format
14 | self._namespaces_dict = namespaces_dict if namespaces_dict is not None else {}
15 | self._compression_mode = compression_mode
16 | self._zip_archive_file = zip_archive_file
17 |
18 | def _yield_triples_of_last_yielder(self, parse_namespaces=True):
19 | for a_triple in self._last_yielder.yield_triples(parse_namespaces):
20 | yield a_triple
21 |
22 | def _constructor_file_yielder(self, a_source_file):
23 | return RdflibParserTripleYielder(source=a_source_file,
24 | allow_untyped_numbers=self._allow_untyped_numbers,
25 | input_format=self._input_format,
26 | compression_mode=self._compression_mode,
27 | zip_archive_file=self._zip_archive_file)
28 |
29 | @property
30 | def namespaces(self):
31 | return self._namespaces_dict # TODO This is not entirely correct. But this method will be rarely used
32 | # and can have a huge performance cost in case the graphs hadnt been parsed yet
33 |
--------------------------------------------------------------------------------
/shexer/io/graph/yielder/multi_tsv_nt_triples_yielder.py:
--------------------------------------------------------------------------------
1 | from shexer.io.graph.yielder.tsv_nt_triples_yielder import TsvNtTriplesYielder
2 | from shexer.io.graph.yielder.multifile_base_triples_yielder import MultifileBaseTripleYielder
3 |
4 |
5 | class MultiTsvNtTriplesYielder(MultifileBaseTripleYielder):
6 |
7 | def __init__(self, list_of_files,
8 | allow_untyped_numbers=False,
9 | compression_mode=None,
10 | zip_base_archive=None):
11 | super(MultiTsvNtTriplesYielder, self).__init__(list_of_files=list_of_files,
12 | allow_untyped_numbers=allow_untyped_numbers,
13 | compression_mode=compression_mode,
14 | zip_base_archive=zip_base_archive)
15 |
16 | def _constructor_file_yielder(self, a_source_file, parse_namespaces=False):
17 | return TsvNtTriplesYielder(source_file=a_source_file,
18 | allow_untyped_numbers=self._allow_untyped_numbers,
19 | compression_mode=self._compression_mode,
20 | zip_base_archive=self._zip_base_archive)
21 |
--------------------------------------------------------------------------------
/shexer/io/graph/yielder/multi_zip_triples_yielder.py:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | from shexer.io.graph.yielder.base_triples_yielder import BaseTriplesYielder
5 |
6 |
7 | class MultiZipTriplesYielder(BaseTriplesYielder):
8 |
9 | def __init__(self, multiyielders):
10 | super().__init__()
11 | self._multiyielders = multiyielders
12 |
13 | self._triples_yielded_from_used_yielders = 0
14 | self._error_triples_from_used_yielders = 0
15 | self._last_yielder = None
16 |
17 | self._current_yielder = None
18 |
19 | def yield_triples(self, parse_namespaces=True):
20 | self._reset_count()
21 | for a_yielder in self._multiyielders:
22 | self._current_yielder = a_yielder
23 | for a_triple in a_yielder.yield_triples():
24 | yield a_triple
25 | self._triples_yielded_from_used_yielders += a_yielder.yielded_triples
26 | self._error_triples_from_used_yielders += a_yielder.error_triples
27 |
28 | @property
29 | def yielded_triples(self):
30 | triples_current_yielder = 0 if self._current_yielder is None else self._current_yielder.yielded_triples
31 | return self._triples_yielded_from_used_yielders + triples_current_yielder
32 |
33 | @property
34 | def error_triples(self):
35 | errors_current_yielder = 0 if self._current_yielder is None else self._current_yielder.error_triples
36 | return self._error_triples_from_used_yielders + errors_current_yielder
37 |
38 | def _reset_count(self):
39 | self._error_triples_from_used_yielders = 0
40 | self._triples_yielded_from_used_yielders = 0
41 |
--------------------------------------------------------------------------------
/shexer/io/graph/yielder/remote/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/graph/yielder/remote/__init__.py
--------------------------------------------------------------------------------
/shexer/io/json/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/json/__init__.py
--------------------------------------------------------------------------------
/shexer/io/json/json_loader.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 |
4 | def load_string_json(raw_string):
5 | return json.loads(raw_string)
6 |
7 |
8 | def load_json_file(source_file):
9 | with open(source_file, "r") as in_stream:
10 | return json.load(in_stream)
--------------------------------------------------------------------------------
/shexer/io/line_reader/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/line_reader/__init__.py
--------------------------------------------------------------------------------
/shexer/io/line_reader/file_line_reader.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | class FileLineReader(object):
4 |
5 | def __init__(self, source_file):
6 | self._source_file = source_file
7 |
8 | def read_lines(self):
9 | with open(self._source_file, "r", errors='ignore') as in_stream:
10 | for a_line in in_stream:
11 | yield a_line
--------------------------------------------------------------------------------
/shexer/io/line_reader/gz_line_reader.py:
--------------------------------------------------------------------------------
1 | import gzip
2 |
3 | class GzFileLineReader(object):
4 |
5 | def __init__(self, gz_file):
6 | self._gz_file = gz_file
7 |
8 | def read_lines(self):
9 | with gzip.open(self._gz_file, "r") as in_stream:
10 | for a_line in in_stream:
11 | yield a_line.decode("utf-8")
12 |
--------------------------------------------------------------------------------
/shexer/io/line_reader/raw_string_line_reader.py:
--------------------------------------------------------------------------------
1 |
2 | class RawStringLineReader():
3 |
4 | def __init__(self, raw_string):
5 | self._raw_string = raw_string
6 |
7 |
8 | def read_lines(self):
9 | for a_line in self._raw_string.split("\n"):
10 | if a_line.strip() != "":
11 | yield a_line
--------------------------------------------------------------------------------
/shexer/io/line_reader/xz_line_reader.py:
--------------------------------------------------------------------------------
1 | from xz import open as xzopen
2 |
3 |
4 | class XzFileLineReader(object):
5 |
6 | def __init__(self, xz_file):
7 | self._xz_file = xz_file
8 |
9 | def read_lines(self):
10 | with xzopen(self._xz_file, "r") as in_stream:
11 | for a_line in in_stream:
12 | yield a_line.decode("utf-8")
--------------------------------------------------------------------------------
/shexer/io/line_reader/zip_file_line_reader.py:
--------------------------------------------------------------------------------
1 | class ZipFileLineReader(object):
2 | def __init__(self, zip_archive, zip_target):
3 | self._zip_archive = zip_archive
4 | self._zip_target = zip_target
5 |
6 | def read_lines(self):
7 | with self._zip_archive.open(self._zip_target, "r") as in_stream:
8 | for a_line in in_stream:
9 | yield a_line.decode("utf-8")
10 |
11 |
--------------------------------------------------------------------------------
/shexer/io/profile/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/profile/__init__.py
--------------------------------------------------------------------------------
/shexer/io/profile/formater/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/profile/formater/__init__.py
--------------------------------------------------------------------------------
/shexer/io/profile/formater/abstract_profile_serializer.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 |
4 | class AbstractProfileSerializer(object):
5 |
6 | def __init__(self, profile_obj):
7 | self._profile_obj = profile_obj
8 |
9 | def write_profile_to_file(self, target_file):
10 | with open(target_file, "w") as out_stream:
11 | json.dump(self._profile_obj, out_stream, indent=2)
12 |
13 | def get_string_representation(self):
14 | return json.dumps(self._profile_obj, indent=2)
15 |
--------------------------------------------------------------------------------
/shexer/io/rdfconfig/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/rdfconfig/__init__.py
--------------------------------------------------------------------------------
/shexer/io/rdfconfig/formater/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/rdfconfig/formater/__init__.py
--------------------------------------------------------------------------------
/shexer/io/shacl/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/shacl/__init__.py
--------------------------------------------------------------------------------
/shexer/io/shacl/formater/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/shacl/formater/__init__.py
--------------------------------------------------------------------------------
/shexer/io/shape_map/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/shape_map/__init__.py
--------------------------------------------------------------------------------
/shexer/io/shape_map/label/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/shape_map/label/__init__.py
--------------------------------------------------------------------------------
/shexer/io/shape_map/label/shape_map_label_parser.py:
--------------------------------------------------------------------------------
1 | from shexer.model.shape import STARTING_CHAR_FOR_SHAPE_NAME
2 | from shexer.io.shex.formater.consts import SHAPE_LINK_CHAR
3 |
4 | class ShapeMapLabelParser(object):
5 |
6 | def __init__(self, prefix_namespaces_dict=None):
7 | self._namespaces_prefix_dict = prefix_namespaces_dict if prefix_namespaces_dict is not None else {}
8 |
9 | def parse_shape_map_label(self, raw_label):
10 |
11 | if self._is_a_prefixed_uri(raw_label):
12 | return STARTING_CHAR_FOR_SHAPE_NAME + self._parse_prefixed_label(raw_label)
13 | return raw_label # todo SURE?
14 | # return self._parse_unprefixed_label(raw_label)
15 |
16 |
17 | def _is_a_prefixed_uri(self, raw_label):
18 | if len(raw_label) < 2:
19 | return False
20 | if raw_label.startswith("<") and raw_label.endswith(">"):
21 | return False
22 | return True
23 |
24 |
25 | # def _parse_unprefixed_label(self, raw_label):
26 | # return raw_label[1:-1]
27 |
28 | def _parse_prefixed_label(self, raw_label):
29 | index_sep = raw_label.find(":")
30 | if index_sep == -1:
31 | raise ValueError("Wrong label: expecting a URI surrounded by <> or a prefixed element: " + raw_label)
32 | target_prefix = raw_label[:index_sep]
33 | if target_prefix in self._namespaces_prefix_dict:
34 | return self._namespaces_prefix_dict[target_prefix] + raw_label[index_sep + 1:]
35 | else:
36 | raise ValueError("Unknown prefix in label: " + raw_label)
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/shexer/io/shape_map/node_selector/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/shape_map/node_selector/__init__.py
--------------------------------------------------------------------------------
/shexer/io/shex/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/shex/__init__.py
--------------------------------------------------------------------------------
/shexer/io/shex/formater/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/shex/formater/__init__.py
--------------------------------------------------------------------------------
/shexer/io/shex/formater/consts.py:
--------------------------------------------------------------------------------
1 | SPACES_GAP_FOR_FREQUENCY = " "
2 | SPACES_GAP_BETWEEN_TOKENS = " "
3 | TARGET_LINE_LENGHT = 60
4 | SPACES_LEVEL_INDENTATION = " "
5 | COMMENT_INI = "# "
6 | POSITIVE_CLOSURE = "+"
7 | KLEENE_CLOSURE = "*"
8 | OPT_CARDINALITY = "?"
9 | SHAPE_LINK_CHAR = "@"
--------------------------------------------------------------------------------
/shexer/io/shex/formater/statement_serializers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/shex/formater/statement_serializers/__init__.py
--------------------------------------------------------------------------------
/shexer/io/shex/formater/statement_serializers/frequency_strategy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/shex/formater/statement_serializers/frequency_strategy/__init__.py
--------------------------------------------------------------------------------
/shexer/io/shex/formater/statement_serializers/frequency_strategy/abs_freq_serializer.py:
--------------------------------------------------------------------------------
1 |
2 | from shexer.io.shex.formater.statement_serializers.frequency_strategy.base_frequency_strategy import BaseFrequencyStrategy
3 |
4 | class AbsFreqSerializer(BaseFrequencyStrategy):
5 |
6 | def serialize_frequency(self, statement):
7 | return str(statement.n_occurences) + " instance{}.".format(
8 | "" if statement.n_occurences == 1
9 | else "s"
10 | )
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/shexer/io/shex/formater/statement_serializers/frequency_strategy/base_frequency_strategy.py:
--------------------------------------------------------------------------------
1 |
2 | class BaseFrequencyStrategy(object):
3 |
4 |
5 | def serialize_frequency(self, statement):
6 | raise NotImplementedError("This should be implemented in child classes")
--------------------------------------------------------------------------------
/shexer/io/shex/formater/statement_serializers/frequency_strategy/mixed_frequency_strategy.py:
--------------------------------------------------------------------------------
1 | from shexer.io.shex.formater.statement_serializers.frequency_strategy.base_frequency_strategy import BaseFrequencyStrategy
2 | from shexer.io.shex.formater.statement_serializers.frequency_strategy.abs_freq_serializer import AbsFreqSerializer
3 | from shexer.io.shex.formater.statement_serializers.frequency_strategy.ratio_freq_serializer import RatioFreqSerializer
4 |
5 | class MixedFrequencyStrategy(BaseFrequencyStrategy):
6 |
7 | def __init__(self, decimals=-1):
8 | self._abs_strategy = AbsFreqSerializer()
9 | self._ratio_strategy = RatioFreqSerializer(decimals=decimals)
10 |
11 | def serialize_frequency(self, statement):
12 | # The abs_strategy return a trailing dot that we want to skip. That why I use slicing here
13 | return self._ratio_strategy.serialize_frequency(statement) + \
14 | " (" + self._abs_strategy.serialize_frequency(statement)[:-1] + ")."
15 |
16 |
17 |
--------------------------------------------------------------------------------
/shexer/io/shex/formater/statement_serializers/frequency_strategy/ratio_freq_serializer.py:
--------------------------------------------------------------------------------
1 | from shexer.io.shex.formater.statement_serializers.frequency_strategy.base_frequency_strategy import BaseFrequencyStrategy
2 |
3 | class RatioFreqSerializer(BaseFrequencyStrategy):
4 |
5 | def __init__(self, decimals=-1):
6 | """
7 |
8 | :param decimals: it indicates the number of decimals to use to express ratios.
9 | When a negative number is provided, decimals won't be controlled
10 | """
11 | self._decimals=decimals
12 | if decimals < 0:
13 | self.serialize_frequency = self._serialize_freq_unbounded
14 | elif decimals ==0:
15 | self.serialize_frequency = self._serialize_freq_int
16 | else:
17 | self.serialize_frequency = self._serialize_freq_decimals
18 |
19 |
20 | def serialize_frequency(self, statement):
21 | raise NotImplementedError("This function will be initialized with a callback during the __init__")
22 |
23 | def _serialize_freq_unbounded(self, statement):
24 | return str(statement.probability * 100) + " %"
25 |
26 | def _serialize_freq_decimals(self, statement):
27 | pattern = "{:." + str(self._decimals) +"f} %"
28 | return pattern.format(statement.probability*100)
29 |
30 | def _serialize_freq_int(self, statement):
31 | return str(int(statement.probability * 100)) + " %"
32 |
--------------------------------------------------------------------------------
/shexer/io/shex/formater/statement_serializers/inverse_statement_serializer.py:
--------------------------------------------------------------------------------
1 | from shexer.io.shex.formater.statement_serializers.base_statement_serializer import BaseStatementSerializer, \
2 | SPACES_GAP_BETWEEN_TOKENS
3 |
4 | #
5 | # class InverseStatementSerializer(BaseStatementSerializer):
6 | #
7 | # def __init__(self, ref_statement_serializer):
8 | # super().__init__(ref_statement_serializer._instantiation_property_str)
9 | # self._ref_statement_serializer = ref_statement_serializer
10 | #
11 | # def serialize_statement_with_indent_level(self, a_statement, is_last_statement_of_shape, namespaces_dict):
12 | # base_result = super().serialize_statement_with_indent_level(
13 | # a_statement=a_statement,
14 | # is_last_statement_of_shape=is_last_statement_of_shape,
15 | # namespaces_dict=namespaces_dict)
16 | # if len(base_result) == 0:
17 | # return base_result
18 | # self._add_inverse_sense_to_first_tuple(base_result)
19 | # return base_result
20 | #
21 | # def _add_inverse_sense_to_first_tuple(self, statement_str_indent_tuples):
22 | # """
23 | # This method modifies the input, no return needed.
24 | # :param statement_str_indent_tuples:
25 | # :return:
26 | # """
27 | # statement_str_indent_tuples[0][0] = _INVERSE_SENSE_SHEXC + \
28 | # SPACES_GAP_BETWEEN_TOKENS + \
29 | # statement_str_indent_tuples[0][0]
30 | #
31 | # def _sense_flag(self):
32 | # return _INVERSE_SENSE_SHEXC + SPACES_GAP_BETWEEN_TOKENS
33 |
--------------------------------------------------------------------------------
/shexer/io/sparql/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/sparql/__init__.py
--------------------------------------------------------------------------------
/shexer/io/uml/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/io/uml/__init__.py
--------------------------------------------------------------------------------
/shexer/io/wikidata.py:
--------------------------------------------------------------------------------
1 | from wlighter import WLighter
2 |
3 |
4 | def wikidata_annotation(raw_input, string_return, out_file, format, rdfs_comments):
5 | wlig = WLighter(raw_input=raw_input,
6 | format=format,
7 | languages=["en"],
8 | generate_rdfs_comments=rdfs_comments,
9 | mode_column_aligned=True)
10 | result = wlig.annotate_all(out_file=out_file, string_return=string_return)
11 | if string_return:
12 | return result
13 |
--------------------------------------------------------------------------------
/shexer/model/IRI.py:
--------------------------------------------------------------------------------
1 | from shexer.model.const_elem_types import IRI_ELEM_TYPE
2 |
3 |
4 | class IRI(object):
5 |
6 | def __init__(self, content):
7 | self._content = content
8 |
9 | def __str__(self):
10 | return self._content
11 |
12 | @property
13 | def elem_type(self):
14 | return IRI_ELEM_TYPE
15 |
16 | @property
17 | def iri(self):
18 | return self._content
19 |
20 | def __eq__(self, other):
21 | if type(other) != type(self):
22 | return False
23 | return str(self) == str(other)
24 |
25 | def __ne__(self, other):
26 | return not self.__eq__(other)
--------------------------------------------------------------------------------
/shexer/model/Literal.py:
--------------------------------------------------------------------------------
1 |
2 | class Literal(object):
3 |
4 | def __init__(self, content, elem_type):
5 | self._content = content
6 | self._elem_type = elem_type
7 |
8 | def __str__(self):
9 | return self._content
10 |
11 | @property
12 | def elem_type(self):
13 | return self._elem_type
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/shexer/model/Macro.py:
--------------------------------------------------------------------------------
1 |
2 | from shexer.model.const_elem_types import *
3 |
4 | _VALID_MACROS = [IRI_ELEM_TYPE, LITERAL_ELEM_TYPE, DOT_ELEM_TYPE, BNODE_ELEM_TYPE]
5 |
6 | class Macro(object):
7 | def __init__(self, macro_const):
8 | if macro_const not in _VALID_MACROS:
9 | # print(_VALID_MACROS)
10 | # print(macro_const == DOT_ELEM_TYPE)
11 | raise ValueError("Not recognized macro: " + macro_const)
12 | self._macro_representation = macro_const
13 |
14 | def __str__(self):
15 | return self._macro_representation
16 |
17 | @property
18 | def elem_type(self):
19 | return self._macro_representation
20 |
21 | def __eq__(self, other):
22 | if type(other) != type(self):
23 | return False
24 | return str(other) == str(self)
25 |
26 | def __ne__(self, other):
27 | return not self.__neq__(other)
--------------------------------------------------------------------------------
/shexer/model/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/model/__init__.py
--------------------------------------------------------------------------------
/shexer/model/bnode.py:
--------------------------------------------------------------------------------
1 | from shexer.model.const_elem_types import BNODE_ELEM_TYPE
2 |
3 | class BNode(object):
4 |
5 | def __init__(self, identifier):
6 | self._identifier = identifier
7 |
8 | def __str__(self):
9 | return self._identifier
10 |
11 | def __eq__(self, other):
12 | if type(other) != type(self):
13 | return False
14 | return str(self) == str(other)
15 |
16 | @property
17 | def elem_type(self):
18 | return BNODE_ELEM_TYPE
19 |
20 | @property
21 | def iri(self):
22 | return self._identifier
23 |
--------------------------------------------------------------------------------
/shexer/model/const_elem_types.py:
--------------------------------------------------------------------------------
1 | BNODE_ELEM_TYPE = "BNode"
2 | IRI_ELEM_TYPE = "IRI"
3 | DOT_ELEM_TYPE = "."
4 | LITERAL_ELEM_TYPE = "LITERAL"
5 | NONLITERAL_ELEM_TYPE = "NONLITERAL"
--------------------------------------------------------------------------------
/shexer/model/fixed_prop_choice_statement.py:
--------------------------------------------------------------------------------
1 | from shexer.model.statement import Statement
2 |
3 | class FixedPropChoiceStatement(Statement):
4 |
5 | def __init__(self, st_property, st_types, cardinality, n_occurences, probability, comments=None,
6 | serializer_object=None, is_inverse=False):
7 | super(FixedPropChoiceStatement, self).__init__(st_property=st_property,
8 | st_type=None,
9 | cardinality=cardinality,
10 | n_occurences=n_occurences,
11 | probability=probability,
12 | comments=comments,
13 | serializer_object=serializer_object,
14 | is_inverse=is_inverse)
15 | self._st_types = st_types
16 |
17 | @property
18 | def st_type(self):
19 | raise TypeError("Choice statements doesnt have a single type")
20 |
21 | @property
22 | def st_types(self):
23 | return self._st_types
--------------------------------------------------------------------------------
/shexer/model/graph/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/model/graph/__init__.py
--------------------------------------------------------------------------------
/shexer/model/property.py:
--------------------------------------------------------------------------------
1 |
2 | class Property(object):
3 |
4 | def __init__(self, content):
5 | self._content = content
6 |
7 | def __str__(self):
8 | return self._content
9 |
10 | def __eq__(self, other):
11 | if type(other) != type(self):
12 | return False
13 | return str(self) == str(other)
14 |
15 | def __ne__(self, other):
16 | return not self.__eq__(other)
17 |
18 | @property
19 | def iri(self):
20 | return self._content
21 |
--------------------------------------------------------------------------------
/shexer/model/shape_map.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | class ShapeMap(object):
4 |
5 | def __init__(self, shape_map_items=None):
6 | self._items = shape_map_items if shape_map_items is not None else []
7 |
8 |
9 | def add_item(self, shape_map_item):
10 | self._items.append(shape_map_item)
11 |
12 |
13 | def yield_items(self):
14 | for an_item in self._items:
15 | yield an_item
16 |
17 | def get_sgraph(self):
18 | if len(self._items) == 0:
19 | return None
20 | return self._items[0].node_selector.sgraph # Assuming they all have the same sgraph
21 |
22 |
23 | class ShapeMapItem(object):
24 |
25 | def __init__(self, node_selector, shape_label):
26 | self._node_selector = node_selector
27 | self._shape_label = shape_label
28 |
29 | @property
30 | def node_selector(self):
31 | return self._node_selector
32 |
33 | @property
34 | def shape_label(self):
35 | return self._shape_label
--------------------------------------------------------------------------------
/shexer/utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/utils/__init__.py
--------------------------------------------------------------------------------
/shexer/utils/compression.py:
--------------------------------------------------------------------------------
1 | from gzip import open as gzopen
2 | from zipfile import ZipFile
3 | from xz import open as xzopen
4 |
5 |
6 | def get_content_xz_file(xz_path):
7 | with xzopen(xz_path, "r") as in_stream:
8 | return in_stream.read()
9 |
10 |
11 | def get_content_gz_file(gz_path):
12 | with gzopen(gz_path, "r") as in_stream:
13 | return in_stream.read()
14 |
15 |
16 | def yield_contents_zip_dir(zip_path):
17 | with ZipFile(zip_path, 'r') as zip:
18 | for a_file_path in zip.filelist:
19 | with zip.open(a_file_path) as in_file:
20 | yield in_file.read()
21 |
22 | def get_content_zip_internal_file(base_archive, target_file):
23 | with base_archive.open(target_file, "r") as in_file:
24 | return in_file.read()
25 |
26 | def list_of_zip_internal_files(zip_base_archive):
27 | return zip_base_archive.namelist()
--------------------------------------------------------------------------------
/shexer/utils/dict.py:
--------------------------------------------------------------------------------
1 | def reverse_keys_and_values(target_dict):
2 | return {y: x for x, y in target_dict.items()}
3 |
--------------------------------------------------------------------------------
/shexer/utils/factories/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/utils/factories/__init__.py
--------------------------------------------------------------------------------
/shexer/utils/factories/h_tree.py:
--------------------------------------------------------------------------------
1 |
2 | from shexer.model.hierarchy_tree import HTree, HNode, HMacro
3 | from shexer.model.Macro import Macro
4 | from shexer.model.const_elem_types import DOT_ELEM_TYPE, IRI_ELEM_TYPE, LITERAL_ELEM_TYPE
5 |
6 |
7 | def get_basic_h_tree():
8 | result = HTree()
9 | dot_node = HNode(hcontent=HMacro(value=Macro(macro_const=DOT_ELEM_TYPE)),
10 | htree=result)
11 | result.root = dot_node
12 | literal_node = HNode(hcontent=HMacro(value=Macro(macro_const=LITERAL_ELEM_TYPE)),
13 | htree=result)
14 | iri_node = HNode(hcontent=HMacro(value=Macro(macro_const=IRI_ELEM_TYPE)),
15 | htree=result)
16 |
17 | dot_node.add_child(literal_node)
18 | dot_node.add_child(iri_node)
19 | return result
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/shexer/utils/factories/iri_factory.py:
--------------------------------------------------------------------------------
1 | from shexer.model.IRI import IRI
2 | from shexer.utils.uri import remove_corners
3 |
4 | def create_IRI_from_string(an_str):
5 | return IRI(content=an_str)
6 |
7 |
8 | def create_IRIs_from_string_list(str_list):
9 | result = []
10 | for an_str in str_list:
11 | result.append(create_IRI_from_string(remove_corners(a_uri=an_str,
12 | raise_error_if_no_corners=False)))
13 | return result
14 |
15 |
--------------------------------------------------------------------------------
/shexer/utils/factories/remote_graph_factory.py:
--------------------------------------------------------------------------------
1 | from shexer.model.graph.endpoint_sgraph import EndpointSGraph
2 |
3 | def get_remote_graph_if_needed(endpoint_url, store_locally):
4 | if endpoint_url is None:
5 | return None
6 | return EndpointSGraph(endpoint_url=endpoint_url,
7 | store_locally=store_locally)
--------------------------------------------------------------------------------
/shexer/utils/factories/shape_map_parser_factory.py:
--------------------------------------------------------------------------------
1 | from shexer.consts import JSON, FIXED_SHAPE_MAP
2 | from shexer.io.shape_map.shape_map_parser import JsonShapeMapParser, FixedShapeMapParser
3 |
4 | def get_shape_map_parser(format, sgraph, namespaces_prefix_dict):
5 | if format == JSON:
6 | return JsonShapeMapParser(sgraph=sgraph,
7 | namespaces_prefix_dict=namespaces_prefix_dict)
8 | elif format == FIXED_SHAPE_MAP:
9 | return FixedShapeMapParser(namespaces_prefix_dict=namespaces_prefix_dict,
10 | sgraph=sgraph)
11 | else:
12 | raise ValueError("ShapeMap format not recognized:" + format)
13 |
--------------------------------------------------------------------------------
/shexer/utils/file.py:
--------------------------------------------------------------------------------
1 |
2 | def load_whole_file_content(source_file):
3 | with open(source_file, "r") as in_stream:
4 | return in_stream.read()
--------------------------------------------------------------------------------
/shexer/utils/log.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from datetime import datetime
3 |
4 | def _curr_time():
5 | return datetime.now().strftime("%d/%m/%Y %H:%M:%S -- ")
6 |
7 |
8 | # def log_to_error(msg, source=None, target_log=sys.stderr):
9 | # # pass
10 | # print(msg + ". Source: " + (source if source is not None else "Not specified"), file=target_log)
11 |
12 |
13 | def log_msg(verbose, msg, err=True):
14 | if verbose:
15 | print(_curr_time() + msg, flush=True, file=None if not err else sys.stderr)
--------------------------------------------------------------------------------
/shexer/utils/namespaces.py:
--------------------------------------------------------------------------------
1 | import string
2 | import random
3 |
4 | _PRIORITY_PREFIXES_FOR_SHAPES = ["", "weso-s", "shapes", "w-shapes"]
5 | _RAND_PREFIX_LENGHT = 3
6 |
7 | def find_adequate_prefix_for_shapes_namespaces(current_namespace_prefix_dict, avoid_empty=False):
8 | curr_prefixes = current_namespace_prefix_dict.values()
9 | for a_prefix in _PRIORITY_PREFIXES_FOR_SHAPES[1 if avoid_empty else 0:]:
10 | if a_prefix not in curr_prefixes:
11 | return a_prefix
12 | # At this point, all the deff prefixes are used. So we generate a random one
13 | candidate = get_random_string(3)
14 | while candidate in curr_prefixes:
15 | candidate = get_random_string(3)
16 | return candidate
17 |
18 | def get_random_string(length):
19 | result_str = ''.join(random.choice(string.ascii_lowercase) for i in range(length))
20 | return result_str
21 |
--------------------------------------------------------------------------------
/shexer/utils/obj_references.py:
--------------------------------------------------------------------------------
1 |
2 | def check_just_one_not_none(*value_refname):
3 | nones=0
4 | for a_tuple in value_refname:
5 | if a_tuple[0] is not None:
6 | nones += 1
7 | if nones != 1:
8 | raise ValueError(error_message_for_non_compatible_references([a_tuple[1] for a_tuple in value_refname]))
9 |
10 |
11 | def check_one_or_zero_not_none(*value_refname):
12 | nones=0
13 | for a_tuple in value_refname:
14 | if a_tuple[0] is not None:
15 | nones += 1
16 | if nones > 1:
17 | raise ValueError(error_message_for_non_compatible_references(
18 | list_of_ref_names=[a_tuple[1] for a_tuple in value_refname],
19 | one_mandatory=False))
20 |
21 |
22 | def error_message_for_non_compatible_references(list_of_ref_names, one_mandatory=True):
23 | if one_mandatory:
24 | return "You must provide one and only one of the following params: " + str(list_of_ref_names)
25 | return "You must provide one as most of the following params: " + str(list_of_ref_names)
26 |
27 |
28 |
--------------------------------------------------------------------------------
/shexer/utils/structures/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/utils/structures/__init__.py
--------------------------------------------------------------------------------
/shexer/utils/target_elements.py:
--------------------------------------------------------------------------------
1 | from shexer.utils.shapes import build_shapes_name_for_class_uri
2 | from shexer.utils.uri import remove_corners, unprefixize_uri_if_possible
3 |
4 |
5 | def tune_target_classes_if_needed(list_target_classes, prefix_namespaces_dict):
6 | result = []
7 | for a_original_class in list_target_classes:
8 | if a_original_class.startswith("<"):
9 | result.append(remove_corners(a_uri=a_original_class))
10 | else:
11 | result.append(unprefixize_uri_if_possible(target_uri=a_original_class,
12 | prefix_namespaces_dict=prefix_namespaces_dict,
13 | include_corners=False))
14 | return result
15 |
16 | def determine_original_target_nodes_if_needed(remove_empty_shapes, original_target_classes, original_shape_map, shapes_namespace):
17 | if not remove_empty_shapes:
18 | return None # We dont need this structure if there are no shapes to remove.
19 | result = set()
20 | if original_target_classes is not None:
21 | for a_class in original_target_classes:
22 | result.add(build_shapes_name_for_class_uri(class_uri=a_class,
23 | shapes_namespace=shapes_namespace))
24 | if original_shape_map is not None:
25 | for an_item in original_shape_map.yield_items():
26 | result.add(an_item.shape_label)
27 | return result
--------------------------------------------------------------------------------
/shexer/utils/translators/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/shexer/utils/translators/__init__.py
--------------------------------------------------------------------------------
/test/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/__init__.py
--------------------------------------------------------------------------------
/test/t_files/bnodes/bnode_people.nt:
--------------------------------------------------------------------------------
1 |
2 | _:Alice _:Bob .
3 | _:Alice a .
4 |
5 | _:Bob _:Eve .
6 | _:Bob a .
7 | _:Bob "Bob" .
8 |
9 | _:Eve "Eve" .
10 | _:Eve a .
--------------------------------------------------------------------------------
/test/t_files/bnodes/bnode_people.ttl:
--------------------------------------------------------------------------------
1 | @prefix ex: .
2 |
3 | _:Alice ex:knows _:Bob ;
4 | a ex:person .
5 |
6 | _:Bob ex:knows _:Eve ;
7 | a ex:person .
8 | ex:name "Bob" .
9 |
10 | _:Eve ex:name "Eve" ;
11 | a ex:person .
--------------------------------------------------------------------------------
/test/t_files/bnodes/or_with_redundant_bnodes_and_shapes.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :person
10 | {
11 | ex:knows BNode OR @:person ;
12 | rdf:type [ex:person]
13 | }
--------------------------------------------------------------------------------
/test/t_files/bnodes/or_with_redundant_bnodes_iris_and_shapes.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :person
10 | {
11 | rdf:type [ex:person] ;
12 | ex:knows NONLITERAL OR @:person ;
13 | ex:name xsd:string ?
14 | }
--------------------------------------------------------------------------------
/test/t_files/bnodes/people_some_bnodes_dont_have_shape.ttl:
--------------------------------------------------------------------------------
1 | @prefix ex: .
2 |
3 | _:Alice ex:knows _:Bob ;
4 | a ex:person .
5 |
6 | _:Bob ex:knows _:Eve ;
7 | a ex:person .
8 | ex:name "Bob" .
9 |
10 | _:Eve ex:name "Eve" .
--------------------------------------------------------------------------------
/test/t_files/bnodes/people_target_mixes_bnodes_and_iris.ttl:
--------------------------------------------------------------------------------
1 | @prefix ex: .
2 |
3 | _:Alice ex:knows _:Bob ;
4 | a ex:person .
5 |
6 | _:Bob ex:knows ex:Eve ;
7 | a ex:person ;
8 | ex:name "Bob" .
9 |
10 | ex:Eve a ex:person .
11 |
--------------------------------------------------------------------------------
/test/t_files/bnodes/people_target_mixes_bnodes_iris_and_no_shapes.ttl:
--------------------------------------------------------------------------------
1 | @prefix ex: .
2 |
3 | _:Alice ex:knows _:Bob ;
4 | a ex:person .
5 |
6 | _:Bob ex:knows ex:Eve ;
7 | a ex:person ;
8 | ex:name "Bob" .
9 |
10 | ex:Eve a ex:person ;
11 | ex:knows _:Milan .
12 |
13 | _:Milan ex:name "Milan" .
14 |
--------------------------------------------------------------------------------
/test/t_files/bnodes/schema_bnode_people.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :person
10 | {
11 | rdf:type [ex:person] ;
12 | ex:knows @:person ?;
13 | ex:name xsd:string ?
14 | }
--------------------------------------------------------------------------------
/test/t_files/bnodes/schema_people_some_bnodes_dont_have_shape.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :person
10 | {
11 | ex:knows BNode ;
12 | rdf:type [ex:person]
13 | }
--------------------------------------------------------------------------------
/test/t_files/bnodes/schema_people_target_mixes_bnodes_iris_and_no_shapes.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :person
10 | {
11 | rdf:type [ex:person] ;
12 | ex:knows NONLITERAL ;
13 | ex:name xsd:string ?
14 | }
--------------------------------------------------------------------------------
/test/t_files/compression/t1_graph_partials_1_2_3__3.nt.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t1_graph_partials_1_2_3__3.nt.zip
--------------------------------------------------------------------------------
/test/t_files/compression/t1_graph_partials_1_2__3.nt.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t1_graph_partials_1_2__3.nt.zip
--------------------------------------------------------------------------------
/test/t_files/compression/t1_graph_partials_3__3.nt.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t1_graph_partials_3__3.nt.zip
--------------------------------------------------------------------------------
/test/t_files/compression/t1_partial_1_3.nt:
--------------------------------------------------------------------------------
1 | .
2 | "23"^^ .
3 | "Jimmy" .
4 | "Jones" .
5 | .
6 | "22"^^ .
7 | "Sarah" .
8 | "Salem" .
--------------------------------------------------------------------------------
/test/t_files/compression/t1_partial_2_3.nt:
--------------------------------------------------------------------------------
1 | .
2 | "56"^^ .
3 | "Isabella" .
4 | .
5 | "David" .
6 | "Doulofeau" .
7 | .
--------------------------------------------------------------------------------
/test/t_files/compression/t1_partial_3_3.nt:
--------------------------------------------------------------------------------
1 | "Person" .
2 | "Maybe" .
3 | "99"^^ .
4 | .
5 | .
6 | "A thing that s nice" .
7 | "A nice thing" .
8 | .
9 | "Another thing" .
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.json.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.json.gz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.json.xz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.json.xz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.json.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.json.zip
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.n3.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.n3.gz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.n3.xz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.n3.xz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.n3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.n3.zip
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.nt.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.nt.gz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.nt.xz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.nt.xz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.nt.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.nt.zip
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.tsv.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.tsv.gz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.tsv.xz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.tsv.xz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.tsv.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.tsv.zip
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.ttl.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.ttl.gz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.ttl.xz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.ttl.xz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.ttl.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.ttl.zip
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.xml.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.xml.gz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.xml.xz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.xml.xz
--------------------------------------------------------------------------------
/test/t_files/compression/t_graph_1.xml.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/shexer/68454d2d8bdb2c189db6e0930ef3d170b1ead985/test/t_files/compression/t_graph_1.xml.zip
--------------------------------------------------------------------------------
/test/t_files/disable_comments/g2.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix ex: .
4 | @prefix foaf: .
5 | @prefix xsd: .
6 |
7 | ex:Jimmy a foaf:Person ;
8 | foaf:age "23"^^xsd:integer .
9 |
10 | ex:Sarah a foaf:Person .
11 |
12 |
--------------------------------------------------------------------------------
/test/t_files/disable_comments/g2_disable.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ;
12 | foaf:age xsd:integer ?
13 | }
--------------------------------------------------------------------------------
/test/t_files/disable_comments/g2_enable.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ; # 100.0 %
12 | foaf:age xsd:integer ?
13 | # 50.0 % obj: xsd:integer. Cardinality: {1}
14 | }
--------------------------------------------------------------------------------
/test/t_files/disable_or/g3_or_example.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix ex: .
4 | @prefix foaf: .
5 | @prefix xsd: .
6 |
7 | ex:Jimmy a foaf:Person ; # Complete
8 | foaf:age "23"^^xsd:integer ;
9 | foaf:name "Jimmy" ;
10 | foaf:familyName "Jones" ;
11 | ex:foo ex:Sarah .
12 |
13 | ex:Sarah a foaf:Person ; # Complete implicit type for age
14 | foaf:age 22 ;
15 | foaf:name "Sarah" ;
16 | foaf:familyName "Salem" ;
17 | ex:foo ex:Jimmy .
18 |
19 | ex:Bella a foaf:Person ; # Missing familyName
20 | foaf:age "56"^^xsd:integer ;
21 | foaf:name "Isabella" ;
22 | ex:foo ex:Sarah .
23 |
24 | ex:David a foaf:Person ; # Missing age and use knows
25 | foaf:name "David" ;
26 | foaf:familyName "Doulofeau" ;
27 | foaf:knows ex:Sarah ;
28 | ex:foo ex:x1 .
29 |
30 | ex:HumanLike foaf:name "Person" ; # foaf properties, but not explicit type.
31 | foaf:familyName "Maybe" ;
32 | foaf:age 99 ;
33 | foaf:knows ex:David .
34 |
35 |
36 | ex:x1 rdf:type foaf:Document ;
37 | foaf:depiction "A thing that is nice" ;
38 | foaf:title "A nice thing" .
39 |
40 |
41 | ex:x2 rdf:type foaf:Document ;
42 | foaf:title "Another thing" .
43 |
44 |
--------------------------------------------------------------------------------
/test/t_files/disable_or/g_or_example_expandable_IRI.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix ex: .
4 | @prefix foaf: .
5 | @prefix xsd: .
6 |
7 | ex:Jimmy a foaf:Person ; # Complete
8 | foaf:age "23"^^xsd:integer ;
9 | foaf:name "Jimmy" ;
10 | foaf:familyName "Jones" ;
11 | ex:foo ex:Sarah .
12 |
13 | ex:Sarah a foaf:Person ; # Complete implicit type for age
14 | a foaf:Document ;
15 | foaf:age 22 ;
16 | foaf:name "Sarah" ;
17 | foaf:familyName "Salem" ;
18 | ex:foo ex:Jimmy .
19 |
20 | ex:Bella a foaf:Person ; # Missing familyName
21 | foaf:age "56"^^xsd:integer ;
22 | foaf:name "Isabella" ;
23 | ex:foo ex:Sarah .
24 |
25 | ex:David a foaf:Person ; # Missing age and use knows
26 | foaf:name "David" ;
27 | foaf:familyName "Doulofeau" ;
28 | foaf:knows ex:Sarah .
29 |
30 | ex:HumanLike foaf:name "Person" ; # foaf properties, but not explicit type.
31 | foaf:familyName "Maybe" ;
32 | foaf:age 99 ;
33 | foaf:knows ex:David .
34 |
35 |
36 | ex:x1 rdf:type foaf:Document ;
37 | foaf:depiction "A thing that is nice" ;
38 | foaf:title "A nice thing" .
39 |
40 |
41 | ex:x2 rdf:type foaf:Document ;
42 | foaf:title "Another thing" .
43 |
44 |
--------------------------------------------------------------------------------
/test/t_files/disable_or/or_disabled.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | ex:foo IRI ;
12 | foaf:name xsd:string ;
13 | rdf:type [foaf:Person] ;
14 | foaf:familyName xsd:string ?;
15 | foaf:age xsd:integer ?;
16 | foaf:knows @:Person ?
17 | }
18 |
19 |
20 | :Document
21 | {
22 | rdf:type [foaf:Document] ;
23 | foaf:title xsd:string ;
24 | foaf:depiction xsd:string ?
25 | }
--------------------------------------------------------------------------------
/test/t_files/disable_or/or_enabled.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ;
12 | foaf:name xsd:string ;
13 | foaf:age xsd:integer ?;
14 | foaf:familyName xsd:string ?;
15 | ex:foo @:Person OR @:Document ?;
16 | rdf:type [foaf:Document] ?;
17 | foaf:knows @:Document OR @:Person ?
18 | }
19 |
20 |
21 | :Document
22 | {
23 | rdf:type [foaf:Document] ;
24 | foaf:title xsd:string ?;
25 | rdf:type [foaf:Person] ?;
26 | foaf:depiction xsd:string ?;
27 | foaf:name xsd:string ?;
28 | foaf:familyName xsd:string ?;
29 | foaf:age xsd:integer ?;
30 | ex:foo @:Person ?
31 | }
--------------------------------------------------------------------------------
/test/t_files/disable_or/redundant_enabled_useful_IRI.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | foaf:name xsd:string ;
12 | rdf:type [foaf:Person] ;
13 | ex:foo IRI OR @:Person OR @:Document ;
14 | foaf:familyName xsd:string ?;
15 | foaf:age xsd:integer ?;
16 | foaf:knows @:Person ?
17 | }
18 |
19 |
20 | :Document
21 | {
22 | foaf:title xsd:string ;
23 | rdf:type [foaf:Document] ;
24 | foaf:depiction xsd:string ?
25 | }
--------------------------------------------------------------------------------
/test/t_files/discard_and_compliant/compliant_no_discard.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ;
12 | foaf:name xsd:string +;
13 | foaf:familyName xsd:string *;
14 | foaf:age xsd:integer *;
15 | foaf:knows @:Person *
16 | }
17 |
18 |
19 | :Document
20 | {
21 | foaf:title xsd:string +;
22 | rdf:type [foaf:Document] ;
23 | foaf:depiction xsd:string *
24 | }
--------------------------------------------------------------------------------
/test/t_files/discard_and_compliant/no_compliant_discard.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ;
12 | foaf:name xsd:string ;
13 | foaf:age xsd:integer ;
14 | foaf:familyName xsd:string ;
15 | foaf:knows @:Person
16 | }
17 |
18 |
19 | :Document
20 | {
21 | rdf:type [foaf:Document] ;
22 | foaf:title xsd:string ;
23 | foaf:depiction xsd:string
24 | }
--------------------------------------------------------------------------------
/test/t_files/discard_and_compliant/no_compliant_no_discard.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | foaf:name xsd:string +;
12 | rdf:type [foaf:Person] ;
13 | foaf:familyName xsd:string +;
14 | foaf:age xsd:integer +;
15 | foaf:knows @:Person +
16 | }
17 |
18 |
19 | :Document
20 | {
21 | foaf:title xsd:string +;
22 | rdf:type [foaf:Document] ;
23 | foaf:depiction xsd:string +
24 | }
--------------------------------------------------------------------------------
/test/t_files/empty_shapes/one_empty_not_remove.shex:
--------------------------------------------------------------------------------
1 | PREFIX xml:
2 | PREFIX rdf:
3 | PREFIX rdfs:
4 | PREFIX xsd:
5 | PREFIX ex:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Machine
10 | {
11 | }
--------------------------------------------------------------------------------
/test/t_files/empty_shapes/some_empty_not_remove.shex:
--------------------------------------------------------------------------------
1 | PREFIX xml:
2 | PREFIX rdf:
3 | PREFIX rdfs:
4 | PREFIX xsd:
5 | PREFIX ex:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Machine
10 | {
11 | }
12 |
13 |
14 | :Person
15 | {
16 | foaf:name xsd:string ;
17 | rdf:type [foaf:Person] ;
18 | foaf:age xsd:integer ?;
19 | foaf:familyName xsd:string ?;
20 | foaf:knows @:Person ?
21 | }
22 |
23 |
24 | :Document
25 | {
26 | rdf:type [foaf:Document] ;
27 | foaf:title xsd:string ;
28 | foaf:depiction xsd:string ?
29 | }
--------------------------------------------------------------------------------
/test/t_files/exact_cardinality/g6_exact_cardinality.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix ex: .
4 | @prefix foaf: .
5 | @prefix xsd: .
6 |
7 | ex:Jimmy a foaf:Person ; # Complete
8 | foaf:age "23"^^xsd:integer ;
9 | foaf:name "Jimmy" ;
10 | foaf:name "Jimbo" ;
11 | foaf:familyName "Jones" .
12 |
13 | ex:Sarah a foaf:Person ; # Complete implicit type for age
14 | foaf:age 22 ;
15 | foaf:name "Sarah" ;
16 | foaf:name "Saru" ;
17 | foaf:familyName "Salem" .
18 |
19 | ex:Bella a foaf:Person ; # Missing familyName
20 | foaf:age "56"^^xsd:integer ;
21 | foaf:name "Isabella" ;
22 | foaf:name "Bella" .
23 |
24 | ex:David a foaf:Person ; # Missing age and use knows
25 | foaf:name "David" ;
26 | foaf:name "Davidoo" ;
27 | foaf:familyName "Doulofeau" ;
28 | foaf:knows ex:Sarah .
--------------------------------------------------------------------------------
/test/t_files/exact_cardinality/g6_exact_disabled.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ;
12 | foaf:name xsd:string +;
13 | foaf:familyName xsd:string ?;
14 | foaf:age xsd:integer ?;
15 | foaf:knows @:Person ?
16 | }
--------------------------------------------------------------------------------
/test/t_files/exact_cardinality/g6_exact_enabled.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ;
12 | foaf:name xsd:string {2};
13 | foaf:familyName xsd:string ?;
14 | foaf:age xsd:integer ?;
15 | foaf:knows @:Person ?
16 | }
--------------------------------------------------------------------------------
/test/t_files/example_features/determ_constraint_examples_no_inverse.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ; # 100.0 %
12 | foaf:age xsd:integer ?;
13 | // rdfs:comment "22" ;
14 | # 80.0 % obj: xsd:integer. Cardinality: {1}
15 | foaf:name xsd:string ?;
16 | // rdfs:comment "Jimmy" ;
17 | # 60.0 % obj: xsd:string. Cardinality: {1}
18 | foaf:familyName xsd:string ?;
19 | // rdfs:comment "Jones" ;
20 | # 40.0 % obj: xsd:string. Cardinality: {1}
21 | foaf:knows @:Person ?
22 | // rdfs:comment "ex:Bella" ;
23 | # 20.0 % obj: @:Person. Cardinality: {1}
24 | }
--------------------------------------------------------------------------------
/test/t_files/example_features/determ_constraint_examples_with_inverse.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ; # 100.0 %
12 | foaf:age xsd:integer ?;
13 | // rdfs:comment "22" ;
14 | # 80.0 % obj: xsd:integer. Cardinality: {1}
15 | foaf:name xsd:string ?;
16 | // rdfs:comment "Jimmy" ;
17 | # 60.0 % obj: xsd:string. Cardinality: {1}
18 | foaf:familyName xsd:string ?;
19 | // rdfs:comment "Jones" ;
20 | # 40.0 % obj: xsd:string. Cardinality: {1}
21 | foaf:knows @:Person ?;
22 | // rdfs:comment ex:Bella ;
23 | # 20.0 % obj: @:Person. Cardinality: {1}
24 | ^ foaf:knows @:Person ?
25 | // rdfs:comment ex:Jimmy ;
26 | # 20.0 % obj: @:Person. Cardinality: {1}
27 | }
--------------------------------------------------------------------------------
/test/t_files/example_features/determ_no_examples_no_inverse.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ;
12 | foaf:age xsd:integer ?;
13 | foaf:name xsd:string ?;
14 | foaf:familyName xsd:string ?;
15 | foaf:knows @:Person ?
16 | }
--------------------------------------------------------------------------------
/test/t_files/example_features/determ_single_instance_single_prop_only_shape_examples_no_count.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] # 100.0 %
12 | } // rdfs:comment ex:Jimmy
--------------------------------------------------------------------------------
/test/t_files/example_features/determ_single_instance_single_prop_only_shape_examples_with_count.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person # 1 instance.
10 | {
11 | rdf:type [foaf:Person] # 1 instance.
12 | } // rdfs:comment ex:Jimmy
--------------------------------------------------------------------------------
/test/t_files/example_features/single_class_deterministic_order.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix ex: .
4 | @prefix foaf: .
5 | @prefix xsd: .
6 |
7 | ex:Jimmy a foaf:Person ; # Complete
8 | foaf:age 22 ;
9 | foaf:name "Jimmy" ;
10 | foaf:familyName "Jones";
11 | foaf:knows ex:Bella .
12 |
13 | ex:Sarah a foaf:Person ; # Complete implicit type for age. Missing one prop
14 | foaf:age 22 ;
15 | foaf:familyName "Jones";
16 | foaf:name "Jimmy" .
17 |
18 | ex:Bella a foaf:Person ; # Missing 2 props
19 | foaf:name "Jimmy" ;
20 | foaf:age 22 .
21 |
22 | ex:David a foaf:Person ; # Missing 3 props
23 | foaf:age 22 .
24 |
25 | ex:Linda a foaf:Person . # Missing all props
--------------------------------------------------------------------------------
/test/t_files/example_features/single_instance_2_prop.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix ex: .
4 | @prefix foaf: .
5 | @prefix xsd: .
6 |
7 | ex:Jimmy a foaf:Person ;
8 | foaf:age 22 .
--------------------------------------------------------------------------------
/test/t_files/example_features/single_instance_single_prop.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix ex: .
4 | @prefix foaf: .
5 | @prefix xsd: .
6 |
7 | ex:Jimmy a foaf:Person .
--------------------------------------------------------------------------------
/test/t_files/freq_reports/g_person_0_decimals.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ; # 100 %
12 | foaf:name xsd:string ?;
13 | # 66 % obj: xsd:string. Cardinality: {1}
14 | foaf:familyName xsd:string ?
15 | # 33 % obj: xsd:string. Cardinality: {1}
16 | }
--------------------------------------------------------------------------------
/test/t_files/freq_reports/g_person_2_decimals.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ; # 100.00 %
12 | foaf:name xsd:string ?;
13 | # 66.67 % obj: xsd:string. Cardinality: {1}
14 | foaf:familyName xsd:string ?
15 | # 33.33 % obj: xsd:string. Cardinality: {1}
16 | }
--------------------------------------------------------------------------------
/test/t_files/freq_reports/g_person_absolute_instances.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person # 3 instances.
10 | {
11 | rdf:type [foaf:Person] ; # 3 instances.
12 | foaf:name xsd:string ?;
13 | # 2 instances. obj: xsd:string. Cardinality: {1}
14 | foaf:familyName xsd:string ?
15 | # 1 instance. obj: xsd:string. Cardinality: {1}
16 | }
--------------------------------------------------------------------------------
/test/t_files/freq_reports/g_person_comments_disabled.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ;
12 | foaf:name xsd:string ?;
13 | foaf:familyName xsd:string ?
14 | }
--------------------------------------------------------------------------------
/test/t_files/freq_reports/g_person_every_decimal.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ; # 100.0 %
12 | foaf:name xsd:string ?;
13 | # 66.66666666666666 % obj: xsd:string. Cardinality: {1}
14 | foaf:familyName xsd:string ?
15 | # 33.33333333333333 % obj: xsd:string. Cardinality: {1}
16 | }
--------------------------------------------------------------------------------
/test/t_files/freq_reports/g_person_infinite_frequencies.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix ex: .
4 | @prefix foaf: .
5 | @prefix xsd: .
6 |
7 | ex:Jimmy a foaf:Person ; # Complete
8 | foaf:name "Jimmy" ;
9 | foaf:familyName "Jones" .
10 |
11 | ex:Sarah a foaf:Person ; # Complete implicit type for age
12 | foaf:name "Sarah" .
13 |
14 | ex:Bella a foaf:Person . # Missing familyName
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/test/t_files/freq_reports/g_person_mixed_2_dec.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person # 3 instances.
10 | {
11 | rdf:type [foaf:Person] ; # 100.00 % (3 instances).
12 | foaf:name xsd:string ?;
13 | # 66.67 % (2 instances). obj: xsd:string. Cardinality: {1}
14 | foaf:familyName xsd:string ?
15 | # 33.33 % (1 instance). obj: xsd:string. Cardinality: {1}
16 | }
--------------------------------------------------------------------------------
/test/t_files/freq_reports/g_person_mixed_unbound_dec.shex:
--------------------------------------------------------------------------------
1 | PREFIX ex:
2 | PREFIX xml:
3 | PREFIX rdf:
4 | PREFIX rdfs:
5 | PREFIX xsd:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person # 3 instances.
10 | {
11 | rdf:type [foaf:Person] ; # 100.0 % (3 instances).
12 | foaf:name xsd:string ?;
13 | # 66.66666666666666 % (2 instances). obj: xsd:string. Cardinality: {1}
14 | foaf:familyName xsd:string ?
15 | # 33.33333333333333 % (1 instance). obj: xsd:string. Cardinality: {1}
16 | }
--------------------------------------------------------------------------------
/test/t_files/general/g1_all_classes_no_comments.shex:
--------------------------------------------------------------------------------
1 | PREFIX xml:
2 | PREFIX rdf:
3 | PREFIX rdfs:
4 | PREFIX xsd:
5 | PREFIX ex:
6 | PREFIX foaf:
7 | PREFIX :
8 |
9 | :Person
10 | {
11 | rdf:type [foaf:Person] ;
12 | foaf:name xsd:string ;
13 | foaf:familyName xsd:string ?;
14 | foaf:age xsd:integer ?;
15 | foaf:knows @:Person ?
16 | }
17 |
18 |
19 | :Document
20 | {
21 | rdf:type [foaf:Document] ;
22 | foaf:title xsd:string ;
23 | foaf:depiction xsd:string ?
24 | }
--------------------------------------------------------------------------------
/test/t_files/graph_list_of_files_input/g1_p1.nt:
--------------------------------------------------------------------------------
1 | .
2 | "23"^^ .
3 | "Jimmy" .
4 | "Jones" .
5 | .
6 | "22"^^ .
7 | "Sarah" .
8 | "Salem" .
9 | .
10 | "56"^^ .
11 | "Isabella" .
12 | .
13 | "David" .
14 | "Doulofeau" .
15 | .
16 |
--------------------------------------------------------------------------------
/test/t_files/graph_list_of_files_input/g1_p1.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix ex: .
4 | @prefix foaf: .
5 | @prefix xsd: .
6 |
7 | ex:Jimmy a foaf:Person ; # Complete
8 | foaf:age "23"^^xsd:integer ;
9 | foaf:name "Jimmy" ;
10 | foaf:familyName "Jones" .
11 |
12 | ex:Sarah a foaf:Person ; # Complete implicit type for age
13 | foaf:age 22 ;
14 | foaf:name "Sarah" ;
15 | foaf:familyName "Salem" .
16 |
17 | ex:Bella a foaf:Person ; # Missing familyName
18 | foaf:age "56"^^xsd:integer ;
19 | foaf:name "Isabella" .
20 |
21 | ex:David a foaf:Person ; # Missing age and use knows
22 | foaf:name "David" ;
23 | foaf:familyName "Doulofeau" ;
24 | foaf:knows ex:Sarah .
25 |
--------------------------------------------------------------------------------
/test/t_files/graph_list_of_files_input/g1_p2.nt:
--------------------------------------------------------------------------------
1 | "Person" .
2 | "Maybe" .
3 | "99"^^ .
4 | .
5 | .
6 | "A thing that s nice" .
7 | "A nice thing" .
8 | .
9 | "Another thing" .
10 |
--------------------------------------------------------------------------------
/test/t_files/graph_list_of_files_input/g1_p2.ttl:
--------------------------------------------------------------------------------
1 | @prefix rdf: .
2 | @prefix rdfs: .
3 | @prefix ex: .
4 | @prefix foaf: .
5 | @prefix xsd: .
6 |
7 |
8 | ex:HumanLike foaf:name "Person" ; # foaf properties, but not explicit type.
9 | foaf:familyName "Maybe" ;
10 | foaf:age 99 ;
11 | foaf:knows ex:David .
12 |
13 |
14 | ex:x1 rdf:type foaf:Document ;
15 | foaf:depiction "A thing that is nice" ;
16 | foaf:title "A nice thing" .
17 |
18 |
19 | ex:x2 rdf:type foaf:Document ;
20 | foaf:title "Another thing" .
21 |
22 |
--------------------------------------------------------------------------------
/test/t_files/https/https.ttl:
--------------------------------------------------------------------------------
1 | @prefix geo: .
2 | @prefix rr: .
3 | @prefix cidoc: .
4 | @prefix xsd: .
5 | @prefix rdfs: .
6 | @prefix b2022: .
7 | @prefix geom: