lookup_word_lemma
Find the base form of Norwegian words using the National Library of Norway's Digital Humanities Lab to support linguistic analysis and text processing.
Instructions
Look up the lemma (base form) of a Norwegian word.
Args: word: The word to look up
Returns: JSON string containing lemma information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| word | Yes |
Implementation Reference
- src/dhlab_mcp/server.py:222-239 (handler)The handler function for the 'lookup_word_lemma' tool. It is decorated with @mcp.tool(), which registers it as an MCP tool. The function uses dhlab.WordLemma to fetch the lemma of the input word and returns it as JSON.@mcp.tool() def lookup_word_lemma(word: str) -> str: """Look up the lemma (base form) of a Norwegian word. Args: word: The word to look up Returns: JSON string containing lemma information """ try: word_lemma = dhlab.WordLemma(word) if hasattr(word_lemma, 'lemmas') and word_lemma.lemmas is not None: return word_lemma.lemmas.to_json(orient='records', force_ascii=False) return f"No lemma found for word: {word}" except Exception as e: return f"Error looking up word lemma: {str(e)}"
- src/dhlab_mcp/server.py:222-222 (registration)The @mcp.tool() decorator registers the lookup_word_lemma function as an MCP tool.@mcp.tool()
- src/dhlab_mcp/server.py:224-230 (schema)The docstring provides the tool description, input argument 'word: str', and output format as JSON string, serving as the schema."""Look up the lemma (base form) of a Norwegian word. Args: word: The word to look up Returns: JSON string containing lemma information