import string


def query_to_url(query, search_type, size):
  """convert query to usuable url

  Args:
      query (str): search query by user
      search_type (str): Search type (choice)
      size (int): number of items to query

  Returns:
      (str) the url for search
  """  

  # remove bad string & convert txt -> search keys
  query = query.translate(str.maketrans('', '', string.punctuation))
  query = query.replace(" ", "+")

  # get the correct mapping  
  mapping = {"All Fields": "",
             "Title": "title",
             "Abstract": "abstract"}
  
  search_type = mapping[search_type]

  #return the url
  return f"https://arxiv.org/search/?query={query}&searchtype={search_type}&abstracts=show&order=&size={size}"