Translate
The translate
functionality converts a search query written
for one platform into the correct syntax for another platform
This is useful when running the same query
across multiple literature databases (e.g., PubMed, Web of Science, or
EBSCO) without rewriting it manually.
In the example below, a query in PubMed syntax is first assigned to a
query_string variable. This string now needs to be parsed by calling the
parse()
function with the string and platform as the input. Using
query.translate()
, it is converted into the Web of Science (wos
)
format. The to_string()
method then outputs the query in the proper
syntax for that platform.
1from search_query.parser import parse
2
3query_string = '("digital health"[Title/Abstract]) AND ("privacy"[Title/Abstract])'
4query = parse(query_string, platform="pubmed")
5wos_query = query.translate(target_syntax="wos")
6print(wos_query.to_string())
7# Output:
8# (AB="digital health" OR TI="digital health") AND (AB="privacy" OR TI="privacy")