Select Git revision
amr_scheme_1.py

Aurélien Lamercerie authored
amr_scheme_1.py 11.19 KiB
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*
#==============================================================================
# TENET: Composition Transduction Scheme for AMR analysis
#------------------------------------------------------------------------------
# Composition Transduction Scheme (CTS) using CTR (rules) for analysis of AMR
# structure.
#==============================================================================
#==============================================================================
# Rule Directory
#==============================================================================
rule_dir = 'amr_ctr/'
#==============================================================================
# Prefix using in CTR
#==============================================================================
prefix_list = [('owl', '<http://www.w3.org/2002/07/owl#>'),
('rdf', '<http://www.w3.org/1999/02/22-rdf-syntax-ns#>'),
('rdfs', '<http://www.w3.org/2000/01/rdf-schema#>'),
('xsd', '<http://www.w3.org/2001/XMLSchema#>'),
('amr', '<https://amr.tetras-libre.fr/rdf/schema#>'),
('ns1', '<http://amr.isi.edu/frames/ld/v1.2.2/>'),
('ns2', '<http://amr.isi.edu/rdf/amr-terms#>'),
('ns3', '<http://amr.isi.edu/rdf/core-amr#>'),
('ns4', '<http://amr.isi.edu/entity-types#>'),
('net', '<https://tenet.tetras-libre.fr/semantic-net#>'),
('cprm', '<https://tenet.tetras-libre.fr/config/parameters#>'),
('fprm', '<https://tenet.tetras-libre.fr/frame/parameters#>'),
('base-out', '<https://tenet.tetras-libre.fr/base-ontology#>'),
('ext-out', '<https://tenet.tetras-libre.fr/extract-result#>')]
#==============================================================================
# Sequences
#==============================================================================
# ---------------------------------------------
# Refinement Sequence(s)
# ---------------------------------------------
default_refinement_sequence = {
'label': 'default-refinement-sequence',
'comment': 'sequence without rule',
'rule_key_list': []
}
transduction_refinement_sequence = {
'label': 'transduction-refinement-sequence',
'comment': 'Refinement Sequence for Transduction Processing',
'rule_key_list': ['refine-cover-node-1',
'refine-cover-node-2']#,
#'propagation-relations-to-nets']
}
# ---------------------------------------------
# Preprocessing Sequence(s)
# ---------------------------------------------
amrld_correcting_sequence = {
'label': 'amrld-correcting-sequence',
'comment': 'correction of AMR-LD data for some known anomalies',
'rule_key_list': ['fix-amr-bug-about-system-solar-planet']
}
amr_reification_sequence = {
'label': 'amr-reification-sequence',
'comment': 'AMR reification from AMR-Linked-Data to AMR (tenet) structure',
'rule_key_list': ['reclassify-concept-1',
'reclassify-concept-2',
'reclassify-concept-3',
'reclassify-concept-4',
'reclassify-concept-5',
# --old --- 'reclassify-role-1',
# --old --- 'reclassify-role-2',
'reify-roles-as-concept',
'reclassify-existing-variable',
'add-new-variable-for-reified-concept',
'add-amr-leaf-for-reclassified-concept',
'add-amr-leaf-for-reified-concept',
'add-amr-edge-for-core-relation',
'add-amr-edge-for-reified-concept',
'add-amr-edge-for-name-relation',
'add-amr-edge-for-quant-relation',
'add-amr-edge-for-polarity-relation',
# --old --- 'set-amr-label-for-variables',
# --old --- 'set-amr-label-for-roles',
'update-amr-edge-role-1',
# --old --- 'update-amr-edge-role-2',
'add-amr-root']
}
# # ---------------------------------------------
# # Transduction Sequences
# # ---------------------------------------------
atomic_extraction_sequence = {
'label': 'atomic-extraction-sequence',
'comment': 'creation of atom element nets (class, individual, property)',
'rule_key_list': ['create-atom-class-net',
'create-individual-net-1',
#'create-individual-net-2',
'create-atom-property-net-1',
# --old --- 'create-atom-property-net-2',
# --old --- 'create-atom-property-net-3',
'create-value-net',
'create-phenomena-net-1']
}
phenomena_application_sequence = {
'label': 'phenomena-application-sequence',
'comment': 'Application of phenomena',
'rule_key_list': ['polarity-phenomena-application',
'and-conjunction-phenomena-application-1',
'and-conjunction-phenomena-application-2',
'and-conjunction-phenomena-application-3',
'and-conjunction-phenomena-application-4',
'and-conjunction-phenomena-application-5']
}
composite_class_extraction_sequence_1 = {
'label': 'composite-class-extraction-sequence-1',
'comment': 'creation of composite classes from properties',
'rule_key_list': ['create-composite-class-net-from-property-1',
'create-composite-class-net-from-property-2',
'create-composite-class-net-from-property-3',
'create-composite-class-net-from-property-4']
}
composite_property_extraction_sequence = {
'label': 'composite-property-extraction-sequence',
'comment': 'creation of composite properties from properties',
'rule_key_list': ['create-composite-property-net-from-property-1',
'create-composite-property-net-from-property-2']
}
restriction_adding_sequence = {
'label': 'restriction-adding-sequence',
'comment': 'add restriction to class from property',
'rule_key_list': ['add-restriction-to-class-net-from-property-1']
}
phenomena_checking_sequence = {
'label': 'phenomena-checking-sequence',
'comment': 'creation of phenomena nets',
'rule_key_list': [# -- 'expand-and-or-conjunction-phenomena-net',
'expand-degree-phenomena-net-1',
'expand-degree-phenomena-net-2',
'expand-degree-phenomena-net-3',
'expand-degree-phenomena-net-4',
'expand-degree-phenomena-net-5',
'expand-degree-phenomena-net-6']
}
composite_class_extraction_sequence_2 = {
'label': 'composite-class-extraction-sequence-2',
'comment': 'creation of composite classes from phenomena',
'rule_key_list': ['create-composite-class-net-from-phenomena-1',
'create-composite-class-net-from-phenomena-2',
'create-composite-class-net-from-phenomena-3',
'create-composite-class-net-from-phenomena-4']
}
classification_sequence = {
'label': 'classification-sequence',
'comment': 'net classification',
'rule_key_list': ['classify-net-from-core-1',
'classify-net-from-core-2',
'classify-net-from-core-3',
# 'classify-net-from-mod', -- TODO: à revoir --
'classify-net-from-part',
'classify-net-from-domain',
'classify-net-from-degree-phenomena-1',
'classify-net-from-degree-phenomena-2',
'classify-net-from-degree-phenomena-3',
'propagate-individual-1',
'propagate-individual-2',
'reclassify-deprecated-net']
}
# # ---------------------------------------------
# # OWL Generation
# # ---------------------------------------------
main_generation_sequence = {
'label': 'main-generation-sequence',
'comment': 'Main generation sequence',
'rule_key_list': ['compute-uri-for-owl-declaration-1',
'compute-uri-for-owl-declaration-2',
'compute-uri-for-owl-declaration-3',
'compute-uri-for-owl-declaration-4',
'compute-uri-for-owl-declaration-5',
'generate-atom-class',
'classify-atom-class-1',
'classify-atom-class-2',
'generate-individual',
'classify-individual',
'generate-atom-property-1',
'generate-atom-property-12',
'generate-inverse-relation',
'generate-composite-class',
'add-restriction-to-class-1',
'add-restriction-to-class-2',
'add-restriction-to-class-3',
'add-restriction-to-class-4',
'add-restriction-to-class-5',
'add-restriction-to-class-6',
'generate-composite-property']
}
#==============================================================================
# Transduction Scheme
#==============================================================================
scheme = {
'preprocessing': [default_refinement_sequence,
amrld_correcting_sequence,
amr_reification_sequence],
'transduction': [transduction_refinement_sequence,
atomic_extraction_sequence,
atomic_extraction_sequence,
phenomena_application_sequence,
phenomena_checking_sequence,
composite_property_extraction_sequence,
composite_class_extraction_sequence_1,
composite_class_extraction_sequence_2,
phenomena_application_sequence,
phenomena_checking_sequence,
composite_property_extraction_sequence,
composite_class_extraction_sequence_1,
composite_class_extraction_sequence_2,
restriction_adding_sequence,
classification_sequence],
# 'transduction': [transduction_refinement_sequence,
# atomic_extraction_sequence,
# composite_class_extraction_sequence_1,
# composite_property_extraction_sequence,
# composite_class_extraction_sequence_1,
# composite_property_extraction_sequence,
# phenomena_checking_sequence,
# composite_class_extraction_sequence_2,
# composite_class_extraction_sequence_1,
# composite_property_extraction_sequence,
# restriction_adding_sequence,
# classification_sequence],
'generation': [default_refinement_sequence,
main_generation_sequence]
}