mirror of
https://github.com/Dushistov/sdcv.git
synced 2026-01-05 01:44:28 +00:00
something working
This commit is contained in:
27
tests/call_stardict_strcmp.cpp
Normal file
27
tests/call_stardict_strcmp.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
//g++ `pkg-config --cflags glib-2.0` call_stardict_strcmp.cpp `pkg-config --libs glib-2.0`
|
||||
#include <glib.h>
|
||||
#include <locale.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
static inline gint stardict_strcmp(const gchar *s1, const gchar *s2)
|
||||
{
|
||||
const gint a = g_ascii_strcasecmp(s1, s2);
|
||||
if (a == 0)
|
||||
return strcmp(s1, s2);
|
||||
else
|
||||
return a;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
std::cin.sync_with_stdio(false);
|
||||
std::string line1, line2;
|
||||
while (std::getline(std::cin, line1) &&
|
||||
std::getline(std::cin, line2)) {
|
||||
std::cout << stardict_strcmp(line1.c_str(), line2.c_str()) << "\n";
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
42
tests/generate_strings_pairs.py
Executable file
42
tests/generate_strings_pairs.py
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import random, sys
|
||||
|
||||
fname = "/home/evgeniy/projects/competitions/words/data/words.txt"
|
||||
|
||||
with open(fname, "r") as fin:
|
||||
words = sorted(set([word.strip() for word in fin.readlines()]))
|
||||
res = []
|
||||
for i in range(0, len(words)):
|
||||
max_idx = len(words) - 1
|
||||
idx1 = random.randint(0, max_idx)
|
||||
idx2 = random.randint(0, max_idx)
|
||||
res.append((words[idx1], words[idx2]))
|
||||
|
||||
letters = "abcdefghijklmnopqrstuvwxyzабвгдеёжзийклмнопрстуфкцчщьъэюя"
|
||||
letters += letters.upper()
|
||||
letters += " \t!@#$%^&*()[]"
|
||||
|
||||
def gen_word(req_word_len):
|
||||
max_idx = len(letters) - 1
|
||||
res = ""
|
||||
for i in range(0, req_word_len):
|
||||
res += letters[random.randint(0, max_idx)]
|
||||
return res
|
||||
|
||||
for i in range(0, 10000):
|
||||
l1 = random.randint(1, 100)
|
||||
l2 = random.randint(1, 100)
|
||||
res.append((gen_word(l1), gen_word(l2)))
|
||||
|
||||
for i in range(0, 10000):
|
||||
l1 = random.randint(1, 100)
|
||||
res.append((gen_word(l1), gen_word(l1)))
|
||||
|
||||
for item in res:
|
||||
print(item[0])
|
||||
print(item[1])
|
||||
|
||||
|
||||
|
||||
|
||||
1363372
tests/stardict_strcmp_test_data.txt
Normal file
1363372
tests/stardict_strcmp_test_data.txt
Normal file
File diff suppressed because it is too large
Load Diff
681686
tests/stardict_strcmp_test_data_cmp_exp.txt
Normal file
681686
tests/stardict_strcmp_test_data_cmp_exp.txt
Normal file
File diff suppressed because it is too large
Load Diff
10
tests/words_dic/gen_dic_from_words.py
Executable file
10
tests/words_dic/gen_dic_from_words.py
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
with open(sys.argv[1], "r") as f:
|
||||
with open(sys.argv[2], "w") as out:
|
||||
words = set([word.strip() for word in f.readlines()])
|
||||
for word in words:
|
||||
out.write(word + "\n")
|
||||
out.write(word + "\n")
|
||||
1671705
tests/words_dic/stardict-words-2.4.2/words.dict
Normal file
1671705
tests/words_dic/stardict-words-2.4.2/words.dict
Normal file
File diff suppressed because it is too large
Load Diff
BIN
tests/words_dic/stardict-words-2.4.2/words.idx
Normal file
BIN
tests/words_dic/stardict-words-2.4.2/words.idx
Normal file
Binary file not shown.
BIN
tests/words_dic/stardict-words-2.4.2/words.idx.oft
Normal file
BIN
tests/words_dic/stardict-words-2.4.2/words.idx.oft
Normal file
Binary file not shown.
7
tests/words_dic/stardict-words-2.4.2/words.ifo
Normal file
7
tests/words_dic/stardict-words-2.4.2/words.ifo
Normal file
@@ -0,0 +1,7 @@
|
||||
StarDict's dict ifo file
|
||||
version=2.4.2
|
||||
wordcount=1671704
|
||||
idxfilesize=30235592
|
||||
bookname=
|
||||
date=2016.06.18
|
||||
sametypesequence=x
|
||||
3343408
tests/words_dic/words.dummy
Normal file
3343408
tests/words_dic/words.dummy
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user