[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210611071241.16728-2-thunder.leizhen@huawei.com>
Date: Fri, 11 Jun 2021 15:12:39 +0800
From: Zhen Lei <thunder.leizhen@...wei.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Nicolas Dichtel <nicolas.dichtel@...nd.com>,
Joe Perches <joe@...ches.com>, Jason Baron <jbaron@...mai.com>,
Stefani Seibold <stefani@...bold.net>,
Jacob Keller <jacob.e.keller@...el.com>,
Thomas Graf <tgraf@...g.ch>,
Herbert Xu <herbert@...dor.apana.org.au>,
Jens Axboe <axboe@...nel.dk>, Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
"Andy Shevchenko" <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
linux-kernel <linux-kernel@...r.kernel.org>
CC: Zhen Lei <thunder.leizhen@...wei.com>
Subject: [PATCH 1/3] scripts: add spelling_sanitizer.sh script
The file scripts/spelling.txt recorded a large number of
"mistake||correction" pairs. These entries are currently maintained in
order, but the results are not strict. In addition, when someone wants to
add some new pairs, he either sort them manually or write a script, which
is clearly a waste of labor. So add this script. It removes the duplicates
first, then sort by correctly spelled words. Sorting based on misspelled
words is not chose because it is uncontrollable.
Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
---
scripts/spelling_sanitizer.sh | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100755 scripts/spelling_sanitizer.sh
diff --git a/scripts/spelling_sanitizer.sh b/scripts/spelling_sanitizer.sh
new file mode 100755
index 000000000000..4936c4191653
--- /dev/null
+++ b/scripts/spelling_sanitizer.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+src=spelling.txt
+tmp=spelling_mistake_correction_pairs.txt
+
+cd `dirname $0`
+
+# Convert the format of 'codespell' to the current
+sed -r -i 's/ ==> /||/' $src
+
+# Move the spelling "mistake||correction" pairs into file $tmp
+# There are currently 9 lines of comments in $src, so the text starts at line 10
+sed -n '10,$p' $src > $tmp
+sed -i '10,$d' $src
+
+# Remove duplicates first, then sort by correctly spelled words
+sort -u $tmp -o $tmp
+sort -t '|' -k 3 $tmp -o $tmp
+
+# Append sorted results to comments
+cat $tmp >> $src
+
+# Delete the temporary file
+rm -f $tmp
+
+cd - > /dev/null
--
2.25.1
Powered by blists - more mailing lists