r/Python • u/Ani171202 • Feb 13 '20
I Made This Python project that answers high-school problems almost instantly. Made using Tesseract, Scrapy and Flask.
227
u/contrieng Feb 13 '20
How does it do that? Explain like I’m five please.
120
u/Ani171202 Feb 13 '20
So here's how it goes.
Frontend takes the picture and sends it to flask(The server module of python)
Flask sends it to OCR, which processes the image and extracts the text.
Scrapy uses to text to search for answers on the web and extract them out, which is then sent back to frontend.
3
2
u/Sevealin_ Feb 14 '20 edited Feb 14 '20
What sites are used to find the answers? Is it a big list? Or just some of the bigger sites q/a sites? Looking at github I think I see it makes a google search, but I can't find how it picks the answer.
Edit: I think I found it! Mostly askiitians I think?
somecralwer.py 117 google_search = "https://www.google.com/search?q=" + \ 118 user_query + "+askiitians+revision+notes"4
u/Ani171202 Feb 14 '20
Right now since we're indian, it works with a few indian sites and stackoverflow. But we have made it scalable so its not hard to expand it to a big range of websites.
21
u/postyoa28 Feb 13 '20
Ah, so you don't have a repository of equations - it's a repository of questions with answers. That's a pretty clean way to do that!
Also, thanks for the high level rundown. Really helpful
2
u/gottsc04 Feb 14 '20
Even cooler that it's not a set repository! The repo is the entire web. I'd imagine more solutions are added every week.
An extra step could be translating that text into other common ways to ask - people ask on Quora for example in different ways to shorten the Q. Or even different numbers but maybe same process.
469
u/hhjjiiyy Feb 13 '20
It reads the text and then inserts it into a search engine for textbook answers and displays a result if found
37
296
u/contrieng Feb 13 '20
Oh cool. But I though it actually learns what the question is asking and solves it! Great stuff
134
u/SeanBrax Feb 13 '20
Yeah I initially thought the same. Now that would be so awesome. Not that this isn’t.
74
39
1
u/KoalaKommander Feb 13 '20
If that's what you're looking for there's an app called owlhat that does that--actually interprets the words and figures out the problems. Not perfect but works most of the time
36
u/itghisi Feb 13 '20
Oh god, thanks... I saw the details of the answer and just though "WTF we jumped 10 years in the future on IA/ML and I missed"
Awesome tool nonetheless... congratz
1
→ More replies (1)1
44
u/Fernando3161 Feb 13 '20
It is "just" a text recognizer with a search engine. (I would be actually impressed if it would actually solve a problem)
54
u/Ani171202 Feb 13 '20
true, wolfram has already mastered it though.
54
u/RomanRiesen Feb 13 '20 edited Feb 13 '20
Everytime I use wolfram alpha for text-based inputs I am in awe.
Either their codebase has more branching than a chess-game tree or there's some mad NLP going on.
20
2
15
u/dermotmcg Feb 13 '20
Exactly. Don't reinvent the wheel. Awesome project
25
u/Ani171202 Feb 13 '20
also not like i can, we're just in high school doing stuff in spare time...... this idea is great but it requires a lot of thought and effort
6
u/punos_de_piedra Feb 13 '20
Very impressed to see such talent so early on. Bright futures ahead for you all.
148
31
u/DluX_Summer Feb 13 '20
Really cool stuff. Now write "solve climate change" down and see what it comes up with.
5
0
42
u/cap10nem0 Feb 13 '20
H.C.Verma made easy. Have an upvote from fellow engineer.
30
4
u/mysterio26 Feb 13 '20
Can you share the GitHub link?
16
u/Ani171202 Feb 13 '20
i already did. but here u go https://github.com/Nps-Cisco-2019/Backend-Fullstack
1
4
3
3
u/crazykid080 Feb 13 '20
How did you get tesseract to function so well? Ive been working on some OCR but the recognition is shit
1
u/Ani171202 Feb 14 '20
Dont worry, our OCR script is working nowhere close to well xD. It works well only when the lighting, clarity and other parameters line up perfectly.
1
u/crazykid080 Feb 14 '20
Lol, mine is a screenshot of the computer, and yet it still gets shit miserably wrong
1
7
Feb 13 '20
Can it do geometry ?
11
u/Ani171202 Feb 13 '20
Good question, but not yet.
Right now all it does is take the text surrounding the figures in geometry problems and try finding a solution from that.
2
4
u/Censoredsmile Feb 13 '20
Link?
12
u/Ani171202 Feb 13 '20
We're having a bunch of bugs(mainly cropping images) at the moment(contribution is welcome) but here it is
https://github.com/NPS-Cisco-2019/Backend-Fullstack
Project is live at https://npsinrcisco.live
3
u/Extraltodeus Feb 13 '20
4
u/Ani171202 Feb 13 '20
i mean you can try haha
but seriously, just click CTRL+SHIFT+I on chrome/CTRL+SHIFT+M on firefox
2
2
u/maythe15 Feb 13 '20
Can u upload it
1
u/Ani171202 Feb 13 '20
Its already online but has a lot of minor bugs. You can check out the link in one of the other comments.
1
1
2
2
Feb 13 '20
any link to try?
3
u/Ani171202 Feb 13 '20
Yes but there are bugs with cropping. In case cropping doesn't work you can try to manually type in the question
1
2
u/Xirious Feb 13 '20
It didn't get any of the units correct. How can it get the answer correct?
You could fill in the units but this isn't a very convincing display of it's capabilities.
1
u/Ani171202 Feb 13 '20
We just scrape the answer from different websites, we don't generate it ourselves. So there is always room for error.
2
Feb 13 '20
Cool man. So you select a portion of the screen, run OCR and perform a search on a few sites, then parse the results for each site. How do you discern what answer to give when you have multiple answers?
2
u/Ani171202 Feb 13 '20
as of now, all we do is rank it on our personal trust worthiness of the website.
planning on improving the site ranking "algorithm" tho
1
Feb 13 '20
Since you're already parsing the sites can you just rank the posters usernames? So when two solutions are found it displays the highest scoring poster? I see you import re but imagine comparing one answer to another would be a pain. Unless you take what's after the last "=" and compare just the number portion some digits left and right of the ".".
Some people using books that are all solved online might benefit from that specific database. Probably easier to handle since there will only be one format. Also would be on local storage so faster and no internet needed.
Good luck!
2
u/Ani171202 Feb 13 '20
Could you elaborate do you mean by rank poster's usernames?
as of now, if one answer has more upvotes than the other in any website, it appears before the other ones and hence gets scraped off first.
Thanks for the suggestions!
1
Feb 13 '20
I just poked around for a minute on starthaks and have never heard of "doubtnut.com", "askiitians.com" or "stackexchange.com" so I don't know how they work, but some of those sites keep track of the number of answered questions, or if they only give the solvers username you could build your own database. You can infer from which answers the users of your app choose that it is "correct" and award a point to that solvers credential. With enough users over time you build value by curating this list of Internet solvers.
I like the layout of your app. Very slick.
E: I heard of stack exchange but haven't used it
3
u/Ani171202 Feb 13 '20
We're students from India, so except stackexchange(which is the best of the lot), the rest are local websites that have a large resource of answers from indian exams.
While yeah we can build our own database, we need a lot of computation/storage/searching algorithm for finding answers. Also there are law concers for intellectual infringement.
I second your other idea though. Will probably add that feature soon. Thanks :)
2
2
u/Toastie101 Feb 13 '20
Okay please excuse my extreme dumbassery but how would you use this? I’m still fairly new to the community and I’d like to know how to upload this code to my iPhone/Android Device. Or is it computer only? And then where do I run it from.
1
u/Ani171202 Feb 13 '20
just click the link on a mobile device. Also we are still working on tis so bugs are there.
2
1
2
u/guy_from_the_intnet Feb 13 '20
Damnit. I just came from my exam having this kind of question. Why does no one tell me these things exist?
2
2
u/ThreeWhistle Feb 13 '20
How does the actual problem solving part work? Does it look up the problem text and then apply some sort of filter to figure out what's relevant? This is awesome.
1
u/Ani171202 Feb 14 '20
Sort the comments by best, i have put a detailed explanation. If you want to know more, you can DM.
2
u/lroman Feb 13 '20
Great work guys. I checked your backend code and see you are writing queries by hand. Since you are using Flask try using Sqlalchemy it will make your life easier😎
1
1
2
u/Xx-AliA-xX Feb 14 '20
Ah, a fellow Indian 11th grade pass this year. Amirite?
2
u/Ani171202 Feb 14 '20
Bingo
2
u/Xx-AliA-xX Feb 14 '20
Happy cake day. Which school are you from btw, cuz my school doesnt teach shit in cs. All i know is how to make a for loop to create a user defined list
2
u/Ani171202 Feb 14 '20
National Public School in BLR. Ha our school doesn't teach anything more advanced than yours, they support us in what we're doing though. You're from?
2
u/Muhznit Feb 14 '20
What happens when this becomes so ubiquitous in high schools that it becomes a problem itself?
1
u/Ani171202 Feb 14 '20
Big brain.
Seriously though, theres a long time for that to happen(and a high probability that it wont).
2
u/Abraham_Wilson Feb 14 '20
Hey, this is really cool, like some next level stuff. If you don't mind, could you explain how it works under the hood, and how did you make the UI
1
2
2
2
u/divided7 Jul 10 '20
how did you scrap the exact answer from different wbesites? becuse the selectors that u need to scrap by on different websites are different
1
3
14
u/itsjakerobb Feb 13 '20
“High-school problems”
Bullying
Decline in public funding
School shootings
Underpaid teachers
Ohhh... you meant “high school math problems” 😜
2
u/DeutscheAutoteknik Feb 14 '20
Just so we’re clear: School shootings isn’t a high school problem...
2
u/itsjakerobb Feb 14 '20
Well, not exclusively, but high schools have definitely had that problem. You’ve perhaps heard of Columbine High School?
1
u/DeutscheAutoteknik Feb 14 '20
I have. Mass school shootings aren’t a pervasive issue.
The media dramatizes the hell out of it because it scares people and drives up media views.You’re way more likely to be killed driving to school than by a shooter at school.
3
u/itsjakerobb Feb 14 '20
Car accidents are also a problem, but that’s not a reason to consider school shootings a non-issue.
Pervasive or not, school shootings have led to children, as young as five years old, doing preparedness drills where they have to hide and stay quiet in case a shooter ever comes to their school. Which is reasonable of course, because a shooting could happen at any school at any time. That in turn has led to more than a handful of cases of PTSD in students who have never experienced an actual shooting. Young children.
The media dramatizes the hell out of it? Are you trying to say that even a single student killed by a gun in a school isn’t an absolute tragedy? It’s just the media that makes it so sad?
→ More replies (2)1
8
2
u/Solucioneador Feb 13 '20
Does it work in more languages?
2
4
4
u/the15thbruce Feb 13 '20
Is this on GitHub. Would be useful, it's quite a hassle to always type out those questions into Google lol
1
u/ItsNateBossBaby Feb 13 '20
I want to start learning code but how?
1
u/Ani171202 Feb 13 '20
I would suggest learning by doing. Find your interest and work on a bunch of fun projects related to your topic of choice. Enjoy
1
u/Paraxic Feb 14 '20
Tons of resources out there, Python's probably the best place for a beginner to start.
YouTube The languages website in this case Python Tutorial
Stack Overflow Udemy
Etc you get the point.
1
u/jkjarvis Feb 13 '20
Omg !!!!! , HC VERMA !!!! I'm also learning machine learning, this seems a very great inspiration now
1
1
u/69shaolin69 Feb 13 '20
How do you get answers after using ocr?
1
u/Ani171202 Feb 13 '20
we use requests to get google search query with all the links and process it furthmore
1
1
1
1
5
u/kkhunte Feb 13 '20
Do time travel and go back where I was preparing for Engineering entrance exams. Pls.
2
2
2
2
2
2
2
2
2
u/dylancaponi Feb 13 '20
What image pre-processing are you doing before sending to Tesseract for OCR?
2
2
2
u/aldo712 Feb 14 '20
Did you strategically wait for your cake day to post this?
Very cool project, btw.
2
2
Feb 13 '20
Imagine a program which would actually be able to understand the question and solve it by itself.
1
1
1
1
1
1
u/ThreeWhistle Feb 13 '20
How does the actual problem solving part work? Does it look up the problem text and then apply some sort of filter to figure out what's relevant? This is awesome.
1
u/ThreeWhistle Feb 13 '20
How does the actual problem solving part work? Does it look up the problem text and then apply some sort of filter to figure out what's relevant? This is awesome.
1
u/metaperl Feb 13 '20
Do you have any suggestions for how to detect which 2 images are similar out of 5, for the sample images given here: https://github.com/metaperl/easyclicks4me/tree/master/img
1
u/AnArousedCatfish Feb 13 '20
!remindme 12 hours
1
u/RemindMeBot Feb 13 '20
There is a 25.0 minute delay fetching comments.
I will be messaging you in 11 hours on 2020-02-14 06:48:49 UTC to remind you of this link
CLICK THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
Info Custom Your Reminders Feedback
1
1
1
1
1
1
u/555rrrsss Feb 14 '20
1
u/VredditDownloader Feb 14 '20
beep. boop. I'm a bot that provides downloadable links for v.redd.it videos!
I also work with links sent by PM
Info | Support me ❤ | Github
1
u/Cannedbred Feb 28 '20
Care to show the code behind it as I want to see if I can do some thing with it, and I’m making something similar but for other subjects
1
1
1
1
1
u/RumiOcean Feb 13 '20
Awesome ... but now kids will stop thinking ...
My advice to improve, is before giving the answer the user have to solve a simpler question of same type to understand the concept... just my 1 cent..
1
1
0
Feb 13 '20
[deleted]
41
u/Ani171202 Feb 13 '20
Whoops you guessed our other side project we were working on, but thats for another day xD
24
4
7
u/BlueWizard3 Newbie Feb 13 '20
“Alright class now I’m going to need you to put away all phones, smart watches, and glasses.”
507
u/Ani171202 Feb 13 '20 edited Feb 13 '20
This was a group project with a bunch of friends including u/jef-_- u/Wikileaks01 u/icosahedralcello
they deserve as much or even more credit than me.