-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmlabgen-module-check
More file actions
executable file
·30 lines (24 loc) · 1016 Bytes
/
Copy pathmlabgen-module-check
File metadata and controls
executable file
·30 lines (24 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /usr/bin/python3
import mlabgen
from sys import argv
from enchant.checker import SpellChecker
from enchant.tokenize import EmailFilter, URLFilter, WikiWordFilter
if ("-h" in argv) or (len(argv) < 2):
print("usage: mlabgen-module-check [-h] [MARKDOWN] [PRJINFO] [SCH]")
exit()
chkr = SpellChecker("en_GB", filters=[EmailFilter, URLFilter, WikiWordFilter])
for word in mlabgen.wordlist:
chkr.add(word)
for path in argv[1:3]:
print(path)
lines = open(path, "r").readlines()
for line in lines:
chkr.set_text(line)
for err in chkr:
print("ERR {},{} {} maybe {}".format(lines.index(line), line.index(err.word), err.word, chkr.suggest(err.word)[:10]))
print(argv[3])
descr = mlabgen.dict_str_rm("\n", mlabgen.descr2dict(mlabgen.sch2descr(open(argv[3], "r").read())))
for key in descr.keys():
chkr.set_text(descr[key])
for err in chkr:
print("ERR {},{} {} maybe {}".format(key, descr[key].index(err.word), err.word, chkr.suggest(err.word)[:10]))