{ "paper_id": "Y05-1001", "header": { "generated_with": "S2ORC 1.0.0", "date_generated": "2023-01-19T13:39:55.623948Z" }, "title": "LPath + : A First-Order Complete Language for Linguistic Tree Query", "authors": [ { "first": "Catherine", "middle": [], "last": "Lai", "suffix": "", "affiliation": {}, "email": "laic@ling.upenn.edu" }, { "first": "Steven", "middle": [], "last": "Bird", "suffix": "", "affiliation": {}, "email": "" } ], "year": "", "venue": null, "identifiers": {}, "abstract": "Annotated linguistic databases are widely used in linguistic research and in language technology development. These annotations are typically hierarchical, and represent the nested structure of syntactic and prosodic constituents. Recently, the LPath language has been proposed as a convenient path-based language for querying linguistic trees. We establish the formal expressiveness of LPath relative to the XPath family of languages. We also extend LPath to permit simple closures, resulting in a first-order complete language which we believe is sufficiently expressive for the majority of linguistic tree query needs.", "pdf_parse": { "paper_id": "Y05-1001", "_pdf_hash": "", "abstract": [ { "text": "Annotated linguistic databases are widely used in linguistic research and in language technology development. These annotations are typically hierarchical, and represent the nested structure of syntactic and prosodic constituents. Recently, the LPath language has been proposed as a convenient path-based language for querying linguistic trees. We establish the formal expressiveness of LPath relative to the XPath family of languages. We also extend LPath to permit simple closures, resulting in a first-order complete language which we believe is sufficiently expressive for the majority of linguistic tree query needs.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Abstract", "sec_num": null } ], "body_text": [ { "text": "In recent years, a great variety of linguistic query languages have been proposed, most of them specialised for linguistic trees (Lai and Bird, 2004) , and applied to corpora such as the Penn Treebank (Marcus et al., 1993) . Despite this considerable effort, relatively little is known about the formal expressiveness of these languages, or the computational resources required to process them as the size of the data grows. One reason for this is that much of the work in this area has taken place in isolation from well-understood database query languages such as SQL and XPath (Clark and DeRose, 1999) .", "cite_spans": [ { "start": 129, "end": 149, "text": "(Lai and Bird, 2004)", "ref_id": "BIBREF8" }, { "start": 201, "end": 222, "text": "(Marcus et al., 1993)", "ref_id": "BIBREF9" }, { "start": 580, "end": 604, "text": "(Clark and DeRose, 1999)", "ref_id": "BIBREF3" } ], "ref_spans": [], "eq_spans": [], "section": "Introduction", "sec_num": "1." }, { "text": "Recently, the LPath language has been proposed as a convenient path-based language for querying linguistic trees (Bird et al., 2006) . It augments the navigational axes of XPath with three additional tree operators, and it can be translation into SQL for efficient execution. In this paper we investigate the expressiveness of LPath with respect to Core XPath and to a first-order complete language called Conditional XPath. We also extend LPath to permit simple closures, and argue that this new language supports all the navigational and closure requirements of linguistic tree query.", "cite_spans": [ { "start": 113, "end": 132, "text": "(Bird et al., 2006)", "ref_id": "BIBREF0" } ], "ref_spans": [], "eq_spans": [], "section": "Introduction", "sec_num": "1." }, { "text": "This paper is organised as follows. Section 2 reviews LPath, XPath, and Conditional XPath, and Section 3 examines the LPath operators to see which of them can be expressed in XPath or Conditional XPath. Section 4 presents an extended language, Conditional LPath, or LPath + , and discusses its merits as a linguistic tree query language. ", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Introduction", "sec_num": "1." }, { "text": "LPath was developed to be expressive enough for linguistic query but also to take advantage of relational database technology. As the name suggests, LPath is an extension of XPath. Bird et al. (2006) present three linguistically motivated syntactic additions. These are the immediate following axis (and its converse), tree edge alignment, and a scoping operator. They also present an efficient interpreter for LPath which converts LPath expressions into equivalent SQL expressions over annotation graphs (Bird and Liberman, 2001 ). Here are a selection of examples intended to illustrate the syntax and interpretation of LPath queries. When applied to the tree in Figure 1 they return the specified node sets.", "cite_spans": [ { "start": 181, "end": 199, "text": "Bird et al. (2006)", "ref_id": "BIBREF0" }, { "start": 505, "end": 529, "text": "(Bird and Liberman, 2001", "ref_id": "BIBREF1" } ], "ref_spans": [ { "start": 665, "end": 673, "text": "Figure 1", "ref_id": null } ], "eq_spans": [], "section": "LPath", "sec_num": "2.1." }, { "text": "1. //S[//_[@lex=saw] {S 2 }", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath", "sec_num": "2.1." }, { "text": "Find a sentence containing the word saw.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath", "sec_num": "2.1." }, { "text": "2. //V->NP {NP 6 , NP 7 }", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath", "sec_num": "2.1." }, { "text": "Find noun phrases that are immediately following a verb.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath", "sec_num": "2.1." }, { "text": "V-->N {N 10 , N 15 , N 17 }", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "//VP/", "sec_num": "3." }, { "text": "Find nouns that follow a verb which is a child of a verb phrase.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "//VP/", "sec_num": "3." }, { "text": "V-->N} {N 10 , N 15 }", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "//VP{/", "sec_num": "4." }, { "text": "Within a verb phrase, find nouns that follow a verb which is a child of the given verb phrase. 5. //VP{/NP$} {NP 6 } Find noun phrases which are the rightmost child of a verb phrase. 6. //VP{//NP$} {NP 6 , NP 13 } Find noun phrases which are rightmost descendants of a verb phrase.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "//VP{/", "sec_num": "4." }, { "text": "Find verb phrases comprised of a verb, a noun phrase, and a prepositional phrase. ", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "//VP[{//\u02c6V->NP->PP$}] {VP 4 }", "sec_num": "7." }, { "text": ":= '\\' | '\\\\' | '\\\\ * ' | '.' | '/' | '//' | '// * ' '->' | '<-' | '-->' | '<--' | '=>' | '<=' | '==>' | '<==' test := p | _ | '\u02c6'p | p'$'", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "//VP[{//\u02c6V->NP->PP$}] {VP 4 }", "sec_num": "7." }, { "text": "Figure 2: LPath Syntax (p is a node label; attribute syntax is omitted)", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "//VP[{//\u02c6V->NP->PP$}] {VP 4 }", "sec_num": "7." }, { "text": "\\ parent / child \\\\ ancestor // descendant \\\\ * ancestor or self // * descendant or self -> immediate following <- immediate preceding --> following <--preceding =>", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "//VP[{//\u02c6V->NP->PP$}] {VP 4 }", "sec_num": "7." }, { "text": "immediate following sibling <= immediate preceding sibling ==> following sibling <== preceding sibling . self", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "//VP[{//\u02c6V->NP->PP$}] {VP 4 }", "sec_num": "7." }, { "text": "The syntax of LPath is described in Figure 2 . Figure 3 gives the translation of abbreviated axes. We briefly review the syntax of LPath here, and refer the reader to (Bird et al., 2006) for full details.", "cite_spans": [ { "start": 167, "end": 186, "text": "(Bird et al., 2006)", "ref_id": "BIBREF0" } ], "ref_spans": [ { "start": 36, "end": 44, "text": "Figure 2", "ref_id": null }, { "start": 47, "end": 55, "text": "Figure 3", "ref_id": null } ], "eq_spans": [], "section": "Figure 3: LPath Axes and their Interpretation", "sec_num": null }, { "text": "Scoping: The scoping operator is denoted by pairs of braces, {}. These braces represent queries constrained to a particular subtree rooted by the context node immediately before the opening brace. The location path inside the scoping braces is evaluated as if this subtree were the whole of the input. This allows us to write queries restricted to a particular constituent.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Figure 3: LPath Axes and their Interpretation", "sec_num": null }, { "text": "Alignment. Left and right tree edge alignment,\u02c6and $ respectively, together with the scoping operator allow us to constrain a node to be leftmost (rightmost) edge in a constituent. For example, the following query returns sentences (S labelled nodes) that begin with a noun phrase and end with a verb phrase:", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Figure 3: LPath Axes and their Interpretation", "sec_num": null }, { "text": "//S{[//\u02c6NP-->VP$]}.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Figure 3: LPath Axes and their Interpretation", "sec_num": null }, { "text": "Horizontal axes. The immediate following axis, ->, is the natural one-step version of the following axis, -->. We can consider this axis as taking a step to constituents immediately right of the current context node. LPath also includes an immediate following sibling relation.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Figure 3: LPath Axes and their Interpretation", "sec_num": null }, { "text": "These extensions to XPath give LPath the ability to express a range of linguistic tree queries. However, LPath cannot express closures of any sort, and it is not clear where LPath lies on the hierarchy of XPath languages. Nor is it clear what extra expressiveness, if any, the LPath operators offer to these path-based languages. The following sections explore this question, and indicate how LPath can be extended to express closures, and how such an extension might be efficiently implemented. Notation. The following sections take an incremental approach to investigating the expressiveness of Core XPath and LPath extensions. This involves several languages constructed and related by restrictions on closures and the LPath operators defined above. Subscripts and superscripts denote the addition of a particular operator. X + {} denotes Conditional XPath extended with the scoping operator (but not -> or its converse). X ->{}$ represents Core XPath with ->, => and their converses, scoping and edge alignment, that is, LPath or L. L + denotes LPath extended with the conditional axis.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Figure 3: LPath Axes and their Interpretation", "sec_num": null }, { "text": "Marx 2004presents a family of XPath languages that extend the navigational functionality of XPath 1.0. Core XPath (X ) was originally presented by Gottlob et al. (2003) . This language can be seen as XPath 1.0 stripped of non-navigational components such as attributes and namespaces. The syntax of X is shown in Figure 4 .", "cite_spans": [ { "start": 147, "end": 168, "text": "Gottlob et al. (2003)", "ref_id": "BIBREF4" } ], "ref_spans": [ { "start": 313, "end": 321, "text": "Figure 4", "ref_id": "FIGREF1" } ], "eq_spans": [], "section": "XPath and Conditional XPath", "sec_num": "2.2." }, { "text": "Conditional XPath (X + ) extends X primarily by adding a conditional axis. This expresses conditional paths where every node in that path satisfies a particular condition represented as a filter expression. X + replaces the definition of axis in Figure 4 as follows:", "cite_spans": [], "ref_spans": [ { "start": 246, "end": 254, "text": "Figure 4", "ref_id": "FIGREF1" } ], "eq_spans": [], "section": "XPath and Conditional XPath", "sec_num": "2.2." }, { "text": "axis := primaxis | '[' fexpr ']' primaxis | primaxis '[' fexpr ']' | axis ' * ' primaxis := self | child | parent | immediate_following_sibling | immediate_preceding_sibling", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "XPath and Conditional XPath", "sec_num": "2.2." }, { "text": "Primary axes (primaxis) represent the smallest steps that can be taken in each direction from nodes in a tree. Note, X does not include the one-step sibling axis immediate following sibling or its converse. However, it does include its transitive closures, following sibling. In fact, the transitive closures of each primary axis are included in X so we will use these axis names for non-conditional closures. For example, child * is equivalent to descendant_or_self. We also define axis+ as the non-reflexive transitive closure of an axis as /axis::_/(axis) * . Again, we will denote child+ as descendant.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "XPath and Conditional XPath", "sec_num": "2.2." }, { "text": "X + is a first-order complete language. However, it is not always easy translate first-order formulas into path expressions. For example, there is often a need to distinguish first and last constituents in a phrase or to find the next constituent. Moreover, linguistic phenomena are often restricted to particular types of constituents and their contents. In order to express scoping we need expressions that have some way of remembering the subtree they should be in. However, path-based, variable-free languages like X + have no explicit memory and so can only do this implicitly.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "XPath and Conditional XPath", "sec_num": "2.2." }, { "text": "How does the expressiveness of LPath, L, compare with that of X and X + , existing wellunderstood languages? Perhaps LPath is just a syntactic variant of one of them, in which case we could build an interpreter to convert L expressions to X or X + expressions. We take up this question in the next two subsections.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Relationship between LPath, XPath and Conditional XPath", "sec_num": "3." }, { "text": "To begin, it is easy to see that edge alignment can be expressed in X . We note the following equivalences:", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "\u02c6A \u2261 A[not <--_ ] and A$ \u2261 A[not --> _ ].", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "The scoping operator can be thought of as the assertion that a dominance relation between the scoping node and those appearing within the scoping braces. This is illustrated in Figure 5 . Here, the query NP{//PP-->NP\\\\VP} is drawn as a cyclic graph where edges are labelled with the axes relating pairs of nodes. The scoping constraint corresponds to the extra dashed edges.", "cite_spans": [], "ref_spans": [ { "start": 177, "end": 185, "text": "Figure 5", "ref_id": "FIGREF2" } ], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "The difficulty implementing the scoping operator in path-based languages such as X is that they have no memory of previous steps. In general, it is not possible to return to a particular node unless every node in the tree is uniquely labelled. This is clearly not the case for linguistic trees. In order to to transform a 'scoped' expression into a X expression we need to convert cyclic queries into a disjunction of acyclic ones. An algorithm that does exactly this for the positive fragment of X has been presented by Gottlob et al. (2004) . Positive X is the set of X expressions that do not include negation in filter expressions. However, note that positive X cannot express the edge alignment operators. Lemma 1. The scoping operator adds no expressiveness to Positive X .", "cite_spans": [ { "start": 521, "end": 542, "text": "Gottlob et al. (2004)", "ref_id": "BIBREF5" } ], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "Proof. Let L be an L expression that uses the scoping operator. We simply draw the query graph of L adding descendant labelled edges between scoping and scoped nodes. Now, the algorithm of Gottlob et al. (2004) results in a disjunction, D of acyclic query trees that is equivalent to the original (cyclic) query. Each query tree in the disjunction has a node x that represents the target node set of of the original expression L. Thus each query tree in D is equivalent to a finite set The result of applying this transformation on the L expression NP{//PP-->N\\\\VP} is shown in Figure 6 . The equivalent X expression is as follows. Unfortunately, this technique does not extend to X expressions with negation. Negation within the scoping braces only holds inside the scoped subtree. This is not a problem for negated paths that do not involve the ancestor axis because such paths cannot escape the scoped subtree. However, the effects of negation and scoping on the ancestor axis give the following lemma.", "cite_spans": [ { "start": 189, "end": 210, "text": "Gottlob et al. (2004)", "ref_id": "BIBREF5" } ], "ref_spans": [ { "start": 578, "end": 586, "text": "Figure 6", "ref_id": "FIGREF3" } ], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "Lemma 2. X {} is strictly more expressive than X .", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "Proof. Consider the L expression //B/A{//A[not (\\\\_[not .A])]}. This finds Alabelled nodes such that there is a \\-path of nodes whose labels conform to the regular expression A + B. Now, Marx and de Rijke (2004) have shown that all X queries can be expressed in first order logic over trees using at most two variables, extended with child and immediate following sibling. However, the regular expression above cannot be expressed in this signature in less than three variables (Marx, 2005) .", "cite_spans": [ { "start": 199, "end": 211, "text": "Rijke (2004)", "ref_id": "BIBREF12" }, { "start": 478, "end": 490, "text": "(Marx, 2005)", "ref_id": "BIBREF11" } ], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "A similar linguistic example is the L query //NP{//VP[not \\\\PP]}. This expression selects VPs that are dominated by NPs with no intervening PP. We can express this in X + as //NP(/_[not PP]) * /VP. However, as we have seen, this closure cannot be expressed in X .", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "The other additions of L to X are the one-step horizontal axes. The next lemma follows from Marx (2005) .", "cite_spans": [ { "start": 92, "end": 103, "text": "Marx (2005)", "ref_id": "BIBREF11" } ], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "Lemma 3. The immediate following sibling and immediate following axes, and their converses, cannot be expressed in X .", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "Thus, X ->{}$ is strictly more expressive than X , and so L is also strictly more expressive than X .", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "We proceed to incrementally add L operators to X as primitives to gain a further idea of the expressiveness they provide. Consider X -> . Since edge alignment can be expressed in X , X -> is equivalent to L without the scoping operator. Now, if scoping was redundant in X -> , then X -> would be expressively equivalent to L. However, we can show that this is not the case. In fact, the interaction of L operators results in queries that require other closures that are inexpressible in X . First, consider the interaction of the scoping and edge alignment operators. As noted previously, this allows us to express subtree edge alignment. The query //S{[//\u02c6NP-->VP$]} is equivalent to constraining the NP (VP) to be a leftmost (rightmost) descendant of the S. This requires us to be able to state that every node on the /-path between the S and NP has no left sibling. This is just the conditional axis, which is inexpressible in X .", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "Second, consider the scoping operator and the immediate following axis. This axis allows the current context node to move outside of the scoped subtree. This is demonstrated in Figure 7 . Consider a situation where we wish to find verb phrases (VP) containing a noun phrase (NP) immediately followed by a prepositional phrase (PP). That is //VP{//NP->PP}. From the point of view of the NP node, there is no way to tell if an immediate following PP is dominated by the same VP originally being tested. If order to constrain -> to be within a subtree, we need to phrase this constraint using other axes. (Note that the following axis, -->, can be alternatively defined as:", "cite_spans": [], "ref_spans": [ { "start": 177, "end": 185, "text": "Figure 7", "ref_id": "FIGREF5" } ], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "-->t[F ] \u2261 \\\\ * _==>_// * t[F ].)", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "Now, the only chance that we may leave the scope is if the 'ancestor' part of the expression takes us above the scoping node. As long as we constrain how far up the ancestor is chosen, we are assured of staying within the scope. The cycle-removing algorithm of Gottlob et al. (2004) enumerates the possible positions such an ancestor can take.", "cite_spans": [ { "start": 261, "end": 282, "text": "Gottlob et al. (2004)", "ref_id": "BIBREF5" } ], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "Although -> has a similar form to its closure --> it requires further constraints that are inexpressible in X . Specifically, we need to to be able to identify ancestors that are rightmost and descendants that are leftmost. This is much the same as subtree edge alignment. As in the previous example, these constraints cannot be expressed in X . Importantly, this means that the only way we can represent the immediate following relation is with the primitive. Without some sort of memory device there is no way to force this primitive to stay within a scope. In a first-order formulas such a memory device would come in the form of extra variables.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "Putting all this together gives a clear picture of the expressiveness is required to implement L operators using members of the XPath family of languages. It is clear the scoping and the immediate following axes are more than syntactic sugar in the context of X . The interaction between all three L operators as well as negation indicate that L requires some of expressiveness of the conditional axes. The next section looks at the affect of these operators in the setting of Conditional XPath.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath Operators and Core XPath", "sec_num": "3.1." }, { "text": "The first thing to notice in moving to Conditional XPath (X + ) is that the immediate following relation is now expressible:", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath operators and Conditional XPath", "sec_num": "3.2." }, { "text": "-> \u2261 ([not(=> _)]\\) * => (/[not(<= _)]) *", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath operators and Conditional XPath", "sec_num": "3.2." }, { "text": "Since X is contained in X + , the definitions of edge alignment operators carry over from X . Once again, the scoping operator requires more work. However, the ability to express this follows immediately from the first-order completeness of X + queries (Marx, 2005) . Consider now X + with the scoping operator added to its syntax, X + {} . Lemma 5. X + is as expressive as X", "cite_spans": [ { "start": 253, "end": 265, "text": "(Marx, 2005)", "ref_id": "BIBREF11" } ], "ref_spans": [], "eq_spans": [], "section": "LPath operators and Conditional XPath", "sec_num": "3.2." }, { "text": "+ {} . Proof. Any X +", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath operators and Conditional XPath", "sec_num": "3.2." }, { "text": "{} with scoping braces deleted is just a X + expression. Therefore we can write any X + {} expression ignoring any scoping braces into a first-order formula \u03c6(x, y). Let z be the variable representing the scoping node and let w 0 , . . . , w k be variables representing nodes in the scoped location path. For each w i we conjoin the clause descendant(z, w i ) in the appropriate variable scope. Since this does not change the number of free variables this has an equivalent X + expression.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath operators and Conditional XPath", "sec_num": "3.2." }, { "text": "Thus all the L operators are expressible in X + . Moreover, the first-order completeness of X + means that the interactions between L operators can add no extra expressiveness. However, there is no Kleene star in L so the reverse case is clearly not true. This gives us the following theorem.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath operators and Conditional XPath", "sec_num": "3.2." }, { "text": "Theorem 6. L is strictly contained in X + .", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath operators and Conditional XPath", "sec_num": "3.2." }, { "text": "That is, the expressiveness of LPath (L) lies strictly between Core XPath (X ) and Conditional XPath (X + ). Thus L is a new member of the XPath family of languages, and not a notational variant of one of the existing languages.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "LPath operators and Conditional XPath", "sec_num": "3.2." }, { "text": "The obvious question now is whether L with conditional axis, L + , is any more expressive than X + . The main point of difference between the two languages is the status of the the immediate following (->) axis. This is elevated to rank of primitive axis in L. Unfortunately, treating -> as a primitive axis does not necessarily give it the same properties as the one-step axes of X + . Consider the relations R i where i \u2208 {=>, <=, /, \\}. If (x, y) \u2208 R * i there is a unique i-path between x and y. This is not the case for the immediate following axis. The -> is a many-to-many mapping and its converse, the immediate preceding relation <-, is as well. Consider the L + expression B(->A)+. We might express this in as:", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "following(x, y) \u2227 B(x) \u2227 A(y) \u2227 \u2200z(following(x, z) \u2227 following(z, y) \u2192 A(z))", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "The possibility of multiple ->-paths between x and y makes this formula too strong a statement. The original L + expression only requires the existence of an ->-path between nodes x and y where x has label B and the other nodes are labelled A. The formula above requires all ->-paths to have this property.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "However, we can derive a formula that is equivalent to the set defined by B(->A)+ as follows. Let x and y be nodes such that following(x, y), where x and y are labelled B and A respectively. Let v be the first common ancestor of x and y and denote the subtree rooted at v as T v . We also need the following to hold. For each leaf l between x and y there is at least one node z labelled A on the each \\-path from a l to v. This set of z nodes gives us the required ->-path. A first-order formula that expresses is as follows:", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "imf BA + (x, y) \u2261 following(x, y) \u2227 B(x) \u2227 A(y)\u2227 \u2200z((following(x, z) \u2227 following(z, y) \u2227 leaf(z) \u2192 \u2203w((z = w \u2227 A(w)) \u2228 (ancestor(z, w) \u2227 A(w) \u2227 \u00ac ancestor(w, x)))).", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "We can easily let A and B represent location paths instead of labels in the the formula above. So this formula can easily be modified to deal with the conditional -> axis in general. This means that all L + expressions without scoping braces can be expressed first-order logic. As in Lemma 5, we can trivially add the scoping operator. L + clearly contains X + so we have the following equivalence:", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "Theorem 7. L + has the same expressiveness as X + . As a result, L + path sets are first-order complete.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "In fact, we can find an equivalent X + expression for the conditional immediate following axis using the fact that X + is closed under intersection and complementation (Marx, 2005) . First note that the formula imf BA + (x, y), hence the L + query //B(->A)+, is equivalent to the following:", "cite_spans": [ { "start": 168, "end": 180, "text": "(Marx, 2005)", "ref_id": "BIBREF11" } ], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "imf BA + (x, y) \u2261 following(x, y) \u2227 B(x) \u2227 A(y)\u2227 \u00ac\u2203z((following(x, z) \u2227 following(z, y) \u2227 leaf(z) \u2227 \u00ac\u2203w((z = w \u2227 A(w)) \u2228 (ancestor(z, w) \u2227 A(w) \u2227 \u00ac ancestor(w, x))))", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "We can write this using intersections and complements of X + path well-formed formulas. Let \u03c6(x, y) \u2261 (?B/ancestor/(child?\u00acA) + /?leaf ) \u2229 f ollowing.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "Now we can write an expression equivalent to //B(->A)+", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "imf BA + (x, y) \u2261 (?B/f ollowing?A) \u2229 \u03c6/f ollowing.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "Along with the proof, Marx (2005, Theorem 2) provides a method for finding the complement of any X + path set. Thus, we now have a concrete method for translating L + expressions into X + .", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "The Expressiveness of Conditional LPath", "sec_num": "4.1." }, { "text": "L + is capable of expressing a large range of linguistic tree queries, including all the basic subtree matching queries identified in our requirements analysis (Lai and Bird, 2004) .", "cite_spans": [ { "start": 160, "end": 180, "text": "(Lai and Bird, 2004)", "ref_id": "BIBREF8" } ], "ref_spans": [], "eq_spans": [], "section": "Conditional LPath as Linguistic Tree Query Language", "sec_num": "4.2." }, { "text": "The only other current linguistic treebank query language with this level of expressiveness is fsq (Kepser, 2003) . However, fsq only allows boolean queries. Moreover, L + 's path-based syntax is much more intuitive and more closely aligned to actual descriptions of structure in the linguistics literature (Palm, 1999) . However, there is still a price to pay for choosing this path-based variable-free approach over the variables and predicates of classical first-order logic.", "cite_spans": [ { "start": 99, "end": 113, "text": "(Kepser, 2003)", "ref_id": "BIBREF6" }, { "start": 307, "end": 319, "text": "(Palm, 1999)", "ref_id": "BIBREF13" } ], "ref_spans": [], "eq_spans": [], "section": "Conditional LPath as Linguistic Tree Query Language", "sec_num": "4.2." }, { "text": "The major advantage of the classical approach of fsq is that variables can be used to identify specific nodes throughout a query. The scoping operator accounts for cases where there is a need to identify the root of a particular subtree, the scoping node, at every step in a path expression. However, although L + is first-order complete, it is not always clear how a first-order formula can be converted into a (variable-free) L + expression.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Conditional LPath as Linguistic Tree Query Language", "sec_num": "4.2." }, { "text": "First-order completeness tells us that the following query is expressible: Find the first common ancestor of noun phrases immediately followed by a verb phrase. This can be expressed as follows:", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Conditional LPath as Linguistic Tree Query Language", "sec_num": "4.2." }, { "text": "\u03d5(x) =\u2203y\u2203z descendant(x, y) \u2227 descendant(x, z) \u2227 NP(y) \u2227 VP(z) \u2227 following(y, z) \u2227 \u00ac\u2203z \u2032 (following(x, z \u2032 ) \u2227 following(z \u2032 , y)) \u2227 \u00ac\u2203w(descendant(w, y) \u2227 descendant(w, z)).", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Conditional LPath as Linguistic Tree Query Language", "sec_num": "4.2." }, { "text": "However, even with the immediate following axis and the scoping operator it is not very obvious how this can be expressed in L + . Note that the following query is incorrect,", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Conditional LPath as Linguistic Tree Query Language", "sec_num": "4.2." }, { "text": "//_[{//NP->VP} and not(//_{//NP->VP})].", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Conditional LPath as Linguistic Tree Query Language", "sec_num": "4.2." }, { "text": "This is because each NP (or VP) may refer to completely different nodes. We can express this query by using the X + definition of the immediate following relation rather than the primitive -> axis. However, this is a very different approach to representing this sort of query than suggested by the first-order formula above. These problems are inherent to path-based, variable-free languages.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Conditional LPath as Linguistic Tree Query Language", "sec_num": "4.2." }, { "text": "As an example of how sequential closures are expressed consider the following query: Find words consisting of consonant-vowel-consonant sequences. 1 Let words, consonants and vowels be represented by the labels W, C, and V respectively. We can express this query in L + as follows: //W{[/\u02c6C(->C) * (->V)+(->C)+_$]} Here, the -> axis allows us to capture the case where the consonants and vowels may not all be at the same depth. Moreover, the scoping operator provides a convenient way of specifying subtree edge alignment. This allows us to specify completely what a node dominates.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Conditional LPath as Linguistic Tree Query Language", "sec_num": "4.2." }, { "text": "We can express more hierarchical closures too, for example, to find NP nodes that conform to the simple grammar fragment, NP \u2192 Adj NP; NP \u2192 N as: //NP[({/\u02c6Adj=>NP$}) * /N] The addition of the immediate following and immediate following sibling axes completes the set of X axes for navigating trees. In L + , each axis has a corresponding one-step axis. The L + axis set accounts for both hierarchical, sequential and sibling orderings on unranked ordered trees. As such, there do not appear to be any such (unconditional) relations lacking in the L + axis set. Thus, L + appears to have the complete set of axes necessary for linguistic tree query.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Conditional LPath as Linguistic Tree Query Language", "sec_num": "4.2." }, { "text": "LPath was proposed as a new query language which augmented the navigational axes of XPath with three additional tree operators. The analysis of LPath operators shows that they are more than just syntactic sugar. In fact, LPath takes up a new rung on the expressiveness hierarchy strictly between Core and Conditional XPath. Conditional LPath, LPath extended with the conditional axis, has the same expressiveness as Conditional XPath. This provides evidence that the closures required for linguistic query can be restricted to conditional paths, and supports the argument that first-order logic provides enough expressiveness for our linguistic tree query needs.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Conclusion", "sec_num": "5." }, { "text": "This is slightly harder version of the query inCassidy (2002).", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "", "sec_num": null } ], "back_matter": [ { "text": "This research has been supported by an Australian Postgraduate Award (Lai) and by the US National Science Foundation project 0317826 Querying Linguistic Databases (Bird). We are grateful to Marcus Kracht and Maarten Marx for helpful discussions of this work. A substantially expanded version of this work may be found in the first author's masters thesis (Lai, 2005) .", "cite_spans": [ { "start": 355, "end": 366, "text": "(Lai, 2005)", "ref_id": "BIBREF7" } ], "ref_spans": [], "eq_spans": [], "section": "Acknowledgements", "sec_num": "6." } ], "bib_entries": { "BIBREF0": { "ref_id": "b0", "title": "Designing and evaluating an XPath dialect for linguistic queries", "authors": [ { "first": "S", "middle": [], "last": "Bird", "suffix": "" }, { "first": "Y", "middle": [], "last": "Chen", "suffix": "" }, { "first": "S", "middle": [ "B" ], "last": "Davidson", "suffix": "" }, { "first": "H", "middle": [], "last": "Lee", "suffix": "" }, { "first": "Y", "middle": [], "last": "Zheng", "suffix": "" } ], "year": 2006, "venue": "22nd International Conference on Data Engineering", "volume": "", "issue": "", "pages": "", "other_ids": {}, "num": null, "urls": [], "raw_text": "Bird, S., Chen, Y., Davidson, S. B., Lee, H., and Zheng, Y. (2006). Designing and evaluating an XPath dialect for linguistic queries. In 22nd International Conference on Data Engineering.", "links": null }, "BIBREF1": { "ref_id": "b1", "title": "A formal framework for linguistic annotation", "authors": [ { "first": "S", "middle": [], "last": "Bird", "suffix": "" }, { "first": "M", "middle": [], "last": "Liberman", "suffix": "" } ], "year": 2001, "venue": "Speech Communication", "volume": "33", "issue": "", "pages": "23--60", "other_ids": {}, "num": null, "urls": [], "raw_text": "Bird, S. and Liberman, M. (2001). A formal framework for linguistic annotation. Speech Communication, 33:23-60.", "links": null }, "BIBREF2": { "ref_id": "b2", "title": "XQuery as an annotation query language: a use case analysis", "authors": [ { "first": "S", "middle": [], "last": "Cassidy", "suffix": "" } ], "year": 2002, "venue": "Proceedings of LREC 2002", "volume": "", "issue": "", "pages": "", "other_ids": {}, "num": null, "urls": [], "raw_text": "Cassidy, S. (2002). XQuery as an annotation query language: a use case analysis. In Proceedings of LREC 2002, Las Palmas, Spain, May.", "links": null }, "BIBREF3": { "ref_id": "b3", "title": "XML Path language (XPath). W3C", "authors": [ { "first": "J", "middle": [], "last": "Clark", "suffix": "" }, { "first": "S", "middle": [], "last": "Derose", "suffix": "" } ], "year": 1999, "venue": "", "volume": "", "issue": "", "pages": "", "other_ids": {}, "num": null, "urls": [], "raw_text": "Clark, J. and DeRose, S. (1999). XML Path language (XPath). W3C. http://www.w3.org/TR/xpath.", "links": null }, "BIBREF4": { "ref_id": "b4", "title": "The complexity of XPath query evaluation", "authors": [ { "first": "G", "middle": [], "last": "Gottlob", "suffix": "" }, { "first": "C", "middle": [], "last": "Koch", "suffix": "" }, { "first": "R", "middle": [], "last": "Pichler", "suffix": "" } ], "year": 2003, "venue": "Proceedings of the Twenty-Second ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, PODS", "volume": "", "issue": "", "pages": "179--190", "other_ids": {}, "num": null, "urls": [], "raw_text": "Gottlob, G., Koch, C., and Pichler, R. (2003). The complexity of XPath query evaluation. In Proceedings of the Twenty-Second ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, PODS, pages 179-190, San Diego, CA, USA. ACM.", "links": null }, "BIBREF5": { "ref_id": "b5", "title": "Conjunctive queries over trees", "authors": [ { "first": "G", "middle": [], "last": "Gottlob", "suffix": "" }, { "first": "C", "middle": [], "last": "Koch", "suffix": "" }, { "first": "K", "middle": [ "U" ], "last": "Schulz", "suffix": "" } ], "year": 2004, "venue": "Proceedings of the Twenty-third ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database System", "volume": "", "issue": "", "pages": "189--200", "other_ids": {}, "num": null, "urls": [], "raw_text": "Gottlob, G., Koch, C., and Schulz, K. U. (2004). Conjunctive queries over trees. In Proceedings of the Twenty-third ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database System, pages 189-200, Paris, France. ACM.", "links": null }, "BIBREF6": { "ref_id": "b6", "title": "Finite structure query: A tool for querying syntactically annotated corpora", "authors": [ { "first": "S", "middle": [], "last": "Kepser", "suffix": "" } ], "year": 2003, "venue": "EACL 2003: The 10th Conference of the European Chapter of the Association for Computational Linguistics", "volume": "", "issue": "", "pages": "179--186", "other_ids": {}, "num": null, "urls": [], "raw_text": "Kepser, S. (2003). Finite structure query: A tool for querying syntactically annotated corpora. In EACL 2003: The 10th Conference of the European Chapter of the Association for Computational Linguistics, pages 179-186.", "links": null }, "BIBREF7": { "ref_id": "b7", "title": "A formal framework for linguistic tree query", "authors": [ { "first": "C", "middle": [], "last": "Lai", "suffix": "" } ], "year": 2005, "venue": "", "volume": "", "issue": "", "pages": "", "other_ids": {}, "num": null, "urls": [], "raw_text": "Lai, C. (2005). A formal framework for linguistic tree query. Master's thesis, Department of Computer Science and Software Engineering, University of Melbourne.", "links": null }, "BIBREF8": { "ref_id": "b8", "title": "Querying and updating treebanks: A critical survey and requirements analysis", "authors": [ { "first": "C", "middle": [], "last": "Lai", "suffix": "" }, { "first": "S", "middle": [], "last": "Bird", "suffix": "" } ], "year": 2004, "venue": "Proceedings of the Australasian Language Technology Workshop", "volume": "", "issue": "", "pages": "139--146", "other_ids": {}, "num": null, "urls": [], "raw_text": "Lai, C. and Bird, S. (2004). Querying and updating treebanks: A critical survey and requirements analysis. In Proceedings of the Australasian Language Technology Workshop, pages 139-146. http://eprints.unimelb.edu.au/archive/00000774/.", "links": null }, "BIBREF9": { "ref_id": "b9", "title": "Building a large annotated corpus of English: The Penn Treebank", "authors": [ { "first": "M", "middle": [ "P" ], "last": "Marcus", "suffix": "" }, { "first": "B", "middle": [], "last": "Santorini", "suffix": "" }, { "first": "M", "middle": [ "A" ], "last": "Marcinkiewicz", "suffix": "" } ], "year": 1993, "venue": "Computational Linguistics", "volume": "19", "issue": "2", "pages": "313--343", "other_ids": {}, "num": null, "urls": [], "raw_text": "Marcus, M. P., Santorini, B., and Marcinkiewicz, M. A. (1993). Building a large annotated corpus of English: The Penn Treebank. Computational Linguistics, 19(2):313-30. http://www.cis.upenn.edu/\u02dctreebank/home.html.", "links": null }, "BIBREF10": { "ref_id": "b10", "title": "XPath with conditional axis relations", "authors": [ { "first": "M", "middle": [], "last": "Marx", "suffix": "" } ], "year": 2004, "venue": "Advances in Database Technology -EDBT 2004, 9th International Conference on Extending Database Technology, Proceedings", "volume": "2992", "issue": "", "pages": "477--494", "other_ids": {}, "num": null, "urls": [], "raw_text": "Marx, M. (2004). XPath with conditional axis relations. In Advances in Database Technology -EDBT 2004, 9th International Conference on Extending Database Technology, Proceedings, volume 2992 of Lecture Notes in Computer Science, pages 477-494, Heraklion, Crete, Greece. Springer.", "links": null }, "BIBREF11": { "ref_id": "b11", "title": "First order paths in ordered trees", "authors": [ { "first": "M", "middle": [], "last": "Marx", "suffix": "" } ], "year": 2005, "venue": "Database Theory -ICDT 2005, 10th International Conference", "volume": "3363", "issue": "", "pages": "114--128", "other_ids": {}, "num": null, "urls": [], "raw_text": "Marx, M. (2005). First order paths in ordered trees. In Eiter, T. and Libkin, L., editors, Database Theory -ICDT 2005, 10th International Conference, Edinburgh, UK, January 5-7, 2005, Proceedings, volume 3363 of Lecture Notes in Computer Science, pages 114-128. Springer.", "links": null }, "BIBREF12": { "ref_id": "b12", "title": "Semantic characterization of navigational XPath", "authors": [ { "first": "M", "middle": [], "last": "Marx", "suffix": "" }, { "first": "M", "middle": [], "last": "De Rijke", "suffix": "" } ], "year": 2004, "venue": "Proceedings of TDM'04 Workshop on XML Databases and Information Retrieval", "volume": "", "issue": "", "pages": "", "other_ids": {}, "num": null, "urls": [], "raw_text": "Marx, M. and de Rijke, M. (2004). Semantic characterization of navigational XPath. In Proceedings of TDM'04 Workshop on XML Databases and Information Retrieval, Twente, The Netherlands.", "links": null }, "BIBREF13": { "ref_id": "b13", "title": "Propositional tense logic for trees", "authors": [ { "first": "A", "middle": [], "last": "Palm", "suffix": "" } ], "year": 1999, "venue": "Proceedings of the Sixth Meeting on Mathematics of Language: MOL6", "volume": "", "issue": "", "pages": "", "other_ids": {}, "num": null, "urls": [], "raw_text": "Palm, A. (1999). Propositional tense logic for trees. In Proceedings of the Sixth Meeting on Mathematics of Language: MOL6, University of Central Florida, Orlando, Florida.", "links": null } }, "ref_entries": { "FIGREF0": { "uris": null, "num": null, "text": "Figure 1: Tree Representation", "type_str": "figure" }, "FIGREF1": { "uris": null, "num": null, "text": "Syntax of Core XPath", "type_str": "figure" }, "FIGREF2": { "uris": null, "num": null, "text": "Scoping induced cycles: NP{//PP-->N\\\\VP}", "type_str": "figure" }, "FIGREF3": { "uris": null, "num": null, "text": "Acyclic version of NP{//PP-->N \\\\VP} of filter expressions, F = {F i }, based at x. Thus L is equivalent to a X expression of the form //_[A] where A \u2261 F i .", "type_str": "figure" }, "FIGREF4": { "uris": null, "num": null, "text": "//N[\\\\VP\\\\_<=\\\\NP[// * PP] or \\\\ * _<=_[// * PP]\\\\VP\\\\NP or \\\\VP<=_[// * PP]\\\\NP]", "type_str": "figure" }, "FIGREF5": { "uris": null, "num": null, "text": "Scoping and immediate following. Dashed lines indicate the path of the query.", "type_str": "figure" }, "FIGREF6": { "uris": null, "num": null, "text": "L is strictly more expressive than X -> .Proof. The additional axes express sequential relations and so do not give X -> any more ability to express queries of the form //B/A{//A[not (\\\\_[not .A])]}. Thus, the scoping operator is not expressible in X -> .", "type_str": "figure" }, "FIGREF7": { "uris": null, "num": null, "text": "/_[/_[(NP or (/_[not(=>_)]) * /NP[not(=>_)) and => (VP or (/_[not(<=_)]) * /VP[not(<=_)])]", "type_str": "figure" } } } }