Code Monkey home page Code Monkey logo

Comments (2)

lukasschwab avatar lukasschwab commented on August 27, 2024 1

Thanks for the easy instructions for reproducing this!

The whitespace here is returned by the underlying arXiv API. It seems to be a ragged line wrap at 80 characters arXiv introduces themselves, but authors can validly include newlines of their own to break paragraphs (at least in abstracts):

So if you want a new paragraph or a table of contents, be sure to indent the lines after the carriage return.

I'd like to find an example paper with a multiparagraph abstract to confirm how this is represented by the API; "strip all newlines that aren't followed by whitespace" may be a valid rule here.

As far as I know, titles can never include user input newlines, so this might be a more straightforward place to strip them. I'm a little concerned about introducing a find-and-replace operation on every query result. I'll shoot an email to the arXiv API Google Group about this behavior.

In the mean time, a small function for stripping newlines that aren't followed by whitespace from strings:

import re

def rm_newlines(entry):
  rm_newlines = lambda s: re.sub(r'\n[^\s]', ' ', res)
  entry.title = rm_newlines(entry.title)
  entry.summary = rm_newlines(entry.summary)
  return entry

from arxiv.py.

lukasschwab avatar lukasschwab commented on August 27, 2024

Sounds like this was a bug introduced into the API itself (link to the Google Group message), but the arXiv API is likely frozen while they work on a new JSON API to replace the current Atom API.

from arxiv.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.