Sphinx Search: Missing accents/diacritics in results - character-encoding

I use Sphinx search version 2.2.11.
Sphinx returns data without accents/diacritics, eg. "cerny" instead of "černý".
It will return correct items, even if the query itself has accents/diacritics, only the
encoding of the results is wrong.
I know I had this problem before, but I can't remember how I solved, it was 3 years ago,
I think it was on version 2.1.something then.
Maybe its somehow badly indexed?
Relevant part of my config:
searchd {
...
collation_server = utf8_general_ci
}
index xxx {
source = xxxSrc
path = /var/lib/sphinxsearch/xxx
charset_table = 0..9, A..Z->a..z, _, a..z, U+0e1->a, U+0c1->a, U+10d->c, U+10c->c,
U+10f->d, U+10e->d, U+0e9->e, U+0c9->e, U+11b->e, U+11a->e, U+0ed->i, U+0cd->i, U+148->n,
U+147->n, U+0f3->o, U+0d3->o, U+159->r, U+158->r, U+161->s, U+160->s, U+165->t, U+164->t,
U+0fa->u, U+0da->u, U+16f->u, U+16e->u, U+0fd->y, U+0dd->y, U+17e->z, U+17d->z,
index_exact_words = 1
docinfo = extern
morphology = stem_cz
min_stemming_len = 5
min_infix_len = 3
}
Thx for any help.

Ok, not actaually sphinx issue, but in ODBC/Oracle
this fixed it
export NLS_LANG="CZECH_CZECH REPUBLIC.AL32UTF8"

Related

How to get an Array of Meshes

myMesh = {}
myMesh[0].x = 30
Nope... doesn't work.
myMesh = Mesh.new{}
myMesh[0].x = 30
Nope... no go.
An array of meshes should be possible, but I don't know how. Can someone help? Thanks
Edit:
Thanks for your responses. Pardon me for this stupid mistake. I just realized, "What nonsense are you doing J?" I really wanted an array of vertices of the mesh, so that I can use loops to manipulate them. Sorry about that... although it didn't hurt to learn how to get an array of meshes.
So I figured it out, because I was sure I did this before, when I used gml.
ptx = {}; pty = {}; ptz = {}
ptx[1] = myMesh.x; pty[1] = myMesh.y; ptz[1] = myMesh.z;
Thanks for the help though. I also learned that lua doesn't use index 0
Edit: Wait. That doesn't work either does it?
Well for now this gives no error, so I'll see if it does what I want.
pMesh = {}
for m=1, 6 do
pMesh[m] = Mesh.new()
end
pMesh[1].x = 0; pMesh[1].y = 0; pMesh[1].z = 0
Thanks guys. If you have any other suggestions, I'm all ears.
myMesh = {}
myMesh[0].x = 30
Will cause an error for indexing a nil value.
myMesh = {} creates an empty Lua table.
doing myMesh[0].x is not allowed because there is no myMesh[0].
First you have to insert a table element at index 0.
myMesh = {}
myMesh[0] = Mesh.new(true)
myMesh[0].x = 30
myMesh is a stupid name for an array of meshes as it suggests it's just a single mesh.
Also in Lua we usually start with index 1 which will makes things a bit easier using Lua's standard table tools.
I'm not sure if
mesh = Mesh.new()
mesh.x = 30
is actually ok. Why would a mesh have an x coordinate? This is not listed in Mesh's properties in the manual.
Usually you would create a Mesh with multiple points And if you want an array of multiple meshes you would simply put those meshes into a table unless there is a particular user data type for this.
Try this:
myMesh = {}
myMesh[0]= Mesh.new{}
myMesh[0].x = 30
you need to initialize as a table and columns and rows:
myMesh = {}
myMesh[0] = {}
myMesh[0].x=30
or
myMesh = { [0]={} }
myMesh[0].x=30

Create a simple Lua .txt Database with write() and read()

im trying to create a simple 2 functions text-file "database" with LUA. All i need is 2 Functions.
my db should look like that:
varName;varValue
JohnAge;18
JohnCity;Munich
LarissaAge;21
LarissaCity;Berlin
In fact im not stuck to any format! I just don't have a way to save data longterm in my lua enviroment and i need to find a workaround. So if you already have a
similiar solution at hand, please feel free to throw it at me. Thank you very much
Function WriteToDB(varName, varValue)
If database.text contains a line that starts with varName
replace whatever comes after seperator ";" with varValue (but dont go into the next line)
Function ReadFromDB(varName)
If database.text contains a line that starts with varName
take whatever comes after the seperator ";" and return that (but dont go into the next line)
elseif not found print("error")
Save the data as Lua code that builds a table:
return {
JohnAge = 18,
JohnCity = "Munich",
LarissaAge = 21,
LarissaCity = "Berlin",
}
Or better yet
return {
["John"] = {Age = 18, City = "Munich"},
["Larissa"] = {Age = 21, City = "Berlin"},
}
Load the data with
db = dofile"db.lua"
Access the data with
print(db["Larissa"].Age)
or
print(db[name].Age)

How to create { x = y | y = z | z = 0 } block dynamically from hash?

Although the context is likely irrelevant, I'm using the Chewy gem to filter Elasticsearch results using this code:
scope = scope.filter {
(send('facet_properties').send(property_ids[0], :or) == val.map(&:to_i)) |
(send('facet_properties').send(property_ids[1], :or) == val.map(&:to_i))
}
I'm looking for a way to loop through each element in property_ids rather than calling property_ids[0], property_ids[1], etc., separated by an or individually. In actual use property_ids will not be a fixed length.
Not sure exactly what your structure looks like or exactly what you are trying to achieve but have you tried something like this?
vals = val.map(&:to_i)
prop_hash = Hash[property_ids.map{|prop| [prop,vals]}]
# alternately prop_hash = property_ids.each_with_object({}){|prop,obj| obj[prop] = vals}
scope.filter(facet_properties: {prop_hash}).filter_mode(:or)
Since chewy has a #filter_mode method to set the join type for where conditions it seems like this should work for you.

Formatting lua table for a parse $in query that is also a table

I am using corona (lua) with parse.com and I have hit a problem constructing an $in query using values from another table / array.
My code is a little like this:
local usersToFetch = {}
table.insert( usersToFetch, "KnVvDiV2Cj")
table.insert( usersToFetch, "Paf6LDmykp")
and the working query I want to perform is the following lua table (which will get encoded before heading to parse). As I said, this works when I am hard coding the values as shown
local queryTable = {
["where"] = {
["objectId"] = { ["$in"] = {"KnVvDiV2Cj","Paf6LDmykp" }}
},
["limit"] = 1000
}
My problem is how do I incorporate my 'usersToFetch' table in the above table so that it will work the same as hard coding the values?
I swore I tried that but clearly I did not.. I think that I placed it inside the braces whereas they are not needed which is where I went wrong.
Thanks, hjpotte92 - what you put worked fine but this is my final solution in a single declaration:
Where I was going wrong before was because I had too many braces ["objectId"] = { ["$in"] = { usersToFetch } }
local queryTable = {
["where"] = {
["objectId"] = { ["$in"] = usersToFetch}
},
["limit"] = 1000
}

How can I efficiently parse formatted text from a file in Qt?

I would like to get efficient way of working with Strings in Qt. Since I am new in Qt environment.
So What I am doing:
I am loading a text file, and getting each lines.
Each line has text with comma separated.
Line schema:
Fname{limit:list:option}, Lname{limit:list:option} ... etc.
Example:
John{0:0:0}, Lname{0:0:0}
Notes:limit can be 1 or 0 and the same as others.
So I would like to get Fname and get limit,list,option values from {}.
I am thinking to write a code with find { and takes what is inside, by reading symbol by symbol.
What is the efficient way to parse that?
Thanks.
The following snippet will give you Fname and limit,list,option from the first set of brackets. It could be easily updated if you are interested in the Lname set as well.
QFile file("input.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
qDebug() << "Failed to open input file.";
QRegularExpression re("(?<name>\\w+)\\{(?<limit>[0-1]):(?<list>[0-1]):(?<option>[0-1])}");
while (!file.atEnd())
{
QString line = file.readLine();
QRegularExpressionMatch match = re.match(line);
QString name = match.captured("name");
int limit = match.captured("limit").toInt();
int list = match.captured("list").toInt();
int option = match.captured("option").toInt();
// Do something with values ...
}

Resources