ontology-mapper
关于
This skill maps materials science terminology and crystal structure descriptions to standardized ontology classes, supporting multiple ontologies like CMSO and ASMO. It translates natural language terms (e.g., "BCC iron") into formal ontology entries with confidence scores and generates machine-readable metadata. Developers should use it when annotating simulation inputs for FAIR compliance or bridging informal lab vocabulary with formal ontology terms.
快速安装
Claude Code
推荐npx skills add HeshamFS/materials-simulation-skills -a claude-code/plugin add https://github.com/HeshamFS/materials-simulation-skillsgit clone https://github.com/HeshamFS/materials-simulation-skills.git ~/.claude/skills/ontology-mapper在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Ontology Mapper
Goal
Translate real-world materials science descriptions into standardized ontology annotations. Given terms like "FCC copper" or structured data like {"material": "iron", "structure": "BCC", "lattice_a": 2.87}, produce the corresponding ontology classes and properties for any registered ontology.
Requirements
- Python 3.8+
- No external dependencies (Python standard library only)
- Requires ontology-explorer's summary JSON and
ontology_registry.json - Per-ontology mapping config (
<name>_mappings.json) for ontology-specific synonyms and labels
Inputs to Gather
| Input | Description | Example |
|---|---|---|
| Ontology | Ontology name from registry | cmso, asmo |
| Term(s) | Natural-language materials concept(s) | "unit cell", "FCC,copper,lattice" |
| Crystal system | One of the 7 crystal systems | cubic, hexagonal |
| Bravais lattice | Lattice type (symbol or common name) | FCC, cF, BCC |
| Space group | Space group number (1-230) | 225 |
| Lattice parameters | a, b, c in angstroms; alpha, beta, gamma in degrees | a=3.615 |
| Sample description | JSON dict with material properties | {"material":"copper","structure":"FCC"} |
Decision Guidance
What do you need to map?
├── A concept or term to find its ontology class
│ └── concept_mapper.py --ontology <name> --term "<term>"
├── Crystal structure parameters to ontology terms
│ └── crystal_mapper.py --ontology <name> --bravais <type> --space-group <N> --a <val>
├── A full sample description to ontology annotations
│ └── sample_annotator.py --ontology <name> --sample '<json>'
└── Multiple terms at once
└── concept_mapper.py --ontology <name> --terms "term1,term2,term3"
Script Outputs (JSON Fields)
| Script | Key Outputs |
|---|---|
scripts/concept_mapper.py | results.matches, results.unmatched, results.suggestions |
scripts/crystal_mapper.py | results.ontology_classes, results.ontology_properties, results.effective_system, results.bravais_lattice, results.validation_warnings |
scripts/sample_annotator.py | results.annotations, results.sample_type, results.material_type, results.unmapped_fields, results.suggested_properties |
Workflow
- If the user provides natural-language terms, use
concept_mapper.pyto find matching ontology classes. - If the user describes crystal structure parameters, use
crystal_mapper.pyto map them and validate constraints. - For a complete sample description, use
sample_annotator.pyto produce full ontology annotations. - Review any validation warnings (e.g., lattice parameter mismatches for the crystal system).
- Check
unmapped_fieldsandsuggested_propertiesfor completeness.
Conversational Workflow Example
User: I'm setting up an MD simulation of BCC iron with lattice parameter 2.87 angstroms.
What CMSO terms should I use?
Agent: Let me map your iron sample to CMSO ontology terms.
[Runs: sample_annotator.py --ontology cmso --sample '{"material":"iron","structure":"BCC","lattice_a":2.87,"space_group":229}' --json]
Your BCC iron simulation maps to these CMSO annotations:
- **Sample**: Atomic Scale Sample (subclass of Computational Sample)
- **Material**: Crystalline Material
- **Unit Cell**: Bravais lattice = "cI" (body-centered cubic)
- **Space Group**: number = 229 (Im-3m)
- **Lattice**: a = 2.87 Å
- **Element**: Fe
Suggested additions:
- Number of atoms in the simulation cell
- Simulation cell vectors and angles
CLI Examples
# Map a single concept
python3 skills/ontology/ontology-mapper/scripts/concept_mapper.py \
--ontology cmso --term "space group" --json
# Map multiple terms
python3 skills/ontology/ontology-mapper/scripts/concept_mapper.py \
--ontology cmso --terms "FCC,copper,lattice constant" --json
# Map crystal parameters (with ontology-specific labels)
python3 skills/ontology/ontology-mapper/scripts/crystal_mapper.py \
--ontology cmso --bravais FCC --space-group 225 --a 3.615 --json
# Map crystal parameters (generic labels, no ontology specified)
python3 skills/ontology/ontology-mapper/scripts/crystal_mapper.py \
--bravais FCC --space-group 225 --a 3.615 --json
# Annotate a full sample
python3 skills/ontology/ontology-mapper/scripts/sample_annotator.py \
--ontology cmso \
--sample '{"material":"copper","structure":"FCC","space_group":225,"lattice_a":3.615}' \
--json
Adding a New Ontology
To support a new ontology (e.g., ASMO), create a <name>_mappings.json in references/:
{
"ontology": "asmo",
"synonyms": { "simulation method": "Simulation Method", ... },
"property_synonyms": { "timestep": "has timestep", ... },
"material_type_rules": { "keyword_rules": [...], "default": "Material" },
"sample_schema": { "sample_class": "Simulation", ... },
"crystal_output": { "base_classes": [...], "property_map": {...} },
"annotation_routing": { "unit_cell_indicators": [...], ... }
}
Then add "mappings_file": "asmo_mappings.json" to the ontology's entry in ontology_registry.json. No code changes needed.
Error Handling
| Error | Cause | Resolution |
|---|---|---|
space_group must be between 1 and 230 | Invalid space group number | Use a valid space group number |
a must be positive | Non-positive lattice parameter | Provide positive values in angstroms |
Sample must be a non-empty dict | Empty or missing sample data | Provide a valid JSON sample dict |
| Validation warnings | Lattice parameters inconsistent with crystal system | Check that a=b=c for cubic, etc. |
Interpretation Guidance
- Confidence scores: 1.0 = exact match, 0.9 = synonym match, 0.7 = substring match, 0.5 = description match
- Validation warnings: indicate potential mistakes (e.g., specifying a!=b for cubic). These are warnings, not errors — the mapping still proceeds.
- Unmapped fields: input keys that the annotator doesn't recognize. These may need manual mapping.
- Suggested properties: additional ontology properties that would make the annotation more complete.
Security
Input Validation
--ontologyis validated against registered ontology names inontology_registry.json(fixed allowlist)--termand--termsare length-limited and used only for substring matching against pre-processed synonym tables (never interpolated into code)--bravaisis validated against a fixed set of recognized lattice type symbols--space-groupis validated as an integer between 1 and 230- Lattice parameters (
--a,--b,--c,--alpha,--beta,--gamma) are validated as finite positive numbers --sampleJSON is parsed withjson.loads()and validated as a non-empty dict; keys and values are type-checked
File Access
- Scripts read pre-processed JSON files from the
references/directory:ontology_registry.json,*_mappings.json,*_summary.json,crystal_systems.json,element_data.json(all read-only) - No scripts write to the filesystem; all output goes to stdout
- No network access is required
Tool Restrictions
- Read: Used to inspect script source, reference files, and ontology data
- Grep: Used to search reference files for mapping patterns or ontology terms
- Glob: Used to locate reference files and ontology data
- Notably, this skill has no Bash or Write access, giving it the lowest attack surface of all skills
Safety Measures
- No
eval(),exec(), or dynamic code generation - No subprocess calls of any kind; all logic runs within Python scripts invoked by the agent
- No file writes; the skill is purely read-only and analytical
- Minimal tool surface (Read, Grep, Glob only) means the agent cannot execute arbitrary commands or modify the filesystem
Limitations
- Concept mapping uses string matching and a per-ontology synonym table; it does not understand arbitrary natural language
- Crystal system validation checks basic constraints only (not all crystallographic rules)
- The element resolver recognizes common element names and symbols but may miss unusual spellings
- Bravais lattice aliases cover common usage (FCC, BCC, HCP) but not all crystallographic notation variants
References
- Mapping Patterns — common mapping examples
- Crystal Systems — crystal system definitions and Bravais lattices
- Element Data — periodic table data
- CMSO Mappings — CMSO-specific synonym tables and annotation config
- CMSO Guide — CMSO ontology overview
Version History
| Date | Version | Changes |
|---|---|---|
| 2026-02-25 | 1.1 | Refactored for multi-ontology support: externalized CMSO-specific knowledge to config |
| 2026-02-25 | 1.0 | Initial release with CMSO mapping support |
GitHub 仓库
相关推荐技能
llamaguard
其他LlamaGuard是Meta推出的7-8B参数内容审核模型,专门用于过滤LLM的输入和输出内容。它能检测六大安全风险类别(暴力/仇恨、性内容、武器、违禁品、自残、犯罪计划),准确率达94-95%。开发者可通过HuggingFace、vLLM或Sagemaker快速部署,并能与NeMo Guardrails集成实现自动化安全防护。
cost-optimization
其他这个Claude Skill帮助开发者优化云成本,通过资源调整、标记策略和预留实例来降低AWS、Azure和GCP的开支。它适用于减少云支出、分析基础设施成本或实施成本治理策略的场景。关键功能包括提供成本可视化、资源规模调整指导和定价模型优化建议。
quantizing-models-bitsandbytes
其他这个Skill使用bitsandbytes库量化大语言模型,能在GPU内存有限时通过8位或4位量化减少50-75%内存占用,同时保持精度损失最小。它支持INT8、NF4、FP4等多种量化格式,可与HuggingFace Transformers无缝集成,适用于需要部署更大模型或加速推理的场景。还提供QLoRA训练和8位优化器支持,让开发者能轻松实现高效模型压缩。
dispatching-parallel-agents
其他该Skill用于并行处理3个以上无依赖关系的独立故障,可为每个问题域分派专属Claude代理同时执行调查修复。它通过并发处理多个独立问题显著提升故障排查效率,特别适用于测试文件、子系统等无共享状态的场景。
