transmute

package module
v0.0.0-...-492a895 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 5 Imported by: 13

README

gopher

transmute

GoDoc Go Report Card gocover

PubMed/Medline Query Transpiler

The goal of transmute is to provide a way of transforming PubMed/Medline search strategies from systematic reviews into other queries suitable for other search engines. The result of the transformation is an immediate representation which can be analysed with greater ease or transformed again run on other search engines. This is why transmute is described as a transpiler. An immediate representation allows trivial transformation to boolean queries acceptable by search engines, such as Elasticsearch.

An example of a Medline and Pubmed query are:

1. MMSE*.ti,ab.
2. sMMSE.ti,ab.
3. Folstein*.ti,ab.
4. MiniMental.ti,ab.
5. \"mini mental stat*\".ti,ab.
6. or/1-5
(\"Contraceptive Agents, Female\"[Mesh] OR \"Contraceptive Devices, Female\"[Mesh] OR contracept*[tiab]) AND (\"Body Weight\"[Mesh] OR weight[tiab] OR \"Body Mass Index\"[Mesh]) NOT (cancer*[ti] OR polycystic [ti] OR exercise [ti] OR physical activity[ti] OR postmenopaus*[ti])

Both are valid Pubmed and Medline search strategies reported in real systematic reviews; transmute can currently transform both Medline and PubMed queries. An example API usage by constructing a pipeline and executing it is shown in the next section.

API Usage

Here we construct a pipeline in Go:

query := `1. MMSE*.ti,ab.
2. sMMSE.ti,ab.
3. Folstein*.ti,ab.
4. MiniMental.ti,ab.
5. \"mini mental stat*\".ti,ab.
6. or/1-5`

p := transmute.pipeline.NewPipeline(transmute.parser.NewMedlineParser(),
                                    transmute.backend.NewElasticsearchCompiler(),
                                    transmute.pipeline.TransmutePipelineOptions{RequiresLexing: true})
dsl, err := p.Execute(query)
if err != nil {
    panic(err)
}

println(dsl.StringPretty())

Which results in:

{
    "query": {
        "bool": {
            "disable_coord": true,
            "should": [
                {
                    "bool": {
                        "should": [
                            {
                                "wildcard": {
                                    "title": "MMSE*"
                                }
                            },
                            {
                                "wildcard": {
                                    "abstract": "MMSE*"
                                }
                            }
                        ]
                    }
                },
                {
                    "multi_match": {
                        "fields": [
                            "title",
                            "abstract"
                        ],
                        "query": "sMMSE"
                    }
                },
                {
                    "bool": {
                        "should": [
                            {
                                "wildcard": {
                                    "title": "Folstein*"
                                }
                            },
                            {
                                "wildcard": {
                                    "abstract": "Folstein*"
                                }
                            }
                        ]
                    }
                },
                {
                    "multi_match": {
                        "fields": [
                            "title",
                            "abstract"
                        ],
                        "query": "MiniMental"
                    }
                },
                {
                    "bool": {
                        "should": [
                            {
                                "wildcard": {
                                    "title": "\"mini mental stat*\""
                                }
                            },
                            {
                                "wildcard": {
                                    "abstract": "\"mini mental stat*\""
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

Command Line Usage

As well as being a well-documented library, transmute can also be used on the command line. Since it is still in development, it can be built from source with go tools:

go get -u github.com/hscells/transmute/cmd/transmute
transmute --help
transmute --input mmse.query --parser medline --backend elasticsearch

The output of the command line pretty-prints the same output from above.

Assumptions

The goal of transmute is to parse and transform PubMed/Medline queries into queries suitable for other search engines. However, the project makes some assumptions about the query:

  • The parser does not attempt to simplify boolean expressions, so badly written queries will remain inefficient.
  • A query cannot compile to Elasticsearch when it contains an adjacency operator with more than one field. This is due to a limitation with Elasticsearch.

Extending

If you would like to extend transmute and create a new backend for it, have a read of the documentation. As this should lead you in the right direction. Writing a new backend requires the transformation of the immediate representation into the target query language.

Citing

If you use this work for scientific publication, please reference

@inproceedings{scells2018framework,
 author = {Scells, Harrisen and Locke, Daniel and Zuccon, Guido},
 title = {An Information Retrieval Experiment Framework for Domain Specific Applications},
 booktitle = {The 41st International ACM SIGIR Conference on Research \& Development in Information Retrieval},
 series = {SIGIR '18},
 year = {2018},
} 

The Go gopher was created by Renee French, licensed under Creative Commons 3.0 Attributions license.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Medline2Cqr = pipeline.NewPipeline(
		parser.NewMedlineParser(),
		backend.NewCQRBackend(),
		pipeline.TransmutePipelineOptions{
			LexOptions: lexer.LexOptions{
				FormatParenthesis: false,
			},
			AddRedundantParenthesis: true,
			RequiresLexing:          true,
		})
	Pubmed2Cqr = pipeline.NewPipeline(
		parser.NewPubMedParser(),
		backend.NewCQRBackend(),
		pipeline.TransmutePipelineOptions{
			LexOptions: lexer.LexOptions{
				FormatParenthesis: true,
			},
			AddRedundantParenthesis: true,
			RequiresLexing:          false,
		})
	Cqr2Medline = pipeline.NewPipeline(
		parser.NewCQRParser(),
		backend.NewMedlineBackend(),
		pipeline.TransmutePipelineOptions{
			LexOptions: lexer.LexOptions{
				FormatParenthesis: false,
			},
			RequiresLexing:          false,
			AddRedundantParenthesis: false,
		})
	Cqr2Pubmed = pipeline.NewPipeline(
		parser.NewCQRParser(),
		backend.NewPubmedBackend(),
		pipeline.TransmutePipelineOptions{
			LexOptions: lexer.LexOptions{
				FormatParenthesis: false,
			},
			RequiresLexing:          false,
			AddRedundantParenthesis: false,
		})
)

Functions

func CompileCqr2Medline

func CompileCqr2Medline(q cqr.CommonQueryRepresentation) (string, error)

func CompileCqr2PubMed

func CompileCqr2PubMed(q cqr.CommonQueryRepresentation) (string, error)

func CompileCqr2String

func CompileCqr2String(q cqr.CommonQueryRepresentation) (string, error)

func CompileMedline2Cqr

func CompileMedline2Cqr(q string) (cqr.CommonQueryRepresentation, error)

func CompilePubmed2Cqr

func CompilePubmed2Cqr(q string) (cqr.CommonQueryRepresentation, error)

func CompileString2Cqr

func CompileString2Cqr(q string) (cqr.CommonQueryRepresentation, error)

Types

This section is empty.

Directories

Path Synopsis
Package backend contains translation code from the immediate representation into a concrete query usable by a search engine.
Package backend contains translation code from the immediate representation into a concrete query usable by a search engine.
cmd
package fields provides default mappings for transmute and cqr fields.
package fields provides default mappings for transmute and cqr fields.
Package ir contains code relating to the immediate representation query structure of a search strategy.
Package ir contains code relating to the immediate representation query structure of a search strategy.
Package lexer build a query tree from the search strategy.
Package lexer build a query tree from the search strategy.
Package parser parses the query strings inside a search strategy.
Package parser parses the query strings inside a search strategy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL