Homophone dictionary

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Search MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-search -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-search/search-net-mcp:latest
Folders, licensing and more →

The HomophoneDictionary class is designed to store homophones in an index. For information on searching using homophones, see the Homophone search page.

To get the number of homophones in the dictionary, use the getCount method.

To add groups of homophones to the dictionary, use the addRange method.

The clear method is used to remove all homophones from the dictionary.

The getHomophones method is used to get a list of synonyms for a given word.

The getHomophoneGroups method is used to get all synonym groups to which a given word belongs.

To get all synonym groups from the dictionary, use the getAllHomophoneGroups method.

To export homophones to a file, use the exportDictionary method.

To import homophones from a file, use the importDictionary method.

The following example demonstrates the use of methods of the homophone dictionary.

String indexFolder = "c:\\MyIndex\\";

// Creating an index from in specified folder
Index index = new Index(indexFolder);

// Creating an index in memory with default homophone dictionary
Index index = new Index();

// Getting homophones for word 'braid'
String[] homophones = index.getDictionaries().getHomophoneDictionary().getHomophones("braid");
System.out.println("Homophones for 'braid':");
for (String homophone : homophones) {
    System.out.println(homophone);
}

// Getting groups of homophones to which word 'braid' belongs to
String[][] groups = index.getDictionaries().getHomophoneDictionary().getHomophoneGroups("braid");
System.out.println("Homophone groups for 'braid':");
for (String[] group : groups) {
    for (String group1 : group) {
        System.out.print(group1 + " ");
    }
    System.out.println();
}

if (index.getDictionaries().getHomophoneDictionary().getCount() > 0) {
    // Removing all homophones from the dictionary
    index.getDictionaries().getHomophoneDictionary().clear();
}

// Adding homophones to the dictionary
String[][] homophoneGroups = new String[][] {
    new String[] { "awe", "oar", "or", "ore" },
    new String[] { "aye", "eye", "i" },
};
index.getDictionaries().getHomophoneDictionary().addRange(homophoneGroups);

// Export homophones to a file
index.getDictionaries().getHomophoneDictionary().exportDictionary("C:\\Homophones.dat");

// Import homophones from a file
index.getDictionaries().getHomophoneDictionary().importDictionary("C:\\Homophones.dat");

More resources

GitHub examples

You may easily run the code from documentation articles and see the features in action in our GitHub examples:

Free online document search App

Along with full featured .NET library we provide simple, but powerful free Apps.

You are welcome to search over your PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX and more with our free online Free Online Document Search App.