Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

structure attributes - compare/sort by float values

14 views
Skip to first unread message

Bohumil Šimčík

unread,
Jun 18, 2024, 8:45:02 AM6/18/24
to NoSketch Engine
Hi all,

I have structure attributes with float number values. Is it possible to compare/sort these attributes via operators >= <= ? For example my document contains structures:

<s mdd= "2.9">...</s>
<s mdd= "1.5">...</s>  
<s mdd= "1.25">...</s> 

and I want to search  e.g. <s mdd >= "1.75" /> but it seems that only value before '.' is considered.

Corpus documentation:

mentions the NUMERIC parameter for sorting but nothing about comparing float numbers.

Thank you.

Bohumil Šimčík




Miloš Jakubíček

unread,
Jun 18, 2024, 9:37:49 AM6/18/24
to Bohumil Šimčík, NoSketch Engine
Dear Bohumil,

Yes, that's correct, the comparison here uses strverscmp() to compare the values, but it makes sense that for attributes marked as NUMERIC one should compare as numbers.
Currently, setting NUMERIC has no effect on query evaluation. I will take note of that but cannot promise when this would get implemented.

Best
Milos


--
You received this message because you are subscribed to the Google Groups "NoSketch Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to noske+un...@sketchengine.co.uk.
To view this discussion on the web visit https://groups.google.com/a/sketchengine.co.uk/d/msgid/noske/aa71ec44-3b08-4c51-883c-2c5a7cfea641n%40sketchengine.co.uk.

Miloš Jakubíček

unread,
Jun 18, 2024, 4:05:38 PM6/18/24
to Bohumil Šimčík, NoSketch Engine
Just to add to this following a hint from one of my colleagues (though you likely found out yourself): if you want this to work these days, all the numbers need to have the same number of floating point digits, i.e. in your case "2.90", "1.50" and "1.25" would work fine.
(see "man strverscmp" for details)

Best
Milos

Bohumil Šimčík

unread,
Jun 19, 2024, 3:15:45 AM6/19/24
to NoSketch Engine, Miloš Jakubíček, NoSketch Engine, Bohumil Šimčík

Thank you Mr. Jakubíček for the clarification.
Reply all
Reply to author
Forward
0 new messages