#๐Ÿ”’ My BibTeX retrieval code doesn't work as I want it to, rejects paper names that are too correct

12 messages ยท Page 1 of 1 (latest)

wicked capeBOT
#

@outer beacon

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

outer beacon
#

Hello can I have some help fixing an issue with my code?,

This is my code:

!pip install scholarly
!pip install pybtex

from scholarly import scholarly

def get_bibtex_citation(paper_title):
    # Search for the publication by title
    search_query = scholarly.search_pubs(paper_title)
    
    try:
        # Get the first result from the search query
        publication = next(search_query)
        
        # Fill in the details of the publication
        filled_publication = scholarly.fill(publication)
        
        # Get the BibTeX citation for the filled publication
        bibtex_citation = scholarly.bibtex(filled_publication)
        
        return bibtex_citation
    except StopIteration:
        return "No publication found with the given title."

paper_title = "A generalized least-square matrix decomposi" # <----=----{Input Paper Name Into Here}----=----
bibtex_citation = get_bibtex_citation(paper_title)
print(bibtex_citation)

which is built to retrieve BibTeX citation's when given a paper's name. It uses the scholarly/pybtex libraries to achieve this. It's still not very functional as it gets rate-limited incredibly quickly, but that isn't the issue I want help with (yet).

#

If I run this code, it will produce the output:

No publication found with the given title.

#

However, if I change the variable string paper_title to "A generalized least-square matrix decompos" instead of ""A generalized least-square matrix decomposition", it will start working.

#

I've noticed it stops working when if you input the name of the paper into google scholar, it only shows you that 1 paper:

#

When I use the string "A generalized least-square matrix decompos", it works perfectly fine.

#

Could I have some guidance on a work around? Because I want to make a program that can fetch BibTeX citations using both exactly and near the paper name.

#

(Output if I use the less complete paper name: )

@article{allen2014generalized,
 abstract = {norm, our decomposition, entitled the generalized least-square matrix decomposition (GMD),   often irrelevant, we also regularize our matrix decomposition by adding two-way penalties},
 author = {Allen, Genevera I and Grosenick, Logan and Taylor, Jonathan},
 journal = {Journal of the American Statistical Association},
 number = {505},
 pages = {145--159},
 pub_year = {2014},
 publisher = {Taylor \& Francis},
 title = {A generalized least-square matrix decomposition},
 venue = {Journal of the American Statistical โ€ฆ},
 volume = {109}
}

(Which is the output I want)

wicked capeBOT
#

@outer beacon

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.