Created
March 17, 2020 14:33
-
-
Save halfak/baa839823ecc0fa7d56bbc6d13975857 to your computer and use it in GitHub Desktop.
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
| import time | |
| import mwapi | |
| import textstat | |
| session = mwapi.Session("https://en.wikipedia.org", user_agent="ahalfaker@wikimedia.org") | |
| doc = session.get(action='query', prop='revisions', rvprop='content', titles='Alan Turing', rvslots="main", formatversion=2) | |
| text = doc['query']['pages'][0]['revisions'][0]['slots']['main']['content'] | |
| start = time.time() | |
| print("flesch_reading_ease", textstat.flesch_reading_ease(text)) | |
| print("Processing took {0} seconds".format(time.time() - start)) | |
| start = time.time() | |
| print("flesch_reading_ease", textstat.flesch_reading_ease(text)) | |
| print("Processing took {0} seconds".format(time.time() - start)) |
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
| $ python demo_flesch_reading_ease.py | |
| flesch_reading_ease -31.94 | |
| Processing took 0.5710229873657227 seconds | |
| flesch_reading_ease -31.94 | |
| Processing took 1.3828277587890625e-05 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment