Skip to main content
Glama

find_concordances

Locate word occurrences with surrounding context in documents from Norwegian digital collections to analyze usage patterns and linguistic context.

Instructions

Find concordances (contexts) for a word in a specific document.

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

Returns: JSON string containing concordance results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urnYes
wordYes
windowNo
limitNo

Implementation Reference

  • The handler function for the 'find_concordances' tool. It is decorated with @mcp.tool(), which registers it with the FastMCP server. The function retrieves concordances (contextual occurrences) of a specified word within a document identified by URN using the dhlab library, returning results as JSON.
    @mcp.tool() def find_concordances( urn: str, word: str, window: int = 25, limit: int = 100, ) -> str: """Find concordances (contexts) for a word in a specific document. Args: urn: URN identifier for the document word: Word to find concordances for window: Number of words before and after the match (default: 25) limit: Maximum number of concordances to return (default: 100) Returns: JSON string containing concordance results """ try: # Create corpus from URN corpus = dhlab.Corpus.from_identifiers([urn]) if len(corpus.corpus) == 0: return f"No document found for URN: {urn}" # Get concordances using corpus method concs = corpus.conc(words=word, window=window, limit=limit) if concs.concordance is not None and len(concs.concordance) > 0: return concs.concordance.to_json(orient='records', force_ascii=False) return "No concordances found" except Exception as e: return f"Error finding 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