Skip to content

digicademy/fcs-ql-parser-xqm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DOI

fcs-ql-parser-xqm

This software package provides an XQuery module developed at the Digital Academy of the Academy of Sciences and Literature | Mainz that may be used to parse FCS-QL and transform FCS-QL queries into a custom XML format that matches the provided schema.

Please note that this parser does not yet support the following FCS-QL features:

  • Main Queries with disjunctions => e.g. "lorem" | [text = "ipsum"]
  • Sequence Queries => e.g. "lorem" [text = "ipsum"]
  • Groupings => e.g. ("lorem")
  • Quantifiers => e.g. "lorem"{,3}
  • Negated expressions => e.g. [!text = "ipsum"]

Requirements

The module was developed and tested to be used with the versions 3.1 of XQuery.

How to Use

  1. Import the module into your own XQuery script or module in the usual way:
import module namespace fcs-ql-parser="http://mwb.adwmainz.net/exist/fcs/fcs-ql-parser" at "PATH/TO/fcs-ql-parser.xqm";
  1. Use the following function:

fcs-ql-parser:parse

fcs-ql-parser:parse($query as xs:string?) as element(query)?

transforms a CLARIN FCS-QL query into a query element

Parameters:

$query? a query following the syntax of FCS-QL (c.f. https://office.clarin.eu/v/CE-2017-1046-FCS-Specification-v89.pdf) - e.g. "lorem" or [lemma = "ipsum"/id & pos != 'NOUN'] or [word='test'] within s

Returns:

element(query)? an XML equivalent - e.g.

<query>
    <segment>
        <expression>
            <attribute>text</attribute>
            <operator>=</operator>
            <regexp>lorem</regexp>
        </expression>
    </segment>
</query>

or

<query>
    <segment>
        <boolean>
            <operator>and</operator>
            <expression>
                <attribute>lemma</attribute>
                <operator>=</operator>
                <regexp flags="id">ipsum</regexp>
            </expression>
            <expression>
                <attribute>pos</attribute>
                <operator>!=</operator>
                <regexp>NOUN</regexp>
            </expression>
        </boolean>
    </segment>
</query>
</query>

or

<query>
    <segment>
        <expression>
            <attribute>word</attribute>
            <operator>=</operator>
            <regexp>test</regexp>
        </expression>
    </segment>
    <scope>s</scope>
</query>

License

The software is published under the terms of the MIT license.

Research Software Engineering and Development

Copyright 2023 Patrick Daniel Brookshire

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.