sphinx search any variations from the initial search words - sphinx

How possible in sphinxsearch for example Lorem ipsum dolor
find first
Lorem ipsum dolor
then
Lorem ipsum
ipsum dolor
Lorem dolor
then
Lorem
ipsum
ipsum
Any variations from the initial search words

Use extended query and write it as
"Lorem ipsum dolor"/1
which basically says only one of the words is required (quorum syntax).
Then play with using different ranking modes.
http://sphinxsearch.com/docs/current.html#builtin-rankers
WORDCOUNT would be pretty good for this, but maybe a bit primitive.
Try MATCHANY ranker - its the ranker from the old match any mode, but is still pretty good for these types of queries.

Related

Batch turn plain text into endnotes/footnotes

In a document containing more than 2000 "manual" endnotes (= which are not formatted as such), I'm trying to batch turn plain text paragraphs into proper endnotes or, to be more precise (since the references already exist, thus empty endnotes as well) to sort of "paste" all manual endnotes' text into existing endnotes, based on numbering.
Here is the document pattern :
Lorem ipsum dolor sit amet1 (ref), consectetur adipiscing
elit2 (ref).
[1] Text endnote 1
[2] Text endnote 2
I've tried to play around with Alternate Find & Replace and Regular Expressions, but I could find a way. Couldn't find anything on forums either.

tmLanguage support for strange multiline string literal

I've got an extension for the LPC programming language for Visual Studio Code. I'm using tmLanguage grammars. However, I haven't figure out a way to support the language's multiline string literals.
regex would be: #{1,2}(\w*)\n((.|\n)*?)\n(###\s*)?(\1)\b
example syntax to match:
set_help_str(#HELP
Lorem ipsum dolor sit amet, "Consectetur adipiscing elit," sed do
eiusmod tempor incididunt ut's labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris.
HELP);
This is basically the last bit of syntax I need to get right and I really haven't figured out a way to handle it.
Any help would be greatly appreciated.
This can't really be done with tmLanguage since their regex only reads a single line at a time and wouldn't really support this.
I'll have to write a language server to handle this.

How to dynamically add items in create pdf in flutter?

I'm trying to generate dynamic pdf, using pdf dependency in flutter. I want the pdf to be generated based on text content, current it is limiting to only one page and dynamically not creating a second page or dynamically increasing the size of pages. The following is my code.
var data = await rootBundle.load("fonts/OpenSans-Regular.ttf");
final ttf = pw.Font.ttf(data);
pdf.addPage(
pw.Page(
theme: pw.ThemeData.withFont(
base: ttf,
),
// pageFormat: PdfPageFormat.undefined,
build: (pw.Context context) {
return pw.Paragraph(
text:
"What is Lorem Ipsum?\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\n\nWhy do we use it?\nIt is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).\n\nWhere does it come from?\nContrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of 'de Finibus Bonorum et Malorum' (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum,'Lorem ipsum dolor sit amet..', comes from a line in section 1.10.32.\nThe standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.;\n\nWhere can I get some?\nThere are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc."); // Center
},
),
);
final appDocDir = await getApplicationDocumentsDirectory();
final appDocPath = appDocDir.path;
final file = File(appDocPath + '/' + 'dummy.pdf');
print('Save as file ${file.path} ...');
await file.writeAsBytes(await pdf.save());
Please look at the following screenshot. Please help me ...
Try adding Multipage like this,
pdf.addPage(
pw.MultiPage(
...)
)
instead of
pdf.addPage(
pw.Page(
...)
)

Is there any way to generate "Lorem ipsum" in eclipse?

I'm into finding a way to generate Lorem ipsum in eclipse when creating views just for dummy texts. for example in Visual studio you can do it simply by typing lorem and press tab.
Is there any to do that in eclipse? any Idea?
In Android Studio, you can preview lorem ipsum TextViews with:
tools:text="#tools:sample/lorem/random"
You can also use this for Names, Cities, Zip codes, Avatars, and more.
see https://developer.android.com/studio/write/tool-attributes.html#toolssample_resources
I haven't encountered an Eclipse functionality to actually generate dummy text, but I do highly recommend this workaround (truth be told, I don't think you need different dummy text each time).
Create an Eclipe template. It's an xml file that looks like this:
<templates>
<template autoinsert="true" context="java" deleted="false" description="Dummy text" enabled="true" name="Lorem Ipsum">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</template>
</templates>
Go to Java -> Editor -> Templates and import the above file.
Now, when you write code and type lore (which represents the name attribute value of the template tag above), and hit CTRL+SPACE, then it will automatically insert the lorem ipsum text.
More Tips:
Add apostrophes to the ipsum text, so that it automatically generates a Java String
Add + signs to the ispum text, so that it breaks down the long string when inserted
Set the autoinsert attribute to false. Then you can see the ipsum description in the proposal
Set the name of the template to something like aaa_LoremIpsum. Then, in Eclipse, type aaa and press CTRL+SPACE. That way you can add many templates beginning with aaa, and select in Eclipse whichever you like.
I myself have templates for separating methods in a class. (e.g. aaa_1.StaticFields, aaa_2.InstanceFields, aaa_3.Constructors etc.)
They can help.
tools:text="#tools:sample/cities"
tools:text="#tools:sample/backgrounds/scenic"
tools:text= "#tools:sample/avatars"
tools:text="#tools:sample/full_names"
tools:text=”#tools:sample/lorem"
tools:text=”#tools:sample/lorem/random"
for other

Parsing / combining nested HTML element values in the original order

I would like to know how you can parse the content of an HTML block and at the same time sustain the order of the strings as they appear in the HTML document by using this (Hpple) wrapper which works with XPath expressions. The environment is iOS.
Example:
<html>
<body>
<div>
Lorem ipsum dolor sit <b>amet,</b> consectetur
</div>
</body>
</html>
Let's say we want to parse all the strings inside the <div> tag in the original order so that we get this result:
Lorem ipsum dolor sit amet, consectetur
The sticking point of this is sustaining the order of strings. It's easy to get all the direct content of <div> as well as that of <a> and <b> seperately or at the same time using an XPath expression which however omits the order, so might result in putting the content of <a> and <b> in the end of the string.
How can you achieve this using an XPath expression with the mentioned wrapper?
Update:
One way to achieve this with the mentioned wrapper and platform (especially libxml2) seems to be the following XPath expression:
//div/descendant-or-self::*/text()
However the resulting elements are seperated and not delivered as one string so that they have to be concatenated manually.
If Hpple is a compliant XPath emgine, then it must be able to evaluate this expression:
string(/*/body/div)
This XPath expression evaluates to the string value of the first (in document order /*/body/div element (in your case there is just one such element).
By definition, the string value of a node is the concatenation of all of its descendent text nodes (in document order) and thus this result is exactly the string you requested.
XSLT-based verification:
This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:value-of select="/*/body/div"/>
</xsl:template>
</xsl:stylesheet>
when applied on the provided XML document:
<html>
<body>
<div> Lorem ipsum
dolor sit
<b>amet,</b> consectetur
</div>
</body>
</html>
produces the wanted, correct result:
Lorem ipsum
dolor sit
amet, consectetur