{"id":50350542,"url":"https://github.com/dren-dk/HunspellJNA","last_synced_at":"2026-06-15T12:01:45.646Z","repository":{"id":2732913,"uuid":"3728315","full_name":"dren-dk/HunspellJNA","owner":"dren-dk","description":"Hunspell library for Java based on JNA","archived":false,"fork":false,"pushed_at":"2023-03-06T09:42:52.000Z","size":5044,"stargazers_count":59,"open_issues_count":8,"forks_count":40,"subscribers_count":7,"default_branch":"master","last_synced_at":"2023-03-11T19:06:45.204Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dren-dk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2012-03-15T13:12:28.000Z","updated_at":"2023-07-05T15:19:45.319Z","dependencies_parsed_at":"2023-07-09T19:46:41.830Z","dependency_job_id":null,"html_url":"https://github.com/dren-dk/HunspellJNA","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/dren-dk/HunspellJNA","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dren-dk%2FHunspellJNA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dren-dk%2FHunspellJNA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dren-dk%2FHunspellJNA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dren-dk%2FHunspellJNA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dren-dk","download_url":"https://codeload.github.com/dren-dk/HunspellJNA/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dren-dk%2FHunspellJNA/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34361403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-29T21:00:23.929Z","updated_at":"2026-06-15T12:01:45.637Z","avatar_url":"https://github.com/dren-dk.png","language":"Java","funding_links":[],"categories":["人工智能"],"sub_categories":["自然语言处理"],"readme":"[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)\n\n# JNA based Java API for Hunspell\n\nThis package contains the JNA based Java bindings for the Hunspell, see:\nhttps://github.com/twall/jna and http://hunspell.github.io/ for details\non how these work.\n\nThis java wrapper lives at:\nhttps://github.com/dren-dk/HunspellJNA\n\nSee this page for dictionaries:\nhttp://wiki.services.openoffice.org/wiki/Dictionaries\n\n# Included native binaries \n\nI'm in the process of obtaining the binaries for new versions of hunspell,\nat the moment these are the versions included:\n\n## 1.6.2\n* libhunspell-linux-x86-64.so\n\n## 1.3.2\n* hunspell-darwin-ppc-32.jnilib\n* hunspell-win-x86-32.dll\n* hunspell-win-x86-64.dll\n* libhunspell-darwin-x86-32.dylib\n* libhunspell-darwin-x86-64.dylib\n* libhunspell-linux-x86-32.so\n\n\n\n# Building the native binaries\n\nBefore using the java API you must build some native binaries to include\nin the jar, to make things easy I've included the binaries from the platforms\nthat I care about in native-lib.\n\nThe binaries in native-lib were built on the various platforms using the\nnative-build.pl script, the source for the native libs is in native-src and\nconsists of an unmodified hunspell source tar ball and any needed diffs.\n\nI've included a script called native-build.pl which might help to build\non at least Linux and 32 bit OSX/windows, for 64 bit OSX/windows you\ncan take it as a hint of what to do.\n\nCompiling libhunspell for 64 bit OSX is a pain, see readme-darwin-64bit.txt\nfor the changes that are needed to make it work.\n\nCompiling libhunspell for 64 bit windows means having to change the vc project\nto compile for the x64 platform.\n\n\n# Building the Java API\n\nTo build `hunspell.jar` simply run `ant`. This will produce\n`build/jar/hunspell.jar` which contains everything a standalone application\ncould want (aside from `jna.jar` which can be found on the JNA page or in lib)\n\n\n# Building the Java API for use via webstart\n\nIf you plan on using `hunspell.jar` from a webstart application run:\n`ant webstart`.\n\nThis will produce two native jar files per supported platform (one for JNA\nand one for hunspell) as well as pure java `jna-jws.jar` and `hunspell-jws.jar`\nin `build/jar`.\n\nInclude `jna-jws.jar` and `hunspell-jws.jar` in the common resources section in\nnormal jar tags, the platform specific binaries must go into platform specific\nresource sections as nativelib entries.\n\n\n# Working around a bug in nativelib handling of webstart\n\nI had great trouble getting nativelib with more than one jar file to work on\nosx and linux (it worked fine on windows), there are two workarounds:\n\n1) Use plain `\u003cjar/\u003e` tags in stead of `\u003cnativelib/\u003e`. This will cause both JNA and\n   hunspell to search the classpath for the needed binaries and they will then\n   extract the binaries and load them as usual.\n   This approach might leak a binary each run on windows because of\n   the mandatory file locking used on that platform.\n\n2) Consolidate all your nativelib files for each platform into one.\n   This looks slightly less pretty, but it works and is slightly faster during\n   download as well.\n\n\n# Output\n\nThe output of `ant` is one large jar file containing binaries for all the supported platforms, it's about 800k, so it's not very nice for folks who have to download it though: \n\n| Name\t\t\t\t| Description\t\t\t\t\t|\n|-------------------------------|-----------------------------------------------|\n| hunspell.jar\t\t\t| the Java API + all binaries\t\t\t|\n| hunspell-jws.jar\t\t| just the Java API, for use in webstart\t|\n| hunspell-darwin-i386.jar\t| binaries for use as OS specific resources\t|\n| hunspell-darwin-ppc.jar\t|\t\t\t\t\t\t|\n| hunspell-linux-amd64.jar\t|\t\t\t\t\t\t|\n| hunspell-linux-i386.jar\t|\t\t\t\t\t\t|\n| hunspell-win32-x86.jar\t|\t\t\t\t\t\t|\n\nI've parted out the lib/jna.jar file in the same manner, also for use in webstart: \n\n| Name\t\t\t| Description\t\t|\n|-----------------------|-----------------------|\njna-jws.jar             | the Java API for JNA\t|\njna-darwin.jar          |\t\t\t|\njna-linux-amd64.jar\t|\t\t\t|\njna-linux-i386.jar\t|\t\t\t|\njna-win32-x86.jar\t|\t\t\t|\n\n\n# API\n\nSee `HunspellMain.java` for a very simple example of how to use the API, it\nboils down to:\n\n```\nHunspell.Dictionary dict = \n\tHunspell.getInstance().getDictionary(\"/path/to/your/unzipped/dictionary/en_US\"); \n\nif (dict.misspelled(\"wrod\")) {\n\tArrayList\u003cString\u003e suggestions = dict.suggest(\"wrod\");\n\t ...\n}\n```\n\nIOW: The application must also supply the two dictionary files (.dic and .aff) found in the zip file unzipped on disk and point at them using the full path, plus  the part of the file name before .dic. \n\n`Hunspell.getInstance()` caches the loaded hunspell library, so there is no overhead in calling it more than once.\n\n`getDictionary()` is also internally cached, so it costs no more than a hash lookup when calling the second time.\n\n# Testing\n\nFor a quick test of the JNA interface run\n\n```\njava -cp lib/jna.jar:build/jar/hunspell.jar\\ \n-Droot=/path/to/your/dicts/ -Dlang=en_GB dk.dren.hunspell.HunspellMain\n```\n\n\n# TODO\n\n`getDictionary()` doesn't re-load the files once they are loaded, it should probably do that automagically if it notices that the files have changed on disk.\n\n\n# Thanks\n\nAlthough this code doesn't contain any, it's very much inspired by the JNA bindings in OmegaT, so thank you to the OmegaT developers.\n\nAndrzej Zydron figured out how to build libhunspell for 64 bit OSX.\n\n# Misc\n\nAt the moment the package contains copies of:\n* jna.jar version 3.4.0 \n* Hunspell version 1.3.2 \n\n\nPatches and suggestions are welcome.\n\nFlemming Frandsen (flfr@stibo.com / ff@nrvissing.net) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdren-dk%2FHunspellJNA","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdren-dk%2FHunspellJNA","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdren-dk%2FHunspellJNA/lists"}