


"""simple docstring"""


import os
import string
import sys


_snake_case          =							1 << 8

_snake_case          =							{
    'tab': ord("\t"),
    'newline': ord("\r"),
    'esc': 27,
    'up': 65 + ARROW_KEY_FLAG,
    'down': 66 + ARROW_KEY_FLAG,
    'right': 67 + ARROW_KEY_FLAG,
    'left': 68 + ARROW_KEY_FLAG,
    'mod_int': 91,
    'undefined': sys.maxsize,
    'interrupt': 3,
    'insert': 50,
    'delete': 51,
    'pg_up': 53,
    'pg_down': 54,
}

_snake_case          =							KEYMAP['up']
_snake_case          =							KEYMAP['left']

if sys.platform == "win32":
   _snake_case          =							[]
   _snake_case          =							{
       B'\xe0H': KEYMAP['up'] - ARROW_KEY_FLAG,
       B'\x00H': KEYMAP['up'] - ARROW_KEY_FLAG,
       B'\xe0P': KEYMAP['down'] - ARROW_KEY_FLAG,
       B'\x00P': KEYMAP['down'] - ARROW_KEY_FLAG,
       B'\xe0M': KEYMAP['right'] - ARROW_KEY_FLAG,
       B'\x00M': KEYMAP['right'] - ARROW_KEY_FLAG,
       B'\xe0K': KEYMAP['left'] - ARROW_KEY_FLAG,
       B'\x00K': KEYMAP['left'] - ARROW_KEY_FLAG,
   }

for i in range(10):
   _snake_case          =							ord(str(i))



def   snake_case						(				)->		Tuple:
      '''simple docstring'''


      if os.name == "nt":
            import msvcrt

            lowerCamelCase__           =		'mbcs'
            # Flush the keyboard buffer
            while msvcrt.kbhit():
                  msvcrt.getch()
            if len(__lowerCAmelCase							) == 0:
                  # Read the keystroke
                  lowerCamelCase__           =		msvcrt.getch()

                  # If it is a prefix char, get second part
                  if ch in (b"\x00", b"\xe0"):
                        lowerCamelCase__           =		ch + msvcrt.getch()
                        # Translate actual Win chars to bullet char types
                        try:
                              lowerCamelCase__           =		chr(WIN_KEYMAP[cha]							)
                              WIN_CH_BUFFER.append(chr(KEYMAP['mod_int']							)							)
                              WIN_CH_BUFFER.append(__lowerCAmelCase							)
                              if ord(__lowerCAmelCase							) in (
                                  KEYMAP["insert"] - 1 << 9,
                                  KEYMAP["delete"] - 1 << 9,
                                  KEYMAP["pg_up"] - 1 << 9,
                                  KEYMAP["pg_down"] - 1 << 9,
                              ):
                                    WIN_CH_BUFFER.append(chr(126							)							)
                              lowerCamelCase__           =		chr(KEYMAP['esc']							)
                        except KeyError:
                              lowerCamelCase__           =		cha[1]
                  else:
                        lowerCamelCase__           =		ch.decode(__lowerCAmelCase							)
            else:
                  lowerCamelCase__           =		WIN_CH_BUFFER.pop(0							)
      elif os.name == "posix":
            import termios
            import tty

            lowerCamelCase__           =		sys.stdin.fileno()
            lowerCamelCase__           =		termios.tcgetattr(__lowerCAmelCase							)
            try:
                  tty.setraw(__lowerCAmelCase							)
                  lowerCamelCase__           =		sys.stdin.read(1							)
            finally:
                  termios.tcsetattr(__lowerCAmelCase		,   termios.TCSADRAIN		,   __lowerCAmelCase							)
      return ch






def   snake_case						(				)->		List[Any]:
      '''simple docstring'''


      lowerCamelCase__           =		get_raw_chars()
      if ord(__lowerCAmelCase							) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
            return char

      elif ord(__lowerCAmelCase							) == KEYMAP["esc"]:
            lowerCamelCase__           =		get_raw_chars()
            if ord(__lowerCAmelCase							) == KEYMAP["mod_int"]:
                  lowerCamelCase__           =		get_raw_chars()
                  if ord(__lowerCAmelCase							) >= KEYMAP["arrow_begin"] - ARROW_KEY_FLAG and ord(__lowerCAmelCase							) <= KEYMAP["arrow_end"] - ARROW_KEY_FLAG:
                        return chr(ord(__lowerCAmelCase							) + ARROW_KEY_FLAG							)
                  else:
                        return KEYMAP["undefined"]
            else:
                  return get_raw_chars()

      else:
            if char in string.printable:
                  return char
            else:
                  return KEYMAP["undefined"]







"""simple docstring"""


import argparse
import json

from tqdm import tqdm



def   snake_case						(				)->		List[Any]:
      '''simple docstring'''


      lowerCamelCase__           =		argparse.ArgumentParser()

      # Required parameters
      parser.add_argument(
          '--src_path'		,   type=_a		,   default='biencoder-nq-dev.json'		,   help='Path to raw DPR training data'		,   )
      parser.add_argument(
          '--evaluation_set'		,   type=_a		,   help='where to store parsed evaluation_set file'		,   )
      parser.add_argument(
          '--gold_data_path'		,   type=_a		,   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(_a							)
            for dpr_record in tqdm(_a							):
                  lowerCamelCase__           =		dpr_record['question']
                  lowerCamelCase__           =		[context['title'] for context in dpr_record['positive_ctxs']]
                  eval_file.write(question + '\n'							)
                  gold_file.write('\t'.join(_a							) + '\n'							)


if __name__ == "__main__":
   main()



