




import argparse
import json

from tqdm import tqdm
def 		a_							( ):
  lowerCAmelCase__										=      argparse.ArgumentParser()

  # Required parameters
  parser.add_argument(
      '''--src_path'''   , type=__lowerCAmelCase   , default='''biencoder-nq-dev.json'''   , help='''Path to raw DPR training data'''   , )
  parser.add_argument(
      '''--evaluation_set'''   , type=__lowerCAmelCase   , help='''where to store parsed evaluation_set file'''   , )
  parser.add_argument(
      '''--gold_data_path'''   , type=__lowerCAmelCase   , help='''where to store parsed gold_data_path file'''   , )
  lowerCAmelCase__										=      parser.parse_args()

  with open(args.src_path   , '''r'''				) as src_file, open(args.evaluation_set   , '''w'''				) as eval_file, open(
      args.gold_data_path   , '''w'''				) as gold_file:
    lowerCAmelCase__										=      json.load(__lowerCAmelCase				)
    for dpr_record in tqdm(__lowerCAmelCase				):
      lowerCAmelCase__										=      dpr_record['''question''']
      lowerCAmelCase__										=      [context['''title'''] for context in dpr_record['''positive_ctxs''']]
      eval_file.write(question + '''\n'''				)
      gold_file.write('''\t'''.join(__lowerCAmelCase				) + '''\n'''				)


if __name__ == "__main__":
      main()







import webbrowser
from sys import argv
from urllib.parse import parse_qs, quote

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

if __name__ == "__main__":
      __magic_name__  :  List[Any]					=       """%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: """)))

      print("""Googling.....""")

      __magic_name__  :  List[Any]					=       F"https://www.google.com/search?q={query}&num=100"

      __magic_name__  :  Union[str, Any]					=       requests.get(
          url,
          headers={"""User-Agent""": str(UserAgent().random)},
      )

      try:
            __magic_name__  :  Optional[Any]					=       (
                BeautifulSoup(res.text, """html.parser""")
                .find("""div""", attrs={"""class""": """yuRUbf"""})
                .find("""a""")
                .get("""href""")
            )

      except AttributeError:
            __magic_name__  :  List[Any]					=       parse_qs(
                BeautifulSoup(res.text, """html.parser""")
                .find("""div""", attrs={"""class""": """kCrYT"""})
                .find("""a""")
                .get("""href""")
            )["""url"""][0]

      webbrowser.open(link)

