fix badge position; purge remaining German user-reference comments
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
6b60e0131f
commit
dc559a4aee
5 changed files with 31 additions and 31 deletions
|
|
@ -1,2 +1,2 @@
|
|||
FROM python:3.11-slim
|
||||
RUN pip install --no-cache-dir pytest
|
||||
RUN pip install --no-cache-dir pytest pyyaml
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
<p align="left">
|
||||
<img src="dervish-logo.png" alt="Dervish" width="180">
|
||||
</p>
|
||||
<p align="left">
|
||||
<img src="https://ci.corentic.eu/api/badges/7/status.svg" alt="CI Pipeline Status">
|
||||
</p>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
"""
|
||||
iLocal — Kontext-basierte Inferenz (Bex 2007).
|
||||
iLocal — context-based inference (Bex 2007).
|
||||
|
||||
Nach Bex et al. 2007: "Inferring XML Schema Definitions from XML Data"
|
||||
Extrahiert aus YAML-Bäumen (Kontext, Sequenz)-Paare, wobei der Kontext
|
||||
der YAML-Key (Container-Key) ist.
|
||||
Per Bex et al. 2007: "Inferring XML Schema Definitions from XML Data"
|
||||
Extracts (context, sequence) pairs from YAML trees, where context is
|
||||
the YAML key (container key).
|
||||
|
||||
Angepasst für YAML:
|
||||
- Kontext = YAML-Key, dessen Wert eine Liste ist (z.B. tasks, steps)
|
||||
- Sequenz = Die item-Keys innerhalb dieser Liste (z.B. apt, template, service)
|
||||
Adapted for YAML:
|
||||
- Context = YAML key whose value is a list (e.g. tasks, steps)
|
||||
- Sequence = item keys within that list (e.g. apt, template, service)
|
||||
|
||||
Anstatt Dateipfade zu verwenden (wie im XML-Kontext), arbeiten wir
|
||||
mit den Container-Keys direkt (Benutzer-Vorgabe: kein Dateipfad-Ballast).
|
||||
Uses container keys directly instead of file paths (design decision:
|
||||
no path overhead).
|
||||
"""
|
||||
|
||||
import yaml
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Generates:
|
|||
|
||||
|
||||
def parse_expression(expr):
|
||||
"""Zerlegt einen regulären Ausdruck in seine Bestandteile."""
|
||||
"""Split a regular expression into its components."""
|
||||
if not expr or expr in ('∅', 'ε', ''):
|
||||
return [('empty', 'ε')]
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ def parse_expression(expr):
|
|||
|
||||
|
||||
def format_prompt_cardinality(quantifier):
|
||||
"""Gibt die deutsche Kardinalitätsbeschreibung für einen Quantifier zurück."""
|
||||
"""Return the cardinality description for a quantifier."""
|
||||
mapping = {
|
||||
'': '# PFLICHT: Genau 1 mal erforderlich',
|
||||
'+': '# PFLICHT: 1 oder mehrmals erforderlich',
|
||||
|
|
@ -80,18 +80,18 @@ def format_prompt_cardinality(quantifier):
|
|||
|
||||
def generate_template(expr, context_key=None, include_header=True):
|
||||
"""
|
||||
Generiert ein YAML-One-Shot-Template aus einem regulären Ausdruck.
|
||||
Generate a YAML one-shot template from a regular expression.
|
||||
|
||||
Args:
|
||||
expr: Der inferierte Ausdruck (String)
|
||||
context_key: Name des YAML-Container-Keys (z.B. 'tasks')
|
||||
include_header: Ob der Header-Teil (name, hosts) eingefügt wird
|
||||
expr: Inferred expression (string)
|
||||
context_key: YAML container key (e.g. 'tasks')
|
||||
include_header: Whether to include header section (name, hosts)
|
||||
|
||||
Returns:
|
||||
String: YAML-Skelett mit Platzhaltern und Kardinalitätskommentaren
|
||||
YAML skeleton with placeholders and cardinality comments
|
||||
"""
|
||||
if not expr or expr in ('∅', 'ε'):
|
||||
return "# Keine Struktur inferiert (leere Sequenzen oder keine Beispiele)"
|
||||
return "# No structure inferred (empty sequences or no examples)"
|
||||
|
||||
if include_header:
|
||||
lines = [
|
||||
|
|
@ -129,21 +129,21 @@ def generate_template(expr, context_key=None, include_header=True):
|
|||
inner_expr = group_str[1:-1]
|
||||
if '|' in inner_expr:
|
||||
alts = inner_expr.split('|')
|
||||
lines.append(f"{indent}# WAHLWEISE (eines auswählen):")
|
||||
lines.append(f"{indent}# CHOOSE (pick one):")
|
||||
for alt in alts:
|
||||
alt_clean = alt.strip()
|
||||
lines.append(f"{indent}# - {alt_clean}: <Parameter für {alt_clean}>")
|
||||
lines.append(f"{indent}# - {alt_clean}: <params>")
|
||||
if card:
|
||||
lines[-1] = f"{lines[-1]} {card}"
|
||||
else:
|
||||
lines.append(f"{indent}- {inner_expr}: <Parameter für {inner_expr}> {card}")
|
||||
lines.append(f"{indent}- {inner_expr}: <params> {card}")
|
||||
task_index += 1
|
||||
|
||||
elif token[0] == 'name':
|
||||
name = token[1]
|
||||
quantifier = token[2]
|
||||
card = format_prompt_cardinality(quantifier)
|
||||
lines.append(f"{indent}- {name}: <Parameter für {name}> {card}")
|
||||
lines.append(f"{indent}- {name}: <params> {card}")
|
||||
task_index += 1
|
||||
|
||||
elif token[0] == 'pipe':
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
"""
|
||||
YAMLTokenizer — Extrahiert Token-Sequenzen aus Ansible YAML-Dateien.
|
||||
YAMLTokenizer — Extracts token sequences from Ansible YAML files.
|
||||
|
||||
Nach Bex 2007/2010 wird jedes YAML-Dokument in eine Sequenz von Symbolen
|
||||
(Token) übersetzt. Für Ansible:
|
||||
- Ein Playbook → eine Sequenz von Module-Namen (apt, service, template, ...)
|
||||
- include_tasks wird als terminaler Token behandelt (nicht rekursiv aufgelöst)
|
||||
- block/rescue/always: Der block-Container selbst wird als Token erfasst,
|
||||
der Inhalt wird NICHT tokenisiert (zu variabel laut Benutzer-Vorgabe)
|
||||
|
||||
Die extrahierten Sequenzen dienen als Eingabe für die Automaten-Konstruktion.
|
||||
Per Bex 2007/2010, each YAML document is translated into a sequence of
|
||||
symbols (tokens). For Ansible:
|
||||
- A playbook → one sequence of module names (apt, service, template, ...)
|
||||
- include_tasks is treated as a terminal token (not resolved recursively)
|
||||
- block/rescue/always: the block container itself is a token,
|
||||
its content is NOT tokenized (too variable)
|
||||
"""
|
||||
|
||||
import os
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue