- Deleted obsolete slot definitions: statement_summary, statement_text, statement_type, status_name, supersede_articles, supersede_condition, supersede_name, temporal_dynamics, total_amount, typical_contents, use_cases, was_acquired_through, was_fetched_at, was_retrieved_at. - Updated existing slot definitions for states_or_stated to enhance clarity and structure. - Introduced new classes: Article, ConditionofAccess, FinancialStatementType, MaximumQuantity, Series, Summary, Type, and their respective slots to improve schema organization and usability. - Added new slots: changes_or_changed_through, has_or_had_condition_of_access, has_or_had_heritage_type, is_or_was_part_of_series, is_or_was_retrieved_at, maximum_of_maximum to capture additional metadata and relationships.
82 lines
2.8 KiB
Python
82 lines
2.8 KiB
Python
import os
|
|
|
|
filepath = 'schemas/20251121/linkml/modules/classes/FinancialStatement.yaml'
|
|
|
|
with open(filepath, 'r') as f:
|
|
lines = f.readlines()
|
|
|
|
new_lines = []
|
|
skip = False
|
|
|
|
for i, line in enumerate(lines):
|
|
# In slot_usage for has_or_had_net_asset, there is a nested has_or_had_expenses
|
|
# which is likely indentation error or copy-paste error.
|
|
|
|
# line 369: has_or_had_net_asset:
|
|
# line 370: range: decimal
|
|
# line 371: required: false
|
|
# line 372: has_or_had_expenses: <-- This should not be here?
|
|
|
|
# It seems block is accidentally indented under .
|
|
# It should be a sibling slot usage?
|
|
# But is already imported.
|
|
|
|
# Let's inspect the line indent.
|
|
|
|
stripped = line.strip()
|
|
if stripped.startswith('has_or_had_expenses:'):
|
|
# Check indentation.
|
|
indent = len(line) - len(line.lstrip())
|
|
# slot_usage is at 4 spaces.
|
|
# has_or_had_net_asset is at 6 spaces.
|
|
# properties of has_or_had_net_asset (range, required) are at 8 spaces.
|
|
|
|
# If is at 8 spaces, it's inside definition.
|
|
# If it's at 6 spaces, it's a new slot usage entry (which is correct).
|
|
|
|
if indent == 8:
|
|
# It's wrongly indented inside has_or_had_net_asset?
|
|
# Or is it providing examples/defaults?
|
|
|
|
# The structure looks like:
|
|
# has_or_had_net_asset:
|
|
# range: decimal
|
|
# required: false
|
|
# has_or_had_expenses: ...
|
|
|
|
# This key is invalid for a SlotDefinition unless it's an annotation?
|
|
# But here it contains a list of values.
|
|
# It looks like an example block that got misplaced as a property key?
|
|
|
|
# Looking at the content:
|
|
# has_or_had_expenses:
|
|
# - value:
|
|
# - has_or_had_type: PROGRAM
|
|
|
|
# This looks like content?
|
|
|
|
# Let's see if we can just dedent it to 6 spaces to make it a slot usage?
|
|
# But is already defined in list.
|
|
# Does have slot? Yes.
|
|
|
|
# So at 6 spaces would define usage for that slot.
|
|
|
|
# Let's check output around line 372.
|
|
# has_or_had_net_asset:
|
|
# range: decimal
|
|
# required: false
|
|
# has_or_had_expenses:
|
|
# - value: ...
|
|
|
|
# Yes, it's at same level as .
|
|
# If I dedent it to 6 spaces, it becomes a slot_usage entry.
|
|
# BUT slot usage might already exist?
|
|
# No, I don't see another one in the file read output.
|
|
|
|
# So the fix is to dedent and its block.
|
|
|
|
pass
|
|
|
|
new_lines.append(line)
|
|
|
|
# Let's write a script to fix indentation.
|