Tumbling window
Wednesday, 3 April 2019 · 3 messages
GC
Giuseppe G. A. Celano3 Apr 2019 10:51 #
I have written the following code:
for tumbling window $s in ("this", "is", "an", "example", "." , "this", "is", "another", "[", "example", ".", "]", "Another", "example", ".")
start $a when fn:true()
end $b next $r when ($b = "." and $r = "]") or $b = "."
return
<s>{$s}</s>which returns:
<s>this is an example .</s>
<s>this is another [ example .</s>
<s>] Another example .</s>but I am looking for
<s>this is an example .</s>
<s>this is another [ example . ]</s>
<s>Another example .</s>I am playing around with if-clauses, but I am wondering whether there is a more direct way to force the end of a sentence at "]" when it is preceded by "." or at "." when there is no following "]". Thanks.
Ciao,
Giuseppe
KD
Kirsten, Dirk3 Apr 2019 10:59 #
Buon giorno,
there as is a “previous” clause in a window, which binds to the previous value. With this you can simply express what you verbalized in XQuery:
for tumbling window $s in ("this", "is", "an", "example", "." , "this", "is", "another", "[", "example", ".", "]", "Another", "example", ".")
start $a when fn:true()
end $b previous $prev next $r when ($b = "]" and $prev = ".") or ($b = "." and $r != "]")
return
<s>{$s}</s>Hope that helps
Dirk
Senacor Technologies Aktiengesellschaft - Sitz: Eschborn - Amtsgericht Frankfurt am Main - Reg.-Nr.: HRB 110482 Vorstand: Matthias Tomann (Vorsitzender), Marcus Purzer - Aufsichtsratsvorsitzender: Daniel Grözinger
Quoted text · Giuseppe G. A. Celano · 1 line
On 3. Apr 2019, at 10:51, Giuseppe G. A. Celano <celano at informatik.uni-leipzig.de<mailto:celano at informatik.uni-leipzig.de>> wrote:
I have written the following code:
for tumbling window $s in ("this", "is", "an", "example", "." , "this", "is", "another", "[", "example", ".", "]", "Another", "example", ".")
start $a when fn:true()
end $b next $r when ($b = "." and $r = "]") or $b = "."
return
<s>{$s}</s>which returns:
<s>this is an example .</s>
<s>this is another [ example .</s>
<s>] Another example .</s>but I am looking for
<s>this is an example .</s>
<s>this is another [ example . ]</s>
<s>Another example .</s>I am playing around with if-clauses, but I am wondering whether there is a more direct way to force the end of a sentence at "]" when it is preceded by "." or at "." when there is no following "]". Thanks.
Ciao,
Giuseppe
GC
Giuseppe G. A. Celano3 Apr 2019 11:22 #
Thanks. I was close :)
Dr. Giuseppe G. A. Celano
DFG-project leader <http://gepris.dfg.de/gepris/projekt/408121292> Universität Leipzig
Institute of Computer Science, NLP
Augustusplatz 10
Tel: +4934132223
04109 Leipzig
Deutschland
E-mail: celano at informatik.uni-leipzig.de <mailto:celano at informatik.uni-leipzig.de> Web site 1: http://asv.informatik.uni-leipzig.de/en/staff/Giuseppe_Celano <http://asv.informatik.uni-leipzig.de/en/staff/Giuseppe_Celano> Web site 2: https://sites.google.com/site/giuseppegacelano/ <https://sites.google.com/site/giuseppegacelano/>
Quoted text · Dirk · 7 lines
> On Apr 3, 2019, at 10:59 AM, Kirsten, Dirk <Dirk.Kirsten at senacor.com> wrote: > > for tumbling window $s in ("this", "is", "an", "example", "." , "this", "is", "another", "[", "example", ".", "]", "Another", "example", ".") > start $a when fn:true() > end $b previous $prev next $r when ($b = "]" and $prev = ".") or ($b = "." and $r != "]") > return > <s>{$s}</s>
Written for BaseX 9.1. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery