intgr / topy Goto Github PK
View Code? Open in Web Editor NEWPython script to fix typos in text, based on the RegExTypoFix project from Wikipedia and AutoWikiBrowser
License: Other
Python script to fix typos in text, based on the RegExTypoFix project from Wikipedia and AutoWikiBrowser
License: Other
write encoding is not specified on "--apply" .
I guess f.write encoding should match to f.read :
if opts.apply: log.info("Writing %s", safe_name) with open(filename, 'w', encoding='utf-8') as f: f.write(text)
For example, with the structure:
project
| README.md
| somefile.txt
|___ first-dir
| file-to-check.txt
| other-typo-file.txt
|
|___ exclude-dir
| ...
If I want to search for typos in all the files in first-dir except for anything in exlude-dir, I would like to do something like
topy --exclude exclude-dir root-dir
Could this option be added to provide a little more flexibility with the tool? Thanks
I have installed topy and I keep getting the following error when I try to run "topy.exe c:\temp\typos.txt":
c:\PythonPortable\App\Scripts>topy.exe c:\temp\typos.txt
Traceback (most recent call last):
File "c:\PythonPortable\App\Scripts\topy-script.py", line 5, in <module>
from pkg_resources import load_entry_point
File "c:\PythonPortable\App\lib\site-packages\pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "c:\PythonPortable\App\lib\site-packages\pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "c:\PythonPortable\App\lib\site-packages\pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: beautifulsoup4
I tried on Linux too and got the same error.
This will make it easier to install and use for Python folks.
(topy) /t/x $ tree
.
└── �\230\203.md
0 directories, 1 file
(topy) /t/x $ topy -a .
/Users/alex_gaynor/.virtualenvs/topy/lib/python2.7/site-packages/bs4/__init__.py:166: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
To get rid of this warning, change this:
BeautifulSoup([your markup])
to this:
BeautifulSoup([your markup], "html.parser")
markup_type=markup_type))
Loaded 3619 rules (except 0 errors, 45 disabled)
Traceback (most recent call last):
File "/Users/alex_gaynor/.virtualenvs/topy/bin/topy", line 11, in <module>
sys.exit(main())
File "/Users/alex_gaynor/.virtualenvs/topy/lib/python2.7/site-packages/topy/topy.py", line 202, in main
for filename in flatten_files(paths):
File "/Users/alex_gaynor/.virtualenvs/topy/lib/python2.7/site-packages/topy/topy.py", line 158, in flatten_files
for filename in walk_dir_tree(path):
File "/Users/alex_gaynor/.virtualenvs/topy/lib/python2.7/site-packages/topy/topy.py", line 148, in walk_dir_tree
if not f.startswith("."):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
I have a very simple use case where topy
fails on a YAML file by trying to add case:
- foo/jordan
Topy would rename jordan
to Jordan
, which will break the code as this is a filename.
Few problems related to this:
There is not a single example of usage in the README. I created a file with some text with typos:
# test.txt
Hellp, my name is not rekevant.
Then I ran the command as specified but got nothing.
$ topy test.txt
Loaded 3729 rules (except 0 errors, 44 disabled)
Did it work but couldn't find any typos? Or am I doing something wrong and it didn't run properly?
Add a flag or an option to do something similar to -
cat f | typo -s > new_file
typo -s <string> > new_file
use case -
Parsing the ruleset tag soup file with BeautifulSoup4 can consume half a second at every startup; see issue #5.
Loading the regs everytime doesn't make sense.
Just keeping a list of known false positives for personal reference. Feel free to add comments here.
Topy replaces:
attribtue
-> attributue
- both are incorrect :)2014-11-01T12:00
-> 2014 and 2011-01T12:00
From then on it's just like any exception
-> From then on its just like any exception
This is somewhat related to #3, we can make the script run over entire directory or a specific file. Also the need for update.sh can be removed as it can be made just a function in the file
Add an option to run it case insensitive
Right now you have to do some bash-fu to run topy over every file, it'd be great if that was a builtin feature.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.