Removed bugs.

This commit is contained in:
retoor 2025-03-17 04:58:10 +01:00
parent e045f96e4d
commit 927d52f588
5 changed files with 38 additions and 8 deletions

7
.gitignore vendored
View File

@ -1,7 +1,10 @@
*.db*
*.png
.*
.venv
contrib
logs_*
*.txt
# ---> C++
# Prerequisites
*.d

View File

@ -10,6 +10,7 @@ PYTHON="./.venv/bin/python"
ensure_env:
-@python3 -m venv .venv
$(PYTHON) -m pip install dataset
merge:
$(PYTHON) merge.py
@ -32,3 +33,5 @@ index:
popular:
$(PYTHON) tags.py --popular
process:
PYTHONPATH=/home/retoor/bin $(PYTHON) process.py

View File

@ -12,6 +12,15 @@ for file in pathlib.Path("logs_plain").glob("*.txt"):
lines_per_hour = return_count // hour_count
for file in pathlib.Path("logs_plain").glob("*.txt"):
with open(file, "r") as f:
all_content.append(f.read())
with open("logs_plain/merged.txt", "w") as f:
f.write("\n\n".join(all_content))
for file in pathlib.Path("logs_summaries").glob("*.txt"):
with open(file, "r") as f:
all_content.append(f.read())

12
sormc.h
View File

@ -8663,14 +8663,22 @@ unsigned int sormcq(char *sql, char *out) {
// converts %s %i parameters to ?
unsigned int count = 0;
char prev = 0;
while (*sql) {
if (*sql != '%' && *sql != '?')
if ((*sql != '%') && (*sql != '?'))
*out = *sql;
else {
count++;
sql++;
if(*sql == '%'){
*out = '%';
//sql++;
}else{
count++;
*out = '?';
}
}
prev = *sql;
out++;
sql++;
}

15
tags.py
View File

@ -134,7 +134,8 @@ class WordDb:
def most_popular(self, count):
self.cursor.execute("SELECT word, count FROM words ORDER BY count DESC LIMIT ?", (count,))
return list(self.cursor.fetchall())
for (x,record) in enumerate(self.cursor.fetchall()):
yield x,record
def __del__(self):
self.commit()
@ -158,9 +159,15 @@ if args.find:
print(db.get(args.find))
if args.popular:
for item in db.most_popular(300):
print(item)
print(db.total_count())
total_count = db.total_count()
all_ = list(db.most_popular(300))
longest_word = max([len(record[0]) for (x, record) in all_])
longest_number = 5
for (x, record) in all_:
percentage = record[1] / total_count
print(str("#" + str(x)).ljust(longest_number), str(record[0]).ljust(longest_word), str("is pressed " + str(record[1]) + " times").rjust(20), str("("+str(round(percentage * 100, 2)) + "% of total input)").ljust(20))
#print(f"#{x}\t`{record[0]}` is {record[1]} times pressed.")
print("Unique words:", db.total_count())
if args.index:
db.reset()