dictionary-mcp-server 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .venv/
8
+ venv/
9
+ .env
10
+ .DS_Store
11
+ *.log
12
+ .pytest_cache/
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: dictionary-mcp-server
3
+ Version: 0.1.0
4
+ Summary: MCP-Server fuer Woerterbuch-Daten: Definitionen, Synonyme, Antonyme, Reime, Phonetik. Free Dictionary API + Datamuse, kein API-Key noetig.
5
+ Project-URL: Homepage, https://github.com/AiAgentKarl/dictionary-mcp-server
6
+ Project-URL: Repository, https://github.com/AiAgentKarl/dictionary-mcp-server
7
+ Project-URL: Issues, https://github.com/AiAgentKarl/dictionary-mcp-server/issues
8
+ Author-email: AiAgentKarl <coach1916@gmail.com>
9
+ License: MIT
10
+ Keywords: ai-agent,antonyms,dictionary,linguistics,mcp,nlp,rhymes,synonyms,thesaurus,wordnet
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Text Processing :: Linguistic
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: httpx>=0.27.0
23
+ Requires-Dist: mcp>=1.0.0
24
+ Description-Content-Type: text/markdown
25
+
26
+ # dictionary-mcp-server
27
+
28
+ MCP-Server fuer AI-Agents mit Zugriff auf Woerterbuch-, Thesaurus- und Linguistik-Daten. Liefert Definitionen, Synonyme, Antonyme, Reime, Phonetik (IPA + Audio), Etymologie und semantische Assoziationen.
29
+
30
+ **Kein API-Key noetig** — kombiniert die [Free Dictionary API](https://dictionaryapi.dev/) und die [Datamuse API](https://www.datamuse.com/api/).
31
+
32
+ ## 15 Tools
33
+
34
+ ### Definitionen & Phonetik
35
+ - `tool_get_definition(word)` — Vollstaendige Definition(en) mit allen Wortarten
36
+ - `tool_get_phonetic(word)` — IPA-Transkription + Audio-URLs
37
+ - `tool_get_examples(word)` — Beispielsaetze, gruppiert nach Wortart
38
+ - `tool_get_word_origin(word)` — Etymologie und Ursprung wenn verfuegbar
39
+
40
+ ### Thesaurus & Semantik
41
+ - `tool_get_synonyms(word, max_results=20)` — Aehnlich bedeutende Woerter
42
+ - `tool_get_antonyms(word, max_results=20)` — Gegenteilige Woerter
43
+ - `tool_get_word_associations(word, max_results=20)` — Semantisch verwandte Woerter (means-like)
44
+ - `tool_get_triggers(word, max_results=20)` — Statistisch oft im Kontext erscheinende Woerter
45
+ - `tool_get_hypernyms(word, max_results=20)` — Oberbegriffe (oak -> tree)
46
+ - `tool_get_hyponyms(word, max_results=20)` — Unterbegriffe (tree -> oak, maple)
47
+
48
+ ### Reime & Phonetische Suche
49
+ - `tool_get_rhymes(word, max_results=20, perfect_only=True)` — Perfekte oder near-rhymes
50
+ - `tool_get_sounds_like(word, max_results=20)` — Phonetisch aehnliche Woerter
51
+ - `tool_spell_check(pattern, max_results=20)` — Pattern-Matching mit `?`/`*` Wildcards
52
+
53
+ ### All-in-One
54
+ - `tool_word_full_report(word)` — Definition + Phonetik + Synonyme + Antonyme + Reime in einem Call
55
+ - `tool_get_server_info()` — Server-Metadaten
56
+
57
+ ## Installation
58
+
59
+ ```bash
60
+ pip install dictionary-mcp-server
61
+ ```
62
+
63
+ ## Konfiguration (Claude Desktop)
64
+
65
+ ```json
66
+ {
67
+ "mcpServers": {
68
+ "dictionary": {
69
+ "command": "dictionary-mcp-server"
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ ## Beispiele
76
+
77
+ ```python
78
+ # Vollstaendige Definition + Beispiele
79
+ await tool_get_definition("serendipity")
80
+
81
+ # Synonyme fuer Brainstorming
82
+ await tool_get_synonyms("happy", max_results=10)
83
+
84
+ # Reime fuer Songtexte / Poesie
85
+ await tool_get_rhymes("love", perfect_only=True)
86
+
87
+ # Spell-Check via Pattern
88
+ await tool_spell_check("hel?o") # findet hello, helio
89
+
90
+ # Alles auf einen Schlag
91
+ await tool_word_full_report("computer")
92
+ ```
93
+
94
+ ## Datenquellen
95
+
96
+ - **Free Dictionary API** (dictionaryapi.dev) — Definitionen, IPA, Beispiele, Audio. Kein API-Key, unbegrenzt.
97
+ - **Datamuse API** (datamuse.com/api) — Thesaurus, Reime, Assoziationen. Kein API-Key, 100k Calls/Tag frei.
98
+
99
+ ## Lizenz
100
+
101
+ MIT
@@ -0,0 +1,76 @@
1
+ # dictionary-mcp-server
2
+
3
+ MCP-Server fuer AI-Agents mit Zugriff auf Woerterbuch-, Thesaurus- und Linguistik-Daten. Liefert Definitionen, Synonyme, Antonyme, Reime, Phonetik (IPA + Audio), Etymologie und semantische Assoziationen.
4
+
5
+ **Kein API-Key noetig** — kombiniert die [Free Dictionary API](https://dictionaryapi.dev/) und die [Datamuse API](https://www.datamuse.com/api/).
6
+
7
+ ## 15 Tools
8
+
9
+ ### Definitionen & Phonetik
10
+ - `tool_get_definition(word)` — Vollstaendige Definition(en) mit allen Wortarten
11
+ - `tool_get_phonetic(word)` — IPA-Transkription + Audio-URLs
12
+ - `tool_get_examples(word)` — Beispielsaetze, gruppiert nach Wortart
13
+ - `tool_get_word_origin(word)` — Etymologie und Ursprung wenn verfuegbar
14
+
15
+ ### Thesaurus & Semantik
16
+ - `tool_get_synonyms(word, max_results=20)` — Aehnlich bedeutende Woerter
17
+ - `tool_get_antonyms(word, max_results=20)` — Gegenteilige Woerter
18
+ - `tool_get_word_associations(word, max_results=20)` — Semantisch verwandte Woerter (means-like)
19
+ - `tool_get_triggers(word, max_results=20)` — Statistisch oft im Kontext erscheinende Woerter
20
+ - `tool_get_hypernyms(word, max_results=20)` — Oberbegriffe (oak -> tree)
21
+ - `tool_get_hyponyms(word, max_results=20)` — Unterbegriffe (tree -> oak, maple)
22
+
23
+ ### Reime & Phonetische Suche
24
+ - `tool_get_rhymes(word, max_results=20, perfect_only=True)` — Perfekte oder near-rhymes
25
+ - `tool_get_sounds_like(word, max_results=20)` — Phonetisch aehnliche Woerter
26
+ - `tool_spell_check(pattern, max_results=20)` — Pattern-Matching mit `?`/`*` Wildcards
27
+
28
+ ### All-in-One
29
+ - `tool_word_full_report(word)` — Definition + Phonetik + Synonyme + Antonyme + Reime in einem Call
30
+ - `tool_get_server_info()` — Server-Metadaten
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install dictionary-mcp-server
36
+ ```
37
+
38
+ ## Konfiguration (Claude Desktop)
39
+
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "dictionary": {
44
+ "command": "dictionary-mcp-server"
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ ## Beispiele
51
+
52
+ ```python
53
+ # Vollstaendige Definition + Beispiele
54
+ await tool_get_definition("serendipity")
55
+
56
+ # Synonyme fuer Brainstorming
57
+ await tool_get_synonyms("happy", max_results=10)
58
+
59
+ # Reime fuer Songtexte / Poesie
60
+ await tool_get_rhymes("love", perfect_only=True)
61
+
62
+ # Spell-Check via Pattern
63
+ await tool_spell_check("hel?o") # findet hello, helio
64
+
65
+ # Alles auf einen Schlag
66
+ await tool_word_full_report("computer")
67
+ ```
68
+
69
+ ## Datenquellen
70
+
71
+ - **Free Dictionary API** (dictionaryapi.dev) — Definitionen, IPA, Beispiele, Audio. Kein API-Key, unbegrenzt.
72
+ - **Datamuse API** (datamuse.com/api) — Thesaurus, Reime, Assoziationen. Kein API-Key, 100k Calls/Tag frei.
73
+
74
+ ## Lizenz
75
+
76
+ MIT
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "dictionary-mcp-server"
7
+ version = "0.1.0"
8
+ description = "MCP-Server fuer Woerterbuch-Daten: Definitionen, Synonyme, Antonyme, Reime, Phonetik. Free Dictionary API + Datamuse, kein API-Key noetig."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "AiAgentKarl", email = "coach1916@gmail.com" }]
13
+ keywords = ["mcp", "dictionary", "thesaurus", "synonyms", "antonyms", "rhymes", "linguistics", "nlp", "wordnet", "ai-agent"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Text Processing :: Linguistic",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ ]
26
+ dependencies = [
27
+ "mcp>=1.0.0",
28
+ "httpx>=0.27.0",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/AiAgentKarl/dictionary-mcp-server"
33
+ Repository = "https://github.com/AiAgentKarl/dictionary-mcp-server"
34
+ Issues = "https://github.com/AiAgentKarl/dictionary-mcp-server/issues"
35
+
36
+ [project.scripts]
37
+ dictionary-mcp-server = "src.server:main"
38
+
39
+ [tool.hatch.build.targets.wheel]
40
+ packages = ["src"]
File without changes
File without changes
@@ -0,0 +1,56 @@
1
+ """Client fuer Datamuse API (api.datamuse.com) -- kostenlos, kein API-Key."""
2
+ import httpx
3
+
4
+ BASE_URL = "https://api.datamuse.com/words"
5
+
6
+
7
+ async def query(params: dict, max_results: int = 20) -> list:
8
+ """Generische Datamuse-Abfrage. Params siehe https://www.datamuse.com/api/"""
9
+ params = {**params, "max": max_results}
10
+ async with httpx.AsyncClient(timeout=15.0) as client:
11
+ response = await client.get(BASE_URL, params=params)
12
+ response.raise_for_status()
13
+ return response.json()
14
+
15
+
16
+ async def synonyms(word: str, max_results: int = 20) -> list:
17
+ return await query({"rel_syn": word}, max_results)
18
+
19
+
20
+ async def antonyms(word: str, max_results: int = 20) -> list:
21
+ return await query({"rel_ant": word}, max_results)
22
+
23
+
24
+ async def rhymes(word: str, max_results: int = 20) -> list:
25
+ return await query({"rel_rhy": word}, max_results)
26
+
27
+
28
+ async def near_rhymes(word: str, max_results: int = 20) -> list:
29
+ return await query({"rel_nry": word}, max_results)
30
+
31
+
32
+ async def means_like(word: str, max_results: int = 20) -> list:
33
+ return await query({"ml": word}, max_results)
34
+
35
+
36
+ async def sounds_like(word: str, max_results: int = 20) -> list:
37
+ return await query({"sl": word}, max_results)
38
+
39
+
40
+ async def spelled_like(pattern: str, max_results: int = 20) -> list:
41
+ return await query({"sp": pattern}, max_results)
42
+
43
+
44
+ async def triggers(word: str, max_results: int = 20) -> list:
45
+ """Woerter, die statistisch im Kontext von 'word' assoziiert sind."""
46
+ return await query({"rel_trg": word}, max_results)
47
+
48
+
49
+ async def hypernyms(word: str, max_results: int = 20) -> list:
50
+ """Oberbegriffe (mehr generisch)."""
51
+ return await query({"rel_spc": word}, max_results)
52
+
53
+
54
+ async def hyponyms(word: str, max_results: int = 20) -> list:
55
+ """Unterbegriffe (mehr spezifisch)."""
56
+ return await query({"rel_gen": word}, max_results)
@@ -0,0 +1,18 @@
1
+ """Client fuer Free Dictionary API (api.dictionaryapi.dev)."""
2
+ import httpx
3
+
4
+ BASE_URL = "https://api.dictionaryapi.dev/api/v2/entries"
5
+
6
+
7
+ async def fetch_word(word: str, lang: str = "en") -> dict:
8
+ """Holt rohen Eintrag von der Free Dictionary API."""
9
+ url = f"{BASE_URL}/{lang}/{word}"
10
+ async with httpx.AsyncClient(timeout=15.0) as client:
11
+ response = await client.get(url)
12
+ if response.status_code == 404:
13
+ return {"error": "not_found", "word": word, "message": f"Wort '{word}' nicht gefunden."}
14
+ response.raise_for_status()
15
+ data = response.json()
16
+ if isinstance(data, list) and data:
17
+ return data[0]
18
+ return {"error": "invalid_response", "word": word}
@@ -0,0 +1,67 @@
1
+ """FastMCP-Server fuer Woerterbuch- und Thesaurus-Daten."""
2
+ from mcp.server.fastmcp import FastMCP
3
+
4
+ from src.tools.definition_tools import (
5
+ tool_get_definition,
6
+ tool_get_phonetic,
7
+ tool_get_examples,
8
+ tool_get_word_origin,
9
+ )
10
+ from src.tools.thesaurus_tools import (
11
+ tool_get_synonyms,
12
+ tool_get_antonyms,
13
+ tool_get_word_associations,
14
+ tool_get_triggers,
15
+ tool_get_hypernyms,
16
+ tool_get_hyponyms,
17
+ )
18
+ from src.tools.phonetic_tools import (
19
+ tool_get_rhymes,
20
+ tool_get_sounds_like,
21
+ tool_spell_check,
22
+ )
23
+ from src.tools.info_tools import (
24
+ tool_word_full_report,
25
+ tool_get_server_info,
26
+ )
27
+
28
+
29
+ mcp = FastMCP(
30
+ "dictionary-mcp-server",
31
+ instructions=(
32
+ "Gibt AI-Agents Zugriff auf Woerterbuch-, Thesaurus- und Linguistik-Daten. "
33
+ "Liefert Definitionen, Synonyme, Antonyme, Reime, Phonetik, Etymologie und semantische Assoziationen. "
34
+ "Quellen: Free Dictionary API + Datamuse API (beide kostenlos, kein API-Key noetig)."
35
+ ),
36
+ )
37
+
38
+
39
+ def _register_tools() -> None:
40
+ """Registriert alle Tool-Funktionen am MCP-Server."""
41
+ mcp.tool()(tool_get_definition)
42
+ mcp.tool()(tool_get_phonetic)
43
+ mcp.tool()(tool_get_examples)
44
+ mcp.tool()(tool_get_word_origin)
45
+ mcp.tool()(tool_get_synonyms)
46
+ mcp.tool()(tool_get_antonyms)
47
+ mcp.tool()(tool_get_word_associations)
48
+ mcp.tool()(tool_get_triggers)
49
+ mcp.tool()(tool_get_hypernyms)
50
+ mcp.tool()(tool_get_hyponyms)
51
+ mcp.tool()(tool_get_rhymes)
52
+ mcp.tool()(tool_get_sounds_like)
53
+ mcp.tool()(tool_spell_check)
54
+ mcp.tool()(tool_word_full_report)
55
+ mcp.tool()(tool_get_server_info)
56
+
57
+
58
+ _register_tools()
59
+
60
+
61
+ def main() -> None:
62
+ """Entry-Point fuer das Console-Script."""
63
+ mcp.run()
64
+
65
+
66
+ if __name__ == "__main__":
67
+ main()
File without changes
@@ -0,0 +1,118 @@
1
+ """Tools fuer Wort-Definitionen, Phonetik, Beispiele, Etymologie."""
2
+ from src.clients import dictionary_client
3
+
4
+
5
+ async def tool_get_definition(word: str) -> dict:
6
+ """Holt vollstaendige Definition(en) eines Wortes.
7
+
8
+ Args:
9
+ word: Englisches Wort, z.B. "happy" oder "computer".
10
+
11
+ Returns:
12
+ Dict mit allen Bedeutungen (parts of speech, definitions, beispiele).
13
+ """
14
+ data = await dictionary_client.fetch_word(word)
15
+ if data.get("error"):
16
+ return data
17
+
18
+ meanings = []
19
+ for m in data.get("meanings", []):
20
+ defs = []
21
+ for d in m.get("definitions", []):
22
+ defs.append({
23
+ "definition": d.get("definition"),
24
+ "example": d.get("example"),
25
+ "synonyms": d.get("synonyms", []),
26
+ "antonyms": d.get("antonyms", []),
27
+ })
28
+ meanings.append({
29
+ "part_of_speech": m.get("partOfSpeech"),
30
+ "definitions": defs,
31
+ })
32
+
33
+ return {
34
+ "word": data.get("word"),
35
+ "meanings": meanings,
36
+ "source": "Free Dictionary API (dictionaryapi.dev)",
37
+ }
38
+
39
+
40
+ async def tool_get_phonetic(word: str) -> dict:
41
+ """Holt Phonetik (IPA) und Audio-Aussprache eines Wortes.
42
+
43
+ Args:
44
+ word: Englisches Wort.
45
+
46
+ Returns:
47
+ Dict mit IPA-Transkription und Audio-URLs.
48
+ """
49
+ data = await dictionary_client.fetch_word(word)
50
+ if data.get("error"):
51
+ return data
52
+
53
+ phonetics = []
54
+ for p in data.get("phonetics", []):
55
+ if p.get("text") or p.get("audio"):
56
+ phonetics.append({
57
+ "ipa": p.get("text"),
58
+ "audio_url": p.get("audio") or None,
59
+ })
60
+
61
+ return {
62
+ "word": data.get("word"),
63
+ "phonetics": phonetics,
64
+ "source": "Free Dictionary API",
65
+ }
66
+
67
+
68
+ async def tool_get_examples(word: str) -> dict:
69
+ """Holt Beispielsaetze fuer ein Wort aus allen Definitionen.
70
+
71
+ Args:
72
+ word: Englisches Wort.
73
+
74
+ Returns:
75
+ Dict mit Liste von Beispielsaetzen, gruppiert nach Wortart.
76
+ """
77
+ data = await dictionary_client.fetch_word(word)
78
+ if data.get("error"):
79
+ return data
80
+
81
+ examples = []
82
+ for m in data.get("meanings", []):
83
+ for d in m.get("definitions", []):
84
+ if d.get("example"):
85
+ examples.append({
86
+ "part_of_speech": m.get("partOfSpeech"),
87
+ "example": d["example"],
88
+ "context_definition": d.get("definition"),
89
+ })
90
+
91
+ return {
92
+ "word": data.get("word"),
93
+ "example_count": len(examples),
94
+ "examples": examples,
95
+ "source": "Free Dictionary API",
96
+ }
97
+
98
+
99
+ async def tool_get_word_origin(word: str) -> dict:
100
+ """Holt etymologische / Ursprungs-Informationen wenn verfuegbar.
101
+
102
+ Args:
103
+ word: Englisches Wort.
104
+
105
+ Returns:
106
+ Dict mit origin/etymology-Info wenn vorhanden.
107
+ """
108
+ data = await dictionary_client.fetch_word(word)
109
+ if data.get("error"):
110
+ return data
111
+
112
+ return {
113
+ "word": data.get("word"),
114
+ "origin": data.get("origin", "Keine Etymologie-Information verfuegbar."),
115
+ "source_urls": data.get("sourceUrls", []),
116
+ "license": data.get("license", {}),
117
+ "source": "Free Dictionary API",
118
+ }
@@ -0,0 +1,64 @@
1
+ """Server-Informationen und Sammel-Tools."""
2
+ from src.clients import dictionary_client, datamuse_client
3
+
4
+
5
+ async def tool_word_full_report(word: str) -> dict:
6
+ """Liefert einen vollstaendigen Report fuer ein Wort: Definition, Phonetik, Synonyme, Antonyme, Reime.
7
+
8
+ Bequemes All-in-One Tool fuer Agenten, die alles auf einmal brauchen.
9
+
10
+ Args:
11
+ word: Englisches Wort, z.B. "happy".
12
+
13
+ Returns:
14
+ Dict mit allen verfuegbaren Informationen.
15
+ """
16
+ dict_data = await dictionary_client.fetch_word(word)
17
+ syn = await datamuse_client.synonyms(word, 10)
18
+ ant = await datamuse_client.antonyms(word, 10)
19
+ rhy = await datamuse_client.rhymes(word, 10)
20
+
21
+ if dict_data.get("error"):
22
+ meanings = []
23
+ phonetics = []
24
+ else:
25
+ meanings = [
26
+ {
27
+ "part_of_speech": m.get("partOfSpeech"),
28
+ "definitions": [d.get("definition") for d in m.get("definitions", [])][:3],
29
+ }
30
+ for m in dict_data.get("meanings", [])
31
+ ]
32
+ phonetics = [p.get("text") for p in dict_data.get("phonetics", []) if p.get("text")]
33
+
34
+ return {
35
+ "word": word,
36
+ "phonetics": phonetics,
37
+ "meanings": meanings,
38
+ "synonyms": [r["word"] for r in syn],
39
+ "antonyms": [r["word"] for r in ant],
40
+ "rhymes": [r["word"] for r in rhy],
41
+ "dictionary_found": not bool(dict_data.get("error")),
42
+ "sources": ["Free Dictionary API", "Datamuse API"],
43
+ }
44
+
45
+
46
+ async def tool_get_server_info() -> dict:
47
+ """Liefert Informationen ueber den dictionary-mcp-server."""
48
+ return {
49
+ "name": "dictionary-mcp-server",
50
+ "version": "0.1.0",
51
+ "description": "MCP-Server fuer Woerterbuch, Thesaurus, Reime und Phonetik.",
52
+ "tools": [
53
+ "tool_get_definition", "tool_get_phonetic", "tool_get_examples", "tool_get_word_origin",
54
+ "tool_get_synonyms", "tool_get_antonyms", "tool_get_word_associations",
55
+ "tool_get_triggers", "tool_get_hypernyms", "tool_get_hyponyms",
56
+ "tool_get_rhymes", "tool_get_sounds_like", "tool_spell_check",
57
+ "tool_word_full_report",
58
+ ],
59
+ "data_sources": {
60
+ "free_dictionary_api": "https://dictionaryapi.dev (kostenlos, kein API-Key)",
61
+ "datamuse_api": "https://www.datamuse.com/api/ (kostenlos, kein API-Key)",
62
+ },
63
+ "languages": "Englisch (en) -- weitere Sprachen via Free Dictionary API moeglich",
64
+ }
@@ -0,0 +1,78 @@
1
+ """Tools fuer Reime, Aussprache-Aehnlichkeit, Spell-Checking."""
2
+ from src.clients import datamuse_client
3
+
4
+
5
+ async def tool_get_rhymes(word: str, max_results: int = 20, perfect_only: bool = True) -> dict:
6
+ """Holt sich reimende Woerter.
7
+
8
+ Args:
9
+ word: Englisches Wort, z.B. "love".
10
+ max_results: Maximale Anzahl Ergebnisse.
11
+ perfect_only: Wenn True, nur perfekte Reime. Sonst auch near-rhymes.
12
+
13
+ Returns:
14
+ Dict mit Liste der Reime + Silbenanzahl.
15
+ """
16
+ if perfect_only:
17
+ results = await datamuse_client.rhymes(word, max_results)
18
+ rhyme_type = "perfect"
19
+ else:
20
+ results = await datamuse_client.near_rhymes(word, max_results)
21
+ rhyme_type = "near"
22
+
23
+ return {
24
+ "word": word,
25
+ "rhyme_type": rhyme_type,
26
+ "rhymes": [
27
+ {
28
+ "word": r["word"],
29
+ "score": r.get("score", 0),
30
+ "syllables": r.get("numSyllables"),
31
+ }
32
+ for r in results
33
+ ],
34
+ "count": len(results),
35
+ "source": "Datamuse API",
36
+ }
37
+
38
+
39
+ async def tool_get_sounds_like(word: str, max_results: int = 20) -> dict:
40
+ """Holt Woerter, die phonetisch aehnlich klingen.
41
+
42
+ Args:
43
+ word: Englisches Wort oder Lautmalerei, z.B. "jirraf".
44
+ max_results: Maximale Anzahl Ergebnisse.
45
+
46
+ Returns:
47
+ Dict mit phonetisch aehnlichen Woertern (gut fuer Spell-Correction).
48
+ """
49
+ results = await datamuse_client.sounds_like(word, max_results)
50
+ return {
51
+ "input": word,
52
+ "sounds_like": [{"word": r["word"], "score": r.get("score", 0)} for r in results],
53
+ "count": len(results),
54
+ "source": "Datamuse API (sl=)",
55
+ }
56
+
57
+
58
+ async def tool_spell_check(pattern: str, max_results: int = 20) -> dict:
59
+ """Spell-Check via Pattern-Matching. Wildcards: ? = 1 Buchstabe, * = beliebig.
60
+
61
+ Beispiele:
62
+ - "hel?o" findet "hello", "helio".
63
+ - "comp*" findet "computer", "compete", etc.
64
+
65
+ Args:
66
+ pattern: Wort-Pattern mit ? und * Wildcards.
67
+ max_results: Maximale Anzahl Ergebnisse.
68
+
69
+ Returns:
70
+ Dict mit passenden Woertern.
71
+ """
72
+ results = await datamuse_client.spelled_like(pattern, max_results)
73
+ return {
74
+ "pattern": pattern,
75
+ "matches": [{"word": r["word"], "score": r.get("score", 0)} for r in results],
76
+ "count": len(results),
77
+ "source": "Datamuse API (sp=)",
78
+ }
@@ -0,0 +1,124 @@
1
+ """Tools fuer Synonyme, Antonyme, semantisch verwandte Woerter."""
2
+ from src.clients import datamuse_client
3
+
4
+
5
+ async def tool_get_synonyms(word: str, max_results: int = 20) -> dict:
6
+ """Holt Synonyme fuer ein Wort (Woerter mit aehnlicher Bedeutung).
7
+
8
+ Args:
9
+ word: Englisches Wort, z.B. "happy".
10
+ max_results: Maximale Anzahl Ergebnisse (Standard 20).
11
+
12
+ Returns:
13
+ Dict mit sortierter Liste von Synonymen + Relevanz-Score.
14
+ """
15
+ results = await datamuse_client.synonyms(word, max_results)
16
+ return {
17
+ "word": word,
18
+ "synonyms": [{"word": r["word"], "score": r.get("score", 0)} for r in results],
19
+ "count": len(results),
20
+ "source": "Datamuse API",
21
+ }
22
+
23
+
24
+ async def tool_get_antonyms(word: str, max_results: int = 20) -> dict:
25
+ """Holt Antonyme fuer ein Wort (Woerter mit entgegengesetzter Bedeutung).
26
+
27
+ Args:
28
+ word: Englisches Wort, z.B. "happy".
29
+ max_results: Maximale Anzahl Ergebnisse.
30
+
31
+ Returns:
32
+ Dict mit sortierter Liste von Antonymen.
33
+ """
34
+ results = await datamuse_client.antonyms(word, max_results)
35
+ return {
36
+ "word": word,
37
+ "antonyms": [{"word": r["word"], "score": r.get("score", 0)} for r in results],
38
+ "count": len(results),
39
+ "source": "Datamuse API",
40
+ }
41
+
42
+
43
+ async def tool_get_word_associations(word: str, max_results: int = 20) -> dict:
44
+ """Holt semantisch verwandte Woerter ('means like' -- aehnliche Bedeutung).
45
+
46
+ Geeignet zum Brainstorming oder fuer Vokabular-Erweiterung.
47
+
48
+ Args:
49
+ word: Englisches Wort.
50
+ max_results: Maximale Anzahl Ergebnisse.
51
+
52
+ Returns:
53
+ Dict mit Liste verwandter Woerter.
54
+ """
55
+ results = await datamuse_client.means_like(word, max_results)
56
+ return {
57
+ "word": word,
58
+ "associations": [{"word": r["word"], "score": r.get("score", 0)} for r in results],
59
+ "count": len(results),
60
+ "source": "Datamuse API (ml=)",
61
+ }
62
+
63
+
64
+ async def tool_get_triggers(word: str, max_results: int = 20) -> dict:
65
+ """Holt Trigger-Woerter (statistisch oft im Kontext von 'word').
66
+
67
+ Beispiel: 'cow' -> milk, farm, moo, bovine, etc.
68
+
69
+ Args:
70
+ word: Englisches Wort.
71
+ max_results: Maximale Anzahl Ergebnisse.
72
+
73
+ Returns:
74
+ Dict mit Trigger-Woertern.
75
+ """
76
+ results = await datamuse_client.triggers(word, max_results)
77
+ return {
78
+ "word": word,
79
+ "triggers": [{"word": r["word"], "score": r.get("score", 0)} for r in results],
80
+ "count": len(results),
81
+ "source": "Datamuse API (rel_trg=)",
82
+ }
83
+
84
+
85
+ async def tool_get_hypernyms(word: str, max_results: int = 20) -> dict:
86
+ """Holt Oberbegriffe (allgemeinere Kategorien).
87
+
88
+ Beispiel: 'oak' -> tree, plant.
89
+
90
+ Args:
91
+ word: Englisches Wort.
92
+ max_results: Maximale Anzahl Ergebnisse.
93
+
94
+ Returns:
95
+ Dict mit Oberbegriffen.
96
+ """
97
+ results = await datamuse_client.hypernyms(word, max_results)
98
+ return {
99
+ "word": word,
100
+ "hypernyms": [{"word": r["word"], "score": r.get("score", 0)} for r in results],
101
+ "count": len(results),
102
+ "source": "Datamuse API (rel_spc=)",
103
+ }
104
+
105
+
106
+ async def tool_get_hyponyms(word: str, max_results: int = 20) -> dict:
107
+ """Holt Unterbegriffe (spezifischere Beispiele).
108
+
109
+ Beispiel: 'tree' -> oak, maple, pine.
110
+
111
+ Args:
112
+ word: Englisches Wort.
113
+ max_results: Maximale Anzahl Ergebnisse.
114
+
115
+ Returns:
116
+ Dict mit Unterbegriffen.
117
+ """
118
+ results = await datamuse_client.hyponyms(word, max_results)
119
+ return {
120
+ "word": word,
121
+ "hyponyms": [{"word": r["word"], "score": r.get("score", 0)} for r in results],
122
+ "count": len(results),
123
+ "source": "Datamuse API (rel_gen=)",
124
+ }