son, but there's no code looping through it , its just codes that were presented me as a solution to me through bartleby, but it's calling from no parameter therefore running an error The problem statement is described in the problem_statement.pdf file. Write the solution into the fuzzy_phrases/solution.py. Please do not change the input and output contract of the def phrasel_search(P, Queries) -> [[string]] fun
Please the First two solutions bartleby gave me dont work, i attached a link for you too take a look at it yourself.
I need to loop through the json file text as sample.json, but there's no code looping through it , its just codes that were presented me as a solution to me through bartleby, but it's calling from no parameter therefore running an error
- The problem statement is described in the problem_statement.pdf file.
- Write the solution into the fuzzy_phrases/solution.py. Please do not change the input and output contract of the def phrasel_search(P, Queries) -> [[string]] function as the testing of the code correctness will be done programmatically.
- Note - You can only use standard python libraries. ex - json, random, etc
- *** This is the most important one **Basically the folder that' contains the dictionary is in a json file called, sample.json, so you wanna have a code that apparently use two parameters and the phrase apparently loops through the queries , inside the json file where the dictionary is found in the json file called sample.json
So in the screenshots below we have one that has the instructions which has to be followed and executed , the next one that follows should be an example, that says sample example python this is the problem statement supposed to be used to give you an idea , showing how you should take the phrases to loop through the queries as a parameter. The other screenshot is called the solution output, that is the sample of how the code should look like but it has to be modified. and the other screenshot that says this is the first sample py, is the json file you want to loop through.The sample.json is the json text file.
(This is where you can see the question directly)
Supposingly the code which they gave to me some weeks ago, doesn't work after all editing i was hoping the coder at bartleby could give it a try for themselves.
https://github.com/JakeMofa/interview-questions
![33 lines (33 sloc)
885 Bytes
Raw
Blame
"queries": [
"close box son add bad strong afford down bad middle",
"business become for department chap offer business become for chap tell afford aware bad name business become for committee chap normal around egg expect learn prepare ba
"phrases": [
goodbye lot forget",
"health contact ever big",
"balance
"business become for chap",
"approach field",
"else after blow inform",
"around egg expect learn",
"add bad",
"increase
accept",
"close box",
"afford bad"
"solution": [
"close box",
"add bad",
"afford down bad"
1.
"business become for department chap",
"business become for chap",
"afford aware bad",
"business become for committee chap",
"around egg expect learn",
"balance goodbye lot forget"
31
32
33](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fef664eea-5861-4a2d-82fb-02ec722ff663%2F6c29657a-0718-400a-80d0-b097feafb053%2Faxv9esy_processed.png&w=3840&q=75)
![13 lines (11 sloc)
411 Bytes
import json
def phrasel_search(P, Queries):
# Write your solution here
ans = [[]]
return ans
if
name_ == "_main_":
with open('sample.json', 'r') as f:
sample_data - json.loads (f.read())
P, Queries = sample_data['phrases'], sample_data['queries']
returned_ans = phrasel_search (P, Queries)
10
11
12
13
print('============= ALL TEST PASSED SUCCESSFULLY ===============')](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fef664eea-5861-4a2d-82fb-02ec722ff663%2F6c29657a-0718-400a-80d0-b097feafb053%2F09ipzlq_processed.png&w=3840&q=75)
![README.md
Instructions
• Clone the repository and use it to create a public repository in your GitHub account.
• The problem statement is described in the problem_statement.pdf file.
• Write the solution into the fuzzy_phrases/solution.py. Please do not change the input and output contract of
the def phrasel_search(P, Queries) -> [[string]] function as the testing of the code correctness will be done
programmatically.
• Note - You can only use standard python libraries. ex - json, random, etc](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fef664eea-5861-4a2d-82fb-02ec722ff663%2F6c29657a-0718-400a-80d0-b097feafb053%2F0sru9j_processed.png&w=3840&q=75)
![O 20 points.json
Add fuzzy phrasal search problem
12 days ago
D 30_points.json
Add fuzzy phrasal search problem
12 days ago
O 50 points,json
Add fuzzy phrasal search problem
12 days ago
O problem_statement.pdf
Add fuzzy phrasal search problem
12 days ago
sample.json
Add fuzzy phrasal search problem
12 days ago
solution.py
Add sample solution.py and update Readme
12 days ago
oo00 o o](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fef664eea-5861-4a2d-82fb-02ec722ff663%2F6c29657a-0718-400a-80d0-b097feafb053%2Fxoezscl_processed.png&w=3840&q=75)
![You have a large list of phrases PO. i.e -> ["i would have", "they love", i analyzed", "made
decision", .]
You will be given Queries[query_string]. i.e -> ["since this morning i have analyzed all the data
from the company and made my decision", "they love the idea"]
Your task is to fuzzy search all the phrases in the query string. For the above example, the
resultant search phrases are -> [["i have analyzed", "made my decision"], ["they love"]]
Note: A fuzzy search is that there can be at max extra one word in the phrase.
The query_strings will come one by one online.
Constraints ->
1 < length(P) < 1000000
1< length(query_string) < 100000
1 < length(Queries) < 1000
Example ->
Given ->
P = ["i would have", "they love", i analyzed", "made decision"]
Queries = [
"since this morming i have analyzed all the data from the company and made my decision",
"they love the idea",
Expected Output = [
["i have analyzed", “made my decision"],
["they love"]](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fef664eea-5861-4a2d-82fb-02ec722ff663%2F6c29657a-0718-400a-80d0-b097feafb053%2F8ata8lf_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
EDITABLE CODE
def phrasel_search(P,Queries):
x1=pd.DataFrame(Queries)
x2=pd.DataFrame(p)
m1=[]
m2=[]
p=[]
l1=x1['name'].tolist();
l2=x2['name'].tolist();
threshold=82
for i in l1:
m1.append(process.extract(i,l2,limit=2))
x1['matches']=m1
for j in x1['matches']:
for k in j:
if k[1]>=threshold;
p.append(k[0])
m2.append(",".join(p))
p=[]
return x1
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)