README.md

# ai-soulmate-sketch-filter

This Elixir package provides a robust filtering mechanism for potential soulmate sketches generated by AI, allowing for refined and targeted searches. It offers a flexible and efficient way to process sketch data based on various configurable criteria.

## Installation

To install `ai-soulmate-sketch-filter`, add it as a dependency to your `mix.exs` file:
elixir
def deps do
  [
    {:ai_soulmate_sketch_filter, "~> 0.1.0"}
  ]
end

Then, run `mix deps.get` to fetch and install the dependency.

## Usage

Here are several examples illustrating how to use `ai-soulmate_sketch_filter` in your Elixir applications.

**Example 1: Basic Filtering by Age Range**
elixir
alias AiSoulmateSketchFilter.Filter

sketch_data = %{age: 28, hair_color: :brown, eye_color: :blue, location: "New York"}

filter_options = %{age_range: 25..30}

case Filter.apply(sketch_data, filter_options) do
  {:ok, filtered_data} ->
    IO.puts "Sketch matches the age criteria: #{filtered_data}"
  {:error, reason} ->
    IO.puts "Sketch does not match the criteria: #{reason}"
end

**Example 2: Filtering by Hair and Eye Color using Pattern Matching**
elixir
alias AiSoulmateSketchFilter.Filter

sketch_data = %{age: 32, hair_color: :blonde, eye_color: :green, location: "London"}

filter_options = %{hair_color: [:blonde, :brown], eye_color: :green}

case Filter.apply(sketch_data, filter_options) do
  {:ok, filtered_data} ->
    IO.puts "Sketch matches hair and eye color criteria: #{filtered_data}"
  {:error, reason} ->
    IO.puts "Sketch does not match the criteria: #{reason}"
end

**Example 3: Using Pipes for Chained Filtering**
elixir
alias AiSoulmateSketchFilter.Filter

sketch_data = %{age: 27, hair_color: :black, eye_color: :brown, location: "Tokyo", interests: [:coding, :travel]}

filter_options_1 = %{age_range: 20..35}
filter_options_2 = %{interests: [:coding]}

sketch_data
|> Filter.apply(filter_options_1)
|> case do
  {:ok, intermediate_data} ->
    intermediate_data
    |> Filter.apply(filter_options_2)
    |> case do
      {:ok, final_data} ->
        IO.puts "Sketch matches all criteria: #{final_data}"
      {:error, reason} ->
        IO.puts "Sketch does not match the second criteria: #{reason}"
    end
  {:error, reason} ->
    IO.puts "Sketch does not match the first criteria: #{reason}"
end

**Example 4:  Handling Missing Data with Guards**

The `AiSoulmateSketchFilter.Filter` can be extended to handle cases where certain keys are missing from the `sketch_data`. Implementations can use guards to conditionally apply filters based on the presence of specific fields.

**Example 5: Filtering by Multiple Interests**
elixir
alias AiSoulmateSketchFilter.Filter

sketch_data = %{age: 25, hair_color: :red, eye_color: :hazel, location: "Paris", interests: [:art, :music, :travel]}

filter_options = %{interests: [:art, :coding]} # Requires at least one matching interest

case Filter.apply(sketch_data, filter_options, match_all_interests?: false) do # match_all_interests defaults to true
  {:ok, filtered_data} ->
    IO.puts "Sketch matches interest criteria: #{filtered_data}"
  {:error, reason} ->
    IO.puts "Sketch does not match the criteria: #{reason}"
end

## Features

*   **Flexible Filtering:** Supports filtering based on various attributes such as age, hair color, eye color, location, and interests.
*   **Configurable Criteria:**  Easily configure filtering criteria using Elixir maps.
*   **Pattern Matching Integration:** Seamlessly integrates with Elixir's pattern matching capabilities for concise and readable code.
*   **Pipe-Friendly:** Designed to be used within Elixir pipelines for composable data processing.
*   **Error Handling:** Provides clear error messages when sketches do not meet the specified criteria.
*   **Extensible Design:** Allows for the addition of custom filtering logic and criteria.

## License

MIT

This package is part of the ai-soulmate-sketch-filter ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/image/blog/ai-soulmate-drawing-free-tool-generate-your-soulmate-sketch/