Fixed how the spoonacular api call parses through the data#154
Merged
Adish-Singh merged 1 commit intomainfrom Dec 2, 2025
Merged
Conversation
|
|
||
| if (!stepText.isEmpty()) { | ||
| steps.add(new InstructionStep(number, stepText)); | ||
| // Split by: period/!/? followed by space + capital OR capital letter after lowercase (missing punctuation) |
There was a problem hiding this comment.
🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 120 characters (found 127).
| if (!stepText.isEmpty()) { | ||
| steps.add(new InstructionStep(number, stepText)); | ||
| // Split by: period/!/? followed by space + capital OR capital letter after lowercase (missing punctuation) | ||
| String[] sentences = stepText.split("(?<=[.!?])\\s*(?=[A-Z])"); |
There was a problem hiding this comment.
🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck> reported by reviewdog 🐶
Variable 'sentences' should be declared final.
| // Split by: period/!/? followed by space + capital OR capital letter after lowercase (missing punctuation) | ||
| String[] sentences = stepText.split("(?<=[.!?])\\s*(?=[A-Z])"); | ||
| for (String sentence : sentences) { | ||
| String trimmed = sentence.trim(); |
There was a problem hiding this comment.
🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck> reported by reviewdog 🐶
Variable 'trimmed' should be declared final.
hussssni
approved these changes
Dec 2, 2025
Collaborator
hussssni
left a comment
There was a problem hiding this comment.
Nice watch out for checkstyle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixed an issue in FindInstructionsSpoonacular where the API returned abnormally long instruction steps that were difficult to read. The parser now splits steps into individual sentences for better readability.
Files Modified
FindInstructionsSpoonacular.java
Problem
The Spoonacular API sometimes returns very long instruction steps that combine multiple sentences into a single step. For example:
Mix the wet ingredients, warm the liquid either in the microwave (about 40 seconds) or on the stovetop you want the temperature to be that of a hot bath.Slowly incorporate the liquid into the dry ingredients while stirring.When you can stir no more, start to knead the dough with your hands.
Solution
Modified the parsing logic to split steps by sentences using regex pattern matching:
Splits on periods, exclamation marks, or question marks followed by a capital letter
Handles edge cases where punctuation is missing (e.g., "bath.Slowly" with no space)
Uses \s* to match zero or more spaces after punctuation
Testing
Manually tested with recipes containing long multi-sentence steps. Confirmed proper splitting at sentence boundaries.