Skip to main content
Glama

word_concordance

Extract structured word concordances from Norwegian digital collections by separating matched words from surrounding context for programmatic text analysis.

Instructions

Find concordances with structured output (no HTML formatting).

Returns clean format with separate before/target/after fields instead of HTML-formatted text. This is useful for programmatic analysis where you need the matched word separated from context.

Args: urn: URN identifier for the document word: Word to find concordances for window: Number of words before and after the match (default: 12, max: 24) limit: Maximum number of concordances to return (default: 100)

Returns: JSON string containing structured concordance results with fields: - dhlabid: Document identifier - before: Text before the matched word - target: The matched word itself - after: Text after the matched word

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urnYes
wordYes
windowNo
limitNo

Implementation Reference

  • The FastMCP tool handler and registration for 'word_concordance'. It wraps the external dhlab.api.dhlab_api.word_concordance function, providing type-hinted parameters and structured JSON output. The @mcp.tool() decorator handles schema inference and registration.
    @mcp.tool() def word_concordance( urn: str, word: str, window: int = 12, limit: int = 100, ) -> str: """Find concordances with structured output (no HTML formatting). Returns clean format with separate before/target/after fields instead of HTML-formatted text. This is useful for programmatic analysis where you need the matched word separated from context. Args: urn: URN identifier for the document word: Word to find concordances for window: Number of words before and after the match (default: 12, max: 24) limit: Maximum number of concordances to return (default: 100) Returns: JSON string containing structured concordance results with fields: - dhlabid: Document identifier - before: Text before the matched word - target: The matched word itself - after: Text after the matched word """ try: from dhlab.api.dhlab_api import word_concordance as dhlab_word_concordance # Call dhlab's word_concordance method directly # Note: urn parameter expects a list, words parameter expects a list result = dhlab_word_concordance( urn=[urn], words=[word], before=window, after=window, limit=limit ) if result is not None and len(result) > 0: return result.to_json(orient='records', force_ascii=False) return "No concordances found" except Exception as e: return f"Error finding word concordances: {str(e)}"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/marksverdhei/dhlab-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server