I was wondering if it was possible to create a sentence jumble that would output all possible variations using all words from a given sentence using node.js
ie.
"The brown fox" would output to:
"Fox the brown"
"Brown fox the"
"The fox brown"
"Brown the fox"
"Fox brown the"
Thank you in advance.
Summary
It's been requested that we add exact matching to the search form on our site.
Below are examples of how we expect the search to operate.
Example 1
No exact match has been indicated by the user
Input: quick brown fox lazy dog
Output: matches for quick, brown, fox, lazy, and dog
Example 2
"brown" is the exact match indicated by the user
Input: quick "brown" fox lazy dog
Output: matches for quick, brown, fox, lazy, and dog (Same as example 1.)
Example 3
"brown fox" is the exact match indicated by the user
Input: quick "brown fox" lazy dog
Output: matches for quick, brown fox, lazy and dog
Example 4
"quick brown" and "lazy dog" are the exact matches indicated by the user
Input: "quick brown" fox "lazy dog"
Output: matches for quick brown, fox, and lazy dog
Question
Now we're trying to determine how edge cases should be handled. Specifically, how should we handle an odd number of quotes (see example 5) and how should we handle double quotes that occur in the middle of words (see example 6 and 7)?
Example 5
Odd number of double-quotes
Input: "quick brown" fox "lazy dog
Possible Output:
Matches for quick brown, fox, "lazy, and dog (Use spaces to delimit the search)
Matches for quick brown, fox, lazy, and dog (Ignore the odd double-quote)
Matches for quick brown, fox, and lazy dog (Add a closing double-quote after the last term)
Example 6
Even number of quotes, some of which interrupt a word
Input: qu"ick brown" fox lazy dog
Possible Output:
Matches for qu, ick brown, fox, lazy, and dog ?
(I couldn't think of another way to handle it, but I'm open to ideas.)
Example 7
Odd number of quotes, final quote interrupts a word
Input: "quick brown" fox la"zy dog
Possible Output:
Matches for quick brown, fox, la"zy, and dog (Use spaces to delimit the search)
Matches for quick brown, fox, lazy, and dog (Ignore the odd double-quote)
Matches for quick brown, fox, la, and zy dog (Add a closing double-quote after the last term)
Resources
I tried to search for resources that suggest best practices or common practices for these edge cases, but I wasn't able to find anything.
If you know of any resources on this, please let me know.
Suppose I have the text:
The quick brown
fox jumps over
the lazy dog.
Where I have used a maximum linewidth of 15 characters.
Then, I want to replace "fox jumps over" with "and", i.e., I get:
The quick brown
and
the lazy dog.
How I can fixed again my line-wrapping, i.e.,
The quick brown
and the lazy
dog.
Is there a "fast" way for doing this ?
I have:
A file called 'fooBar'.
A variable called 'myVar', which has the string 'the lazy' assigned to it.
I want to insert $myVar into the file fooBar before the text '</dog>'
fooBar Before:
The quick brown fox jumps over </dog>
fooBarAfter:
The quick brown fox jumps over the lazy </dog>
What is the best way to achieve this please?
You can use sed like this:
cat fooBar
The quick brown fox jumps over </dog>
myVar='the lazy'
sed -i.bak "s~</dog>~$myVar &~" fooBar
cat fooBar
The quick brown fox jumps over the lazy </dog>
I am using edismax SearchHandler in my search and I have some issues in the search results. As I understand if the "defaultOperator" is set to OR the search query will be passed as -> The OR quick OR brown OR fox implicitly. However if I search for The quick brown fox, I get lesser results than explicitly adding the OR. Another issue is that if I search for The quick brown fox other documents that contain the word fox is not in the search results.
Thanks.
Make sure mm is 0%. Then the search should be OR.