-
-
Notifications
You must be signed in to change notification settings - Fork 145
feat: add prototype for Proofreading Tool lab #1140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a087254
7c20ebe
5b888d3
81a0865
12f2e24
122594a
8cb1d08
9e56fb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,49 @@ | ||||||
| function findRepeatedPhrases(words, phraseLength) { | ||||||
| const repeatedWordsIndecies = [] | ||||||
|
|
||||||
| for (let i = 0; i <= words.length - phraseLength; i++) { | ||||||
| for (let j = i + 1; j <= words.length - phraseLength; j++) { | ||||||
| let match = true | ||||||
|
|
||||||
| for (let k = 0; k < phraseLength; k++) { | ||||||
| if (words[i + k] !== words[j + k]) { | ||||||
| match = false | ||||||
| break | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (match) { | ||||||
| repeatedWordsIndecies.push(i) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| break | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| return repeatedWordsIndecies | ||||||
| } | ||||||
|
|
||||||
| function findPalindromeBreaks(words) { | ||||||
| const palindromesBroken = [] | ||||||
|
|
||||||
| for (let i = 0; i < Math.floor(words.length / 2); i++) { | ||||||
| const palindromeIndex = words.length - 1 - i | ||||||
|
|
||||||
| if (words[i] !== words[palindromeIndex]) { | ||||||
| palindromesBroken.push(i) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| return palindromesBroken | ||||||
| } | ||||||
|
|
||||||
| function analyseTexts(texts, phraseLength) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| let results = [] | ||||||
| for (let i = 0; i < texts.length; i++) { | ||||||
| const repeatedPhrases = findRepeatedPhrases(texts[i], phraseLength) | ||||||
| const palindromeBreaks = findPalindromeBreaks(texts[i]) | ||||||
|
|
||||||
| results.push({ repeatedPhrases, palindromeBreaks }) | ||||||
| } | ||||||
|
|
||||||
| return results | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||
| In this lab, you will create a proofreading tool, a tool that checks text for repeated phrases and palindrome breaks. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
what is a palidrome break? |
||||||
|
|
||||||
| **Objective**: Fulfill the user stories below and get all the tests to pass to complete the lab. | ||||||
|
|
||||||
| **User Stories**: | ||||||
|
|
||||||
| 1. You should implement `findRepeatedPhrases(words, phraseLength)` - given an array of words and a phrase length, find the starting indices of any repeated word sequences. Use nested loops with early exit `break` flags. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with anyway, the user story does not give enough infos to know what the function should do |
||||||
| 2. You should implement `findPalindromeBreaks(words)` — given an array of words, find the indices where the word-level palindrome is broken. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are not enough details of what the function should do |
||||||
| 3. You should implement `analyseTexts(texts, phraseLength)` — run both checks on each text in an array and return an array of result objects. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you mean with an array of result objects? does the order matter? please add details |
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.