Syntactic Search by Example

Micah Shlain, Hillel Taub-Tabib, Shoval Sadde, Yoav Goldberg

Abstract

Large-scale syntactically annotated corpora offer immense potential for information extraction, yet their utility is often limited by the complexity of existing query languages. We present Spike, a "search by example" system that enables users to perform sophisticated syntactic searches using natural language examples and lightweight markup. By automatically inferring dependency patterns from user-provided sentences, Spike lowers the barrier to entry for non-linguists and accelerates the workflow for experts.

Introduction

The advent of high-performance neural parsers has enabled the creation of massive, syntactically annotated datasets, such as the entirety of Wikipedia or PubMed. However, searching these datasets remains a significant challenge. Traditional tools like Odin or SemGrex require users to master specific dependency grammars and verbose query syntaxes. For instance, identifying "who founded which company" might require manually specifying that a "Person" entity must be the nominal subject (nsubj) of the verb "founded." This high barrier to entry makes the technology inaccessible to many and slows down the research cycle for experts.

Methodology: The Spike System

Spike shifts the paradigm from writing complex code to annotating natural language examples. The system follows a streamlined workflow:

Query by Example and Automatic Inference

Users provide a natural language sentence and apply lightweight markup to define captures and constraints. The system then parses this example into a dependency graph and automatically maps the user's markup onto the graph structure. This allows the system to extract the underlying syntactic pattern without the user needing to know the names of specific dependency relations (e.g., nmod or xcomp).

The Spike interface showing a query for founders, the inferred dependency graph, and the resulting matches in the corpus.

Lightweight Markup Language

The system employs a simple syntax for defining search parameters:

  • Captures: Using the name:word syntax (e.g., inst:Harvard) identifies slots to be returned in the results.
  • Constraints: Shorthands like [e] for entity type, [l] for lemma, [t] for POS tag, and [w] for exact word allow for precise filtering.
  • Anchors: The $ symbol marks words that are syntactically necessary but should not be captured.
  • Expansions: The <> "diamond" operator enables the capture of entire noun phrases or entity spans rather than just headwords.
An example query demonstrating the use of captures, entity constraints, and anchors to find educational degree relationships.

Backend Engine

The system is powered by Odinson, a search engine built on Lucene. It translates example-based queries into graph-path queries that execute against pre-indexed corpora at interactive speeds.

Evaluation and Results

The utility of Spike was demonstrated on two large-scale corpora: English Wikipedia and PubMed Abstracts. The latter, processed with the SciSpacy pipeline, highlights the system's ability to handle domain-specific entities like chemicals and diseases.

In a qualitative walk-through, the authors demonstrated the extraction of people who obtained degrees from specific institutions. Starting from a simple example, a user can iteratively refine a query to extract thousands of structured data rows (e.g., 6,197 rows from Wikipedia), capturing diverse expressions of the "degree-from" relationship such as "earned," "received," or "completed."

Discussion

Key Insights

  • Syntactic Abstraction: By providing a sentence that contains a relation, users can leverage complex syntactic patterns without formal linguistic training.
  • Interactive Refinement: The system's speed supports a trial-and-error workflow, allowing users to prune search spaces by adding constraints based on initial results.
  • The Power of Expansion: Capturing full entity names (e.g., "The Microsoft Corporation") via the diamond operator is crucial for practical information extraction.

Limitations and Future Work

The current system does not support complex quantification (e.g., chains of conjunctions). Furthermore, performance is inherently tied to the accuracy of the underlying syntactic parser. Future research will explore more sophisticated expansion strategies beyond simple NP-chunks and entity boundaries.

Conclusion

Spike demonstrates that "search by example" is a viable and efficient method for querying large, syntactically annotated corpora. By abstracting away the complexities of dependency grammars, it opens up powerful information extraction capabilities to a broader audience.

A demo of the system is available at https://allenai.github.io/spike/.

Summary updated

BibTeX
@inproceedings{shlain2020syntactic,
  author = {Micah Shlain and Hillel Taub-Tabib and Shoval Sadde and Yoav Goldberg},
  title = {{Syntactic Search by Example}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2020},
  doi = {10.18653/v1/2020.acl-demos.3},
}
Figure