Utils
count_tokens(text)
Counts the number of tokens in a given text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The text to tokenize. |
required |
Returns:
Name | Type | Description |
---|---|---|
int | The number of tokens in |
Examples:
>>> count_tokens("This is a sentence.")
6
Notes
The encoding used is determined by the tiktoken.encoding_for_model
function.
Source code in autoresearcher/utils/count_tokens.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
generate_keyword_combinations(research_question)
Generates keyword combinations for a given research question.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
research_question |
str
|
The research question to generate keyword combinations for. |
required |
Returns:
Name | Type | Description |
---|---|---|
list | A list of keyword combinations for the given research question. |
Examples:
>>> generate_keyword_combinations("What is the impact of AI on healthcare?")
["AI healthcare", "impact AI healthcare", "AI healthcare impact"]
Source code in autoresearcher/utils/generate_keyword_combinations.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
get_citation_by_doi(doi)
Retrieves a citation for a given DOI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doi |
str
|
The DOI of the citation to retrieve. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | The citation for the given DOI. |
Raises:
Type | Description |
---|---|
ValueError
|
If the response is not valid JSON. |
Notes
Requires an email address to be set in the EMAIL environment variable.
Examples:
>>> get_citation_by_doi("10.1038/s41586-020-2003-7")
"Liu, Y., Chen, X., Han, M., Li, Y., Li, L., Zhang, J., ... & Zhang, Y. (2020). A SARS-CoV-2 protein interaction map reveals targets for drug repurposing. Nature, 581(7809), 561-570."
Source code in autoresearcher/utils/get_citations.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|