Skip to content

Commit

Permalink
Add keywords frequency report.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolandscat committed Aug 9, 2024
1 parent 02765fd commit 115218e
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 33 deletions.
5 changes: 3 additions & 2 deletions apps/resources/messages/compiled/adl_messages_db.e
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ feature -- Initialisation

make
do
create message_table.make (977)
create message_table.make (978)
message_table.put ("Terminology initialisation failed; reason: $1", ec_terminology_init_failed)
message_table.put ("Using ADL version $1 for output serialisation", ec_adl_version_warning)
message_table.put ("Validation level STRICT", ec_validation_strict)
Expand Down Expand Up @@ -547,7 +547,8 @@ feature -- Initialisation
message_table.put ("Create in directory: ", ec_archetype_dir_label_text)
message_table.put ("Archetype id: ", ec_archetype_id_label_text)
message_table.put ("Parent id: ", ec_parent_archetype_id_label_text)
message_table.put ("Id $1 already exists in library", ec_duplicate_archetype_id_err_msg)
message_table.put ("Archetype with id $1 already exists in library", ec_duplicate_archetype_id_err_msg)
message_table.put ("Template overlay id $1 in template $2 already exists in template $3", ec_duplicate_template_overlay_id_err_msg)
message_table.put ("Concept $1 contains invalid characters", ec_invalid_archetype_id_concept_err)
message_table.put ("Configure object constraint", ec_initial_c_object_config_dialog_title)
message_table.put ("Constraint type: ", ec_initial_c_object_config_constraint_type_text)
Expand Down
1 change: 1 addition & 0 deletions apps/resources/messages/compiled/adl_messages_ids.e
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ feature -- Definitions
ec_archetype_id_label_text: STRING = "archetype_id_label_text"
ec_parent_archetype_id_label_text: STRING = "parent_archetype_id_label_text"
ec_duplicate_archetype_id_err_msg: STRING = "duplicate_archetype_id_err_msg"
ec_duplicate_template_overlay_id_err_msg: STRING = "duplicate_template_overlay_id_err_msg"
ec_invalid_archetype_id_concept_err: STRING = "invalid_archetype_id_concept_err"
ec_initial_c_object_config_dialog_title: STRING = "initial_c_object_config_dialog_title"
ec_initial_c_object_config_constraint_type_text: STRING = "initial_c_object_config_constraint_type_text"
Expand Down
3 changes: 2 additions & 1 deletion apps/resources/messages/source/app_awb_ui_messages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ templates = <
["archetype_dir_label_text"] = <"Create in directory: ">
["archetype_id_label_text"] = <"Archetype id: ">
["parent_archetype_id_label_text"] = <"Parent id: ">
["duplicate_archetype_id_err_msg"] = <"Id $1 already exists in library">
["duplicate_archetype_id_err_msg"] = <"Archetype with id $1 already exists in library">
["duplicate_template_overlay_id_err_msg"] = <"Template overlay id $1 in template $2 already exists in template $3">
["invalid_archetype_id_concept_err"] = <"Concept $1 contains invalid characters">

-- INITIAL_C_OBJECT_DIALOG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ feature {ARCHETYPE_REPORTER} -- Processing

feature {NONE}

text_quote_agent: FUNCTION [ANY, TUPLE[STRING], STRING]
text_quote_agent: FUNCTION [ANY, TUPLE[READABLE_STRING_8], READABLE_STRING_8]
-- function to use to quote output format
attribute
Result := default_text_quoting_agent
Expand Down
2 changes: 1 addition & 1 deletion components/adl_compiler/src/interface/Id_code_report.e
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ feature -- Access
Result := "All id-coded nodes in archetype library"
end

output_table: ARRAYED_LIST[TUPLE [arch_id, id_code, path, use_ref, description, loinc_code: STRING]]
output_table: ARRAYED_LIST[TUPLE [arch_id, id_code, path, use_ref, description, loinc_code: READABLE_STRING_8]]
once
create Result.make(0)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ feature -- Access
Result := "LOINC to Archetype id map"
end

output_table: ARRAYED_LIST [TUPLE [loinc_code, arch_id, id_code, path, use_ref, description: STRING]]
output_table: ARRAYED_LIST [TUPLE [loinc_code, arch_id, id_code, path, use_ref, description: READABLE_STRING_8]]
once
create Result.make(0)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ feature -- Access
Result := "Archetype ID to Template ID map"
end

output_table: ARRAYED_LIST[TUPLE [arch_id, tpl_id: STRING]]
output_table: ARRAYED_LIST[TUPLE [arch_id, tpl_id: READABLE_STRING_8]]
once
create Result.make(0)
end
Expand Down
9 changes: 8 additions & 1 deletion components/adl_compiler/src/interface/archetype_reporter.e
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ feature -- Access
report3: ARCH_ID_TO_TPL_ID_MAP
report4: VALUE_SETS_REPORT
report5: SPECIALIZATION_GRAPH
report6: KEYWORDS_FREQUENCY_REPORT
once
create Result.make(0)

Expand All @@ -80,6 +81,9 @@ feature -- Access

create report5.make
Result.put (report5, report5.title)

create report6.make
Result.put (report6, report6.title)
end

feature -- Commands
Expand Down Expand Up @@ -160,6 +164,9 @@ feature {NONE} -- Commands
-- Generate `syntax' serialisation of archetypes under `an_export_dir' from all archetypes that have already been built.
do
current_library.do_all_archetypes (agent process_archetype)
across reports as rpts_csr loop
rpts_csr.item.finalise
end
end

valid_setup_args (args: like build_args_type): BOOLEAN
Expand Down Expand Up @@ -228,7 +235,7 @@ feature {NONE} -- Implementation
create Result
end

text_quote_agent: FUNCTION [ANY, TUPLE[STRING], STRING]
text_quote_agent: FUNCTION [ANY, TUPLE[READABLE_STRING_8], READABLE_STRING_8]
-- function to use to quote output format
attribute
Result := default_text_quoting_agent
Expand Down
86 changes: 86 additions & 0 deletions components/adl_compiler/src/interface/keywords_report.e
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
note
component: "openEHR ADL Tools"
description: "Keywords frequency report"
keywords: "export, archetype, ADL"
author: "Thomas Beale <[email protected]>"
support: "openEHR AWB project <http://www.openehr.org/issues/browse/AWB>"
copyright: "Copyright (c) 2024- openEHR International"
license: "Apache 2.0 License <http://www.apache.org/licenses/LICENSE-2.0.html>"

class KEYWORDS_FREQUENCY_REPORT

inherit
ARCHETYPE_LIBRARY_REPORT
export
{NONE} all
redefine
output_table, finalise
end

SHARED_ARCHETYPE_LIBRARIES
export
{NONE} all
end

EXCEPTIONS
export
{NONE} all
end

create
make

feature -- Access

id: STRING
do
Result := "keywords_fequency_report"
end

title: STRING
do
Result := "Keywords frequency in archetype library"
end

output_table: ARRAYED_LIST[TUPLE [keyword, arch_count: READABLE_STRING_8]]
once
create Result.make(0)
end

feature {ARCHETYPE_REPORTER} -- Processing

process_archetype (auth_ara: ARCH_LIB_ARCHETYPE)
-- Generate serialised output under `output_dir' from `ara', optionally building it first if necessary.
local
description: RESOURCE_DESCRIPTION
do
if attached {ARCH_LIB_AUTHORED_ARCHETYPE} auth_ara as aca and then attached aca.differential_archetype as arch then
if attached arch.description as desc and then attached desc.detail_for_language(Default_language) as desc_details then
if attached desc_details.keywords as kws then
across kws as kws_csr loop
if not keywords_table.has (kws_csr.item) then
keywords_table.put (1, kws_csr.item)
else
keywords_table.force (keywords_table.item (kws_csr.item) + 1, kws_csr.item)
end
end
end
end
end
end

finalise
do
across keywords_table as kw_csr loop
output_table.extend ([text_quote_agent.item([kw_csr.key.as_string_8]), kw_csr.item.out])
end
end

feature {NONE} -- Implementation

keywords_table: STRING_TABLE[INTEGER]
attribute
create Result.make(0)
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ feature -- Access
Result := "Specialization graph of archetype library"
end

output_table: ARRAYED_LIST[TUPLE [arch_id, spec_lineage: STRING]]
output_table: ARRAYED_LIST[TUPLE [arch_id, spec_lineage: READABLE_STRING_8]]
once
create Result.make(0)
end
Expand Down
21 changes: 15 additions & 6 deletions components/adl_compiler/src/syntax/adl/adl_2_engine.e
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,22 @@ feature -- Parsing
amp.parse_from_text (overlay_texts_csr.item, tpl_aca.id.physical_id + " @overlay " + overlay_texts_csr.target_index.out)
if not amp.has_errors and then attached amp.last_archetype as arch_thumbnail then
-- now create a descriptor for this overlay
check not current_library.has_archetype_with_id (arch_thumbnail.archetype_id.physical_id) end
if attached arch_thumbnail.parent_archetype_id as att_parent_id and then current_library.has_archetype_matching_ref (att_parent_id) then
create arch_lib_tpl_ovl.make (arch_thumbnail.archetype_id, att_parent_id, tpl_aca)
current_library.put_new_archetype (arch_lib_tpl_ovl)
tpl_aca.add_overlay (arch_lib_tpl_ovl, overlay_texts_csr.item, arch_thumbnail.archetype_id.physical_id)
if not current_library.has_archetype_with_id (arch_thumbnail.archetype_id.physical_id) then
if attached arch_thumbnail.parent_archetype_id as att_parent_id and then current_library.has_archetype_matching_ref (att_parent_id) then
create arch_lib_tpl_ovl.make (arch_thumbnail.archetype_id, att_parent_id, tpl_aca)
current_library.put_new_archetype (arch_lib_tpl_ovl)
tpl_aca.add_overlay (arch_lib_tpl_ovl, overlay_texts_csr.item, arch_thumbnail.archetype_id.physical_id)
else
errors.add_error ({ADL_MESSAGES_IDS}.ec_VTPIOV, <<tpl_aca.id.physical_id, arch_thumbnail.archetype_id.physical_id>>, generator + ".parse")
end
else
errors.add_error ({ADL_MESSAGES_IDS}.ec_VTPIOV, <<tpl_aca.id.physical_id, arch_thumbnail.archetype_id.physical_id>>, generator + ".parse")
if attached {ARCH_LIB_TEMPLATE_OVERLAY} current_library.archetype_with_id (arch_thumbnail.archetype_id.physical_id) as aca_ovl then
errors.add_error ({ADL_MESSAGES_IDS}.ec_duplicate_template_overlay_id_err_msg,
<<arch_thumbnail.archetype_id.physical_id, tpl_aca.id.physical_id, aca_ovl.template.id.as_string >>, generator + ".parse")
else
errors.add_error ({ADL_MESSAGES_IDS}.ec_duplicate_template_overlay_id_err_msg,
<<arch_thumbnail.archetype_id.physical_id, tpl_aca.id.physical_id, "Unknown owning template" >>, generator + ".parse")
end
end
else
errors.add_error ({ADL_MESSAGES_IDS}.ec_STOV, Void, generator + ".parse")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ feature -- Artefacts

differential_archetype: detachable TEMPLATE_OVERLAY

template: ARCH_LIB_TEMPLATE
-- owning template

feature {ARCH_LIB_ARCHETYPE} -- Compilation

compile_actions: HASH_TABLE [PROCEDURE [ARCH_LIB_ARCHETYPE, TUPLE], INTEGER]
Expand Down Expand Up @@ -131,11 +134,6 @@ feature -- Editing
-- set revision appropriately
end

feature {NONE} -- Implementation

template: ARCH_LIB_TEMPLATE
-- owning template

invariant
Is_specialised: is_specialised

Expand Down
9 changes: 5 additions & 4 deletions libraries/openehr/src/am/archetype/archetype_definitions.e
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ feature -- Export Types
not_empty: not Result.is_empty
end

text_quoting_agents: HASH_TABLE [FUNCTION [ANY, TUPLE[STRING], STRING], STRING]
text_quoting_agents: HASH_TABLE [FUNCTION [ANY, TUPLE[READABLE_STRING_8], READABLE_STRING_8], READABLE_STRING_8]
once
create Result.make(0)
Result.put (agent json_quote_text, {ODIN_DEFINITIONS}.syntax_type_json)
Expand All @@ -145,12 +145,13 @@ feature -- Export Types
Result := s
end

csv_quote_text (s: STRING): STRING
csv_quote_text (s: READABLE_STRING_8): READABLE_STRING_8
do
Result := Csv_default_quote + s + Csv_default_quote
-- create {STRING} Result.make_from_string (Csv_default_quote + s + Csv_default_quote)
Result := Csv_default_quote + s + Csv_default_quote
end

default_text_quoting_agent: FUNCTION [ANY, TUPLE[STRING], STRING]
default_text_quoting_agent: FUNCTION [ANY, TUPLE[READABLE_STRING_8], READABLE_STRING_8]
once
Result := agent csv_quote_text
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ feature -- Initialisation
create original_author.make(0)
ensure then
lifecycle_state_set: lifecycle_state.is_equal(Default_lifecycle_state)
details_exists: details /= Void
end

make
Expand Down Expand Up @@ -68,7 +67,7 @@ feature -- Access
-- Original author of this archetype, with all relevant details,
-- including organisation.

archetype_package_uri: URI
archetype_package_uri: detachable URI
-- URI of archetype package

details: HASH_TABLE [ARCHETYPE_DESCRIPTION_ITEM, STRING]
Expand All @@ -79,15 +78,15 @@ feature -- Access
-- submitted, experimental, awaiting_approval, approved,
-- superseded, obsolete. State machine defined by archetype system

other_contributors: ARRAYED_LIST [STRING]
other_contributors: detachable ARRAYED_LIST [STRING]

other_details: HASH_TABLE [STRING, STRING]
other_details: detachable HASH_TABLE [STRING, STRING]

details_for_lang(a_lang: STRING): ARCHETYPE_DESCRIPTION_ITEM
details_for_lang(a_lang: STRING): detachable ARCHETYPE_DESCRIPTION_ITEM
-- get details for given language
-- Void if nothing for that language
require
Lang_valid: a_lang /= Void and then not a_lang.is_empty
Lang_valid: not a_lang.is_empty
do
if details.has(a_lang) then
Result := details.item(a_lang)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ feature -- Initialisation

make_lang (a_lang, a_purpose: STRING)
require
Lang_valid: a_lang /= Void and then not a_lang.is_empty
Purpose_valid: a_purpose /= Void and then not a_purpose.is_empty
Lang_valid: not a_lang.is_empty
Purpose_valid: not a_purpose.is_empty
do
language := a_lang
purpose := a_purpose
create use.make_empty
create keywords.make (0)
create misuse.make_empty
create copyright.make_empty
create other_details.make (0)
ensure
Language_set: language = a_lang
Purpose_set: purpose = a_purpose
Expand Down Expand Up @@ -65,7 +70,7 @@ feature -- Access
-- Rights over the archetype as a knowledge resource;
-- usually copyright and/or license to use.

original_resource_uri: HASH_TABLE [URI, STRING]
original_resource_uri: detachable HASH_TABLE [URI, STRING]
-- URI of precursor resource of archetype, e.g. natural language
-- document, semi-formal description

Expand Down

0 comments on commit 115218e

Please sign in to comment.