Removed bugs.
This commit is contained in:
parent
e045f96e4d
commit
927d52f588
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,7 +1,10 @@
|
|||||||
*.db*
|
*.db*
|
||||||
|
*.png
|
||||||
|
.*
|
||||||
.venv
|
.venv
|
||||||
|
contrib
|
||||||
|
logs_*
|
||||||
|
*.txt
|
||||||
# ---> C++
|
# ---> C++
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
*.d
|
*.d
|
||||||
|
3
Makefile
3
Makefile
@ -10,6 +10,7 @@ PYTHON="./.venv/bin/python"
|
|||||||
|
|
||||||
ensure_env:
|
ensure_env:
|
||||||
-@python3 -m venv .venv
|
-@python3 -m venv .venv
|
||||||
|
$(PYTHON) -m pip install dataset
|
||||||
|
|
||||||
merge:
|
merge:
|
||||||
$(PYTHON) merge.py
|
$(PYTHON) merge.py
|
||||||
@ -32,3 +33,5 @@ index:
|
|||||||
popular:
|
popular:
|
||||||
$(PYTHON) tags.py --popular
|
$(PYTHON) tags.py --popular
|
||||||
|
|
||||||
|
process:
|
||||||
|
PYTHONPATH=/home/retoor/bin $(PYTHON) process.py
|
||||||
|
9
merge.py
9
merge.py
@ -12,6 +12,15 @@ for file in pathlib.Path("logs_plain").glob("*.txt"):
|
|||||||
|
|
||||||
lines_per_hour = return_count // hour_count
|
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"):
|
for file in pathlib.Path("logs_summaries").glob("*.txt"):
|
||||||
with open(file, "r") as f:
|
with open(file, "r") as f:
|
||||||
all_content.append(f.read())
|
all_content.append(f.read())
|
||||||
|
12
sormc.h
12
sormc.h
@ -8663,14 +8663,22 @@ unsigned int sormcq(char *sql, char *out) {
|
|||||||
// converts %s %i parameters to ?
|
// converts %s %i parameters to ?
|
||||||
|
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
|
char prev = 0;
|
||||||
while (*sql) {
|
while (*sql) {
|
||||||
if (*sql != '%' && *sql != '?')
|
if ((*sql != '%') && (*sql != '?'))
|
||||||
*out = *sql;
|
*out = *sql;
|
||||||
else {
|
else {
|
||||||
count++;
|
|
||||||
sql++;
|
sql++;
|
||||||
|
if(*sql == '%'){
|
||||||
|
*out = '%';
|
||||||
|
//sql++;
|
||||||
|
}else{
|
||||||
|
count++;
|
||||||
*out = '?';
|
*out = '?';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
prev = *sql;
|
||||||
out++;
|
out++;
|
||||||
sql++;
|
sql++;
|
||||||
}
|
}
|
||||||
|
15
tags.py
15
tags.py
@ -134,7 +134,8 @@ class WordDb:
|
|||||||
|
|
||||||
def most_popular(self, count):
|
def most_popular(self, count):
|
||||||
self.cursor.execute("SELECT word, count FROM words ORDER BY count DESC LIMIT ?", (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):
|
def __del__(self):
|
||||||
self.commit()
|
self.commit()
|
||||||
@ -158,9 +159,15 @@ if args.find:
|
|||||||
print(db.get(args.find))
|
print(db.get(args.find))
|
||||||
|
|
||||||
if args.popular:
|
if args.popular:
|
||||||
for item in db.most_popular(300):
|
total_count = db.total_count()
|
||||||
print(item)
|
all_ = list(db.most_popular(300))
|
||||||
print(db.total_count())
|
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:
|
if args.index:
|
||||||
db.reset()
|
db.reset()
|
||||||
|
Loading…
Reference in New Issue
Block a user