https://github.com/amokan/human_name
Elixir bindings for the human-name crate implemented as a safe Rust NIF
https://github.com/amokan/human_name
elixir human-names name-parsing nlp rustler
Last synced: 28 days ago
JSON representation
Elixir bindings for the human-name crate implemented as a safe Rust NIF
- Host: GitHub
- URL: https://github.com/amokan/human_name
- Owner: amokan
- License: mit
- Created: 2021-09-18T23:32:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-10T03:59:02.000Z (about 2 months ago)
- Last Synced: 2025-04-26T06:15:32.972Z (about 1 month ago)
- Topics: elixir, human-names, name-parsing, nlp, rustler
- Language: Elixir
- Homepage:
- Size: 99.6 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# HumanName
[](https://github.com/amokan/human_name/actions/workflows/ci.yaml)
[](https://hex.pm/packages/human_name)
[](https://coveralls.io/github/amokan/human_name?branch=main)Elixir wrapper for [David Judd's](https://github.com/djudd) excellent [human-name](https://crates.io/crates/human_name) crate implemented as a BEAM-friendly Rust NIF.
The API implemented for use in Elixir/Erlang does not cover every aspect of the Rust library. Feel free to open a PR for contributions.
## Installation
This package can be installed by adding `human_name` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:human_name, "~> 0.6.2"}
]
end
```By default **you do not need Rust installed** because the lib will try to download a precompiled NIF file.
In case you want to force compilation set the
`HUMAN_NAME_BUILD` environment variable to `true` or `1`.To run tests locally, you could do a `HUMAN_NAME_BUILD=1 mix test`.
Alternatively you can also set the application env `:build_from_source` to `true` in order to force the build:
```elixir
config :human_name, HumanName, build_from_source: true
```## Usage
```elixir
iex> HumanName.consistent_with?("Jimmy H Jenkins", "Jim Jenkins")
{:ok, true}iex> HumanName.first_and_last_initials("Dr. Alibaster Cornelius Juniper III")
{:ok, "AJ"}iex> HumanName.first_initial("Dr. Alibaster Cornelius Juniper III")
{:ok, "A"}iex> HumanName.first_initial_last("Jimmy H Jenkins")
{:ok, "J. Jenkins"}iex> HumanName.first_name("Dr. Alibaster Cornelius Juniper III")
{:ok, "Alibaster"}iex> HumanName.middle_initials("Dr. Alibaster Cornelius Juniper III")
{:ok, "C"}iex> HumanName.middle_name("Dr. Alibaster Cornelius Juniper III")
{:ok, "Cornelius"}iex> HumanName.last_initial("Jimmy H Jenkins")
{:ok, "J"}iex> HumanName.last_name("Dr. Alibaster Cornelius Juniper III")
{:ok, "Juniper"}iex> HumanName.normalize("Dr. Alibaster Cornelius Juniper III")
{:ok, "Alibaster Juniper"}iex> HumanName.normalize_full("JIMMY H JENKINS")
{:ok, "Jimmy H. Jenkins"}
```----
## License
MIT License
See the [license file](LICENSE.txt) for details.