diff --git a/lib/text_chunker/strategies/recursive_chunk/recursive_chunk.ex b/lib/text_chunker/strategies/recursive_chunk/recursive_chunk.ex index 33192bb..c912bf3 100644 --- a/lib/text_chunker/strategies/recursive_chunk/recursive_chunk.ex +++ b/lib/text_chunker/strategies/recursive_chunk/recursive_chunk.ex @@ -94,15 +94,17 @@ defmodule TextChunker.Strategies.RecursiveChunk do end end) - if chunks != [], - do: chunks, - else: [ + if chunks == [] do + [ %Chunk{ start_byte: 0, end_byte: 1, text: "incompatible_config_or_text_no_chunks_saved" } ] + else + chunks + end end defp perform_split(text, separators, chunk_size, chunk_overlap) do diff --git a/mix.exs b/mix.exs index 4ac26a5..33682d3 100644 --- a/mix.exs +++ b/mix.exs @@ -35,7 +35,7 @@ defmodule TextChunker.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ - {:styler, "~> 0.7", only: [:dev, :test], runtime: false}, + {:styler, "~> 1.0", only: [:dev, :test], runtime: false}, {:ex_doc, "~> 0.29", only: [:dev, :test], runtime: false}, {:nimble_options, "~> 1.0"} ] diff --git a/mix.lock b/mix.lock index d467d91..23e886b 100644 --- a/mix.lock +++ b/mix.lock @@ -6,5 +6,5 @@ "makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"}, "nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, - "styler": {:hex, :styler, "0.11.9", "2595393b94e660cd6e8b582876337cc50ff047d184ccbed42fdad2bfd5d78af5", [:mix], [], "hexpm", "8b7806ba1fdc94d0a75127c56875f91db89b75117fcc67572661010c13e1f259"}, + "styler": {:hex, :styler, "1.0.0", "87daf4a8e421d7678da78f9532a632974de6b8060b80d7827abec3bca5140173", [:mix], [], "hexpm", "4ba5bc40c5eaebe2bb05ec0bb7b5a889d38c6ea6865c584dffd360b3a94ec625"}, } diff --git a/test/recursive_chunk_test.exs b/test/recursive_chunk_test.exs index 9dbdd94..e490a9d 100644 --- a/test/recursive_chunk_test.exs +++ b/test/recursive_chunk_test.exs @@ -247,19 +247,19 @@ defmodule TextChunkerTest do expected_result = [ - "class PetShop:\n \"\"\"Represents a pet shop with inventory and sales functionality.\"\"\"", + ~s(class PetShop:\n """Represents a pet shop with inventory and sales functionality."""), "\n\n def __init__(self, name):\n self.name = name\n self.inventory = {}", "\n\n def add_pet(self, pet_type, quantity):", - "\n \"\"\"Adds a specified quantity of a pet type to the inventory.\"\"\"", + ~s(\n """Adds a specified quantity of a pet type to the inventory."""), "\n if pet_type in self.inventory:\n self.inventory[pet_type] += quantity", "\n else:\n self.inventory[pet_type] = quantity", "\n\n def sell_pet(self, pet_type, quantity):", - "\n \"\"\"Sells a specified quantity of a pet type.\"\"\"", + ~s(\n """Sells a specified quantity of a pet type."""), "\n if pet_type in self.inventory and self.inventory[pet_type] >= quantity:", "\n self.inventory[pet_type] -= quantity\n return True\n else:", "\n return False", "\n\n def get_pet_count(self, pet_type):", - "\n \"\"\"Returns the current count of a specific pet type.\"\"\"", + ~s(\n """Returns the current count of a specific pet type."""), "\n return self.inventory.get(pet_type, 0)\n" ] @@ -279,20 +279,20 @@ defmodule TextChunkerTest do expected_result = [ - "class PetShop:\n \"\"\"Represents a pet shop with inventory and sales functionality.\"\"\"", + ~s(class PetShop:\n """Represents a pet shop with inventory and sales functionality."""), "\n\n def __init__(self, name):\n self.name = name\n self.inventory = {}", "\n\n def add_pet(self, pet_type, quantity):", - "\n \"\"\"Adds a specified quantity of a pet type to the inventory.\"\"\"", + ~s(\n """Adds a specified quantity of a pet type to the inventory."""), "\n if pet_type in self.inventory:\n self.inventory[pet_type] += quantity", "\n self.inventory[pet_type] += quantity\n else:", "\n else:\n self.inventory[pet_type] = quantity", "\n\n def sell_pet(self, pet_type, quantity):", - "\n def sell_pet(self, pet_type, quantity):\n \"\"\"Sells a specified quantity of a pet type.\"\"\"", + ~s{\n def sell_pet(self, pet_type, quantity):\n """Sells a specified quantity of a pet type."""}, "\n if pet_type in self.inventory and self.inventory[pet_type] >= quantity:", "\n self.inventory[pet_type] -= quantity\n return True\n else:", "\n return True\n else:\n return False", "\n\n def get_pet_count(self, pet_type):", - "\n \"\"\"Returns the current count of a specific pet type.\"\"\"", + ~s(\n """Returns the current count of a specific pet type."""), "\n return self.inventory.get(pet_type, 0)\n" ]