repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
allenai/allennlp
scripts/check_requirements_and_setup.py
parse_requirements
def parse_requirements() -> Tuple[PackagesType, PackagesType, Set[str]]: """Parse all dependencies out of the requirements.txt file.""" essential_packages: PackagesType = {} other_packages: PackagesType = {} duplicates: Set[str] = set() with open("requirements.txt", "r") as req_file: section: str = "" for line in req_file: line = line.strip() if line.startswith("####"): # Line is a section name. section = parse_section_name(line) continue if not line or line.startswith("#"): # Line is empty or just regular comment. continue module, version = parse_package(line) if module in essential_packages or module in other_packages: duplicates.add(module) if section.startswith("ESSENTIAL"): essential_packages[module] = version else: other_packages[module] = version return essential_packages, other_packages, duplicates
python
def parse_requirements() -> Tuple[PackagesType, PackagesType, Set[str]]: """Parse all dependencies out of the requirements.txt file.""" essential_packages: PackagesType = {} other_packages: PackagesType = {} duplicates: Set[str] = set() with open("requirements.txt", "r") as req_file: section: str = "" for line in req_file: line = line.strip() if line.startswith("####"): # Line is a section name. section = parse_section_name(line) continue if not line or line.startswith("#"): # Line is empty or just regular comment. continue module, version = parse_package(line) if module in essential_packages or module in other_packages: duplicates.add(module) if section.startswith("ESSENTIAL"): essential_packages[module] = version else: other_packages[module] = version return essential_packages, other_packages, duplicates
[ "def", "parse_requirements", "(", ")", "->", "Tuple", "[", "PackagesType", ",", "PackagesType", ",", "Set", "[", "str", "]", "]", ":", "essential_packages", ":", "PackagesType", "=", "{", "}", "other_packages", ":", "PackagesType", "=", "{", "}", "duplicates", ":", "Set", "[", "str", "]", "=", "set", "(", ")", "with", "open", "(", "\"requirements.txt\"", ",", "\"r\"", ")", "as", "req_file", ":", "section", ":", "str", "=", "\"\"", "for", "line", "in", "req_file", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "line", ".", "startswith", "(", "\"####\"", ")", ":", "# Line is a section name.", "section", "=", "parse_section_name", "(", "line", ")", "continue", "if", "not", "line", "or", "line", ".", "startswith", "(", "\"#\"", ")", ":", "# Line is empty or just regular comment.", "continue", "module", ",", "version", "=", "parse_package", "(", "line", ")", "if", "module", "in", "essential_packages", "or", "module", "in", "other_packages", ":", "duplicates", ".", "add", "(", "module", ")", "if", "section", ".", "startswith", "(", "\"ESSENTIAL\"", ")", ":", "essential_packages", "[", "module", "]", "=", "version", "else", ":", "other_packages", "[", "module", "]", "=", "version", "return", "essential_packages", ",", "other_packages", ",", "duplicates" ]
Parse all dependencies out of the requirements.txt file.
[ "Parse", "all", "dependencies", "out", "of", "the", "requirements", ".", "txt", "file", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/check_requirements_and_setup.py#L32-L60
train
Parse all dependencies out of the requirements. txt file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,s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,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b101 + 0o53) + '\x6f' + '\061' + chr(0b110110) + chr(0b1111 + 0o47), 0b1000), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1000110 + 0o51) + chr(51) + chr(0b100100 + 0o22) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b100110 + 0o15) + '\067' + chr(0b101010 + 0o14), 0b1000), ehT0Px3KOsy9(chr(0b10101 + 0o33) + '\x6f' + '\x31' + '\067' + chr(0b110010 + 0o5), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\x31' + chr(2142 - 2090) + '\x31', 53495 - 53487), ehT0Px3KOsy9(chr(48) + chr(111) + chr(49) + chr(0b10 + 0o61), 0o10), ehT0Px3KOsy9('\060' + chr(10555 - 10444) + chr(0b110011) + chr(2742 - 2689) + '\x30', 46537 - 46529), ehT0Px3KOsy9(chr(48) + chr(6489 - 6378) + chr(0b110010 + 0o1) + chr(50) + '\060', 0o10), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101111) + chr(0b1011 + 0o50) + chr(280 - 225), 57159 - 57151), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110010) + chr(0b101101 + 0o12) + chr(49), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + chr(0b110110) + '\060', 0b1000), ehT0Px3KOsy9(chr(48) + chr(9745 - 9634) + chr(0b100011 + 0o20) + chr(0b110111) + '\x34', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\x32' + '\x31', 0o10), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(0b100001 + 0o116) + chr(2501 - 2449) + chr(2485 - 2434), ord("\x08")), ehT0Px3KOsy9(chr(1168 - 1120) + '\157' + chr(51) + chr(2084 - 2034) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b100101 + 0o13) + '\157' + '\x32' + '\060' + '\x36', 15044 - 15036), ehT0Px3KOsy9('\x30' + chr(11794 - 11683) + '\x31' + '\067' + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(111) + chr(1266 - 1216) + '\x36' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(1735 - 1687) + chr(2144 - 2033) + chr(2386 - 2336) + '\061' + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(11804 - 11693) + '\x32' + chr(0b110110) + chr(0b0 + 0o61), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + '\x37' + chr(0b110110), 8), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + chr(1974 - 1919) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(0b1110 + 0o42) + '\x6f' + '\x31' + chr(807 - 757) + '\x30', 25089 - 25081), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101000 + 0o11) + '\067' + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(4928 - 4817) + '\063' + chr(0b110101) + chr(0b110001), 62768 - 62760), ehT0Px3KOsy9(chr(979 - 931) + chr(0b1101101 + 0o2) + chr(509 - 459) + chr(0b110001 + 0o6) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(540 - 491) + chr(0b110001), 55904 - 55896), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\062' + chr(144 - 90) + chr(0b110010), 31608 - 31600), ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(111) + chr(50) + chr(51) + chr(0b10001 + 0o43), 0o10), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(0b1011 + 0o144) + '\065' + chr(0b110010), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110010) + '\x37' + chr(0b1100 + 0o53), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(51) + chr(50) + chr(0b110011), 12122 - 12114), ehT0Px3KOsy9(chr(0b110000) + chr(9922 - 9811) + chr(0b110011) + '\067' + chr(0b101001 + 0o11), 39402 - 39394), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + chr(961 - 908) + chr(0b10010 + 0o45), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1247 - 1197) + chr(52) + '\064', 0b1000), ehT0Px3KOsy9(chr(1788 - 1740) + '\x6f' + chr(49) + chr(1445 - 1391) + chr(0b110110), 8), ehT0Px3KOsy9(chr(0b111 + 0o51) + '\x6f' + '\061' + '\x32' + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b100110 + 0o111) + chr(51) + chr(1997 - 1949) + chr(49), 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\157' + chr(2291 - 2242) + '\067' + '\x37', 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(49) + chr(52) + '\066', 42912 - 42904)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(111) + chr(53) + chr(0b110000), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'X'), '\144' + chr(7205 - 7104) + chr(99) + chr(111) + '\144' + chr(2935 - 2834))(chr(0b1000110 + 0o57) + chr(9420 - 9304) + chr(3262 - 3160) + chr(0b101101) + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def u_fwmzLUNOPL() -> MRK8Uzg2En3D[HDxRagCwXJZ_, HDxRagCwXJZ_, nRCEkXkGnMeI[M8_cKLkHVB2V]]: hcRA1fmNrNgE = {} yhcARcZzeAar = {} TJgV3vuHy3_X = MVEN8G6CxlvR() with _fwkIVCGgtAN(xafqLlk3kkUe(SXOLrMavuUCe(b'\x04\x93\x8f\n\x08y\x8d\xbdz\xd7\xc4\x8f?W\xae\xf2'), chr(100) + chr(6529 - 6428) + '\143' + chr(111) + '\x64' + '\145')('\x75' + '\x74' + chr(0b1001010 + 0o34) + '\x2d' + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x04'), '\x64' + chr(101) + chr(8596 - 8497) + '\x6f' + chr(0b1100100) + '\x65')('\165' + '\x74' + '\x66' + chr(0b10100 + 0o31) + chr(0b110010 + 0o6))) as l3EJ7aNZN_WV: zhibvHFgaDZW = xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(2470 - 2370) + '\x65' + chr(99) + chr(5043 - 4932) + chr(0b1010100 + 0o20) + chr(4678 - 4577))(chr(0b1011010 + 0o33) + chr(116) + chr(0b1100110) + '\x2d' + chr(0b110000 + 0o10)) for LycYkDpyelF6 in l3EJ7aNZN_WV: LycYkDpyelF6 = LycYkDpyelF6.strip() if xafqLlk3kkUe(LycYkDpyelF6, xafqLlk3kkUe(SXOLrMavuUCe(b'\x05\x82\x9f\r\x15x\x9f\xb9k\xd1'), chr(0b1000011 + 0o41) + chr(0b1 + 0o144) + chr(5676 - 5577) + chr(4515 - 4404) + chr(6324 - 6224) + chr(3439 - 3338))('\x75' + chr(0b1000011 + 0o61) + '\x66' + chr(0b101101) + chr(0b101111 + 0o11)))(xafqLlk3kkUe(SXOLrMavuUCe(b'U\xd5\xdd\\'), '\144' + chr(101) + chr(6659 - 6560) + chr(0b1101111) + '\x64' + chr(101))(chr(0b10011 + 0o142) + chr(9651 - 9535) + chr(102) + chr(449 - 404) + '\x38')): zhibvHFgaDZW = CmbtAbC9Gl_R(LycYkDpyelF6) continue if not LycYkDpyelF6 or xafqLlk3kkUe(LycYkDpyelF6, xafqLlk3kkUe(SXOLrMavuUCe(b'\x05\x82\x9f\r\x15x\x9f\xb9k\xd1'), '\x64' + chr(101) + chr(99) + '\157' + chr(5420 - 5320) + chr(6177 - 6076))(chr(0b1110001 + 0o4) + chr(5290 - 5174) + chr(0b1100110) + chr(45) + chr(0b100110 + 0o22)))(xafqLlk3kkUe(SXOLrMavuUCe(b'U'), chr(0b1001100 + 0o30) + chr(0b1010101 + 0o20) + chr(99) + chr(0b1101111) + chr(0b0 + 0o144) + chr(101))(chr(0b1010 + 0o153) + '\164' + chr(5823 - 5721) + '\x2d' + chr(0b100 + 0o64))): continue (RqocVGOryNPv, cpMfQ_4_Vb7C) = kS7ocH__HbSg(LycYkDpyelF6) if RqocVGOryNPv in hcRA1fmNrNgE or RqocVGOryNPv in yhcARcZzeAar: xafqLlk3kkUe(TJgV3vuHy3_X, xafqLlk3kkUe(SXOLrMavuUCe(b'\x03\xbc\xce\x0eXh\xaf\xe5E\xf6\xe2\xcf'), '\144' + '\x65' + '\143' + chr(5828 - 5717) + chr(0b100111 + 0o75) + '\145')(chr(0b110111 + 0o76) + chr(0b1110100) + chr(0b1011 + 0o133) + chr(986 - 941) + '\x38'))(RqocVGOryNPv) if xafqLlk3kkUe(zhibvHFgaDZW, xafqLlk3kkUe(SXOLrMavuUCe(b'\x05\x82\x9f\r\x15x\x9f\xb9k\xd1'), chr(3860 - 3760) + '\145' + '\x63' + chr(0b1101111) + chr(5254 - 5154) + chr(0b1000110 + 0o37))(chr(0b1011111 + 0o26) + chr(0b1110100) + chr(102) + '\x2d' + chr(0b111000)))(xafqLlk3kkUe(SXOLrMavuUCe(b'3\xa5\xad:/_\xa1\x91S'), chr(100) + '\145' + chr(99) + chr(0b1010110 + 0o31) + chr(100) + '\145')(chr(4320 - 4203) + chr(3449 - 3333) + '\x66' + '\x2d' + chr(56))): hcRA1fmNrNgE[RqocVGOryNPv] = cpMfQ_4_Vb7C else: yhcARcZzeAar[RqocVGOryNPv] = cpMfQ_4_Vb7C return (hcRA1fmNrNgE, yhcARcZzeAar, TJgV3vuHy3_X)
allenai/allennlp
scripts/check_requirements_and_setup.py
parse_setup
def parse_setup() -> Tuple[PackagesType, PackagesType, Set[str], Set[str]]: """Parse all dependencies out of the setup.py script.""" essential_packages: PackagesType = {} test_packages: PackagesType = {} essential_duplicates: Set[str] = set() test_duplicates: Set[str] = set() with open('setup.py') as setup_file: contents = setup_file.read() # Parse out essential packages. package_string = re.search(r"""install_requires=\[[\s\n]*['"](.*?)['"],?[\s\n]*\]""", contents, re.DOTALL).groups()[0].strip() for package in re.split(r"""['"],[\s\n]+['"]""", package_string): module, version = parse_package(package) if module in essential_packages: essential_duplicates.add(module) else: essential_packages[module] = version # Parse packages only needed for testing. package_string = re.search(r"""tests_require=\[[\s\n]*['"](.*?)['"],?[\s\n]*\]""", contents, re.DOTALL).groups()[0].strip() for package in re.split(r"""['"],[\s\n]+['"]""", package_string): module, version = parse_package(package) if module in test_packages: test_duplicates.add(module) else: test_packages[module] = version return essential_packages, test_packages, essential_duplicates, test_duplicates
python
def parse_setup() -> Tuple[PackagesType, PackagesType, Set[str], Set[str]]: """Parse all dependencies out of the setup.py script.""" essential_packages: PackagesType = {} test_packages: PackagesType = {} essential_duplicates: Set[str] = set() test_duplicates: Set[str] = set() with open('setup.py') as setup_file: contents = setup_file.read() # Parse out essential packages. package_string = re.search(r"""install_requires=\[[\s\n]*['"](.*?)['"],?[\s\n]*\]""", contents, re.DOTALL).groups()[0].strip() for package in re.split(r"""['"],[\s\n]+['"]""", package_string): module, version = parse_package(package) if module in essential_packages: essential_duplicates.add(module) else: essential_packages[module] = version # Parse packages only needed for testing. package_string = re.search(r"""tests_require=\[[\s\n]*['"](.*?)['"],?[\s\n]*\]""", contents, re.DOTALL).groups()[0].strip() for package in re.split(r"""['"],[\s\n]+['"]""", package_string): module, version = parse_package(package) if module in test_packages: test_duplicates.add(module) else: test_packages[module] = version return essential_packages, test_packages, essential_duplicates, test_duplicates
[ "def", "parse_setup", "(", ")", "->", "Tuple", "[", "PackagesType", ",", "PackagesType", ",", "Set", "[", "str", "]", ",", "Set", "[", "str", "]", "]", ":", "essential_packages", ":", "PackagesType", "=", "{", "}", "test_packages", ":", "PackagesType", "=", "{", "}", "essential_duplicates", ":", "Set", "[", "str", "]", "=", "set", "(", ")", "test_duplicates", ":", "Set", "[", "str", "]", "=", "set", "(", ")", "with", "open", "(", "'setup.py'", ")", "as", "setup_file", ":", "contents", "=", "setup_file", ".", "read", "(", ")", "# Parse out essential packages.", "package_string", "=", "re", ".", "search", "(", "r\"\"\"install_requires=\\[[\\s\\n]*['\"](.*?)['\"],?[\\s\\n]*\\]\"\"\"", ",", "contents", ",", "re", ".", "DOTALL", ")", ".", "groups", "(", ")", "[", "0", "]", ".", "strip", "(", ")", "for", "package", "in", "re", ".", "split", "(", "r\"\"\"['\"],[\\s\\n]+['\"]\"\"\"", ",", "package_string", ")", ":", "module", ",", "version", "=", "parse_package", "(", "package", ")", "if", "module", "in", "essential_packages", ":", "essential_duplicates", ".", "add", "(", "module", ")", "else", ":", "essential_packages", "[", "module", "]", "=", "version", "# Parse packages only needed for testing.", "package_string", "=", "re", ".", "search", "(", "r\"\"\"tests_require=\\[[\\s\\n]*['\"](.*?)['\"],?[\\s\\n]*\\]\"\"\"", ",", "contents", ",", "re", ".", "DOTALL", ")", ".", "groups", "(", ")", "[", "0", "]", ".", "strip", "(", ")", "for", "package", "in", "re", ".", "split", "(", "r\"\"\"['\"],[\\s\\n]+['\"]\"\"\"", ",", "package_string", ")", ":", "module", ",", "version", "=", "parse_package", "(", "package", ")", "if", "module", "in", "test_packages", ":", "test_duplicates", ".", "add", "(", "module", ")", "else", ":", "test_packages", "[", "module", "]", "=", "version", "return", "essential_packages", ",", "test_packages", ",", "essential_duplicates", ",", "test_duplicates" ]
Parse all dependencies out of the setup.py script.
[ "Parse", "all", "dependencies", "out", "of", "the", "setup", ".", "py", "script", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/check_requirements_and_setup.py#L63-L93
train
Parse the setup. py script.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BX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SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(111) + '\062' + chr(0b110000) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x33' + chr(2572 - 2521) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x32' + chr(0b110101) + chr(48), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + '\x32' + chr(1026 - 974), ord("\x08")), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1101111) + chr(0b110011) + '\x31' + chr(48), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + chr(51) + chr(0b1111 + 0o46), 0o10), ehT0Px3KOsy9('\060' + chr(6515 - 6404) + chr(0b110001) + '\067' + chr(1734 - 1686), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(11934 - 11823) + chr(0b100010 + 0o23) + '\061', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101000 + 0o7) + chr(770 - 721) + chr(0b110111) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b110 + 0o52) + '\x6f' + chr(0b1110 + 0o45) + chr(0b110101) + chr(0b110000 + 0o2), 0o10), ehT0Px3KOsy9('\x30' + chr(0b10001 + 0o136) + '\063' + chr(55) + '\063', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1011000 + 0o27) + '\062' + chr(0b10100 + 0o40) + '\061', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063', 2054 - 2046), ehT0Px3KOsy9('\060' + chr(5303 - 5192) + chr(0b101 + 0o55) + chr(0b100110 + 0o13) + chr(1962 - 1914), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1100000 + 0o17) + chr(0b110010) + chr(48) + '\061', 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31' + '\x34' + '\x33', 0b1000), ehT0Px3KOsy9(chr(624 - 576) + chr(0b1110 + 0o141) + chr(51) + chr(1349 - 1298), 0o10), ehT0Px3KOsy9(chr(48) + chr(8754 - 8643) + '\063' + chr(0b100010 + 0o22) + chr(0b110110), 4210 - 4202), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(0b1101111) + chr(0b101 + 0o55) + chr(0b101111 + 0o1) + chr(0b110110), 36357 - 36349), ehT0Px3KOsy9(chr(798 - 750) + '\157' + chr(49) + chr(50) + chr(0b101111 + 0o5), 64449 - 64441), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1597 - 1546) + '\064' + chr(54), 8), ehT0Px3KOsy9('\060' + chr(111) + chr(309 - 257) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(1458 - 1410) + chr(0b1101111) + chr(0b11110 + 0o25) + chr(0b110000) + chr(0b100001 + 0o25), 54498 - 54490), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + chr(0b101011 + 0o11), ord("\x08")), ehT0Px3KOsy9(chr(2279 - 2231) + '\157' + '\x37' + '\060', 24471 - 24463), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + chr(55) + '\x30', 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b110000 + 0o77) + '\061' + chr(0b110010 + 0o2) + chr(48), 42646 - 42638), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + '\061', 0b1000), ehT0Px3KOsy9('\x30' + chr(7208 - 7097) + chr(0b10010 + 0o41) + chr(606 - 552) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\060' + chr(6698 - 6587) + '\061' + '\x34' + chr(1700 - 1648), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + chr(49) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(50) + '\061', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + chr(0b110100) + chr(48), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(49) + chr(273 - 218) + chr(53), 36208 - 36200), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110010) + chr(52) + chr(0b10011 + 0o43), 10761 - 10753), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x32' + '\x37' + chr(51), 36184 - 36176), ehT0Px3KOsy9(chr(48) + chr(111) + chr(49) + chr(0b110110) + '\x33', 0o10), ehT0Px3KOsy9('\060' + chr(10468 - 10357) + chr(0b110010) + chr(1810 - 1756) + chr(0b11010 + 0o27), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1006 - 956) + '\x37' + chr(0b1111 + 0o43), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b11010 + 0o125) + chr(0b10000 + 0o42) + '\x32' + chr(2046 - 1997), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + '\x35' + chr(48), 14492 - 14484)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xaf'), chr(100) + chr(0b1000111 + 0o36) + chr(0b111000 + 0o53) + '\157' + chr(2584 - 2484) + chr(3808 - 3707))('\x75' + chr(6075 - 5959) + '\146' + '\055' + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def MoBWMFE4QEb9() -> MRK8Uzg2En3D[HDxRagCwXJZ_, HDxRagCwXJZ_, nRCEkXkGnMeI[M8_cKLkHVB2V], nRCEkXkGnMeI[M8_cKLkHVB2V]]: hcRA1fmNrNgE = {} NEggJGWr0j_l = {} vctY4yR_9m3d = MVEN8G6CxlvR() fHPVNodjyCPg = MVEN8G6CxlvR() with _fwkIVCGgtAN(xafqLlk3kkUe(SXOLrMavuUCe(b'\xf2\xba\xdc\xa1\xb8s\x08P'), chr(100) + chr(101) + chr(0b1001111 + 0o24) + chr(0b1101111) + chr(100) + '\x65')(chr(0b1110101) + chr(116) + chr(102) + chr(45) + '\x38')) as pWwcfpHb0XXt: aqpRP5sxx_oP = pWwcfpHb0XXt.U6MiWrhuCi2Y() tUwIAk8fjE2e = _7u55U49WwX2.search(xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8\xb1\xdb\xa0\xa91\x14v\x0c\x8f\x8a\xd4j\xfa\xe4\x10&\xba\xdd\x0f\xbaV\x9azeR;>\xd29\xe6?\xcaB\x8f\xe0T\x93\xe7\xbd\xbe\x84\xf4\xa7\x943%\x03"\xb7'), chr(0b1011110 + 0o6) + '\x65' + '\143' + chr(111) + chr(0b11 + 0o141) + chr(101))('\x75' + chr(0b10000 + 0o144) + chr(0b1100110) + chr(45) + '\070'), aqpRP5sxx_oP, _7u55U49WwX2.DOTALL).groups()[ehT0Px3KOsy9(chr(48) + chr(0b1101011 + 0o4) + chr(48), ord("\x08"))].strip() for WposWUfRseFp in xafqLlk3kkUe(_7u55U49WwX2, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf2\xaf\xc4\xbd\xbc'), chr(100) + chr(0b101100 + 0o71) + chr(2819 - 2720) + '\x6f' + chr(7360 - 7260) + chr(1214 - 1113))('\165' + '\164' + chr(0b1000010 + 0o44) + chr(45) + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xda\xf8\x8a\x89\xe4\x06$Z"\x84\xa6\x8aX\xaf\xa3>'), chr(0b1100100) + chr(0b101111 + 0o66) + '\x63' + '\x6f' + chr(0b1100100) + '\145')('\165' + chr(0b101011 + 0o111) + chr(102) + chr(0b101001 + 0o4) + '\070'), tUwIAk8fjE2e): (RqocVGOryNPv, cpMfQ_4_Vb7C) = kS7ocH__HbSg(WposWUfRseFp) if RqocVGOryNPv in hcRA1fmNrNgE: xafqLlk3kkUe(vctY4yR_9m3d, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf4\x95\x98\xa5\xf1>?\x1c$\xa5\xa9\x92'), chr(7112 - 7012) + '\145' + chr(99) + chr(9700 - 9589) + '\144' + '\x65')(chr(0b1100 + 0o151) + chr(0b1000011 + 0o61) + chr(9587 - 9485) + '\055' + '\x38'))(RqocVGOryNPv) else: hcRA1fmNrNgE[RqocVGOryNPv] = cpMfQ_4_Vb7C tUwIAk8fjE2e = _7u55U49WwX2.search(xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5\xba\xdb\xa0\xbb\x02\nL\x0f\x9f\x92\xd3f\xb5\xdd8@\xba\xf5\x08\x88x\xecO\x1fZ=1\xdeN\xf18\xbbZ\x84\xe6_\x8e\xe1\xcd\xf2\x83\xc6\x89\xe2\x01%'), '\144' + '\145' + chr(99) + chr(111) + chr(0b1100100) + '\145')(chr(12728 - 12611) + chr(0b1110100) + chr(102) + '\055' + chr(0b111000)), aqpRP5sxx_oP, _7u55U49WwX2.DOTALL).groups()[ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b100100 + 0o14), 8)].strip() for WposWUfRseFp in xafqLlk3kkUe(_7u55U49WwX2, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf2\xaf\xc4\xbd\xbc'), chr(409 - 309) + chr(0b101011 + 0o72) + chr(99) + chr(0b100011 + 0o114) + '\144' + chr(8813 - 8712))('\165' + chr(13114 - 12998) + '\x66' + '\055' + chr(0b10001 + 0o47)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xda\xf8\x8a\x89\xe4\x06$Z"\x84\xa6\x8aX\xaf\xa3>'), '\144' + '\145' + chr(0b110010 + 0o61) + '\157' + '\144' + chr(101))('\x75' + chr(0b110010 + 0o102) + '\x66' + chr(0b101101) + '\x38'), tUwIAk8fjE2e): (RqocVGOryNPv, cpMfQ_4_Vb7C) = kS7ocH__HbSg(WposWUfRseFp) if RqocVGOryNPv in NEggJGWr0j_l: xafqLlk3kkUe(fHPVNodjyCPg, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf4\x95\x98\xa5\xf1>?\x1c$\xa5\xa9\x92'), chr(0b101011 + 0o71) + chr(0b1010000 + 0o25) + chr(0b1100011) + chr(4461 - 4350) + chr(3612 - 3512) + chr(4405 - 4304))(chr(0b0 + 0o165) + chr(11278 - 11162) + '\x66' + chr(0b10110 + 0o27) + chr(0b111000)))(RqocVGOryNPv) else: NEggJGWr0j_l[RqocVGOryNPv] = cpMfQ_4_Vb7C return (hcRA1fmNrNgE, NEggJGWr0j_l, vctY4yR_9m3d, fHPVNodjyCPg)
allenai/allennlp
allennlp/data/dataset_readers/dataset_utils/span_utils.py
enumerate_spans
def enumerate_spans(sentence: List[T], offset: int = 0, max_span_width: int = None, min_span_width: int = 1, filter_function: Callable[[List[T]], bool] = None) -> List[Tuple[int, int]]: """ Given a sentence, return all token spans within the sentence. Spans are `inclusive`. Additionally, you can provide a maximum and minimum span width, which will be used to exclude spans outside of this range. Finally, you can provide a function mapping ``List[T] -> bool``, which will be applied to every span to decide whether that span should be included. This allows filtering by length, regex matches, pos tags or any Spacy ``Token`` attributes, for example. Parameters ---------- sentence : ``List[T]``, required. The sentence to generate spans for. The type is generic, as this function can be used with strings, or Spacy ``Tokens`` or other sequences. offset : ``int``, optional (default = 0) A numeric offset to add to all span start and end indices. This is helpful if the sentence is part of a larger structure, such as a document, which the indices need to respect. max_span_width : ``int``, optional (default = None) The maximum length of spans which should be included. Defaults to len(sentence). min_span_width : ``int``, optional (default = 1) The minimum length of spans which should be included. Defaults to 1. filter_function : ``Callable[[List[T]], bool]``, optional (default = None) A function mapping sequences of the passed type T to a boolean value. If ``True``, the span is included in the returned spans from the sentence, otherwise it is excluded.. """ max_span_width = max_span_width or len(sentence) filter_function = filter_function or (lambda x: True) spans: List[Tuple[int, int]] = [] for start_index in range(len(sentence)): last_end_index = min(start_index + max_span_width, len(sentence)) first_end_index = min(start_index + min_span_width - 1, len(sentence)) for end_index in range(first_end_index, last_end_index): start = offset + start_index end = offset + end_index # add 1 to end index because span indices are inclusive. if filter_function(sentence[slice(start_index, end_index + 1)]): spans.append((start, end)) return spans
python
def enumerate_spans(sentence: List[T], offset: int = 0, max_span_width: int = None, min_span_width: int = 1, filter_function: Callable[[List[T]], bool] = None) -> List[Tuple[int, int]]: """ Given a sentence, return all token spans within the sentence. Spans are `inclusive`. Additionally, you can provide a maximum and minimum span width, which will be used to exclude spans outside of this range. Finally, you can provide a function mapping ``List[T] -> bool``, which will be applied to every span to decide whether that span should be included. This allows filtering by length, regex matches, pos tags or any Spacy ``Token`` attributes, for example. Parameters ---------- sentence : ``List[T]``, required. The sentence to generate spans for. The type is generic, as this function can be used with strings, or Spacy ``Tokens`` or other sequences. offset : ``int``, optional (default = 0) A numeric offset to add to all span start and end indices. This is helpful if the sentence is part of a larger structure, such as a document, which the indices need to respect. max_span_width : ``int``, optional (default = None) The maximum length of spans which should be included. Defaults to len(sentence). min_span_width : ``int``, optional (default = 1) The minimum length of spans which should be included. Defaults to 1. filter_function : ``Callable[[List[T]], bool]``, optional (default = None) A function mapping sequences of the passed type T to a boolean value. If ``True``, the span is included in the returned spans from the sentence, otherwise it is excluded.. """ max_span_width = max_span_width or len(sentence) filter_function = filter_function or (lambda x: True) spans: List[Tuple[int, int]] = [] for start_index in range(len(sentence)): last_end_index = min(start_index + max_span_width, len(sentence)) first_end_index = min(start_index + min_span_width - 1, len(sentence)) for end_index in range(first_end_index, last_end_index): start = offset + start_index end = offset + end_index # add 1 to end index because span indices are inclusive. if filter_function(sentence[slice(start_index, end_index + 1)]): spans.append((start, end)) return spans
[ "def", "enumerate_spans", "(", "sentence", ":", "List", "[", "T", "]", ",", "offset", ":", "int", "=", "0", ",", "max_span_width", ":", "int", "=", "None", ",", "min_span_width", ":", "int", "=", "1", ",", "filter_function", ":", "Callable", "[", "[", "List", "[", "T", "]", "]", ",", "bool", "]", "=", "None", ")", "->", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", ":", "max_span_width", "=", "max_span_width", "or", "len", "(", "sentence", ")", "filter_function", "=", "filter_function", "or", "(", "lambda", "x", ":", "True", ")", "spans", ":", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", "=", "[", "]", "for", "start_index", "in", "range", "(", "len", "(", "sentence", ")", ")", ":", "last_end_index", "=", "min", "(", "start_index", "+", "max_span_width", ",", "len", "(", "sentence", ")", ")", "first_end_index", "=", "min", "(", "start_index", "+", "min_span_width", "-", "1", ",", "len", "(", "sentence", ")", ")", "for", "end_index", "in", "range", "(", "first_end_index", ",", "last_end_index", ")", ":", "start", "=", "offset", "+", "start_index", "end", "=", "offset", "+", "end_index", "# add 1 to end index because span indices are inclusive.", "if", "filter_function", "(", "sentence", "[", "slice", "(", "start_index", ",", "end_index", "+", "1", ")", "]", ")", ":", "spans", ".", "append", "(", "(", "start", ",", "end", ")", ")", "return", "spans" ]
Given a sentence, return all token spans within the sentence. Spans are `inclusive`. Additionally, you can provide a maximum and minimum span width, which will be used to exclude spans outside of this range. Finally, you can provide a function mapping ``List[T] -> bool``, which will be applied to every span to decide whether that span should be included. This allows filtering by length, regex matches, pos tags or any Spacy ``Token`` attributes, for example. Parameters ---------- sentence : ``List[T]``, required. The sentence to generate spans for. The type is generic, as this function can be used with strings, or Spacy ``Tokens`` or other sequences. offset : ``int``, optional (default = 0) A numeric offset to add to all span start and end indices. This is helpful if the sentence is part of a larger structure, such as a document, which the indices need to respect. max_span_width : ``int``, optional (default = None) The maximum length of spans which should be included. Defaults to len(sentence). min_span_width : ``int``, optional (default = 1) The minimum length of spans which should be included. Defaults to 1. filter_function : ``Callable[[List[T]], bool]``, optional (default = None) A function mapping sequences of the passed type T to a boolean value. If ``True``, the span is included in the returned spans from the sentence, otherwise it is excluded..
[ "Given", "a", "sentence", "return", "all", "token", "spans", "within", "the", "sentence", ".", "Spans", "are", "inclusive", ".", "Additionally", "you", "can", "provide", "a", "maximum", "and", "minimum", "span", "width", "which", "will", "be", "used", "to", "exclude", "spans", "outside", "of", "this", "range", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/span_utils.py#L20-L66
train
Given a list of sentences return all token spans within the sentence.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvR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UlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\157' + chr(0b110011) + chr(53) + chr(1146 - 1098), 1551 - 1543), ehT0Px3KOsy9('\060' + '\157' + '\x33' + chr(0b100100 + 0o16) + chr(0b110100), 46926 - 46918), ehT0Px3KOsy9('\060' + '\157' + '\x32' + '\x31' + chr(0b101000 + 0o14), 0b1000), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b111100 + 0o63) + chr(0b10110 + 0o34) + chr(1276 - 1223) + chr(183 - 130), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\061' + '\064' + chr(1357 - 1307), 19095 - 19087), ehT0Px3KOsy9(chr(355 - 307) + chr(0b1101111) + '\x33' + chr(0b110010) + '\x35', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\062' + chr(56 - 5) + chr(0b100110 + 0o14), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\x31' + chr(0b101101 + 0o4) + chr(445 - 397), 1456 - 1448), ehT0Px3KOsy9(chr(2056 - 2008) + '\157' + chr(0b110010) + '\x33' + chr(0b11 + 0o62), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + chr(770 - 715) + '\x37', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b100010 + 0o115) + chr(49) + chr(0b10011 + 0o41) + chr(1852 - 1798), 31279 - 31271), ehT0Px3KOsy9('\x30' + chr(0b111100 + 0o63) + chr(49) + chr(0b110001) + '\060', 8), ehT0Px3KOsy9('\060' + chr(2548 - 2437) + '\x31' + '\063' + chr(1062 - 1011), 0o10), ehT0Px3KOsy9(chr(930 - 882) + '\x6f' + chr(55) + '\x33', 0b1000), ehT0Px3KOsy9(chr(48) + chr(11649 - 11538) + chr(49) + '\067' + chr(0b110111), 0b1000), ehT0Px3KOsy9('\x30' + chr(2360 - 2249) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\062' + chr(0b110010) + chr(710 - 656), 10091 - 10083), ehT0Px3KOsy9(chr(1181 - 1133) + '\157' + chr(0b110010) + chr(52) + chr(53), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b10001 + 0o45) + '\x37', 5746 - 5738), ehT0Px3KOsy9(chr(406 - 358) + '\x6f' + chr(51) + chr(1212 - 1164) + '\x32', 0o10), ehT0Px3KOsy9(chr(1074 - 1026) + '\157' + '\x30', 0b1000), ehT0Px3KOsy9(chr(1423 - 1375) + chr(111) + '\x32' + chr(0b110000) + '\x37', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b1 + 0o61) + chr(52) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b100110 + 0o14) + chr(0b110111) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(2049 - 2001) + chr(0b111 + 0o150) + chr(0b1001 + 0o54) + '\061', 62035 - 62027), ehT0Px3KOsy9(chr(0b110000) + chr(1473 - 1362) + chr(0b11010 + 0o31) + '\061' + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(0b110000) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(10073 - 9962) + '\062' + '\065' + '\x32', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(6650 - 6539) + chr(0b100001 + 0o21) + chr(0b100000 + 0o27) + '\x30', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + '\063' + '\061', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(55) + chr(0b10000 + 0o45), 0b1000), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\157' + '\063' + chr(1276 - 1222) + '\061', 26653 - 26645), ehT0Px3KOsy9('\x30' + chr(0b100001 + 0o116) + chr(0b1010 + 0o55) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + '\x37' + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(11387 - 11276) + chr(1459 - 1410) + chr(0b110110) + '\064', 12064 - 12056), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + chr(0b110100) + chr(0b101000 + 0o10), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(6799 - 6688) + chr(49) + chr(0b110000) + '\x36', 0b1000), ehT0Px3KOsy9('\060' + chr(3577 - 3466) + chr(1403 - 1354) + chr(0b100100 + 0o22) + chr(50), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1110 + 0o141) + chr(383 - 332) + chr(0b110000) + chr(0b10111 + 0o34), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1001010 + 0o45) + '\x33' + '\060' + '\061', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(6740 - 6629) + '\065' + chr(0b11110 + 0o22), 58984 - 58976)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc6'), chr(1632 - 1532) + '\145' + chr(5815 - 5716) + '\x6f' + '\x64' + chr(1069 - 968))(chr(11271 - 11154) + chr(0b111101 + 0o67) + chr(9676 - 9574) + chr(45) + chr(0b11101 + 0o33)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def KrzE1AOMDsJ8(pamQPTGoym5v, VRaYxwVeIO1g=ehT0Px3KOsy9('\x30' + '\157' + chr(0b110000), 8), rYIG8vToO5S7=None, qyITN22BCqI1=ehT0Px3KOsy9(chr(363 - 315) + chr(4812 - 4701) + chr(49), 0o10), XVQKf8KysRbr=None) -> qRxF7OQ0y39T[MRK8Uzg2En3D[ehT0Px3KOsy9, ehT0Px3KOsy9]]: rYIG8vToO5S7 = rYIG8vToO5S7 or c2A0yzQpDQB3(pamQPTGoym5v) XVQKf8KysRbr = XVQKf8KysRbr or (lambda OeWW0F1dBPRQ: ehT0Px3KOsy9(chr(982 - 934) + '\157' + chr(49), 8)) aPSH2X7oF0wS = [] for jrpEXfDZwQEA in vQr8gNKaIaWE(c2A0yzQpDQB3(pamQPTGoym5v)): I5aJ6M3H0mPV = Dx22bkKPdt5d(jrpEXfDZwQEA + rYIG8vToO5S7, c2A0yzQpDQB3(pamQPTGoym5v)) hud5n8hd1O3x = Dx22bkKPdt5d(jrpEXfDZwQEA + qyITN22BCqI1 - ehT0Px3KOsy9('\060' + chr(111) + chr(0b101011 + 0o6), 8), c2A0yzQpDQB3(pamQPTGoym5v)) for WjkykCmrXkZ6 in vQr8gNKaIaWE(hud5n8hd1O3x, I5aJ6M3H0mPV): avRbFsnfJxQj = VRaYxwVeIO1g + jrpEXfDZwQEA whWDZq5_lP01 = VRaYxwVeIO1g + WjkykCmrXkZ6 if XVQKf8KysRbr(pamQPTGoym5v[W3g84rNiEdDQ(jrpEXfDZwQEA, WjkykCmrXkZ6 + ehT0Px3KOsy9(chr(48) + chr(0b1010100 + 0o33) + '\x31', 8))]): xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'\x89\xa4\xfc\xc8\x0c\xb1'), chr(7244 - 7144) + chr(101) + '\143' + '\x6f' + chr(0b1100100) + chr(0b1100101))(chr(5905 - 5788) + '\164' + chr(0b1000 + 0o136) + chr(0b101 + 0o50) + chr(0b111000)))((avRbFsnfJxQj, whWDZq5_lP01)) return aPSH2X7oF0wS
allenai/allennlp
allennlp/data/dataset_readers/dataset_utils/span_utils.py
bio_tags_to_spans
def bio_tags_to_spans(tag_sequence: List[str], classes_to_ignore: List[str] = None) -> List[TypedStringSpan]: """ Given a sequence corresponding to BIO tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are also included (i.e those which do not start with a "B-LABEL"), as otherwise it is possible to get a perfect precision score whilst still predicting ill-formed spans in addition to the correct spans. This function works properly when the spans are unlabeled (i.e., your labels are simply "B", "I", and "O"). Parameters ---------- tag_sequence : List[str], required. The integer class labels for a sequence. classes_to_ignore : List[str], optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : List[TypedStringSpan] The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). Note that the label `does not` contain any BIO tag prefixes. """ classes_to_ignore = classes_to_ignore or [] spans: Set[Tuple[str, Tuple[int, int]]] = set() span_start = 0 span_end = 0 active_conll_tag = None for index, string_tag in enumerate(tag_sequence): # Actual BIO tag. bio_tag = string_tag[0] if bio_tag not in ["B", "I", "O"]: raise InvalidTagSequence(tag_sequence) conll_tag = string_tag[2:] if bio_tag == "O" or conll_tag in classes_to_ignore: # The span has ended. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) active_conll_tag = None # We don't care about tags we are # told to ignore, so we do nothing. continue elif bio_tag == "B": # We are entering a new span; reset indices # and active tag to new span. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) active_conll_tag = conll_tag span_start = index span_end = index elif bio_tag == "I" and conll_tag == active_conll_tag: # We're inside a span. span_end += 1 else: # This is the case the bio label is an "I", but either: # 1) the span hasn't started - i.e. an ill formed span. # 2) The span is an I tag for a different conll annotation. # We'll process the previous span if it exists, but also # include this span. This is important, because otherwise, # a model may get a perfect F1 score whilst still including # false positive ill-formed spans. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) active_conll_tag = conll_tag span_start = index span_end = index # Last token might have been a part of a valid span. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) return list(spans)
python
def bio_tags_to_spans(tag_sequence: List[str], classes_to_ignore: List[str] = None) -> List[TypedStringSpan]: """ Given a sequence corresponding to BIO tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are also included (i.e those which do not start with a "B-LABEL"), as otherwise it is possible to get a perfect precision score whilst still predicting ill-formed spans in addition to the correct spans. This function works properly when the spans are unlabeled (i.e., your labels are simply "B", "I", and "O"). Parameters ---------- tag_sequence : List[str], required. The integer class labels for a sequence. classes_to_ignore : List[str], optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : List[TypedStringSpan] The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). Note that the label `does not` contain any BIO tag prefixes. """ classes_to_ignore = classes_to_ignore or [] spans: Set[Tuple[str, Tuple[int, int]]] = set() span_start = 0 span_end = 0 active_conll_tag = None for index, string_tag in enumerate(tag_sequence): # Actual BIO tag. bio_tag = string_tag[0] if bio_tag not in ["B", "I", "O"]: raise InvalidTagSequence(tag_sequence) conll_tag = string_tag[2:] if bio_tag == "O" or conll_tag in classes_to_ignore: # The span has ended. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) active_conll_tag = None # We don't care about tags we are # told to ignore, so we do nothing. continue elif bio_tag == "B": # We are entering a new span; reset indices # and active tag to new span. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) active_conll_tag = conll_tag span_start = index span_end = index elif bio_tag == "I" and conll_tag == active_conll_tag: # We're inside a span. span_end += 1 else: # This is the case the bio label is an "I", but either: # 1) the span hasn't started - i.e. an ill formed span. # 2) The span is an I tag for a different conll annotation. # We'll process the previous span if it exists, but also # include this span. This is important, because otherwise, # a model may get a perfect F1 score whilst still including # false positive ill-formed spans. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) active_conll_tag = conll_tag span_start = index span_end = index # Last token might have been a part of a valid span. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) return list(spans)
[ "def", "bio_tags_to_spans", "(", "tag_sequence", ":", "List", "[", "str", "]", ",", "classes_to_ignore", ":", "List", "[", "str", "]", "=", "None", ")", "->", "List", "[", "TypedStringSpan", "]", ":", "classes_to_ignore", "=", "classes_to_ignore", "or", "[", "]", "spans", ":", "Set", "[", "Tuple", "[", "str", ",", "Tuple", "[", "int", ",", "int", "]", "]", "]", "=", "set", "(", ")", "span_start", "=", "0", "span_end", "=", "0", "active_conll_tag", "=", "None", "for", "index", ",", "string_tag", "in", "enumerate", "(", "tag_sequence", ")", ":", "# Actual BIO tag.", "bio_tag", "=", "string_tag", "[", "0", "]", "if", "bio_tag", "not", "in", "[", "\"B\"", ",", "\"I\"", ",", "\"O\"", "]", ":", "raise", "InvalidTagSequence", "(", "tag_sequence", ")", "conll_tag", "=", "string_tag", "[", "2", ":", "]", "if", "bio_tag", "==", "\"O\"", "or", "conll_tag", "in", "classes_to_ignore", ":", "# The span has ended.", "if", "active_conll_tag", "is", "not", "None", ":", "spans", ".", "add", "(", "(", "active_conll_tag", ",", "(", "span_start", ",", "span_end", ")", ")", ")", "active_conll_tag", "=", "None", "# We don't care about tags we are", "# told to ignore, so we do nothing.", "continue", "elif", "bio_tag", "==", "\"B\"", ":", "# We are entering a new span; reset indices", "# and active tag to new span.", "if", "active_conll_tag", "is", "not", "None", ":", "spans", ".", "add", "(", "(", "active_conll_tag", ",", "(", "span_start", ",", "span_end", ")", ")", ")", "active_conll_tag", "=", "conll_tag", "span_start", "=", "index", "span_end", "=", "index", "elif", "bio_tag", "==", "\"I\"", "and", "conll_tag", "==", "active_conll_tag", ":", "# We're inside a span.", "span_end", "+=", "1", "else", ":", "# This is the case the bio label is an \"I\", but either:", "# 1) the span hasn't started - i.e. an ill formed span.", "# 2) The span is an I tag for a different conll annotation.", "# We'll process the previous span if it exists, but also", "# include this span. This is important, because otherwise,", "# a model may get a perfect F1 score whilst still including", "# false positive ill-formed spans.", "if", "active_conll_tag", "is", "not", "None", ":", "spans", ".", "add", "(", "(", "active_conll_tag", ",", "(", "span_start", ",", "span_end", ")", ")", ")", "active_conll_tag", "=", "conll_tag", "span_start", "=", "index", "span_end", "=", "index", "# Last token might have been a part of a valid span.", "if", "active_conll_tag", "is", "not", "None", ":", "spans", ".", "add", "(", "(", "active_conll_tag", ",", "(", "span_start", ",", "span_end", ")", ")", ")", "return", "list", "(", "spans", ")" ]
Given a sequence corresponding to BIO tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are also included (i.e those which do not start with a "B-LABEL"), as otherwise it is possible to get a perfect precision score whilst still predicting ill-formed spans in addition to the correct spans. This function works properly when the spans are unlabeled (i.e., your labels are simply "B", "I", and "O"). Parameters ---------- tag_sequence : List[str], required. The integer class labels for a sequence. classes_to_ignore : List[str], optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : List[TypedStringSpan] The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). Note that the label `does not` contain any BIO tag prefixes.
[ "Given", "a", "sequence", "corresponding", "to", "BIO", "tags", "extracts", "spans", ".", "Spans", "are", "inclusive", "and", "can", "be", "of", "zero", "length", "representing", "a", "single", "word", "span", ".", "Ill", "-", "formed", "spans", "are", "also", "included", "(", "i", ".", "e", "those", "which", "do", "not", "start", "with", "a", "B", "-", "LABEL", ")", "as", "otherwise", "it", "is", "possible", "to", "get", "a", "perfect", "precision", "score", "whilst", "still", "predicting", "ill", "-", "formed", "spans", "in", "addition", "to", "the", "correct", "spans", ".", "This", "function", "works", "properly", "when", "the", "spans", "are", "unlabeled", "(", "i", ".", "e", ".", "your", "labels", "are", "simply", "B", "I", "and", "O", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/span_utils.py#L69-L139
train
Given a sequence corresponding to BIO tags extracts spans from the BIO tags and returns a list of typed string spans.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi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bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(111) + chr(2669 - 2614) + '\x37', 0o10), ehT0Px3KOsy9(chr(837 - 789) + chr(111) + chr(49) + chr(0b110010) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\x32' + chr(0b110010) + chr(53), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1001010 + 0o45) + chr(0b100101 + 0o15) + chr(885 - 830), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001) + chr(1133 - 1085) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(1625 - 1575) + chr(0b1011 + 0o45) + chr(52), 0o10), ehT0Px3KOsy9('\060' + chr(0b1011101 + 0o22) + chr(0b110001) + chr(0b110011) + '\063', 3357 - 3349), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(51) + chr(54) + '\x32', 48601 - 48593), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\x6f' + chr(0b1100 + 0o47) + chr(48) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(1756 - 1645) + chr(0b101011 + 0o6) + '\x34', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110011) + '\061' + chr(0b101 + 0o56), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + chr(2385 - 2336), 30593 - 30585), ehT0Px3KOsy9(chr(1128 - 1080) + chr(111) + '\062' + '\067' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(2027 - 1979) + chr(7495 - 7384) + chr(1564 - 1511) + chr(674 - 622), 0o10), ehT0Px3KOsy9(chr(0b11100 + 0o24) + '\157' + '\067' + chr(52), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + '\x33' + chr(54), 62765 - 62757), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\x6f' + chr(0b110011) + '\x37' + chr(0b110010), 11729 - 11721), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110001) + chr(0b1010 + 0o50) + chr(0b110001 + 0o0), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\064', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(49) + chr(0b11010 + 0o35) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(1600 - 1552) + '\x6f' + '\x36' + chr(796 - 744), 0o10), ehT0Px3KOsy9(chr(1412 - 1364) + chr(8211 - 8100) + chr(2146 - 2095) + '\062' + '\067', 19411 - 19403), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100011 + 0o20) + '\x34' + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\063' + chr(0b110000), 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + chr(0b100100 + 0o15) + '\060', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110010 + 0o1) + chr(50) + '\061', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + chr(0b110110), 60012 - 60004), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + chr(1395 - 1344) + '\x31', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b100110 + 0o13) + chr(49) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b11110 + 0o22) + '\157' + '\x31' + '\066', 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(326 - 276) + '\061', 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + '\x33', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(5470 - 5359) + chr(0b110111) + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1373 - 1323) + chr(574 - 522) + chr(1613 - 1564), 2114 - 2106), ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(0b111010 + 0o65) + '\062' + '\060' + chr(2113 - 2058), 19754 - 19746), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(1128 - 1074) + chr(0b110001), 0o10), ehT0Px3KOsy9('\060' + chr(2891 - 2780) + chr(49) + '\063' + chr(51), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1810 - 1760) + '\061' + chr(50), 17973 - 17965), ehT0Px3KOsy9(chr(683 - 635) + '\157' + chr(51) + '\x36', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\066' + '\067', 57282 - 57274)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1196 - 1148) + chr(0b1101111) + chr(1159 - 1106) + '\060', 3874 - 3866)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x11'), '\x64' + chr(101) + '\143' + chr(0b1101111) + chr(100) + chr(0b1100101))(chr(7332 - 7215) + chr(0b1110100) + '\x66' + chr(0b101101) + chr(0b100101 + 0o23)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def UwYLV38hGgKm(utunRCPj8Imk, CwAp18FPCQND=None) -> qRxF7OQ0y39T[JWGWO_DJzASh]: CwAp18FPCQND = CwAp18FPCQND or [] aPSH2X7oF0wS = MVEN8G6CxlvR() CGzUSvlyKBQD = ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(48), ord("\x08")) b5O2oQPg9Xzq = ehT0Px3KOsy9(chr(208 - 160) + chr(111) + chr(0b110000), 8) yLFZp0KTSDdd = None for (XdowRbJKZWL9, pMllmnQutflp) in YlkZvXL8qwsX(utunRCPj8Imk): nqlyuzJKYN3X = pMllmnQutflp[ehT0Px3KOsy9('\x30' + '\157' + '\x30', 8)] if nqlyuzJKYN3X not in [xafqLlk3kkUe(SXOLrMavuUCe(b'}'), chr(0b1100100) + chr(101) + '\x63' + '\x6f' + chr(100) + '\145')(chr(117) + chr(0b10000 + 0o144) + '\146' + '\055' + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'v'), chr(4303 - 4203) + chr(0b1100 + 0o131) + chr(99) + chr(111) + chr(6825 - 6725) + chr(101))('\x75' + '\x74' + chr(1636 - 1534) + chr(45) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'p'), chr(0b1100100) + chr(5689 - 5588) + chr(8958 - 8859) + '\x6f' + chr(100) + chr(101))(chr(117) + '\164' + chr(0b1100110) + chr(45) + chr(0b111000))]: raise WPN1tW8jgnXd(utunRCPj8Imk) cyGlHNlV75NR = pMllmnQutflp[ehT0Px3KOsy9(chr(0b110000) + chr(4953 - 4842) + chr(407 - 357), 0o10):] if nqlyuzJKYN3X == xafqLlk3kkUe(SXOLrMavuUCe(b'p'), '\144' + chr(0b1100101) + chr(0b11110 + 0o105) + '\157' + chr(0b100100 + 0o100) + chr(0b1100101))('\x75' + chr(116) + chr(102) + chr(0b101101) + chr(0b111000)) or cyGlHNlV75NR in CwAp18FPCQND: if yLFZp0KTSDdd is not None: xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'J\x1f\xa5f}\xe7\x1c\xc7\x98C\x99"'), '\x64' + chr(9607 - 9506) + chr(0b1100011) + '\x6f' + chr(0b1100100) + chr(0b101000 + 0o75))('\x75' + chr(0b1110000 + 0o4) + '\x66' + chr(1054 - 1009) + '\070'))((yLFZp0KTSDdd, (CGzUSvlyKBQD, b5O2oQPg9Xzq))) yLFZp0KTSDdd = None continue elif nqlyuzJKYN3X == xafqLlk3kkUe(SXOLrMavuUCe(b'}'), chr(0b111100 + 0o50) + chr(0b11001 + 0o114) + chr(99) + chr(0b10110 + 0o131) + '\x64' + chr(5096 - 4995))(chr(117) + chr(5389 - 5273) + '\x66' + '\055' + chr(2451 - 2395)): if yLFZp0KTSDdd is not None: xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'J\x1f\xa5f}\xe7\x1c\xc7\x98C\x99"'), chr(0b1010110 + 0o16) + '\x65' + '\143' + '\157' + '\x64' + chr(0b1100101))(chr(9923 - 9806) + chr(0b1110100) + '\146' + '\055' + '\x38'))((yLFZp0KTSDdd, (CGzUSvlyKBQD, b5O2oQPg9Xzq))) yLFZp0KTSDdd = cyGlHNlV75NR CGzUSvlyKBQD = XdowRbJKZWL9 b5O2oQPg9Xzq = XdowRbJKZWL9 elif nqlyuzJKYN3X == xafqLlk3kkUe(SXOLrMavuUCe(b'v'), chr(100) + chr(0b100111 + 0o76) + '\x63' + '\157' + chr(0b1100100) + '\145')(chr(13022 - 12905) + '\164' + chr(0b1100110) + '\x2d' + '\x38') and cyGlHNlV75NR == yLFZp0KTSDdd: b5O2oQPg9Xzq += ehT0Px3KOsy9(chr(610 - 562) + '\x6f' + chr(1975 - 1926), 1419 - 1411) else: if yLFZp0KTSDdd is not None: xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'J\x1f\xa5f}\xe7\x1c\xc7\x98C\x99"'), chr(3697 - 3597) + chr(101) + '\x63' + chr(0b1101111) + chr(7251 - 7151) + '\x65')(chr(11133 - 11016) + chr(0b1110100) + chr(102) + chr(0b1101 + 0o40) + chr(0b111000)))((yLFZp0KTSDdd, (CGzUSvlyKBQD, b5O2oQPg9Xzq))) yLFZp0KTSDdd = cyGlHNlV75NR CGzUSvlyKBQD = XdowRbJKZWL9 b5O2oQPg9Xzq = XdowRbJKZWL9 if yLFZp0KTSDdd is not None: xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'J\x1f\xa5f}\xe7\x1c\xc7\x98C\x99"'), '\x64' + chr(3668 - 3567) + '\143' + chr(0b1111 + 0o140) + '\144' + chr(0b1100101))(chr(117) + chr(0b1110 + 0o146) + chr(0b11 + 0o143) + '\055' + chr(56)))((yLFZp0KTSDdd, (CGzUSvlyKBQD, b5O2oQPg9Xzq))) return YyaZ4tpXu4lf(aPSH2X7oF0wS)
allenai/allennlp
allennlp/data/dataset_readers/dataset_utils/span_utils.py
iob1_tags_to_spans
def iob1_tags_to_spans(tag_sequence: List[str], classes_to_ignore: List[str] = None) -> List[TypedStringSpan]: """ Given a sequence corresponding to IOB1 tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are also included (i.e., those where "B-LABEL" is not preceded by "I-LABEL" or "B-LABEL"). Parameters ---------- tag_sequence : List[str], required. The integer class labels for a sequence. classes_to_ignore : List[str], optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : List[TypedStringSpan] The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). Note that the label `does not` contain any BIO tag prefixes. """ classes_to_ignore = classes_to_ignore or [] spans: Set[Tuple[str, Tuple[int, int]]] = set() span_start = 0 span_end = 0 active_conll_tag = None prev_bio_tag = None prev_conll_tag = None for index, string_tag in enumerate(tag_sequence): curr_bio_tag = string_tag[0] curr_conll_tag = string_tag[2:] if curr_bio_tag not in ["B", "I", "O"]: raise InvalidTagSequence(tag_sequence) if curr_bio_tag == "O" or curr_conll_tag in classes_to_ignore: # The span has ended. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) active_conll_tag = None elif _iob1_start_of_chunk(prev_bio_tag, prev_conll_tag, curr_bio_tag, curr_conll_tag): # We are entering a new span; reset indices # and active tag to new span. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) active_conll_tag = curr_conll_tag span_start = index span_end = index else: # bio_tag == "I" and curr_conll_tag == active_conll_tag # We're continuing a span. span_end += 1 prev_bio_tag = string_tag[0] prev_conll_tag = string_tag[2:] # Last token might have been a part of a valid span. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) return list(spans)
python
def iob1_tags_to_spans(tag_sequence: List[str], classes_to_ignore: List[str] = None) -> List[TypedStringSpan]: """ Given a sequence corresponding to IOB1 tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are also included (i.e., those where "B-LABEL" is not preceded by "I-LABEL" or "B-LABEL"). Parameters ---------- tag_sequence : List[str], required. The integer class labels for a sequence. classes_to_ignore : List[str], optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : List[TypedStringSpan] The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). Note that the label `does not` contain any BIO tag prefixes. """ classes_to_ignore = classes_to_ignore or [] spans: Set[Tuple[str, Tuple[int, int]]] = set() span_start = 0 span_end = 0 active_conll_tag = None prev_bio_tag = None prev_conll_tag = None for index, string_tag in enumerate(tag_sequence): curr_bio_tag = string_tag[0] curr_conll_tag = string_tag[2:] if curr_bio_tag not in ["B", "I", "O"]: raise InvalidTagSequence(tag_sequence) if curr_bio_tag == "O" or curr_conll_tag in classes_to_ignore: # The span has ended. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) active_conll_tag = None elif _iob1_start_of_chunk(prev_bio_tag, prev_conll_tag, curr_bio_tag, curr_conll_tag): # We are entering a new span; reset indices # and active tag to new span. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) active_conll_tag = curr_conll_tag span_start = index span_end = index else: # bio_tag == "I" and curr_conll_tag == active_conll_tag # We're continuing a span. span_end += 1 prev_bio_tag = string_tag[0] prev_conll_tag = string_tag[2:] # Last token might have been a part of a valid span. if active_conll_tag is not None: spans.add((active_conll_tag, (span_start, span_end))) return list(spans)
[ "def", "iob1_tags_to_spans", "(", "tag_sequence", ":", "List", "[", "str", "]", ",", "classes_to_ignore", ":", "List", "[", "str", "]", "=", "None", ")", "->", "List", "[", "TypedStringSpan", "]", ":", "classes_to_ignore", "=", "classes_to_ignore", "or", "[", "]", "spans", ":", "Set", "[", "Tuple", "[", "str", ",", "Tuple", "[", "int", ",", "int", "]", "]", "]", "=", "set", "(", ")", "span_start", "=", "0", "span_end", "=", "0", "active_conll_tag", "=", "None", "prev_bio_tag", "=", "None", "prev_conll_tag", "=", "None", "for", "index", ",", "string_tag", "in", "enumerate", "(", "tag_sequence", ")", ":", "curr_bio_tag", "=", "string_tag", "[", "0", "]", "curr_conll_tag", "=", "string_tag", "[", "2", ":", "]", "if", "curr_bio_tag", "not", "in", "[", "\"B\"", ",", "\"I\"", ",", "\"O\"", "]", ":", "raise", "InvalidTagSequence", "(", "tag_sequence", ")", "if", "curr_bio_tag", "==", "\"O\"", "or", "curr_conll_tag", "in", "classes_to_ignore", ":", "# The span has ended.", "if", "active_conll_tag", "is", "not", "None", ":", "spans", ".", "add", "(", "(", "active_conll_tag", ",", "(", "span_start", ",", "span_end", ")", ")", ")", "active_conll_tag", "=", "None", "elif", "_iob1_start_of_chunk", "(", "prev_bio_tag", ",", "prev_conll_tag", ",", "curr_bio_tag", ",", "curr_conll_tag", ")", ":", "# We are entering a new span; reset indices", "# and active tag to new span.", "if", "active_conll_tag", "is", "not", "None", ":", "spans", ".", "add", "(", "(", "active_conll_tag", ",", "(", "span_start", ",", "span_end", ")", ")", ")", "active_conll_tag", "=", "curr_conll_tag", "span_start", "=", "index", "span_end", "=", "index", "else", ":", "# bio_tag == \"I\" and curr_conll_tag == active_conll_tag", "# We're continuing a span.", "span_end", "+=", "1", "prev_bio_tag", "=", "string_tag", "[", "0", "]", "prev_conll_tag", "=", "string_tag", "[", "2", ":", "]", "# Last token might have been a part of a valid span.", "if", "active_conll_tag", "is", "not", "None", ":", "spans", ".", "add", "(", "(", "active_conll_tag", ",", "(", "span_start", ",", "span_end", ")", ")", ")", "return", "list", "(", "spans", ")" ]
Given a sequence corresponding to IOB1 tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are also included (i.e., those where "B-LABEL" is not preceded by "I-LABEL" or "B-LABEL"). Parameters ---------- tag_sequence : List[str], required. The integer class labels for a sequence. classes_to_ignore : List[str], optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : List[TypedStringSpan] The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). Note that the label `does not` contain any BIO tag prefixes.
[ "Given", "a", "sequence", "corresponding", "to", "IOB1", "tags", "extracts", "spans", ".", "Spans", "are", "inclusive", "and", "can", "be", "of", "zero", "length", "representing", "a", "single", "word", "span", ".", "Ill", "-", "formed", "spans", "are", "also", "included", "(", "i", ".", "e", ".", "those", "where", "B", "-", "LABEL", "is", "not", "preceded", "by", "I", "-", "LABEL", "or", "B", "-", "LABEL", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/span_utils.py#L142-L201
train
Given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eSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(5623 - 5512) + chr(407 - 357) + '\x33' + chr(0b110001 + 0o3), ord("\x08")), ehT0Px3KOsy9(chr(2029 - 1981) + '\157' + chr(0b10010 + 0o37) + '\066' + '\060', 42588 - 42580), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(4392 - 4281) + chr(50) + chr(0b110011) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(1133 - 1085) + chr(0b10111 + 0o130) + '\x33' + '\x33' + chr(1495 - 1443), 14421 - 14413), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1208 - 1158) + chr(52) + chr(0b101000 + 0o13), 35501 - 35493), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110100) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + '\x30' + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b111 + 0o150) + chr(50) + chr(49) + chr(48), 0o10), ehT0Px3KOsy9('\x30' + chr(0b101011 + 0o104) + '\x33' + chr(0b110010), 21883 - 21875), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\x6f' + '\066' + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\157' + chr(84 - 33) + '\063' + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b101000 + 0o13) + chr(2331 - 2280) + chr(1875 - 1824), 8), ehT0Px3KOsy9(chr(2070 - 2022) + chr(5239 - 5128) + '\062' + chr(0b110110), 0o10), ehT0Px3KOsy9('\060' + chr(293 - 182) + chr(0b110011) + '\067' + chr(0b11000 + 0o33), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + '\x30' + chr(1625 - 1576), ord("\x08")), ehT0Px3KOsy9(chr(395 - 347) + '\x6f' + '\x31' + chr(55) + chr(2655 - 2603), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(1368 - 1317) + chr(0b110 + 0o54) + chr(54), 0o10), ehT0Px3KOsy9('\060' + chr(0b1000100 + 0o53) + chr(134 - 83) + '\x37' + chr(0b110111), 38377 - 38369), ehT0Px3KOsy9(chr(1835 - 1787) + chr(111) + '\066' + '\067', 0b1000), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(0b101011 + 0o104) + chr(0b110011) + chr(2069 - 2021) + '\x31', 0b1000), ehT0Px3KOsy9('\060' + chr(2844 - 2733) + chr(842 - 792) + chr(0b11 + 0o60) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11110 + 0o31) + chr(1828 - 1773), ord("\x08")), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\157' + '\x31' + '\062' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(2261 - 2213) + chr(111) + chr(52) + chr(0b110100), 8), ehT0Px3KOsy9('\060' + '\157' + chr(856 - 801) + '\x33', 65458 - 65450), ehT0Px3KOsy9(chr(48) + chr(111) + '\x31' + chr(749 - 700) + '\x35', 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\062' + chr(54) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(5922 - 5811) + chr(0b101111 + 0o4) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(1595 - 1484) + chr(50) + chr(51) + '\062', 0b1000), ehT0Px3KOsy9(chr(1318 - 1270) + '\x6f' + '\x33' + '\x31' + '\065', 0b1000), ehT0Px3KOsy9(chr(48) + chr(2352 - 2241) + '\062' + '\066' + chr(0b1111 + 0o50), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b111100 + 0o63) + chr(0b110001) + '\066' + chr(0b10010 + 0o44), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(6651 - 6540) + chr(2152 - 2101) + '\x30' + chr(0b10110 + 0o36), 0b1000), ehT0Px3KOsy9(chr(48) + chr(10784 - 10673) + chr(0b101101 + 0o4) + chr(2207 - 2153), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\063' + chr(51) + chr(433 - 381), 8), ehT0Px3KOsy9('\060' + '\157' + '\062' + chr(0b101100 + 0o12) + '\x33', 20416 - 20408), ehT0Px3KOsy9(chr(0b110000) + chr(0b10 + 0o155) + chr(51) + chr(0b11000 + 0o31) + '\065', 8), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b11000 + 0o33) + chr(990 - 935) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(6642 - 6531) + chr(360 - 311) + '\061' + '\x37', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + '\066' + chr(188 - 140), 47196 - 47188)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110101) + chr(99 - 51), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xb2'), '\x64' + '\x65' + chr(6226 - 6127) + chr(0b1101111) + chr(0b1100100) + chr(101))(chr(0b1101100 + 0o11) + '\164' + '\x66' + chr(0b11101 + 0o20) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def GqdjCr0_J4dY(utunRCPj8Imk, CwAp18FPCQND=None) -> qRxF7OQ0y39T[JWGWO_DJzASh]: CwAp18FPCQND = CwAp18FPCQND or [] aPSH2X7oF0wS = MVEN8G6CxlvR() CGzUSvlyKBQD = ehT0Px3KOsy9('\060' + chr(111) + chr(48), 0o10) b5O2oQPg9Xzq = ehT0Px3KOsy9(chr(1784 - 1736) + chr(111) + chr(48), 8) yLFZp0KTSDdd = None TliSd_m0sUbU = None Si1rS1kQYZAH = None for (XdowRbJKZWL9, pMllmnQutflp) in YlkZvXL8qwsX(utunRCPj8Imk): FNODlWdx5KQL = pMllmnQutflp[ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x30', 8)] DQ8LtNukkeHf = pMllmnQutflp[ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50), 0o10):] if FNODlWdx5KQL not in [xafqLlk3kkUe(SXOLrMavuUCe(b'\xde'), chr(4785 - 4685) + chr(667 - 566) + '\x63' + chr(0b10 + 0o155) + '\144' + '\x65')('\165' + chr(116) + '\x66' + chr(0b100100 + 0o11) + chr(0b101100 + 0o14)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd5'), chr(0b1011000 + 0o14) + '\x65' + chr(0b1001100 + 0o27) + chr(0b1101111) + chr(100) + chr(0b10101 + 0o120))(chr(7529 - 7412) + chr(116) + chr(0b1100110) + chr(0b101101) + chr(0b1011 + 0o55)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd3'), chr(7053 - 6953) + '\145' + '\x63' + chr(3571 - 3460) + '\x64' + chr(0b1100010 + 0o3))('\x75' + '\x74' + chr(5951 - 5849) + chr(0b101101) + chr(56))]: raise WPN1tW8jgnXd(utunRCPj8Imk) if FNODlWdx5KQL == xafqLlk3kkUe(SXOLrMavuUCe(b'\xd3'), chr(0b1100100) + chr(0b1001101 + 0o30) + chr(99) + chr(10854 - 10743) + chr(7297 - 7197) + chr(0b1001000 + 0o35))(chr(0b1110011 + 0o2) + chr(0b1110100) + '\146' + '\x2d' + '\x38') or DQ8LtNukkeHf in CwAp18FPCQND: if yLFZp0KTSDdd is not None: xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe9:\xaf\xad\x9aG\x81\xbd@z\x89\xe8'), '\x64' + chr(246 - 145) + chr(0b1011011 + 0o10) + '\157' + '\144' + chr(0b11100 + 0o111))(chr(0b1001100 + 0o51) + '\164' + chr(102) + chr(282 - 237) + chr(0b100100 + 0o24)))((yLFZp0KTSDdd, (CGzUSvlyKBQD, b5O2oQPg9Xzq))) yLFZp0KTSDdd = None elif ZmFycLFm5Va5(TliSd_m0sUbU, Si1rS1kQYZAH, FNODlWdx5KQL, DQ8LtNukkeHf): if yLFZp0KTSDdd is not None: xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe9:\xaf\xad\x9aG\x81\xbd@z\x89\xe8'), chr(0b1100100) + chr(8644 - 8543) + chr(2017 - 1918) + '\x6f' + chr(0b111000 + 0o54) + chr(0b1100101))(chr(0b111010 + 0o73) + '\164' + chr(102) + chr(0b1000 + 0o45) + '\x38'))((yLFZp0KTSDdd, (CGzUSvlyKBQD, b5O2oQPg9Xzq))) yLFZp0KTSDdd = DQ8LtNukkeHf CGzUSvlyKBQD = XdowRbJKZWL9 b5O2oQPg9Xzq = XdowRbJKZWL9 else: b5O2oQPg9Xzq += ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100001 + 0o20), ord("\x08")) TliSd_m0sUbU = pMllmnQutflp[ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(111) + chr(48), 8)] Si1rS1kQYZAH = pMllmnQutflp[ehT0Px3KOsy9(chr(1591 - 1543) + chr(0b111001 + 0o66) + '\062', 8):] if yLFZp0KTSDdd is not None: xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe9:\xaf\xad\x9aG\x81\xbd@z\x89\xe8'), '\144' + chr(101) + chr(99) + chr(111) + chr(0b1100100) + '\145')('\165' + '\164' + '\x66' + '\x2d' + '\070'))((yLFZp0KTSDdd, (CGzUSvlyKBQD, b5O2oQPg9Xzq))) return YyaZ4tpXu4lf(aPSH2X7oF0wS)
allenai/allennlp
allennlp/data/dataset_readers/dataset_utils/span_utils.py
bioul_tags_to_spans
def bioul_tags_to_spans(tag_sequence: List[str], classes_to_ignore: List[str] = None) -> List[TypedStringSpan]: """ Given a sequence corresponding to BIOUL tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are not allowed and will raise ``InvalidTagSequence``. This function works properly when the spans are unlabeled (i.e., your labels are simply "B", "I", "O", "U", and "L"). Parameters ---------- tag_sequence : ``List[str]``, required. The tag sequence encoded in BIOUL, e.g. ["B-PER", "L-PER", "O"]. classes_to_ignore : ``List[str]``, optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : ``List[TypedStringSpan]`` The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). """ spans = [] classes_to_ignore = classes_to_ignore or [] index = 0 while index < len(tag_sequence): label = tag_sequence[index] if label[0] == 'U': spans.append((label.partition('-')[2], (index, index))) elif label[0] == 'B': start = index while label[0] != 'L': index += 1 if index >= len(tag_sequence): raise InvalidTagSequence(tag_sequence) label = tag_sequence[index] if not (label[0] == 'I' or label[0] == 'L'): raise InvalidTagSequence(tag_sequence) spans.append((label.partition('-')[2], (start, index))) else: if label != 'O': raise InvalidTagSequence(tag_sequence) index += 1 return [span for span in spans if span[0] not in classes_to_ignore]
python
def bioul_tags_to_spans(tag_sequence: List[str], classes_to_ignore: List[str] = None) -> List[TypedStringSpan]: """ Given a sequence corresponding to BIOUL tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are not allowed and will raise ``InvalidTagSequence``. This function works properly when the spans are unlabeled (i.e., your labels are simply "B", "I", "O", "U", and "L"). Parameters ---------- tag_sequence : ``List[str]``, required. The tag sequence encoded in BIOUL, e.g. ["B-PER", "L-PER", "O"]. classes_to_ignore : ``List[str]``, optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : ``List[TypedStringSpan]`` The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). """ spans = [] classes_to_ignore = classes_to_ignore or [] index = 0 while index < len(tag_sequence): label = tag_sequence[index] if label[0] == 'U': spans.append((label.partition('-')[2], (index, index))) elif label[0] == 'B': start = index while label[0] != 'L': index += 1 if index >= len(tag_sequence): raise InvalidTagSequence(tag_sequence) label = tag_sequence[index] if not (label[0] == 'I' or label[0] == 'L'): raise InvalidTagSequence(tag_sequence) spans.append((label.partition('-')[2], (start, index))) else: if label != 'O': raise InvalidTagSequence(tag_sequence) index += 1 return [span for span in spans if span[0] not in classes_to_ignore]
[ "def", "bioul_tags_to_spans", "(", "tag_sequence", ":", "List", "[", "str", "]", ",", "classes_to_ignore", ":", "List", "[", "str", "]", "=", "None", ")", "->", "List", "[", "TypedStringSpan", "]", ":", "spans", "=", "[", "]", "classes_to_ignore", "=", "classes_to_ignore", "or", "[", "]", "index", "=", "0", "while", "index", "<", "len", "(", "tag_sequence", ")", ":", "label", "=", "tag_sequence", "[", "index", "]", "if", "label", "[", "0", "]", "==", "'U'", ":", "spans", ".", "append", "(", "(", "label", ".", "partition", "(", "'-'", ")", "[", "2", "]", ",", "(", "index", ",", "index", ")", ")", ")", "elif", "label", "[", "0", "]", "==", "'B'", ":", "start", "=", "index", "while", "label", "[", "0", "]", "!=", "'L'", ":", "index", "+=", "1", "if", "index", ">=", "len", "(", "tag_sequence", ")", ":", "raise", "InvalidTagSequence", "(", "tag_sequence", ")", "label", "=", "tag_sequence", "[", "index", "]", "if", "not", "(", "label", "[", "0", "]", "==", "'I'", "or", "label", "[", "0", "]", "==", "'L'", ")", ":", "raise", "InvalidTagSequence", "(", "tag_sequence", ")", "spans", ".", "append", "(", "(", "label", ".", "partition", "(", "'-'", ")", "[", "2", "]", ",", "(", "start", ",", "index", ")", ")", ")", "else", ":", "if", "label", "!=", "'O'", ":", "raise", "InvalidTagSequence", "(", "tag_sequence", ")", "index", "+=", "1", "return", "[", "span", "for", "span", "in", "spans", "if", "span", "[", "0", "]", "not", "in", "classes_to_ignore", "]" ]
Given a sequence corresponding to BIOUL tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are not allowed and will raise ``InvalidTagSequence``. This function works properly when the spans are unlabeled (i.e., your labels are simply "B", "I", "O", "U", and "L"). Parameters ---------- tag_sequence : ``List[str]``, required. The tag sequence encoded in BIOUL, e.g. ["B-PER", "L-PER", "O"]. classes_to_ignore : ``List[str]``, optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : ``List[TypedStringSpan]`` The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)).
[ "Given", "a", "sequence", "corresponding", "to", "BIOUL", "tags", "extracts", "spans", ".", "Spans", "are", "inclusive", "and", "can", "be", "of", "zero", "length", "representing", "a", "single", "word", "span", ".", "Ill", "-", "formed", "spans", "are", "not", "allowed", "and", "will", "raise", "InvalidTagSequence", ".", "This", "function", "works", "properly", "when", "the", "spans", "are", "unlabeled", "(", "i", ".", "e", ".", "your", "labels", "are", "simply", "B", "I", "O", "U", "and", "L", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/span_utils.py#L217-L260
train
Given a sequence corresponding to BIOUL tags extracts spans from the sequence.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthd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Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b10101 + 0o33) + '\x6f' + chr(0b110010) + chr(0b110010) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1795 - 1745) + chr(0b11110 + 0o25) + '\x30', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(49) + '\x34' + chr(0b101101 + 0o5), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1001111 + 0o40) + chr(770 - 721) + chr(0b110001) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(865 - 817) + chr(111) + '\063' + chr(48) + '\061', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1654 - 1603) + chr(0b1000 + 0o50) + chr(0b11010 + 0o30), 0o10), ehT0Px3KOsy9('\060' + chr(4450 - 4339) + chr(50) + chr(49), 53592 - 53584), ehT0Px3KOsy9('\x30' + chr(0b1101110 + 0o1) + chr(51) + chr(48) + '\065', 50848 - 50840), ehT0Px3KOsy9(chr(2118 - 2070) + chr(0b1101101 + 0o2) + '\x32' + chr(0b110011) + chr(919 - 869), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110010) + chr(50) + chr(0b0 + 0o63), 0b1000), ehT0Px3KOsy9('\060' + chr(7949 - 7838) + '\x33' + chr(1808 - 1755) + chr(1962 - 1912), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(10335 - 10224) + chr(0b110011) + chr(727 - 672) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(10671 - 10560) + '\062' + '\x34' + chr(1981 - 1929), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(2388 - 2339) + chr(54) + chr(0b11011 + 0o26), 0b1000), ehT0Px3KOsy9(chr(217 - 169) + chr(111) + chr(1706 - 1655) + chr(1884 - 1833) + chr(0b110000), 33345 - 33337), ehT0Px3KOsy9(chr(2001 - 1953) + chr(12191 - 12080) + chr(49) + '\x34' + '\x31', 0o10), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(111) + chr(0b110011) + chr(50) + chr(0b110010), 0b1000), ehT0Px3KOsy9('\060' + chr(8795 - 8684) + chr(0b101101 + 0o6) + chr(0b110100) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + chr(0b110110) + '\061', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(0b1100 + 0o47) + '\061', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(3405 - 3294) + chr(642 - 593) + chr(1397 - 1344) + chr(52), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + chr(0b110111) + chr(54), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(2297 - 2247) + '\064', 52253 - 52245), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(10943 - 10832) + chr(0b110010) + '\061' + chr(0b110110), 45999 - 45991), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(9553 - 9442) + '\x31' + chr(55), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\x31' + '\061' + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\157' + chr(456 - 405) + chr(373 - 324) + '\x34', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(50) + chr(2115 - 2065) + chr(766 - 718), 0b1000), ehT0Px3KOsy9(chr(85 - 37) + chr(0b11010 + 0o125) + chr(0b1100 + 0o47) + chr(1055 - 1003) + chr(0b10000 + 0o40), 56954 - 56946), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + chr(0b110000) + chr(0b110010 + 0o5), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + '\064' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(54) + chr(0b110001 + 0o3), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x32' + chr(2404 - 2351) + chr(2051 - 2002), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101101 + 0o2) + '\x31' + chr(148 - 96) + '\063', 0b1000), ehT0Px3KOsy9('\060' + chr(11545 - 11434) + chr(1783 - 1734) + chr(0b110001) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + '\060' + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b1001 + 0o47) + '\157' + chr(49) + chr(0b110111) + '\065', 15066 - 15058), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001 + 0o1) + chr(0b110101) + chr(2077 - 2023), 54441 - 54433), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(55) + chr(2157 - 2104), 8), ehT0Px3KOsy9(chr(2135 - 2087) + chr(0b1101111) + '\063' + chr(0b110010) + '\065', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(0b1001111 + 0o40) + '\065' + '\060', 30320 - 30312)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xbb'), chr(5608 - 5508) + '\x65' + '\143' + chr(10176 - 10065) + chr(0b1100100) + chr(9719 - 9618))(chr(0b10110 + 0o137) + '\164' + chr(7437 - 7335) + chr(0b101101) + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def Ny_wXMrDbXuP(utunRCPj8Imk, CwAp18FPCQND=None) -> qRxF7OQ0y39T[JWGWO_DJzASh]: aPSH2X7oF0wS = [] CwAp18FPCQND = CwAp18FPCQND or [] XdowRbJKZWL9 = ehT0Px3KOsy9('\060' + chr(111) + chr(0b1100 + 0o44), 0o10) while XdowRbJKZWL9 < c2A0yzQpDQB3(utunRCPj8Imk): TRUOLFLuD08x = utunRCPj8Imk[XdowRbJKZWL9] if TRUOLFLuD08x[ehT0Px3KOsy9(chr(48) + '\157' + chr(775 - 727), 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0'), chr(0b1100100) + chr(101) + chr(6585 - 6486) + '\x6f' + chr(100) + chr(0b1000011 + 0o42))(chr(117) + '\164' + chr(0b1010100 + 0o22) + chr(45) + '\070'): xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf4\xe8\x12*\xaf\xa6'), chr(0b1001010 + 0o32) + chr(0b1100101) + '\x63' + chr(0b1000010 + 0o55) + chr(7165 - 7065) + chr(953 - 852))(chr(11693 - 11576) + '\x74' + chr(0b1100110) + chr(0b100011 + 0o12) + chr(56)))((xafqLlk3kkUe(TRUOLFLuD08x, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe5\xf9\x10;\xa8\xb6x\xaa\xf4'), '\144' + chr(0b1100101) + chr(0b101111 + 0o64) + chr(0b11111 + 0o120) + chr(100) + chr(101))('\x75' + chr(0b1110100) + chr(851 - 749) + chr(45) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xb8'), '\144' + chr(4181 - 4080) + '\143' + chr(0b1101111) + '\144' + '\x65')('\x75' + chr(12690 - 12574) + chr(0b11001 + 0o115) + '\x2d' + '\x38'))[ehT0Px3KOsy9(chr(48) + chr(5447 - 5336) + '\062', ord("\x08"))], (XdowRbJKZWL9, XdowRbJKZWL9))) elif TRUOLFLuD08x[ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x30', 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7'), chr(0b1001010 + 0o32) + chr(0b1100101) + chr(99) + chr(0b110000 + 0o77) + chr(5057 - 4957) + '\145')(chr(117) + '\x74' + chr(102) + chr(1186 - 1141) + '\x38'): avRbFsnfJxQj = XdowRbJKZWL9 while TRUOLFLuD08x[ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b111110 + 0o61) + '\x30', 8)] != xafqLlk3kkUe(SXOLrMavuUCe(b'\xd9'), chr(9217 - 9117) + '\x65' + chr(7439 - 7340) + chr(0b11101 + 0o122) + chr(100) + chr(1881 - 1780))(chr(0b1110101) + chr(116) + chr(102) + chr(1365 - 1320) + chr(0b10011 + 0o45)): XdowRbJKZWL9 += ehT0Px3KOsy9('\060' + chr(111) + chr(49), 32769 - 32761) if XdowRbJKZWL9 >= c2A0yzQpDQB3(utunRCPj8Imk): raise WPN1tW8jgnXd(utunRCPj8Imk) TRUOLFLuD08x = utunRCPj8Imk[XdowRbJKZWL9] if not (TRUOLFLuD08x[ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b1110 + 0o42), 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xdc'), chr(0b1010110 + 0o16) + chr(0b1100101) + chr(8178 - 8079) + chr(271 - 160) + chr(100) + chr(101))(chr(4165 - 4048) + chr(116) + chr(0b1100110) + chr(45) + chr(0b111000)) or TRUOLFLuD08x[ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(8911 - 8800) + '\060', 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xd9'), chr(6544 - 6444) + chr(0b1001 + 0o134) + chr(99) + '\x6f' + '\144' + '\145')(chr(117) + '\x74' + chr(9415 - 9313) + '\055' + chr(2429 - 2373))): raise WPN1tW8jgnXd(utunRCPj8Imk) xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf4\xe8\x12*\xaf\xa6'), chr(100) + chr(101) + chr(99) + chr(0b1101111) + chr(0b1100100) + chr(4429 - 4328))(chr(0b11101 + 0o130) + chr(0b1110100) + '\146' + '\055' + chr(56)))((xafqLlk3kkUe(TRUOLFLuD08x, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe5\xf9\x10;\xa8\xb6x\xaa\xf4'), '\144' + '\145' + chr(0b1100011) + chr(0b1101111) + chr(0b1100100) + chr(0b1100101))(chr(117) + chr(0b1010 + 0o152) + '\146' + chr(45) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xb8'), chr(100) + '\145' + '\143' + chr(0b11010 + 0o125) + chr(0b1011100 + 0o10) + chr(7386 - 7285))(chr(117) + '\x74' + '\146' + chr(0b101101) + '\070'))[ehT0Px3KOsy9(chr(0b110000) + chr(167 - 56) + chr(50), 8)], (avRbFsnfJxQj, XdowRbJKZWL9))) elif TRUOLFLuD08x != xafqLlk3kkUe(SXOLrMavuUCe(b'\xda'), chr(0b1100100) + chr(4325 - 4224) + chr(207 - 108) + chr(0b1100100 + 0o13) + chr(0b1100100) + chr(0b111010 + 0o53))('\x75' + '\x74' + chr(102) + '\x2d' + chr(0b100100 + 0o24)): raise WPN1tW8jgnXd(utunRCPj8Imk) XdowRbJKZWL9 += ehT0Px3KOsy9(chr(48) + '\x6f' + '\061', 8) return [cM7fEShWxtgh for cM7fEShWxtgh in aPSH2X7oF0wS if cM7fEShWxtgh[ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(0b1101111) + chr(48), 8)] not in CwAp18FPCQND]
allenai/allennlp
allennlp/data/dataset_readers/dataset_utils/span_utils.py
to_bioul
def to_bioul(tag_sequence: List[str], encoding: str = "IOB1") -> List[str]: """ Given a tag sequence encoded with IOB1 labels, recode to BIOUL. In the IOB1 scheme, I is a token inside a span, O is a token outside a span and B is the beginning of span immediately following another span of the same type. In the BIO scheme, I is a token inside a span, O is a token outside a span and B is the beginning of a span. Parameters ---------- tag_sequence : ``List[str]``, required. The tag sequence encoded in IOB1, e.g. ["I-PER", "I-PER", "O"]. encoding : `str`, optional, (default = ``IOB1``). The encoding type to convert from. Must be either "IOB1" or "BIO". Returns ------- bioul_sequence: ``List[str]`` The tag sequence encoded in IOB1, e.g. ["B-PER", "L-PER", "O"]. """ if not encoding in {"IOB1", "BIO"}: raise ConfigurationError(f"Invalid encoding {encoding} passed to 'to_bioul'.") # pylint: disable=len-as-condition def replace_label(full_label, new_label): # example: full_label = 'I-PER', new_label = 'U', returns 'U-PER' parts = list(full_label.partition('-')) parts[0] = new_label return ''.join(parts) def pop_replace_append(in_stack, out_stack, new_label): # pop the last element from in_stack, replace the label, append # to out_stack tag = in_stack.pop() new_tag = replace_label(tag, new_label) out_stack.append(new_tag) def process_stack(stack, out_stack): # process a stack of labels, add them to out_stack if len(stack) == 1: # just a U token pop_replace_append(stack, out_stack, 'U') else: # need to code as BIL recoded_stack = [] pop_replace_append(stack, recoded_stack, 'L') while len(stack) >= 2: pop_replace_append(stack, recoded_stack, 'I') pop_replace_append(stack, recoded_stack, 'B') recoded_stack.reverse() out_stack.extend(recoded_stack) # Process the tag_sequence one tag at a time, adding spans to a stack, # then recode them. bioul_sequence = [] stack: List[str] = [] for label in tag_sequence: # need to make a dict like # token = {'token': 'Matt', "labels": {'conll2003': "B-PER"} # 'gold': 'I-PER'} # where 'gold' is the raw value from the CoNLL data set if label == 'O' and len(stack) == 0: bioul_sequence.append(label) elif label == 'O' and len(stack) > 0: # need to process the entries on the stack plus this one process_stack(stack, bioul_sequence) bioul_sequence.append(label) elif label[0] == 'I': # check if the previous type is the same as this one # if it is then append to stack # otherwise this start a new entity if the type # is different if len(stack) == 0: if encoding == "BIO": raise InvalidTagSequence(tag_sequence) stack.append(label) else: # check if the previous type is the same as this one this_type = label.partition('-')[2] prev_type = stack[-1].partition('-')[2] if this_type == prev_type: stack.append(label) else: if encoding == "BIO": raise InvalidTagSequence(tag_sequence) # a new entity process_stack(stack, bioul_sequence) stack.append(label) elif label[0] == 'B': if len(stack) > 0: process_stack(stack, bioul_sequence) stack.append(label) else: raise InvalidTagSequence(tag_sequence) # process the stack if len(stack) > 0: process_stack(stack, bioul_sequence) return bioul_sequence
python
def to_bioul(tag_sequence: List[str], encoding: str = "IOB1") -> List[str]: """ Given a tag sequence encoded with IOB1 labels, recode to BIOUL. In the IOB1 scheme, I is a token inside a span, O is a token outside a span and B is the beginning of span immediately following another span of the same type. In the BIO scheme, I is a token inside a span, O is a token outside a span and B is the beginning of a span. Parameters ---------- tag_sequence : ``List[str]``, required. The tag sequence encoded in IOB1, e.g. ["I-PER", "I-PER", "O"]. encoding : `str`, optional, (default = ``IOB1``). The encoding type to convert from. Must be either "IOB1" or "BIO". Returns ------- bioul_sequence: ``List[str]`` The tag sequence encoded in IOB1, e.g. ["B-PER", "L-PER", "O"]. """ if not encoding in {"IOB1", "BIO"}: raise ConfigurationError(f"Invalid encoding {encoding} passed to 'to_bioul'.") # pylint: disable=len-as-condition def replace_label(full_label, new_label): # example: full_label = 'I-PER', new_label = 'U', returns 'U-PER' parts = list(full_label.partition('-')) parts[0] = new_label return ''.join(parts) def pop_replace_append(in_stack, out_stack, new_label): # pop the last element from in_stack, replace the label, append # to out_stack tag = in_stack.pop() new_tag = replace_label(tag, new_label) out_stack.append(new_tag) def process_stack(stack, out_stack): # process a stack of labels, add them to out_stack if len(stack) == 1: # just a U token pop_replace_append(stack, out_stack, 'U') else: # need to code as BIL recoded_stack = [] pop_replace_append(stack, recoded_stack, 'L') while len(stack) >= 2: pop_replace_append(stack, recoded_stack, 'I') pop_replace_append(stack, recoded_stack, 'B') recoded_stack.reverse() out_stack.extend(recoded_stack) # Process the tag_sequence one tag at a time, adding spans to a stack, # then recode them. bioul_sequence = [] stack: List[str] = [] for label in tag_sequence: # need to make a dict like # token = {'token': 'Matt', "labels": {'conll2003': "B-PER"} # 'gold': 'I-PER'} # where 'gold' is the raw value from the CoNLL data set if label == 'O' and len(stack) == 0: bioul_sequence.append(label) elif label == 'O' and len(stack) > 0: # need to process the entries on the stack plus this one process_stack(stack, bioul_sequence) bioul_sequence.append(label) elif label[0] == 'I': # check if the previous type is the same as this one # if it is then append to stack # otherwise this start a new entity if the type # is different if len(stack) == 0: if encoding == "BIO": raise InvalidTagSequence(tag_sequence) stack.append(label) else: # check if the previous type is the same as this one this_type = label.partition('-')[2] prev_type = stack[-1].partition('-')[2] if this_type == prev_type: stack.append(label) else: if encoding == "BIO": raise InvalidTagSequence(tag_sequence) # a new entity process_stack(stack, bioul_sequence) stack.append(label) elif label[0] == 'B': if len(stack) > 0: process_stack(stack, bioul_sequence) stack.append(label) else: raise InvalidTagSequence(tag_sequence) # process the stack if len(stack) > 0: process_stack(stack, bioul_sequence) return bioul_sequence
[ "def", "to_bioul", "(", "tag_sequence", ":", "List", "[", "str", "]", ",", "encoding", ":", "str", "=", "\"IOB1\"", ")", "->", "List", "[", "str", "]", ":", "if", "not", "encoding", "in", "{", "\"IOB1\"", ",", "\"BIO\"", "}", ":", "raise", "ConfigurationError", "(", "f\"Invalid encoding {encoding} passed to 'to_bioul'.\"", ")", "# pylint: disable=len-as-condition", "def", "replace_label", "(", "full_label", ",", "new_label", ")", ":", "# example: full_label = 'I-PER', new_label = 'U', returns 'U-PER'", "parts", "=", "list", "(", "full_label", ".", "partition", "(", "'-'", ")", ")", "parts", "[", "0", "]", "=", "new_label", "return", "''", ".", "join", "(", "parts", ")", "def", "pop_replace_append", "(", "in_stack", ",", "out_stack", ",", "new_label", ")", ":", "# pop the last element from in_stack, replace the label, append", "# to out_stack", "tag", "=", "in_stack", ".", "pop", "(", ")", "new_tag", "=", "replace_label", "(", "tag", ",", "new_label", ")", "out_stack", ".", "append", "(", "new_tag", ")", "def", "process_stack", "(", "stack", ",", "out_stack", ")", ":", "# process a stack of labels, add them to out_stack", "if", "len", "(", "stack", ")", "==", "1", ":", "# just a U token", "pop_replace_append", "(", "stack", ",", "out_stack", ",", "'U'", ")", "else", ":", "# need to code as BIL", "recoded_stack", "=", "[", "]", "pop_replace_append", "(", "stack", ",", "recoded_stack", ",", "'L'", ")", "while", "len", "(", "stack", ")", ">=", "2", ":", "pop_replace_append", "(", "stack", ",", "recoded_stack", ",", "'I'", ")", "pop_replace_append", "(", "stack", ",", "recoded_stack", ",", "'B'", ")", "recoded_stack", ".", "reverse", "(", ")", "out_stack", ".", "extend", "(", "recoded_stack", ")", "# Process the tag_sequence one tag at a time, adding spans to a stack,", "# then recode them.", "bioul_sequence", "=", "[", "]", "stack", ":", "List", "[", "str", "]", "=", "[", "]", "for", "label", "in", "tag_sequence", ":", "# need to make a dict like", "# token = {'token': 'Matt', \"labels\": {'conll2003': \"B-PER\"}", "# 'gold': 'I-PER'}", "# where 'gold' is the raw value from the CoNLL data set", "if", "label", "==", "'O'", "and", "len", "(", "stack", ")", "==", "0", ":", "bioul_sequence", ".", "append", "(", "label", ")", "elif", "label", "==", "'O'", "and", "len", "(", "stack", ")", ">", "0", ":", "# need to process the entries on the stack plus this one", "process_stack", "(", "stack", ",", "bioul_sequence", ")", "bioul_sequence", ".", "append", "(", "label", ")", "elif", "label", "[", "0", "]", "==", "'I'", ":", "# check if the previous type is the same as this one", "# if it is then append to stack", "# otherwise this start a new entity if the type", "# is different", "if", "len", "(", "stack", ")", "==", "0", ":", "if", "encoding", "==", "\"BIO\"", ":", "raise", "InvalidTagSequence", "(", "tag_sequence", ")", "stack", ".", "append", "(", "label", ")", "else", ":", "# check if the previous type is the same as this one", "this_type", "=", "label", ".", "partition", "(", "'-'", ")", "[", "2", "]", "prev_type", "=", "stack", "[", "-", "1", "]", ".", "partition", "(", "'-'", ")", "[", "2", "]", "if", "this_type", "==", "prev_type", ":", "stack", ".", "append", "(", "label", ")", "else", ":", "if", "encoding", "==", "\"BIO\"", ":", "raise", "InvalidTagSequence", "(", "tag_sequence", ")", "# a new entity", "process_stack", "(", "stack", ",", "bioul_sequence", ")", "stack", ".", "append", "(", "label", ")", "elif", "label", "[", "0", "]", "==", "'B'", ":", "if", "len", "(", "stack", ")", ">", "0", ":", "process_stack", "(", "stack", ",", "bioul_sequence", ")", "stack", ".", "append", "(", "label", ")", "else", ":", "raise", "InvalidTagSequence", "(", "tag_sequence", ")", "# process the stack", "if", "len", "(", "stack", ")", ">", "0", ":", "process_stack", "(", "stack", ",", "bioul_sequence", ")", "return", "bioul_sequence" ]
Given a tag sequence encoded with IOB1 labels, recode to BIOUL. In the IOB1 scheme, I is a token inside a span, O is a token outside a span and B is the beginning of span immediately following another span of the same type. In the BIO scheme, I is a token inside a span, O is a token outside a span and B is the beginning of a span. Parameters ---------- tag_sequence : ``List[str]``, required. The tag sequence encoded in IOB1, e.g. ["I-PER", "I-PER", "O"]. encoding : `str`, optional, (default = ``IOB1``). The encoding type to convert from. Must be either "IOB1" or "BIO". Returns ------- bioul_sequence: ``List[str]`` The tag sequence encoded in IOB1, e.g. ["B-PER", "L-PER", "O"].
[ "Given", "a", "tag", "sequence", "encoded", "with", "IOB1", "labels", "recode", "to", "BIOUL", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/span_utils.py#L267-L373
train
Convert a tag sequence encoded with IOB1 labels to BIOUL.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,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0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\x6f' + chr(51) + chr(1787 - 1735) + chr(0b1001 + 0o53), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b101011 + 0o10) + chr(424 - 370) + chr(0b101 + 0o56), 19225 - 19217), ehT0Px3KOsy9('\060' + chr(10954 - 10843) + '\x36' + chr(1216 - 1168), ord("\x08")), ehT0Px3KOsy9(chr(2133 - 2085) + chr(0b1101111) + chr(1804 - 1755) + '\061' + chr(0b10000 + 0o47), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110 + 0o54) + '\064' + chr(54), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b10011 + 0o134) + '\x31' + chr(0b10001 + 0o37) + chr(280 - 228), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(51) + chr(0b10000 + 0o40), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(51) + chr(0b110001) + '\x31', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(132 - 82) + chr(0b110010) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(2174 - 2126) + '\x6f' + '\x32' + '\x32' + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + '\061' + chr(0b101 + 0o60), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + chr(48) + '\x35', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b100010 + 0o115) + chr(49) + '\x35' + chr(0b10101 + 0o40), 0o10), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b11011 + 0o124) + '\061' + chr(49) + '\x32', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\064' + '\x35', 10668 - 10660), ehT0Px3KOsy9('\060' + chr(0b1010000 + 0o37) + chr(2261 - 2211) + '\x33' + chr(0b10001 + 0o43), ord("\x08")), ehT0Px3KOsy9(chr(1966 - 1918) + chr(111) + chr(0b11101 + 0o26), 53453 - 53445), ehT0Px3KOsy9('\x30' + chr(0b1100010 + 0o15) + chr(0b110111) + '\067', 0b1000), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b1010100 + 0o33) + chr(0b110011) + chr(51) + chr(0b10011 + 0o35), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(11373 - 11262) + '\061' + chr(2494 - 2442) + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(0b1101111) + '\062' + chr(0b110010) + chr(0b110010), 8), ehT0Px3KOsy9(chr(48) + chr(0b10001 + 0o136) + chr(53) + chr(663 - 615), 0o10), ehT0Px3KOsy9(chr(1630 - 1582) + '\157' + chr(0b110010) + chr(0b110010) + '\x32', 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(1027 - 978) + chr(0b110111) + chr(52), 61449 - 61441), ehT0Px3KOsy9(chr(1327 - 1279) + chr(111) + chr(0b10 + 0o60) + '\x35' + chr(1827 - 1779), ord("\x08")), ehT0Px3KOsy9(chr(338 - 290) + '\x6f' + '\x32' + chr(55) + '\x33', 47123 - 47115), ehT0Px3KOsy9(chr(1370 - 1322) + chr(2273 - 2162) + '\x35' + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x31' + chr(0b100011 + 0o20) + chr(951 - 902), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + chr(0b110000) + '\066', 0o10), ehT0Px3KOsy9(chr(216 - 168) + chr(9861 - 9750) + chr(0b110110) + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110011) + '\061' + chr(0b101101 + 0o7), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(52), 13276 - 13268), ehT0Px3KOsy9(chr(48) + chr(3244 - 3133) + chr(0b100110 + 0o15) + '\066' + chr(48), 0b1000), ehT0Px3KOsy9(chr(283 - 235) + chr(0b1101111) + chr(49) + chr(1093 - 1042), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + '\x37' + chr(2011 - 1962), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + '\x32' + '\061', ord("\x08")), ehT0Px3KOsy9(chr(68 - 20) + '\157' + chr(0b110010) + chr(0b110011) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(52) + chr(517 - 468), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b10110 + 0o131) + '\x33' + chr(0b110101) + '\x33', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(9332 - 9221) + chr(2316 - 2263) + chr(1445 - 1397), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xca'), chr(0b1100100) + chr(0b1100101) + chr(0b1100011) + '\x6f' + chr(100) + chr(4575 - 4474))(chr(117) + chr(0b111001 + 0o73) + chr(10068 - 9966) + chr(45) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def vpFIyjxeWBLi(utunRCPj8Imk, _pPd9lb_XZ4K=xafqLlk3kkUe(SXOLrMavuUCe(b'\xad\xbcr~'), '\x64' + chr(0b1100101) + '\x63' + chr(1981 - 1870) + chr(100) + chr(6932 - 6831))(chr(0b1110101) + '\x74' + '\146' + '\x2d' + chr(0b111000))) -> qRxF7OQ0y39T[M8_cKLkHVB2V]: if _pPd9lb_XZ4K not in {xafqLlk3kkUe(SXOLrMavuUCe(b'\xad\xbcr~'), chr(5773 - 5673) + chr(288 - 187) + chr(99) + chr(1091 - 980) + chr(0b1010 + 0o132) + '\145')(chr(117) + '\x74' + chr(102) + '\x2d' + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xa6\xba\x7f'), '\144' + chr(101) + chr(0b1100011) + chr(8482 - 8371) + chr(100) + chr(0b1100101))(chr(0b1110101) + '\164' + chr(8714 - 8612) + chr(0b101101) + chr(56))}: raise h0iXqtiKVeKg(f"Invalid encoding {_pPd9lb_XZ4K} passed to 'to_bioul'.") def DOAchFb8kQQU(xRNl7UJ5juwh, jp5pe2X662PZ): gIfWK5W_pmM4 = YyaZ4tpXu4lf(xRNl7UJ5juwh.partition(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc9'), '\x64' + chr(0b110000 + 0o65) + chr(0b1100011) + chr(111) + chr(7678 - 7578) + chr(0b1001000 + 0o35))(chr(0b1110101) + chr(0b1110100) + chr(0b1100110) + '\055' + chr(246 - 190)))) gIfWK5W_pmM4[ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\157' + chr(730 - 682), 14656 - 14648)] = jp5pe2X662PZ return xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(0b10111 + 0o115) + '\145' + chr(0b10100 + 0o117) + '\x6f' + chr(2495 - 2395) + chr(9644 - 9543))(chr(117) + chr(11540 - 11424) + '\x66' + chr(1093 - 1048) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\x9cY!'), chr(0b1100100) + chr(101) + chr(9750 - 9651) + '\x6f' + '\144' + chr(4785 - 4684))(chr(0b1110101) + chr(8206 - 8090) + chr(7503 - 7401) + chr(0b10011 + 0o32) + '\070'))(gIfWK5W_pmM4) def kHFQLFFb7Dlm(SWLGJ4jwf8y2, hvArimoLy6p1, jp5pe2X662PZ): CPdEsc5O1sf7 = SWLGJ4jwf8y2.pop() Jwk4GcfLGi2l = DOAchFb8kQQU(CPdEsc5O1sf7, jp5pe2X662PZ) xafqLlk3kkUe(hvArimoLy6p1, xafqLlk3kkUe(SXOLrMavuUCe(b'\x85\x83@*\xc8 '), '\144' + '\145' + chr(99) + '\157' + '\144' + '\x65')('\x75' + '\x74' + chr(7319 - 7217) + chr(45) + chr(1529 - 1473)))(Jwk4GcfLGi2l) def SmzoQkSWE36g(rFoCQMjVYqWa, hvArimoLy6p1): if c2A0yzQpDQB3(rFoCQMjVYqWa) == ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061', 0o10): kHFQLFFb7Dlm(rFoCQMjVYqWa, hvArimoLy6p1, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb1'), '\144' + chr(0b101010 + 0o73) + chr(0b111111 + 0o44) + '\x6f' + chr(0b1001110 + 0o26) + chr(3048 - 2947))(chr(0b1010101 + 0o40) + chr(0b11111 + 0o125) + '\146' + chr(45) + chr(0b101 + 0o63))) else: LEVAWk5khDa0 = [] kHFQLFFb7Dlm(rFoCQMjVYqWa, LEVAWk5khDa0, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa8'), chr(100) + chr(0b1100101) + '\x63' + '\157' + chr(0b1100100) + chr(8862 - 8761))(chr(7013 - 6896) + chr(0b1110100) + '\146' + chr(1694 - 1649) + '\x38')) while c2A0yzQpDQB3(rFoCQMjVYqWa) >= ehT0Px3KOsy9('\060' + chr(0b1100000 + 0o17) + chr(0b110010), 0o10): kHFQLFFb7Dlm(rFoCQMjVYqWa, LEVAWk5khDa0, xafqLlk3kkUe(SXOLrMavuUCe(b'\xad'), '\x64' + chr(3212 - 3111) + chr(2556 - 2457) + chr(7668 - 7557) + chr(6032 - 5932) + '\145')(chr(0b1100 + 0o151) + chr(9189 - 9073) + '\x66' + chr(0b101101) + '\x38')) kHFQLFFb7Dlm(rFoCQMjVYqWa, LEVAWk5khDa0, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa6'), '\x64' + chr(101) + chr(99) + chr(111) + '\x64' + chr(0b0 + 0o145))('\x75' + chr(4841 - 4725) + '\146' + chr(0b1111 + 0o36) + chr(0b111000))) xafqLlk3kkUe(LEVAWk5khDa0, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\xa3x6\xc9\rRY\xb1\xef\xdb\xd2'), chr(0b1111 + 0o125) + chr(0b1100101) + chr(0b1100011) + chr(111) + '\x64' + chr(101))(chr(12880 - 12763) + chr(12094 - 11978) + chr(0b1100110) + chr(45) + chr(241 - 185)))() xafqLlk3kkUe(hvArimoLy6p1, xafqLlk3kkUe(SXOLrMavuUCe(b'\x81\x8bD*\xc8 '), chr(492 - 392) + '\145' + '\x63' + '\x6f' + chr(0b1100100) + '\x65')('\165' + chr(116) + '\146' + '\055' + chr(56)))(LEVAWk5khDa0) qFB4Kcv_2IeA = [] rFoCQMjVYqWa = [] for TRUOLFLuD08x in utunRCPj8Imk: if TRUOLFLuD08x == xafqLlk3kkUe(SXOLrMavuUCe(b'\xab'), '\144' + '\x65' + '\x63' + chr(8112 - 8001) + chr(6184 - 6084) + '\x65')(chr(0b1110101) + chr(116) + chr(102) + '\055' + '\070') and c2A0yzQpDQB3(rFoCQMjVYqWa) == ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(111) + chr(0b110000), 8): xafqLlk3kkUe(qFB4Kcv_2IeA, xafqLlk3kkUe(SXOLrMavuUCe(b'\x85\x83@*\xc8 '), chr(0b1000110 + 0o36) + chr(270 - 169) + chr(99) + chr(0b1010000 + 0o37) + chr(3819 - 3719) + chr(6877 - 6776))('\x75' + chr(116) + chr(0b110111 + 0o57) + chr(1030 - 985) + chr(1716 - 1660)))(TRUOLFLuD08x) elif TRUOLFLuD08x == xafqLlk3kkUe(SXOLrMavuUCe(b'\xab'), chr(100) + chr(3131 - 3030) + '\x63' + '\157' + chr(6332 - 6232) + '\145')('\x75' + chr(116) + '\x66' + chr(0b1011 + 0o42) + chr(0b111000 + 0o0)) and c2A0yzQpDQB3(rFoCQMjVYqWa) > ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x30', 8): SmzoQkSWE36g(rFoCQMjVYqWa, qFB4Kcv_2IeA) xafqLlk3kkUe(qFB4Kcv_2IeA, xafqLlk3kkUe(SXOLrMavuUCe(b'\x85\x83@*\xc8 '), '\x64' + chr(101) + chr(0b1100011) + '\157' + '\x64' + '\x65')(chr(0b1101000 + 0o15) + chr(12582 - 12466) + chr(0b1100110) + chr(0b101101) + '\x38'))(TRUOLFLuD08x) elif TRUOLFLuD08x[ehT0Px3KOsy9(chr(247 - 199) + chr(0b101011 + 0o104) + '\060', 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xad'), chr(4767 - 4667) + chr(0b1100101) + '\x63' + '\157' + '\x64' + chr(0b1100101))('\x75' + '\164' + chr(0b1100110) + chr(0b11100 + 0o21) + chr(0b111000)): if c2A0yzQpDQB3(rFoCQMjVYqWa) == ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110000 + 0o0), 8): if _pPd9lb_XZ4K == xafqLlk3kkUe(SXOLrMavuUCe(b'\xa6\xba\x7f'), '\x64' + '\145' + chr(0b100110 + 0o75) + chr(0b1101111) + chr(6927 - 6827) + chr(0b11111 + 0o106))(chr(117) + chr(0b1110100) + '\146' + chr(0b101101) + chr(2591 - 2535)): raise WPN1tW8jgnXd(utunRCPj8Imk) xafqLlk3kkUe(rFoCQMjVYqWa, xafqLlk3kkUe(SXOLrMavuUCe(b'\x85\x83@*\xc8 '), chr(0b1100001 + 0o3) + '\x65' + '\143' + '\x6f' + '\144' + chr(4702 - 4601))(chr(12998 - 12881) + chr(0b1100010 + 0o22) + chr(0b1100110) + chr(0b101101) + '\x38'))(TRUOLFLuD08x) else: cFpWZ9oapuqT = TRUOLFLuD08x.partition(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc9'), '\144' + '\145' + '\x63' + chr(111) + '\144' + chr(0b1100101))(chr(0b1110101) + chr(0b1100111 + 0o15) + '\x66' + chr(0b10 + 0o53) + chr(0b11 + 0o65)))[ehT0Px3KOsy9(chr(0b110000) + chr(0b1001000 + 0o47) + '\062', 8)] VM8L8mwylnOO = rFoCQMjVYqWa[-ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31', 8)].partition(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc9'), chr(0b1100100) + '\x65' + '\143' + chr(111) + chr(0b1101 + 0o127) + chr(6310 - 6209))(chr(117) + chr(116) + '\x66' + '\055' + chr(1525 - 1469)))[ehT0Px3KOsy9(chr(0b11 + 0o55) + '\x6f' + chr(0b101111 + 0o3), 8)] if cFpWZ9oapuqT == VM8L8mwylnOO: xafqLlk3kkUe(rFoCQMjVYqWa, xafqLlk3kkUe(SXOLrMavuUCe(b'\x85\x83@*\xc8 '), chr(3046 - 2946) + chr(3781 - 3680) + chr(99) + chr(111) + chr(0b1100100) + '\x65')('\x75' + '\164' + '\x66' + chr(0b100110 + 0o7) + chr(0b111000)))(TRUOLFLuD08x) else: if _pPd9lb_XZ4K == xafqLlk3kkUe(SXOLrMavuUCe(b'\xa6\xba\x7f'), chr(100) + '\145' + chr(2160 - 2061) + '\x6f' + chr(8475 - 8375) + '\x65')('\165' + '\x74' + '\x66' + chr(0b101101) + '\x38'): raise WPN1tW8jgnXd(utunRCPj8Imk) SmzoQkSWE36g(rFoCQMjVYqWa, qFB4Kcv_2IeA) xafqLlk3kkUe(rFoCQMjVYqWa, xafqLlk3kkUe(SXOLrMavuUCe(b'\x85\x83@*\xc8 '), chr(100) + chr(101) + chr(1108 - 1009) + chr(0b1101111) + chr(100) + chr(0b10000 + 0o125))(chr(12653 - 12536) + chr(7051 - 6935) + chr(9840 - 9738) + chr(0b100100 + 0o11) + chr(0b10110 + 0o42)))(TRUOLFLuD08x) elif TRUOLFLuD08x[ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\157' + chr(48), 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xa6'), chr(0b1100100) + chr(0b1011000 + 0o15) + '\x63' + chr(7922 - 7811) + '\144' + chr(0b101001 + 0o74))(chr(0b1010010 + 0o43) + '\164' + chr(0b1100110) + chr(0b101101) + chr(0b101101 + 0o13)): if c2A0yzQpDQB3(rFoCQMjVYqWa) > ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(48), 8): SmzoQkSWE36g(rFoCQMjVYqWa, qFB4Kcv_2IeA) xafqLlk3kkUe(rFoCQMjVYqWa, xafqLlk3kkUe(SXOLrMavuUCe(b'\x85\x83@*\xc8 '), chr(0b1100100) + chr(0b1100101) + '\143' + '\157' + chr(0b1100100) + chr(0b11101 + 0o110))('\x75' + chr(0b1110100) + chr(5397 - 5295) + '\055' + chr(0b111000)))(TRUOLFLuD08x) else: raise WPN1tW8jgnXd(utunRCPj8Imk) if c2A0yzQpDQB3(rFoCQMjVYqWa) > ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110000), 8): SmzoQkSWE36g(rFoCQMjVYqWa, qFB4Kcv_2IeA) return qFB4Kcv_2IeA
allenai/allennlp
allennlp/data/dataset_readers/dataset_utils/span_utils.py
bmes_tags_to_spans
def bmes_tags_to_spans(tag_sequence: List[str], classes_to_ignore: List[str] = None) -> List[TypedStringSpan]: """ Given a sequence corresponding to BMES tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are also included (i.e those which do not start with a "B-LABEL"), as otherwise it is possible to get a perfect precision score whilst still predicting ill-formed spans in addition to the correct spans. This function works properly when the spans are unlabeled (i.e., your labels are simply "B", "M", "E" and "S"). Parameters ---------- tag_sequence : List[str], required. The integer class labels for a sequence. classes_to_ignore : List[str], optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : List[TypedStringSpan] The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). Note that the label `does not` contain any BIO tag prefixes. """ def extract_bmes_tag_label(text): bmes_tag = text[0] label = text[2:] return bmes_tag, label spans: List[Tuple[str, List[int]]] = [] prev_bmes_tag: Optional[str] = None for index, tag in enumerate(tag_sequence): bmes_tag, label = extract_bmes_tag_label(tag) if bmes_tag in ('B', 'S'): # Regardless of tag, we start a new span when reaching B & S. spans.append( (label, [index, index]) ) elif bmes_tag in ('M', 'E') and prev_bmes_tag in ('B', 'M') and spans[-1][0] == label: # Only expand the span if # 1. Valid transition: B/M -> M/E. # 2. Matched label. spans[-1][1][1] = index else: # Best effort split for invalid span. spans.append( (label, [index, index]) ) # update previous BMES tag. prev_bmes_tag = bmes_tag classes_to_ignore = classes_to_ignore or [] return [ # to tuple. (span[0], (span[1][0], span[1][1])) for span in spans if span[0] not in classes_to_ignore ]
python
def bmes_tags_to_spans(tag_sequence: List[str], classes_to_ignore: List[str] = None) -> List[TypedStringSpan]: """ Given a sequence corresponding to BMES tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are also included (i.e those which do not start with a "B-LABEL"), as otherwise it is possible to get a perfect precision score whilst still predicting ill-formed spans in addition to the correct spans. This function works properly when the spans are unlabeled (i.e., your labels are simply "B", "M", "E" and "S"). Parameters ---------- tag_sequence : List[str], required. The integer class labels for a sequence. classes_to_ignore : List[str], optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : List[TypedStringSpan] The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). Note that the label `does not` contain any BIO tag prefixes. """ def extract_bmes_tag_label(text): bmes_tag = text[0] label = text[2:] return bmes_tag, label spans: List[Tuple[str, List[int]]] = [] prev_bmes_tag: Optional[str] = None for index, tag in enumerate(tag_sequence): bmes_tag, label = extract_bmes_tag_label(tag) if bmes_tag in ('B', 'S'): # Regardless of tag, we start a new span when reaching B & S. spans.append( (label, [index, index]) ) elif bmes_tag in ('M', 'E') and prev_bmes_tag in ('B', 'M') and spans[-1][0] == label: # Only expand the span if # 1. Valid transition: B/M -> M/E. # 2. Matched label. spans[-1][1][1] = index else: # Best effort split for invalid span. spans.append( (label, [index, index]) ) # update previous BMES tag. prev_bmes_tag = bmes_tag classes_to_ignore = classes_to_ignore or [] return [ # to tuple. (span[0], (span[1][0], span[1][1])) for span in spans if span[0] not in classes_to_ignore ]
[ "def", "bmes_tags_to_spans", "(", "tag_sequence", ":", "List", "[", "str", "]", ",", "classes_to_ignore", ":", "List", "[", "str", "]", "=", "None", ")", "->", "List", "[", "TypedStringSpan", "]", ":", "def", "extract_bmes_tag_label", "(", "text", ")", ":", "bmes_tag", "=", "text", "[", "0", "]", "label", "=", "text", "[", "2", ":", "]", "return", "bmes_tag", ",", "label", "spans", ":", "List", "[", "Tuple", "[", "str", ",", "List", "[", "int", "]", "]", "]", "=", "[", "]", "prev_bmes_tag", ":", "Optional", "[", "str", "]", "=", "None", "for", "index", ",", "tag", "in", "enumerate", "(", "tag_sequence", ")", ":", "bmes_tag", ",", "label", "=", "extract_bmes_tag_label", "(", "tag", ")", "if", "bmes_tag", "in", "(", "'B'", ",", "'S'", ")", ":", "# Regardless of tag, we start a new span when reaching B & S.", "spans", ".", "append", "(", "(", "label", ",", "[", "index", ",", "index", "]", ")", ")", "elif", "bmes_tag", "in", "(", "'M'", ",", "'E'", ")", "and", "prev_bmes_tag", "in", "(", "'B'", ",", "'M'", ")", "and", "spans", "[", "-", "1", "]", "[", "0", "]", "==", "label", ":", "# Only expand the span if", "# 1. Valid transition: B/M -> M/E.", "# 2. Matched label.", "spans", "[", "-", "1", "]", "[", "1", "]", "[", "1", "]", "=", "index", "else", ":", "# Best effort split for invalid span.", "spans", ".", "append", "(", "(", "label", ",", "[", "index", ",", "index", "]", ")", ")", "# update previous BMES tag.", "prev_bmes_tag", "=", "bmes_tag", "classes_to_ignore", "=", "classes_to_ignore", "or", "[", "]", "return", "[", "# to tuple.", "(", "span", "[", "0", "]", ",", "(", "span", "[", "1", "]", "[", "0", "]", ",", "span", "[", "1", "]", "[", "1", "]", ")", ")", "for", "span", "in", "spans", "if", "span", "[", "0", "]", "not", "in", "classes_to_ignore", "]" ]
Given a sequence corresponding to BMES tags, extracts spans. Spans are inclusive and can be of zero length, representing a single word span. Ill-formed spans are also included (i.e those which do not start with a "B-LABEL"), as otherwise it is possible to get a perfect precision score whilst still predicting ill-formed spans in addition to the correct spans. This function works properly when the spans are unlabeled (i.e., your labels are simply "B", "M", "E" and "S"). Parameters ---------- tag_sequence : List[str], required. The integer class labels for a sequence. classes_to_ignore : List[str], optional (default = None). A list of string class labels `excluding` the bio tag which should be ignored when extracting spans. Returns ------- spans : List[TypedStringSpan] The typed, extracted spans from the sequence, in the format (label, (span_start, span_end)). Note that the label `does not` contain any BIO tag prefixes.
[ "Given", "a", "sequence", "corresponding", "to", "BMES", "tags", "extracts", "spans", ".", "Spans", "are", "inclusive", "and", "can", "be", "of", "zero", "length", "representing", "a", "single", "word", "span", ".", "Ill", "-", "formed", "spans", "are", "also", "included", "(", "i", ".", "e", "those", "which", "do", "not", "start", "with", "a", "B", "-", "LABEL", ")", "as", "otherwise", "it", "is", "possible", "to", "get", "a", "perfect", "precision", "score", "whilst", "still", "predicting", "ill", "-", "formed", "spans", "in", "addition", "to", "the", "correct", "spans", ".", "This", "function", "works", "properly", "when", "the", "spans", "are", "unlabeled", "(", "i", ".", "e", ".", "your", "labels", "are", "simply", "B", "M", "E", "and", "S", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/span_utils.py#L376-L435
train
Given a sequence corresponding to BMES tags extracts spans from the BMES tag and returns a list of typed string spans.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTxpD_zs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,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(4170 - 4059) + '\061' + chr(570 - 518) + chr(0b11110 + 0o25), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101110 + 0o1) + '\x33' + '\x33' + chr(330 - 280), 14869 - 14861), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(12124 - 12013) + chr(53) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b100111 + 0o110) + chr(0b110010) + '\061' + chr(0b100001 + 0o17), 51025 - 51017), ehT0Px3KOsy9('\x30' + chr(0b1100001 + 0o16) + chr(0b10011 + 0o36) + '\060', 41034 - 41026), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11110 + 0o23) + chr(302 - 248) + '\067', 0o10), ehT0Px3KOsy9(chr(0b1 + 0o57) + '\157' + chr(1429 - 1377) + chr(0b10 + 0o62), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(676 - 623) + '\x30', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + chr(0b110111) + '\062', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(2142 - 2031) + '\061' + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b110000 + 0o77) + chr(0b110001) + chr(0b101110 + 0o7) + chr(0b100110 + 0o21), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + '\x32' + chr(0b110110), 29508 - 29500), ehT0Px3KOsy9(chr(2176 - 2128) + chr(0b1100 + 0o143) + '\063' + chr(0b110010) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\062' + chr(0b100111 + 0o14) + chr(1510 - 1457), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x36' + chr(0b110001 + 0o3), 0o10), ehT0Px3KOsy9(chr(157 - 109) + chr(0b1001000 + 0o47) + chr(50) + chr(0b110110) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1177 - 1128) + '\067' + '\066', 0o10), ehT0Px3KOsy9('\x30' + chr(1044 - 933) + chr(0b110001) + '\064' + chr(0b100001 + 0o25), 0o10), ehT0Px3KOsy9(chr(0b10000 + 0o40) + '\157' + chr(0b1000 + 0o52) + chr(2181 - 2132) + chr(0b100111 + 0o13), 0o10), ehT0Px3KOsy9('\060' + chr(0b100111 + 0o110) + chr(0b110010) + chr(0b10111 + 0o33) + '\062', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(0b110111) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(9183 - 9072) + '\063' + chr(0b110000 + 0o4) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(516 - 467) + chr(0b10110 + 0o34) + chr(49), 5976 - 5968), ehT0Px3KOsy9(chr(0b11111 + 0o21) + '\157' + '\x33' + '\062' + chr(53), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x32' + chr(0b110011), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101000 + 0o7) + chr(0b110010) + chr(1597 - 1542) + chr(437 - 387), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + chr(0b110010) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x33' + '\067' + chr(0b110001 + 0o0), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1011 + 0o144) + chr(0b100011 + 0o17) + '\060' + chr(0b110100 + 0o0), 0b1000), ehT0Px3KOsy9(chr(511 - 463) + '\157' + chr(0b101110 + 0o4) + '\066' + chr(2406 - 2355), 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(0b1010010 + 0o35) + '\x32' + '\062' + chr(255 - 207), 17489 - 17481), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001011 + 0o44) + '\x32' + chr(0b110100) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(374 - 326) + chr(111) + chr(713 - 663) + '\064' + '\061', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110011) + chr(0b101000 + 0o15) + chr(845 - 794), 0o10), ehT0Px3KOsy9(chr(960 - 912) + chr(111) + '\062' + chr(0b11 + 0o63) + chr(1854 - 1801), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101110 + 0o4) + chr(50) + '\062', 8), ehT0Px3KOsy9('\x30' + '\157' + chr(0b11001 + 0o34) + '\x35', 63937 - 63929), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + chr(48) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(10836 - 10725) + '\x37' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(3794 - 3683) + chr(50) + chr(54) + '\x36', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(111) + chr(53) + chr(0b101 + 0o53), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'M'), '\x64' + chr(0b111001 + 0o54) + chr(0b1100011) + chr(10653 - 10542) + chr(0b1100100) + chr(0b1010100 + 0o21))(chr(117) + chr(0b101101 + 0o107) + '\x66' + chr(0b101101) + chr(0b11000 + 0o40)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def zWqnaYCaTDof(utunRCPj8Imk, CwAp18FPCQND=None) -> qRxF7OQ0y39T[JWGWO_DJzASh]: def Bj7cFDNhp9ag(Ah1rInvg48Hb): aqoPN7zK4Pdq = Ah1rInvg48Hb[ehT0Px3KOsy9('\060' + '\157' + chr(1518 - 1470), 0b1000)] TRUOLFLuD08x = Ah1rInvg48Hb[ehT0Px3KOsy9('\x30' + chr(111) + chr(1160 - 1110), 2855 - 2847):] return (aqoPN7zK4Pdq, TRUOLFLuD08x) aPSH2X7oF0wS = [] xUlObWaG2UbI = None for (XdowRbJKZWL9, CPdEsc5O1sf7) in YlkZvXL8qwsX(utunRCPj8Imk): (aqoPN7zK4Pdq, TRUOLFLuD08x) = Bj7cFDNhp9ag(CPdEsc5O1sf7) if aqoPN7zK4Pdq in (xafqLlk3kkUe(SXOLrMavuUCe(b'!'), chr(100) + chr(0b1100101) + chr(99) + chr(111) + chr(100) + chr(101))('\165' + chr(0b1110100) + chr(0b1100001 + 0o5) + chr(0b101101) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'0'), chr(0b1100100) + '\145' + chr(6499 - 6400) + chr(0b110000 + 0o77) + '\x64' + '\x65')(chr(0b1110101) + chr(0b1010001 + 0o43) + chr(0b1100110) + chr(0b101101) + chr(0b111000))): xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'\x02\xaa_\xedf\x13'), chr(0b1100100) + chr(101) + '\x63' + chr(6098 - 5987) + '\x64' + chr(101))(chr(0b1110101) + chr(116) + chr(0b1000100 + 0o42) + chr(0b111 + 0o46) + chr(56)))((TRUOLFLuD08x, [XdowRbJKZWL9, XdowRbJKZWL9])) elif aqoPN7zK4Pdq in (xafqLlk3kkUe(SXOLrMavuUCe(b'.'), chr(100) + '\x65' + chr(5752 - 5653) + chr(10293 - 10182) + chr(0b110 + 0o136) + '\145')(chr(0b1101100 + 0o11) + chr(0b1010101 + 0o37) + chr(0b1000 + 0o136) + '\x2d' + chr(0b1000 + 0o60)), xafqLlk3kkUe(SXOLrMavuUCe(b'&'), chr(642 - 542) + '\145' + chr(5935 - 5836) + '\x6f' + chr(0b1000011 + 0o41) + '\x65')('\165' + '\x74' + '\x66' + '\055' + chr(0b111000))) and xUlObWaG2UbI in (xafqLlk3kkUe(SXOLrMavuUCe(b'!'), '\x64' + chr(101) + '\x63' + chr(111) + '\x64' + chr(0b10111 + 0o116))('\165' + chr(0b101000 + 0o114) + '\x66' + chr(176 - 131) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'.'), chr(0b1100100) + chr(2639 - 2538) + chr(99) + chr(0b100 + 0o153) + '\144' + '\x65')(chr(0b1110101) + '\x74' + '\146' + chr(45) + '\x38')) and (aPSH2X7oF0wS[-ehT0Px3KOsy9('\060' + chr(111) + '\x31', 0b1000)][ehT0Px3KOsy9(chr(48) + chr(268 - 157) + chr(0b11110 + 0o22), 8)] == TRUOLFLuD08x): aPSH2X7oF0wS[-ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + chr(0b110001), 8)][ehT0Px3KOsy9(chr(1378 - 1330) + chr(721 - 610) + chr(2182 - 2133), 8)][ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(0b1000011 + 0o54) + '\061', 8)] = XdowRbJKZWL9 else: xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'\x02\xaa_\xedf\x13'), chr(0b1100100) + chr(5476 - 5375) + chr(0b1100011) + chr(2631 - 2520) + '\x64' + chr(9754 - 9653))('\165' + '\164' + chr(0b1000111 + 0o37) + '\x2d' + '\070'))((TRUOLFLuD08x, [XdowRbJKZWL9, XdowRbJKZWL9])) xUlObWaG2UbI = aqoPN7zK4Pdq CwAp18FPCQND = CwAp18FPCQND or [] return [(cM7fEShWxtgh[ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x30', 8)], (cM7fEShWxtgh[ehT0Px3KOsy9('\x30' + chr(0b111101 + 0o62) + chr(49), 8)][ehT0Px3KOsy9('\x30' + chr(111) + chr(48), 8)], cM7fEShWxtgh[ehT0Px3KOsy9('\060' + chr(3453 - 3342) + chr(0b11010 + 0o27), 8)][ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + chr(49), 8)])) for cM7fEShWxtgh in aPSH2X7oF0wS if cM7fEShWxtgh[ehT0Px3KOsy9('\x30' + chr(0b1101000 + 0o7) + chr(0b10001 + 0o37), 8)] not in CwAp18FPCQND]
allenai/allennlp
allennlp/commands/dry_run.py
dry_run_from_args
def dry_run_from_args(args: argparse.Namespace): """ Just converts from an ``argparse.Namespace`` object to params. """ parameter_path = args.param_path serialization_dir = args.serialization_dir overrides = args.overrides params = Params.from_file(parameter_path, overrides) dry_run_from_params(params, serialization_dir)
python
def dry_run_from_args(args: argparse.Namespace): """ Just converts from an ``argparse.Namespace`` object to params. """ parameter_path = args.param_path serialization_dir = args.serialization_dir overrides = args.overrides params = Params.from_file(parameter_path, overrides) dry_run_from_params(params, serialization_dir)
[ "def", "dry_run_from_args", "(", "args", ":", "argparse", ".", "Namespace", ")", ":", "parameter_path", "=", "args", ".", "param_path", "serialization_dir", "=", "args", ".", "serialization_dir", "overrides", "=", "args", ".", "overrides", "params", "=", "Params", ".", "from_file", "(", "parameter_path", ",", "overrides", ")", "dry_run_from_params", "(", "params", ",", "serialization_dir", ")" ]
Just converts from an ``argparse.Namespace`` object to params.
[ "Just", "converts", "from", "an", "argparse", ".", "Namespace", "object", "to", "params", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/commands/dry_run.py#L72-L82
train
Just converts from an argparse. Namespace object to params.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA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xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1250 - 1202) + '\157' + '\x31' + chr(55) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b101000 + 0o13), ord("\x08")), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b1101111) + '\061' + '\x37' + '\065', 53704 - 53696), ehT0Px3KOsy9(chr(504 - 456) + '\157' + '\063' + '\x33' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\060' + chr(259 - 148) + chr(1458 - 1408) + chr(0b110101) + chr(990 - 935), ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1101111) + '\061' + chr(50) + '\064', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\x6f' + chr(0b101010 + 0o7) + chr(2746 - 2691), 14966 - 14958), ehT0Px3KOsy9('\x30' + chr(0b1100111 + 0o10) + chr(0b110011), 8), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\x6f' + '\x31' + chr(0b110001) + chr(0b0 + 0o64), 0b1000), ehT0Px3KOsy9(chr(312 - 264) + chr(10118 - 10007) + chr(1258 - 1208) + '\x34' + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(1610 - 1499) + chr(50) + chr(0b110011) + chr(0b110111), 26297 - 26289), ehT0Px3KOsy9(chr(0b110000) + chr(0b100111 + 0o110) + chr(0b1111 + 0o44) + chr(2498 - 2446), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b100101 + 0o112) + chr(0b10001 + 0o41) + chr(0b110110) + chr(54), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b10 + 0o155) + chr(0b1110 + 0o44) + chr(2737 - 2684) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b11001 + 0o126) + chr(0b101110 + 0o3) + '\067' + chr(2657 - 2604), 8), ehT0Px3KOsy9('\060' + chr(0b1010 + 0o145) + chr(51) + chr(0b110000) + '\x30', 40639 - 40631), ehT0Px3KOsy9(chr(48) + chr(0b1011100 + 0o23) + chr(976 - 927) + chr(0b110000) + chr(54), 0b1000), ehT0Px3KOsy9('\x30' + chr(1379 - 1268) + '\062' + chr(0b10101 + 0o36) + chr(0b110101), 30677 - 30669), ehT0Px3KOsy9(chr(48) + '\157' + chr(1068 - 1017) + '\064', 8), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b101001 + 0o12) + chr(0b11000 + 0o33) + chr(0b110001), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b111 + 0o54) + '\x37' + chr(2708 - 2655), 16846 - 16838), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(1902 - 1791) + '\x31' + chr(51), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1000010 + 0o55) + '\x32' + chr(891 - 839) + chr(781 - 730), 0o10), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(0b1101111) + chr(53) + '\x32', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101011 + 0o6) + chr(53) + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b10100 + 0o133) + chr(0b110001) + chr(578 - 527) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(0b1101111) + '\x31' + chr(0b110100) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x33' + '\x36' + '\067', 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b110010) + chr(0b100 + 0o63) + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b101001 + 0o106) + chr(0b110100) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(6987 - 6876) + chr(2290 - 2241) + '\x30' + chr(0b110001), 56220 - 56212), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + chr(49) + '\062' + chr(1790 - 1737), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b11011 + 0o33) + '\067', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(50) + chr(52) + chr(1889 - 1835), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(150 - 96) + chr(0b110010), 0o10), ehT0Px3KOsy9('\060' + chr(11067 - 10956) + chr(519 - 470) + chr(0b1000 + 0o50) + chr(651 - 598), 0o10), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(0b1101111) + chr(2101 - 2051) + '\x33' + chr(153 - 104), 0o10), ehT0Px3KOsy9('\060' + chr(10790 - 10679) + chr(49) + chr(0b110101) + '\067', 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x30', 55028 - 55020)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b110101 + 0o72) + chr(0b110101) + chr(48), 10447 - 10439)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'Q'), '\x64' + chr(2548 - 2447) + '\x63' + chr(0b1001101 + 0o42) + chr(100) + chr(0b1100101))(chr(10308 - 10191) + chr(0b100011 + 0o121) + chr(0b1100 + 0o132) + '\x2d' + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def in3ngL2Apqj0(kJDRfRhcZHjS): zUM_ax8w1tU1 = kJDRfRhcZHjS.param_path _NgEteHO5j9h = kJDRfRhcZHjS.serialization_dir de6iQhrbBQ5Y = kJDRfRhcZHjS.overrides nEbJZ4wfte2w = pboYvIgFA4qm.from_file(zUM_ax8w1tU1, de6iQhrbBQ5Y) p0pedkwkP6vc(nEbJZ4wfte2w, _NgEteHO5j9h)
allenai/allennlp
allennlp/state_machines/constrained_beam_search.py
ConstrainedBeamSearch.search
def search(self, initial_state: State, transition_function: TransitionFunction) -> Dict[int, List[State]]: """ Parameters ---------- initial_state : ``State`` The starting state of our search. This is assumed to be `batched`, and our beam search is batch-aware - we'll keep ``beam_size`` states around for each instance in the batch. transition_function : ``TransitionFunction`` The ``TransitionFunction`` object that defines and scores transitions from one state to the next. Returns ------- best_states : ``Dict[int, List[State]]`` This is a mapping from batch index to the top states for that instance. """ finished_states: Dict[int, List[State]] = defaultdict(list) states = [initial_state] step_num = 0 while states: step_num += 1 next_states: Dict[int, List[State]] = defaultdict(list) grouped_state = states[0].combine_states(states) allowed_actions = [] for batch_index, action_history in zip(grouped_state.batch_indices, grouped_state.action_history): allowed_actions.append(self._allowed_transitions[batch_index][tuple(action_history)]) for next_state in transition_function.take_step(grouped_state, max_actions=self._per_node_beam_size, allowed_actions=allowed_actions): # NOTE: we're doing state.batch_indices[0] here (and similar things below), # hard-coding a group size of 1. But, our use of `next_state.is_finished()` # already checks for that, as it crashes if the group size is not 1. batch_index = next_state.batch_indices[0] if next_state.is_finished(): finished_states[batch_index].append(next_state) else: next_states[batch_index].append(next_state) states = [] for batch_index, batch_states in next_states.items(): # The states from the generator are already sorted, so we can just take the first # ones here, without an additional sort. if self._beam_size: batch_states = batch_states[:self._beam_size] states.extend(batch_states) best_states: Dict[int, List[State]] = {} for batch_index, batch_states in finished_states.items(): # The time this sort takes is pretty negligible, no particular need to optimize this # yet. Maybe with a larger beam size... finished_to_sort = [(-state.score[0].item(), state) for state in batch_states] finished_to_sort.sort(key=lambda x: x[0]) best_states[batch_index] = [state[1] for state in finished_to_sort[:self._beam_size]] return best_states
python
def search(self, initial_state: State, transition_function: TransitionFunction) -> Dict[int, List[State]]: """ Parameters ---------- initial_state : ``State`` The starting state of our search. This is assumed to be `batched`, and our beam search is batch-aware - we'll keep ``beam_size`` states around for each instance in the batch. transition_function : ``TransitionFunction`` The ``TransitionFunction`` object that defines and scores transitions from one state to the next. Returns ------- best_states : ``Dict[int, List[State]]`` This is a mapping from batch index to the top states for that instance. """ finished_states: Dict[int, List[State]] = defaultdict(list) states = [initial_state] step_num = 0 while states: step_num += 1 next_states: Dict[int, List[State]] = defaultdict(list) grouped_state = states[0].combine_states(states) allowed_actions = [] for batch_index, action_history in zip(grouped_state.batch_indices, grouped_state.action_history): allowed_actions.append(self._allowed_transitions[batch_index][tuple(action_history)]) for next_state in transition_function.take_step(grouped_state, max_actions=self._per_node_beam_size, allowed_actions=allowed_actions): # NOTE: we're doing state.batch_indices[0] here (and similar things below), # hard-coding a group size of 1. But, our use of `next_state.is_finished()` # already checks for that, as it crashes if the group size is not 1. batch_index = next_state.batch_indices[0] if next_state.is_finished(): finished_states[batch_index].append(next_state) else: next_states[batch_index].append(next_state) states = [] for batch_index, batch_states in next_states.items(): # The states from the generator are already sorted, so we can just take the first # ones here, without an additional sort. if self._beam_size: batch_states = batch_states[:self._beam_size] states.extend(batch_states) best_states: Dict[int, List[State]] = {} for batch_index, batch_states in finished_states.items(): # The time this sort takes is pretty negligible, no particular need to optimize this # yet. Maybe with a larger beam size... finished_to_sort = [(-state.score[0].item(), state) for state in batch_states] finished_to_sort.sort(key=lambda x: x[0]) best_states[batch_index] = [state[1] for state in finished_to_sort[:self._beam_size]] return best_states
[ "def", "search", "(", "self", ",", "initial_state", ":", "State", ",", "transition_function", ":", "TransitionFunction", ")", "->", "Dict", "[", "int", ",", "List", "[", "State", "]", "]", ":", "finished_states", ":", "Dict", "[", "int", ",", "List", "[", "State", "]", "]", "=", "defaultdict", "(", "list", ")", "states", "=", "[", "initial_state", "]", "step_num", "=", "0", "while", "states", ":", "step_num", "+=", "1", "next_states", ":", "Dict", "[", "int", ",", "List", "[", "State", "]", "]", "=", "defaultdict", "(", "list", ")", "grouped_state", "=", "states", "[", "0", "]", ".", "combine_states", "(", "states", ")", "allowed_actions", "=", "[", "]", "for", "batch_index", ",", "action_history", "in", "zip", "(", "grouped_state", ".", "batch_indices", ",", "grouped_state", ".", "action_history", ")", ":", "allowed_actions", ".", "append", "(", "self", ".", "_allowed_transitions", "[", "batch_index", "]", "[", "tuple", "(", "action_history", ")", "]", ")", "for", "next_state", "in", "transition_function", ".", "take_step", "(", "grouped_state", ",", "max_actions", "=", "self", ".", "_per_node_beam_size", ",", "allowed_actions", "=", "allowed_actions", ")", ":", "# NOTE: we're doing state.batch_indices[0] here (and similar things below),", "# hard-coding a group size of 1. But, our use of `next_state.is_finished()`", "# already checks for that, as it crashes if the group size is not 1.", "batch_index", "=", "next_state", ".", "batch_indices", "[", "0", "]", "if", "next_state", ".", "is_finished", "(", ")", ":", "finished_states", "[", "batch_index", "]", ".", "append", "(", "next_state", ")", "else", ":", "next_states", "[", "batch_index", "]", ".", "append", "(", "next_state", ")", "states", "=", "[", "]", "for", "batch_index", ",", "batch_states", "in", "next_states", ".", "items", "(", ")", ":", "# The states from the generator are already sorted, so we can just take the first", "# ones here, without an additional sort.", "if", "self", ".", "_beam_size", ":", "batch_states", "=", "batch_states", "[", ":", "self", ".", "_beam_size", "]", "states", ".", "extend", "(", "batch_states", ")", "best_states", ":", "Dict", "[", "int", ",", "List", "[", "State", "]", "]", "=", "{", "}", "for", "batch_index", ",", "batch_states", "in", "finished_states", ".", "items", "(", ")", ":", "# The time this sort takes is pretty negligible, no particular need to optimize this", "# yet. Maybe with a larger beam size...", "finished_to_sort", "=", "[", "(", "-", "state", ".", "score", "[", "0", "]", ".", "item", "(", ")", ",", "state", ")", "for", "state", "in", "batch_states", "]", "finished_to_sort", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x", "[", "0", "]", ")", "best_states", "[", "batch_index", "]", "=", "[", "state", "[", "1", "]", "for", "state", "in", "finished_to_sort", "[", ":", "self", ".", "_beam_size", "]", "]", "return", "best_states" ]
Parameters ---------- initial_state : ``State`` The starting state of our search. This is assumed to be `batched`, and our beam search is batch-aware - we'll keep ``beam_size`` states around for each instance in the batch. transition_function : ``TransitionFunction`` The ``TransitionFunction`` object that defines and scores transitions from one state to the next. Returns ------- best_states : ``Dict[int, List[State]]`` This is a mapping from batch index to the top states for that instance.
[ "Parameters", "----------", "initial_state", ":", "State", "The", "starting", "state", "of", "our", "search", ".", "This", "is", "assumed", "to", "be", "batched", "and", "our", "beam", "search", "is", "batch", "-", "aware", "-", "we", "ll", "keep", "beam_size", "states", "around", "for", "each", "instance", "in", "the", "batch", ".", "transition_function", ":", "TransitionFunction", "The", "TransitionFunction", "object", "that", "defines", "and", "scores", "transitions", "from", "one", "state", "to", "the", "next", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/state_machines/constrained_beam_search.py#L60-L114
train
Search for the next state in the beam.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ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GiMiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b10100 + 0o34) + '\x6f' + chr(1371 - 1322) + '\x30' + chr(0b110111), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(957 - 902) + chr(0b11101 + 0o32), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b100000 + 0o22) + chr(0b110010) + '\x37', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b10001 + 0o40) + chr(541 - 493) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\062' + chr(55) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(0b1001110 + 0o41) + chr(1580 - 1529) + chr(0b10000 + 0o41), 8332 - 8324), ehT0Px3KOsy9(chr(48) + chr(0b1011101 + 0o22) + chr(54) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b101111 + 0o100) + chr(49) + '\066' + '\x31', ord("\x08")), ehT0Px3KOsy9('\060' + chr(2272 - 2161) + chr(55) + chr(55), 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x35' + chr(53), 0o10), ehT0Px3KOsy9('\060' + chr(3955 - 3844) + chr(1089 - 1040) + chr(0b10001 + 0o46) + '\066', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1000111 + 0o50) + '\x31' + '\066' + chr(0b100001 + 0o22), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b110111 + 0o70) + chr(1796 - 1747) + chr(1535 - 1485) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(11187 - 11076) + chr(49) + chr(1837 - 1789) + chr(1924 - 1870), 62480 - 62472), ehT0Px3KOsy9(chr(1888 - 1840) + chr(11851 - 11740) + chr(49) + chr(0b110110) + chr(0b110111), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1001010 + 0o45) + chr(0b110001) + chr(2826 - 2772) + '\060', 30068 - 30060), ehT0Px3KOsy9(chr(0b110 + 0o52) + '\x6f' + '\061' + chr(54) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + chr(1003 - 955) + '\062', 55310 - 55302), ehT0Px3KOsy9(chr(48) + chr(300 - 189) + chr(0b100010 + 0o21) + '\061' + '\064', 11567 - 11559), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1860 - 1805) + chr(0b100011 + 0o24), 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110010) + chr(1681 - 1632), 0o10), ehT0Px3KOsy9(chr(938 - 890) + '\x6f' + chr(538 - 489) + chr(0b100111 + 0o13) + chr(0b110111), 34309 - 34301), ehT0Px3KOsy9(chr(1323 - 1275) + chr(0b1010010 + 0o35) + '\062' + chr(352 - 297) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101101 + 0o6) + chr(50) + '\x35', 32944 - 32936), ehT0Px3KOsy9(chr(0b110000) + chr(8485 - 8374) + chr(0b110001) + chr(783 - 729) + chr(0b110110), 8), ehT0Px3KOsy9('\060' + chr(2814 - 2703) + chr(0b10010 + 0o41) + chr(0b110110) + '\066', 34716 - 34708), ehT0Px3KOsy9('\x30' + '\x6f' + '\x36' + '\065', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100000 + 0o22) + chr(0b110000) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + '\060' + '\x35', 50100 - 50092), ehT0Px3KOsy9(chr(48) + chr(0b1000111 + 0o50) + chr(0b1110 + 0o45) + chr(49) + chr(290 - 236), ord("\x08")), ehT0Px3KOsy9(chr(1106 - 1058) + chr(10177 - 10066) + '\061' + chr(49) + chr(0b100001 + 0o24), 0b1000), ehT0Px3KOsy9(chr(1076 - 1028) + chr(4386 - 4275) + chr(0b10110 + 0o34) + chr(49) + chr(1341 - 1293), 28639 - 28631), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + '\x35' + chr(1881 - 1832), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(11994 - 11883) + chr(0b11011 + 0o27) + chr(55) + chr(423 - 372), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(543 - 493) + chr(962 - 911), 20788 - 20780), ehT0Px3KOsy9(chr(2291 - 2243) + chr(263 - 152) + chr(1240 - 1191) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(111) + '\061' + chr(0b110010) + chr(53), 0b1000), ehT0Px3KOsy9(chr(155 - 107) + chr(111) + '\x37' + chr(1957 - 1904), 0b1000), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1101100 + 0o3) + '\062' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(484 - 436) + '\x6f' + '\063' + chr(0b110111) + chr(0b110010), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(2100 - 2052) + '\157' + chr(0b110001 + 0o4) + chr(48), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'i'), '\144' + '\x65' + chr(0b1000 + 0o133) + chr(0b1101111) + chr(0b1100100) + '\x65')(chr(7779 - 7662) + chr(116) + '\146' + '\x2d' + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def d3sjjjpuU5tq(oVre8I6UXc3b, jXyGqlVq68Bb, Ew8eGiv6mHjR) -> zBnV56fc6HrA[ehT0Px3KOsy9, qRxF7OQ0y39T[uWBOm14kSj2p]]: HV1dcqfUnFmU = rLgqW9imlCdX(YyaZ4tpXu4lf) jI0E6zso5mLP = [jXyGqlVq68Bb] s4MGxQMbnqrH = ehT0Px3KOsy9(chr(2050 - 2002) + chr(0b111100 + 0o63) + chr(0b110000), 0o10) while jI0E6zso5mLP: s4MGxQMbnqrH += ehT0Px3KOsy9('\x30' + '\157' + chr(49), 44331 - 44323) jPZpDZH3GdVX = rLgqW9imlCdX(YyaZ4tpXu4lf) HFKIjhy8OINa = jI0E6zso5mLP[ehT0Px3KOsy9(chr(1371 - 1323) + '\157' + chr(48), 8)].combine_states(jI0E6zso5mLP) BNz_fSTQLGui = [] for (Q3TVZeZzkrZ0, sdGUbW0q0W8A) in pZ0NK2y6HRbn(xafqLlk3kkUe(HFKIjhy8OINa, xafqLlk3kkUe(SXOLrMavuUCe(b'%^\xe3"\xd1F^\x1f[D\x1d\x16\''), chr(0b111000 + 0o54) + chr(0b1000111 + 0o36) + chr(253 - 154) + chr(0b1101111) + chr(100) + chr(0b1111 + 0o126))(chr(4817 - 4700) + chr(12013 - 11897) + '\146' + '\x2d' + '\070')), xafqLlk3kkUe(HFKIjhy8OINa, xafqLlk3kkUe(SXOLrMavuUCe(b'&\\\xe3(\xd6wh\x19V^\n\x1c&?'), chr(100) + chr(9541 - 9440) + chr(99) + '\x6f' + chr(0b1011000 + 0o14) + chr(0b1100101))('\x75' + chr(915 - 799) + chr(9066 - 8964) + chr(1046 - 1001) + '\070'))): xafqLlk3kkUe(BNz_fSTQLGui, xafqLlk3kkUe(SXOLrMavuUCe(b'&O\xe7$\xd7}'), chr(0b1100100) + chr(101) + chr(0b1100011) + chr(0b1101111) + chr(100) + chr(9213 - 9112))(chr(0b1110101) + '\164' + chr(102) + chr(0b1111 + 0o36) + '\x38'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x18^\xfb-\xd6nR\x15`Y\x0c\x12:5\x1e\x04\x1f\xad\xa2L'), '\x64' + '\145' + chr(9098 - 8999) + '\x6f' + '\144' + '\x65')('\165' + chr(0b1110100) + '\146' + '\x2d' + chr(56)))[Q3TVZeZzkrZ0][KNyTy8rYcwji(sdGUbW0q0W8A)]) for l7yOP9uqtsC4 in xafqLlk3kkUe(Ew8eGiv6mHjR, xafqLlk3kkUe(SXOLrMavuUCe(b'3^\xfc$\xe6jC\x14O'), chr(0b1100100) + chr(0b1100101) + chr(0b1100011) + '\157' + chr(100) + chr(101))(chr(0b1110101) + chr(0b1110100) + chr(394 - 292) + chr(45) + chr(3109 - 3053)))(HFKIjhy8OINa, max_actions=xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x18O\xf23\xe6wX\x15Zr\x1c\x165+(\x03\x1f\xb8\xa9'), '\x64' + chr(0b1100101) + chr(99) + '\157' + '\x64' + chr(5712 - 5611))(chr(117) + '\x74' + chr(102) + chr(742 - 697) + chr(0b111000))), allowed_actions=BNz_fSTQLGui): Q3TVZeZzkrZ0 = l7yOP9uqtsC4.batch_indices[ehT0Px3KOsy9('\x30' + chr(1922 - 1811) + chr(0b1001 + 0o47), 8)] if xafqLlk3kkUe(l7yOP9uqtsC4, xafqLlk3kkUe(SXOLrMavuUCe(b".L\xc8'\xd0w^\x02WH\x1a"), chr(2176 - 2076) + chr(544 - 443) + chr(99) + chr(0b1100100 + 0o13) + '\144' + chr(101))('\165' + '\x74' + chr(3809 - 3707) + chr(942 - 897) + chr(0b100 + 0o64)))(): xafqLlk3kkUe(HV1dcqfUnFmU[Q3TVZeZzkrZ0], xafqLlk3kkUe(SXOLrMavuUCe(b'&O\xe7$\xd7}'), '\144' + '\x65' + chr(0b1100011) + '\x6f' + chr(1205 - 1105) + '\x65')('\x75' + chr(0b1000111 + 0o55) + chr(102) + '\055' + '\070'))(l7yOP9uqtsC4) else: xafqLlk3kkUe(jPZpDZH3GdVX[Q3TVZeZzkrZ0], xafqLlk3kkUe(SXOLrMavuUCe(b'&O\xe7$\xd7}'), chr(0b11011 + 0o111) + chr(0b1100101) + chr(0b1100011) + '\x6f' + chr(0b1010010 + 0o22) + chr(7419 - 7318))(chr(0b1110101) + '\x74' + chr(3039 - 2937) + chr(1842 - 1797) + '\x38'))(l7yOP9uqtsC4) jI0E6zso5mLP = [] for (Q3TVZeZzkrZ0, t6Sd6XIAAZlg) in xafqLlk3kkUe(jPZpDZH3GdVX, xafqLlk3kkUe(SXOLrMavuUCe(b'\tE\xe1$\xf0C\x048S~6J'), chr(0b1100100) + chr(0b111110 + 0o47) + chr(0b1010111 + 0o14) + chr(0b1111 + 0o140) + chr(100) + chr(6030 - 5929))('\x75' + chr(0b101000 + 0o114) + chr(0b11110 + 0o110) + '\x2d' + '\x38'))(): if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x18]\xf2 \xd4FD\x18EH'), '\x64' + '\145' + '\x63' + chr(0b111111 + 0o60) + chr(100) + chr(839 - 738))(chr(0b1010001 + 0o44) + chr(116) + chr(0b111011 + 0o53) + chr(0b1100 + 0o41) + '\070')): t6Sd6XIAAZlg = t6Sd6XIAAZlg[:oVre8I6UXc3b._beam_size] xafqLlk3kkUe(jI0E6zso5mLP, xafqLlk3kkUe(SXOLrMavuUCe(b'"G\xe3$\xd7}'), chr(0b1110 + 0o126) + '\145' + chr(5882 - 5783) + '\x6f' + chr(2055 - 1955) + '\145')(chr(0b1110101) + chr(0b1000101 + 0o57) + chr(102) + '\x2d' + chr(0b111000)))(t6Sd6XIAAZlg) FYmaFou6uVaj = {} for (Q3TVZeZzkrZ0, t6Sd6XIAAZlg) in xafqLlk3kkUe(HV1dcqfUnFmU, xafqLlk3kkUe(SXOLrMavuUCe(b'\tE\xe1$\xf0C\x048S~6J'), chr(4433 - 4333) + '\x65' + chr(99) + chr(0b1101111) + chr(100) + chr(0b1000101 + 0o40))('\165' + '\164' + chr(0b1010010 + 0o24) + chr(803 - 758) + chr(0b101011 + 0o15)))(): QYnhBbKeq8Ml = [(-KKFQISrGeiAm.score[ehT0Px3KOsy9('\060' + chr(0b1001110 + 0o41) + chr(48), 8)].N7j7ePTXzzI0(), KKFQISrGeiAm) for KKFQISrGeiAm in t6Sd6XIAAZlg] xafqLlk3kkUe(QYnhBbKeq8Ml, xafqLlk3kkUe(SXOLrMavuUCe(b'4P\xe55'), chr(5140 - 5040) + '\x65' + '\x63' + chr(111) + '\144' + '\x65')('\x75' + '\164' + '\x66' + '\055' + chr(56)))(key=lambda OeWW0F1dBPRQ: OeWW0F1dBPRQ[ehT0Px3KOsy9('\x30' + '\x6f' + '\060', 8)]) FYmaFou6uVaj[Q3TVZeZzkrZ0] = [KKFQISrGeiAm[ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001), 8)] for KKFQISrGeiAm in QYnhBbKeq8Ml[:oVre8I6UXc3b._beam_size]] return FYmaFou6uVaj
allenai/allennlp
scripts/check_links.py
url_ok
def url_ok(match_tuple: MatchTuple) -> bool: """Check if a URL is reachable.""" try: result = requests.get(match_tuple.link, timeout=5) return result.ok except (requests.ConnectionError, requests.Timeout): return False
python
def url_ok(match_tuple: MatchTuple) -> bool: """Check if a URL is reachable.""" try: result = requests.get(match_tuple.link, timeout=5) return result.ok except (requests.ConnectionError, requests.Timeout): return False
[ "def", "url_ok", "(", "match_tuple", ":", "MatchTuple", ")", "->", "bool", ":", "try", ":", "result", "=", "requests", ".", "get", "(", "match_tuple", ".", "link", ",", "timeout", "=", "5", ")", "return", "result", ".", "ok", "except", "(", "requests", ".", "ConnectionError", ",", "requests", ".", "Timeout", ")", ":", "return", "False" ]
Check if a URL is reachable.
[ "Check", "if", "a", "URL", "is", "reachable", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/check_links.py#L24-L30
train
Check if a URL is reachable.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5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0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(0b1011010 + 0o25) + chr(51) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110011) + chr(1121 - 1066) + chr(939 - 889), ord("\x08")), ehT0Px3KOsy9(chr(1392 - 1344) + '\157' + chr(0b110001) + chr(0b110100) + chr(1571 - 1523), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(112 - 62) + chr(48), 0b1000), ehT0Px3KOsy9(chr(2019 - 1971) + '\157' + chr(1150 - 1101) + chr(0b110111) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + chr(0b101 + 0o61) + chr(0b101111 + 0o2), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(49) + chr(512 - 462) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\x6f' + '\067' + chr(2076 - 2023), 10298 - 10290), ehT0Px3KOsy9('\x30' + chr(10836 - 10725) + chr(51) + chr(0b110110) + '\x32', 38429 - 38421), ehT0Px3KOsy9(chr(2012 - 1964) + '\x6f' + '\063' + chr(0b110001) + chr(0b1010 + 0o50), 0o10), ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\157' + '\x33' + chr(0b110010) + chr(1530 - 1482), 17577 - 17569), ehT0Px3KOsy9(chr(48) + chr(0b1011000 + 0o27) + chr(0b1001 + 0o52) + chr(0b110110) + '\062', 8), ehT0Px3KOsy9('\060' + '\157' + chr(0b110010) + chr(50) + '\x32', 0b1000), ehT0Px3KOsy9('\060' + chr(4702 - 4591) + chr(229 - 180) + chr(55), 0b1000), ehT0Px3KOsy9(chr(1426 - 1378) + '\157' + chr(0b110010) + chr(0b1 + 0o64) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1946 - 1896) + chr(49) + '\x30', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + '\x36' + chr(0b110110), 38476 - 38468), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(1413 - 1360) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(637 - 589) + chr(11229 - 11118) + '\062' + chr(1153 - 1098) + '\x33', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x30', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b10111 + 0o32) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(240 - 192) + '\x6f' + '\062' + chr(1176 - 1124) + '\062', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(714 - 663) + chr(0b1110 + 0o46) + chr(0b1110 + 0o50), 36751 - 36743), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + '\062' + chr(1163 - 1110), ord("\x08")), ehT0Px3KOsy9(chr(1172 - 1124) + chr(11221 - 11110) + chr(0b11100 + 0o26) + '\065' + '\063', 21542 - 21534), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1010 + 0o47) + chr(710 - 658) + chr(0b110110), 59505 - 59497), ehT0Px3KOsy9('\x30' + '\x6f' + '\062' + chr(2130 - 2082) + '\x36', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + '\x30' + chr(0b1000 + 0o50), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(6879 - 6768) + chr(49) + chr(0b11 + 0o55) + chr(48), 8), ehT0Px3KOsy9('\060' + '\157' + '\063' + chr(0b110000) + '\062', 3973 - 3965), ehT0Px3KOsy9('\x30' + '\x6f' + '\062' + '\x30' + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(6393 - 6282) + '\061' + '\x32' + chr(190 - 142), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\064' + chr(0b1111 + 0o47), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(469 - 420) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + '\063' + chr(0b110011), 25893 - 25885), ehT0Px3KOsy9(chr(401 - 353) + chr(0b1101111) + chr(0b110011) + '\060' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + chr(0b110010) + chr(0b11110 + 0o31) + '\x36', 37953 - 37945), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1101111) + chr(0b110011) + chr(48) + chr(0b101111 + 0o3), 8), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101001 + 0o6) + chr(0b1101 + 0o50) + chr(0b101 + 0o53), 0o10), ehT0Px3KOsy9(chr(799 - 751) + chr(11647 - 11536) + '\061' + '\x37', 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1647 - 1599) + chr(0b10000 + 0o137) + chr(0b110101) + chr(0b110000), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'4'), chr(0b1001000 + 0o34) + chr(0b1100101) + '\143' + chr(111) + chr(0b1100100) + chr(101))(chr(0b1110101) + chr(0b1110100) + '\x66' + chr(0b101101) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def Ne4q_zXsxKUd(XWJOt3HYLGkq) -> WbBjf8Y7v9VN: try: ShZmEKfTkAOZ = Mx6ixpcPMQy3.get(XWJOt3HYLGkq.link, timeout=ehT0Px3KOsy9('\x30' + '\x6f' + '\x35', 0o10)) return xafqLlk3kkUe(ShZmEKfTkAOZ, xafqLlk3kkUe(SXOLrMavuUCe(b'u\x91'), chr(100) + chr(101) + chr(0b101010 + 0o71) + chr(0b100111 + 0o110) + '\144' + chr(0b1100101))(chr(0b1110101) + '\164' + '\x66' + '\055' + '\070')) except (xafqLlk3kkUe(Mx6ixpcPMQy3, xafqLlk3kkUe(SXOLrMavuUCe(b'Y\x95\x0e\xfe\x19\xd2#T\x9d\xa4\x95\x80\xe0`\xdc'), chr(0b11101 + 0o107) + chr(0b11011 + 0o112) + chr(0b10010 + 0o121) + chr(12207 - 12096) + '\x64' + '\145')(chr(117) + chr(0b1100100 + 0o20) + chr(0b1001110 + 0o30) + '\055' + chr(0b100011 + 0o25))), xafqLlk3kkUe(Mx6ixpcPMQy3, xafqLlk3kkUe(SXOLrMavuUCe(b'N\x93\r\xf5\x13\xc4#'), chr(9472 - 9372) + chr(0b1100010 + 0o3) + chr(0b1100011) + chr(0b11000 + 0o127) + chr(0b1100100) + chr(0b1100101))('\165' + chr(0b1110100) + '\146' + chr(0b101101) + '\070'))): return ehT0Px3KOsy9('\x30' + '\157' + chr(0b110000), 8)
allenai/allennlp
scripts/check_links.py
path_ok
def path_ok(match_tuple: MatchTuple) -> bool: """Check if a file in this repository exists.""" relative_path = match_tuple.link.split("#")[0] full_path = os.path.join(os.path.dirname(str(match_tuple.source)), relative_path) return os.path.exists(full_path)
python
def path_ok(match_tuple: MatchTuple) -> bool: """Check if a file in this repository exists.""" relative_path = match_tuple.link.split("#")[0] full_path = os.path.join(os.path.dirname(str(match_tuple.source)), relative_path) return os.path.exists(full_path)
[ "def", "path_ok", "(", "match_tuple", ":", "MatchTuple", ")", "->", "bool", ":", "relative_path", "=", "match_tuple", ".", "link", ".", "split", "(", "\"#\"", ")", "[", "0", "]", "full_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "str", "(", "match_tuple", ".", "source", ")", ")", ",", "relative_path", ")", "return", "os", ".", "path", ".", "exists", "(", "full_path", ")" ]
Check if a file in this repository exists.
[ "Check", "if", "a", "file", "in", "this", "repository", "exists", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/check_links.py#L33-L37
train
Check if a file in this repository exists.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,ko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Z6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(937 - 889) + chr(111) + chr(1061 - 1011) + chr(0b11100 + 0o25) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(518 - 470) + '\x6f' + chr(0b110011) + '\x33' + chr(0b10110 + 0o32), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(49) + '\063', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b10011 + 0o44) + '\x32', 0o10), ehT0Px3KOsy9('\x30' + chr(5275 - 5164) + '\063' + '\x32', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1000101 + 0o52) + '\063' + chr(0b110000 + 0o4), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x34' + chr(1207 - 1159), 5114 - 5106), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(51) + chr(49) + chr(50), 25756 - 25748), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1010 + 0o145) + chr(0b110010) + chr(2699 - 2646) + chr(1198 - 1149), 0b1000), ehT0Px3KOsy9('\060' + chr(3096 - 2985) + '\x33' + '\067' + chr(0b11010 + 0o32), 23356 - 23348), ehT0Px3KOsy9(chr(48) + chr(9592 - 9481) + chr(50) + chr(2824 - 2769), 0o10), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b101111 + 0o100) + chr(49) + chr(2321 - 2272) + chr(893 - 845), 32428 - 32420), ehT0Px3KOsy9(chr(621 - 573) + chr(111) + chr(49) + '\060' + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(278 - 167) + '\x33' + '\067' + chr(0b10010 + 0o40), 0o10), ehT0Px3KOsy9('\x30' + chr(1912 - 1801) + chr(0b110110) + '\060', 0b1000), ehT0Px3KOsy9(chr(1459 - 1411) + chr(9256 - 9145) + '\066' + '\062', 0o10), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b1101111) + '\066' + chr(0b101011 + 0o13), 0b1000), ehT0Px3KOsy9(chr(0b11011 + 0o25) + '\x6f' + chr(50) + '\066' + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(11574 - 11463) + chr(60 - 10) + chr(0b110110) + chr(0b10111 + 0o32), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1936 - 1885) + '\065' + '\x37', 58436 - 58428), ehT0Px3KOsy9('\x30' + chr(4795 - 4684) + chr(51) + chr(0b110101) + chr(0b110111), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010001 + 0o36) + chr(53) + chr(917 - 865), ord("\x08")), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(111) + '\x32' + chr(487 - 437) + chr(2349 - 2300), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x30', 0o10), ehT0Px3KOsy9(chr(1160 - 1112) + chr(11473 - 11362) + '\063' + chr(52) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(869 - 814) + chr(50), 8), ehT0Px3KOsy9(chr(48) + chr(4922 - 4811) + chr(1435 - 1384) + chr(0b1110 + 0o44) + chr(209 - 155), 0o10), ehT0Px3KOsy9(chr(2123 - 2075) + chr(111) + chr(50) + chr(1550 - 1502) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(0b110110 + 0o71) + '\063' + chr(0b110011) + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(3658 - 3547) + '\062' + '\x37' + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(1088 - 1040) + chr(111) + chr(325 - 274) + '\066' + '\064', 0b1000), ehT0Px3KOsy9(chr(1715 - 1667) + chr(0b1101111) + chr(0b10111 + 0o32) + chr(0b110100) + chr(0b101 + 0o61), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b1101001 + 0o6) + chr(0b11000 + 0o31) + '\065' + chr(50), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(51), 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(0b1100 + 0o51), 32042 - 32034), ehT0Px3KOsy9(chr(48) + chr(111) + '\x31' + '\065' + chr(52), 2224 - 2216), ehT0Px3KOsy9(chr(2134 - 2086) + '\157' + chr(2208 - 2158) + chr(0b110100) + chr(0b110110), 35165 - 35157), ehT0Px3KOsy9(chr(1795 - 1747) + chr(7841 - 7730) + chr(0b10100 + 0o41) + '\x32', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(1286 - 1237) + chr(0b101100 + 0o12) + '\060', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110101) + '\x30', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa1'), chr(5177 - 5077) + chr(0b1100101) + chr(0b10111 + 0o114) + chr(0b11110 + 0o121) + '\x64' + '\x65')(chr(0b1110101) + chr(9967 - 9851) + chr(0b111010 + 0o54) + chr(0b101101) + chr(2576 - 2520)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def dbOJY6_ZXaUl(XWJOt3HYLGkq) -> WbBjf8Y7v9VN: Sv44uDWJDn04 = XWJOt3HYLGkq.link.split(xafqLlk3kkUe(SXOLrMavuUCe(b'\xac'), chr(0b111100 + 0o50) + chr(0b11111 + 0o106) + chr(0b1100011) + chr(0b110110 + 0o71) + chr(0b111 + 0o135) + '\145')('\165' + chr(0b1110100) + chr(102) + chr(0b101101) + '\070'))[ehT0Px3KOsy9(chr(48) + chr(0b1011110 + 0o21) + chr(0b100010 + 0o16), 8)] rI6LPzVe_y18 = oqhJDdMJfuwx.path.join(oqhJDdMJfuwx.path.dirname(M8_cKLkHVB2V(XWJOt3HYLGkq.Qas9W3D0Xbzi)), Sv44uDWJDn04) return xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\xea\xa0bIno'), chr(0b1100100) + chr(0b1100101) + chr(99) + chr(11685 - 11574) + chr(2692 - 2592) + chr(101))(chr(0b1100 + 0o151) + chr(116) + chr(0b100111 + 0o77) + '\x2d' + chr(3036 - 2980)))(rI6LPzVe_y18)
allenai/allennlp
allennlp/common/params.py
infer_and_cast
def infer_and_cast(value: Any): """ In some cases we'll be feeding params dicts to functions we don't own; for example, PyTorch optimizers. In that case we can't use ``pop_int`` or similar to force casts (which means you can't specify ``int`` parameters using environment variables). This function takes something that looks JSON-like and recursively casts things that look like (bool, int, float) to (bool, int, float). """ # pylint: disable=too-many-return-statements if isinstance(value, (int, float, bool)): # Already one of our desired types, so leave as is. return value elif isinstance(value, list): # Recursively call on each list element. return [infer_and_cast(item) for item in value] elif isinstance(value, dict): # Recursively call on each dict value. return {key: infer_and_cast(item) for key, item in value.items()} elif isinstance(value, str): # If it looks like a bool, make it a bool. if value.lower() == "true": return True elif value.lower() == "false": return False else: # See if it could be an int. try: return int(value) except ValueError: pass # See if it could be a float. try: return float(value) except ValueError: # Just return it as a string. return value else: raise ValueError(f"cannot infer type of {value}")
python
def infer_and_cast(value: Any): """ In some cases we'll be feeding params dicts to functions we don't own; for example, PyTorch optimizers. In that case we can't use ``pop_int`` or similar to force casts (which means you can't specify ``int`` parameters using environment variables). This function takes something that looks JSON-like and recursively casts things that look like (bool, int, float) to (bool, int, float). """ # pylint: disable=too-many-return-statements if isinstance(value, (int, float, bool)): # Already one of our desired types, so leave as is. return value elif isinstance(value, list): # Recursively call on each list element. return [infer_and_cast(item) for item in value] elif isinstance(value, dict): # Recursively call on each dict value. return {key: infer_and_cast(item) for key, item in value.items()} elif isinstance(value, str): # If it looks like a bool, make it a bool. if value.lower() == "true": return True elif value.lower() == "false": return False else: # See if it could be an int. try: return int(value) except ValueError: pass # See if it could be a float. try: return float(value) except ValueError: # Just return it as a string. return value else: raise ValueError(f"cannot infer type of {value}")
[ "def", "infer_and_cast", "(", "value", ":", "Any", ")", ":", "# pylint: disable=too-many-return-statements", "if", "isinstance", "(", "value", ",", "(", "int", ",", "float", ",", "bool", ")", ")", ":", "# Already one of our desired types, so leave as is.", "return", "value", "elif", "isinstance", "(", "value", ",", "list", ")", ":", "# Recursively call on each list element.", "return", "[", "infer_and_cast", "(", "item", ")", "for", "item", "in", "value", "]", "elif", "isinstance", "(", "value", ",", "dict", ")", ":", "# Recursively call on each dict value.", "return", "{", "key", ":", "infer_and_cast", "(", "item", ")", "for", "key", ",", "item", "in", "value", ".", "items", "(", ")", "}", "elif", "isinstance", "(", "value", ",", "str", ")", ":", "# If it looks like a bool, make it a bool.", "if", "value", ".", "lower", "(", ")", "==", "\"true\"", ":", "return", "True", "elif", "value", ".", "lower", "(", ")", "==", "\"false\"", ":", "return", "False", "else", ":", "# See if it could be an int.", "try", ":", "return", "int", "(", "value", ")", "except", "ValueError", ":", "pass", "# See if it could be a float.", "try", ":", "return", "float", "(", "value", ")", "except", "ValueError", ":", "# Just return it as a string.", "return", "value", "else", ":", "raise", "ValueError", "(", "f\"cannot infer type of {value}\"", ")" ]
In some cases we'll be feeding params dicts to functions we don't own; for example, PyTorch optimizers. In that case we can't use ``pop_int`` or similar to force casts (which means you can't specify ``int`` parameters using environment variables). This function takes something that looks JSON-like and recursively casts things that look like (bool, int, float) to (bool, int, float).
[ "In", "some", "cases", "we", "ll", "be", "feeding", "params", "dicts", "to", "functions", "we", "don", "t", "own", ";", "for", "example", "PyTorch", "optimizers", ".", "In", "that", "case", "we", "can", "t", "use", "pop_int", "or", "similar", "to", "force", "casts", "(", "which", "means", "you", "can", "t", "specify", "int", "parameters", "using", "environment", "variables", ")", ".", "This", "function", "takes", "something", "that", "looks", "JSON", "-", "like", "and", "recursively", "casts", "things", "that", "look", "like", "(", "bool", "int", "float", ")", "to", "(", "bool", "int", "float", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L35-L72
train
Infer the type of the value and return it.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0M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N,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\x6f' + chr(0b110011) + chr(0b10101 + 0o35) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110101) + chr(0b11 + 0o62), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + chr(2315 - 2260) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b11001 + 0o32) + '\x36' + chr(2039 - 1986), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b101000 + 0o12) + chr(0b110110) + chr(0b110110), 11645 - 11637), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b11 + 0o60) + chr(738 - 686) + chr(1838 - 1784), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(51) + chr(0b100111 + 0o16) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\157' + chr(51) + chr(0b100110 + 0o13) + '\x31', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(10616 - 10505) + chr(0b110001) + '\x35' + chr(0b110001), 146 - 138), ehT0Px3KOsy9(chr(2243 - 2195) + chr(9152 - 9041) + '\062' + chr(2497 - 2442) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(403 - 355) + chr(0b1101111) + '\x31' + chr(0b1 + 0o57) + chr(0b110001 + 0o4), 53708 - 53700), ehT0Px3KOsy9(chr(1146 - 1098) + '\157' + '\x37' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b11001 + 0o126) + '\x32' + chr(0b110100) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b100110 + 0o111) + '\062' + '\x37' + '\x31', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + '\067' + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(1634 - 1586) + chr(1394 - 1283) + chr(0b110000), 25737 - 25729), ehT0Px3KOsy9(chr(1576 - 1528) + chr(9948 - 9837) + chr(0b100011 + 0o16) + '\060' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(1046 - 998) + '\157' + '\x32' + '\063' + '\x36', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + '\063' + chr(0b11100 + 0o26), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b11110 + 0o24) + '\x32' + '\x37', 34620 - 34612), ehT0Px3KOsy9(chr(48) + chr(0b1011101 + 0o22) + '\062' + chr(51) + chr(0b10001 + 0o46), 0b1000), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(111) + '\063' + '\061' + chr(0b11010 + 0o35), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\062' + '\x37' + chr(48), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x35' + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(1115 - 1067) + chr(3948 - 3837) + chr(1522 - 1473) + chr(0b110000) + '\x36', 33795 - 33787), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + '\x30' + chr(773 - 722), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(10498 - 10387) + '\x32' + chr(0b110111) + chr(140 - 86), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b10110 + 0o131) + chr(0b100001 + 0o21) + chr(0b1001 + 0o50) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b1101111) + chr(0b101110 + 0o5) + chr(0b10010 + 0o44) + chr(50), 0o10), ehT0Px3KOsy9(chr(1995 - 1947) + chr(0b1011011 + 0o24) + '\x31' + '\067' + '\x34', 0b1000), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(207 - 96) + chr(0b10111 + 0o37) + '\x34', 46232 - 46224), ehT0Px3KOsy9(chr(1183 - 1135) + chr(111) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b100001 + 0o17) + '\x6f' + '\x33' + '\x35' + chr(2679 - 2625), 33817 - 33809), ehT0Px3KOsy9(chr(48) + chr(9547 - 9436) + chr(1449 - 1400) + chr(0b110101 + 0o0) + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + chr(1380 - 1332) + '\x34', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1011010 + 0o25) + chr(1943 - 1892) + chr(54) + chr(0b110010), 8), ehT0Px3KOsy9('\060' + '\157' + '\x32' + chr(1156 - 1104) + chr(2353 - 2300), 910 - 902), ehT0Px3KOsy9(chr(0b110000) + chr(0b111001 + 0o66) + chr(0b101101 + 0o10), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + chr(54) + chr(0b110100), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b10010 + 0o135) + chr(1657 - 1606) + chr(54), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(53) + chr(0b110000), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xff'), '\x64' + chr(0b1100101) + '\x63' + chr(0b100111 + 0o110) + chr(0b1100100) + '\x65')(chr(0b1110101) + '\164' + chr(1596 - 1494) + '\x2d' + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def IzIWaN_cBkXc(QmmgWUB13VCJ): if PlSM16l2KDPD(QmmgWUB13VCJ, (ehT0Px3KOsy9, kkSX4ccExqw4, WbBjf8Y7v9VN)): return QmmgWUB13VCJ elif PlSM16l2KDPD(QmmgWUB13VCJ, YyaZ4tpXu4lf): return [IzIWaN_cBkXc(N7j7ePTXzzI0) for N7j7ePTXzzI0 in QmmgWUB13VCJ] elif PlSM16l2KDPD(QmmgWUB13VCJ, wLqBDw8l0eIm): return {K3J4ZwSlE0sT: IzIWaN_cBkXc(N7j7ePTXzzI0) for (K3J4ZwSlE0sT, N7j7ePTXzzI0) in xafqLlk3kkUe(QmmgWUB13VCJ, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9fW\x88\x90\xff\xbc\xdf\x80\x05\xe8\r\x06'), '\x64' + chr(0b1101 + 0o130) + '\143' + chr(0b1101111) + chr(3899 - 3799) + '\145')(chr(0b1110101) + '\x74' + chr(102) + '\x2d' + chr(0b111000)))()} elif PlSM16l2KDPD(QmmgWUB13VCJ, M8_cKLkHVB2V): if xafqLlk3kkUe(QmmgWUB13VCJ, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbdB\x89\x90\xc4'), chr(0b1100100) + '\x65' + chr(0b1100011) + chr(0b1101111) + chr(100) + chr(101))(chr(6160 - 6043) + chr(0b1110100) + '\x66' + chr(1415 - 1370) + '\x38'))() == xafqLlk3kkUe(SXOLrMavuUCe(b'\xa5_\x8b\x90'), '\144' + chr(0b11011 + 0o112) + chr(99) + chr(0b1101111) + chr(0b1100100) + '\145')(chr(0b101010 + 0o113) + chr(0b10101 + 0o137) + chr(102) + '\x2d' + chr(56)): return ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(6101 - 5990) + chr(49), ord("\x08")) elif xafqLlk3kkUe(QmmgWUB13VCJ, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbdB\x89\x90\xc4'), chr(100) + '\x65' + '\143' + chr(12251 - 12140) + '\144' + '\145')(chr(0b1110101) + '\164' + chr(102) + chr(0b101101) + chr(624 - 568)))() == xafqLlk3kkUe(SXOLrMavuUCe(b'\xb7L\x92\x86\xd3'), '\144' + chr(1844 - 1743) + chr(1552 - 1453) + chr(0b1101111) + chr(5252 - 5152) + '\145')('\x75' + chr(11757 - 11641) + '\x66' + '\x2d' + chr(2852 - 2796)): return ehT0Px3KOsy9(chr(48) + chr(8269 - 8158) + chr(0b110000 + 0o0), 8) else: try: return ehT0Px3KOsy9(QmmgWUB13VCJ) except q1QCh3W88sgk: pass try: return kkSX4ccExqw4(QmmgWUB13VCJ) except q1QCh3W88sgk: return QmmgWUB13VCJ else: raise q1QCh3W88sgk(f'cannot infer type of {QmmgWUB13VCJ}')
allenai/allennlp
allennlp/common/params.py
_environment_variables
def _environment_variables() -> Dict[str, str]: """ Wraps `os.environ` to filter out non-encodable values. """ return {key: value for key, value in os.environ.items() if _is_encodable(value)}
python
def _environment_variables() -> Dict[str, str]: """ Wraps `os.environ` to filter out non-encodable values. """ return {key: value for key, value in os.environ.items() if _is_encodable(value)}
[ "def", "_environment_variables", "(", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "return", "{", "key", ":", "value", "for", "key", ",", "value", "in", "os", ".", "environ", ".", "items", "(", ")", "if", "_is_encodable", "(", "value", ")", "}" ]
Wraps `os.environ` to filter out non-encodable values.
[ "Wraps", "os", ".", "environ", "to", "filter", "out", "non", "-", "encodable", "values", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L85-L91
train
Returns a dictionary of environment variables that can be used to filter out non - encodable values.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03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MiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(6354 - 6243) + chr(0b110010) + chr(1799 - 1746) + chr(2157 - 2104), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31' + '\x34' + '\x32', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + chr(48) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(483 - 435) + '\x6f' + '\x33', 0o10), ehT0Px3KOsy9(chr(48) + chr(9591 - 9480) + chr(0b1100 + 0o51) + chr(2788 - 2734), 0o10), ehT0Px3KOsy9('\x30' + chr(7187 - 7076) + chr(0b110111) + '\061', 45243 - 45235), ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\x6f' + '\x33' + '\x35' + chr(0b10101 + 0o33), 17598 - 17590), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b1 + 0o61) + chr(0b11011 + 0o26) + chr(54), ord("\x08")), ehT0Px3KOsy9('\060' + chr(1455 - 1344) + chr(51) + chr(0b101110 + 0o3) + '\x33', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\067' + chr(1667 - 1616), ord("\x08")), ehT0Px3KOsy9('\060' + chr(1974 - 1863) + chr(0b101100 + 0o12) + chr(1005 - 954), 0o10), ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(0b1101111) + '\x31' + '\x33' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + chr(0b110100) + chr(1281 - 1227), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\061' + '\062' + chr(525 - 475), 0b1000), ehT0Px3KOsy9(chr(768 - 720) + chr(0b110111 + 0o70) + '\x32' + chr(0b110000) + '\x30', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(7608 - 7497) + chr(1333 - 1284) + chr(0b110010) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(10883 - 10772) + chr(50) + chr(52) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(622 - 571) + '\x36' + chr(0b110011), 0b1000), ehT0Px3KOsy9('\060' + chr(1181 - 1070) + chr(0b10110 + 0o33) + '\067' + '\x34', 0o10), ehT0Px3KOsy9(chr(600 - 552) + chr(4054 - 3943) + '\x31' + '\066' + '\066', 0o10), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1001010 + 0o45) + chr(50) + chr(0b110010 + 0o1) + chr(1893 - 1838), 0o10), ehT0Px3KOsy9(chr(1109 - 1061) + chr(12248 - 12137) + '\063' + chr(51) + '\x34', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110011) + chr(0b110100) + chr(1823 - 1772), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010100 + 0o33) + '\062' + chr(1241 - 1186) + chr(0b11111 + 0o23), 0o10), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1101111) + '\x31' + chr(1386 - 1333) + '\x32', 0b1000), ehT0Px3KOsy9(chr(1362 - 1314) + '\157' + '\x35' + '\x33', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x36' + chr(50), 2621 - 2613), ehT0Px3KOsy9(chr(48) + chr(8345 - 8234) + chr(510 - 460) + chr(2796 - 2743) + '\060', 0o10), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(111) + '\062' + '\x37' + chr(0b110000), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(604 - 554) + chr(1097 - 1044) + chr(0b110101), 8), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110011) + chr(50) + chr(0b101010 + 0o14), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + chr(0b110110) + chr(0b110010), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + '\x34' + '\x35', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100000 + 0o17) + chr(0b1111 + 0o43) + '\062' + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(0b1010100 + 0o33) + chr(561 - 512) + chr(1993 - 1943) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + chr(0b110010 + 0o0) + chr(51), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(51) + chr(546 - 491), ord("\x08")), ehT0Px3KOsy9(chr(545 - 497) + '\x6f' + chr(0b100011 + 0o20) + '\063' + chr(0b11000 + 0o32), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x35' + chr(48), 11129 - 11121), ehT0Px3KOsy9(chr(48) + chr(111) + chr(683 - 634) + chr(54) + '\060', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(0b1000100 + 0o53) + '\065' + '\060', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x83'), chr(0b10011 + 0o121) + '\x65' + chr(0b1000011 + 0o40) + chr(127 - 16) + '\x64' + '\x65')(chr(117) + '\x74' + chr(0b1100110) + chr(0b11101 + 0o20) + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def hGYpHXjjxp0x() -> zBnV56fc6HrA[M8_cKLkHVB2V, M8_cKLkHVB2V]: return {K3J4ZwSlE0sT: QmmgWUB13VCJ for (K3J4ZwSlE0sT, QmmgWUB13VCJ) in xafqLlk3kkUe(oqhJDdMJfuwx.environ, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3\x182fgc\xdb\xc7\xa7h{e'), chr(100) + chr(0b1011 + 0o132) + chr(0b1100011) + chr(0b111000 + 0o67) + chr(3729 - 3629) + chr(1434 - 1333))(chr(0b1110101) + '\x74' + chr(0b1100110) + chr(1419 - 1374) + chr(0b111000)))() if l74ZLAtgT_6Q(QmmgWUB13VCJ)}
allenai/allennlp
allennlp/common/params.py
unflatten
def unflatten(flat_dict: Dict[str, Any]) -> Dict[str, Any]: """ Given a "flattened" dict with compound keys, e.g. {"a.b": 0} unflatten it: {"a": {"b": 0}} """ unflat: Dict[str, Any] = {} for compound_key, value in flat_dict.items(): curr_dict = unflat parts = compound_key.split(".") for key in parts[:-1]: curr_value = curr_dict.get(key) if key not in curr_dict: curr_dict[key] = {} curr_dict = curr_dict[key] elif isinstance(curr_value, dict): curr_dict = curr_value else: raise ConfigurationError("flattened dictionary is invalid") if not isinstance(curr_dict, dict) or parts[-1] in curr_dict: raise ConfigurationError("flattened dictionary is invalid") else: curr_dict[parts[-1]] = value return unflat
python
def unflatten(flat_dict: Dict[str, Any]) -> Dict[str, Any]: """ Given a "flattened" dict with compound keys, e.g. {"a.b": 0} unflatten it: {"a": {"b": 0}} """ unflat: Dict[str, Any] = {} for compound_key, value in flat_dict.items(): curr_dict = unflat parts = compound_key.split(".") for key in parts[:-1]: curr_value = curr_dict.get(key) if key not in curr_dict: curr_dict[key] = {} curr_dict = curr_dict[key] elif isinstance(curr_value, dict): curr_dict = curr_value else: raise ConfigurationError("flattened dictionary is invalid") if not isinstance(curr_dict, dict) or parts[-1] in curr_dict: raise ConfigurationError("flattened dictionary is invalid") else: curr_dict[parts[-1]] = value return unflat
[ "def", "unflatten", "(", "flat_dict", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "unflat", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", "for", "compound_key", ",", "value", "in", "flat_dict", ".", "items", "(", ")", ":", "curr_dict", "=", "unflat", "parts", "=", "compound_key", ".", "split", "(", "\".\"", ")", "for", "key", "in", "parts", "[", ":", "-", "1", "]", ":", "curr_value", "=", "curr_dict", ".", "get", "(", "key", ")", "if", "key", "not", "in", "curr_dict", ":", "curr_dict", "[", "key", "]", "=", "{", "}", "curr_dict", "=", "curr_dict", "[", "key", "]", "elif", "isinstance", "(", "curr_value", ",", "dict", ")", ":", "curr_dict", "=", "curr_value", "else", ":", "raise", "ConfigurationError", "(", "\"flattened dictionary is invalid\"", ")", "if", "not", "isinstance", "(", "curr_dict", ",", "dict", ")", "or", "parts", "[", "-", "1", "]", "in", "curr_dict", ":", "raise", "ConfigurationError", "(", "\"flattened dictionary is invalid\"", ")", "else", ":", "curr_dict", "[", "parts", "[", "-", "1", "]", "]", "=", "value", "return", "unflat" ]
Given a "flattened" dict with compound keys, e.g. {"a.b": 0} unflatten it: {"a": {"b": 0}}
[ "Given", "a", "flattened", "dict", "with", "compound", "keys", "e", ".", "g", ".", "{", "a", ".", "b", ":", "0", "}", "unflatten", "it", ":", "{", "a", ":", "{", "b", ":", "0", "}}" ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L93-L119
train
Given a flattened dictionary with compound keys e. g. a. b. c returns a new dict with the flattened keys.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7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qgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(0b1011 + 0o144) + chr(1094 - 1043) + '\x33' + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(574 - 523) + chr(1506 - 1451) + chr(0b110011 + 0o2), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b101111 + 0o100) + '\062' + '\x35' + chr(0b110010), 63243 - 63235), ehT0Px3KOsy9(chr(48) + chr(0b1011100 + 0o23) + chr(51) + '\063' + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b101111 + 0o100) + chr(0b11000 + 0o31) + chr(1674 - 1625) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\060' + chr(1926 - 1815) + chr(0b101000 + 0o12) + '\x37' + chr(1518 - 1470), 0b1000), ehT0Px3KOsy9(chr(1878 - 1830) + chr(0b1100010 + 0o15) + '\x32' + '\x32' + chr(426 - 376), 0b1000), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b1101111) + '\x31' + '\067' + '\064', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b101000 + 0o16) + chr(53), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(7205 - 7094) + chr(0b110011) + '\062' + chr(1324 - 1270), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b100101 + 0o14) + '\063' + '\065', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(650 - 601) + chr(743 - 692) + '\062', 64784 - 64776), ehT0Px3KOsy9(chr(0b100100 + 0o14) + '\x6f' + chr(0b110010) + chr(1433 - 1381) + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b100111 + 0o110) + '\x32' + chr(0b110100) + chr(0b110000), 34434 - 34426), ehT0Px3KOsy9('\060' + '\157' + '\063' + chr(0b10010 + 0o40) + chr(0b11101 + 0o27), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(50) + chr(0b110111) + chr(0b10101 + 0o36), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110101) + chr(641 - 588), 0b1000), ehT0Px3KOsy9(chr(423 - 375) + chr(0b1011100 + 0o23) + chr(1976 - 1927) + chr(812 - 757) + chr(0b111 + 0o52), 0b1000), ehT0Px3KOsy9(chr(1713 - 1665) + chr(0b1101111) + chr(51) + chr(51) + chr(54), 0b1000), ehT0Px3KOsy9(chr(48) + chr(4014 - 3903) + '\061' + '\x32' + chr(0b110100 + 0o1), 26537 - 26529), ehT0Px3KOsy9(chr(48) + chr(5500 - 5389) + '\064' + '\x36', 30107 - 30099), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(773 - 662) + chr(0b1010 + 0o47) + '\060' + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(12167 - 12056) + chr(50) + chr(0b1001 + 0o56) + chr(1461 - 1407), 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(11983 - 11872) + chr(432 - 383) + chr(0b110111) + chr(55), 0o10), ehT0Px3KOsy9('\060' + chr(8167 - 8056) + chr(0b100 + 0o57) + chr(48) + chr(1384 - 1333), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + '\x31' + chr(0b1000 + 0o55), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\063' + '\x36' + chr(0b11111 + 0o25), ord("\x08")), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(0b1101101 + 0o2) + '\063' + '\x31' + '\061', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + chr(0b100011 + 0o21) + chr(0b10101 + 0o34), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110010) + '\x30' + '\x30', 0b1000), ehT0Px3KOsy9(chr(48) + chr(6366 - 6255) + '\x37' + '\x36', 38469 - 38461), ehT0Px3KOsy9(chr(0b100 + 0o54) + '\x6f' + '\x31' + '\062' + chr(816 - 768), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1664 - 1613) + chr(0b1100 + 0o44) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b10 + 0o155) + chr(51) + chr(0b10011 + 0o41) + chr(0b110101), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + chr(0b110101) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(2200 - 2152) + '\x6f' + chr(0b111 + 0o60), 0o10), ehT0Px3KOsy9('\060' + chr(0b111010 + 0o65) + chr(0b110101) + chr(0b110101), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110010) + '\x30' + chr(0b110 + 0o52), 8), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b111011 + 0o64) + chr(0b110010) + '\065' + chr(1087 - 1032), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011110 + 0o21) + '\x33' + chr(927 - 876) + '\064', 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\065' + chr(0b110000), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf2'), chr(100) + '\x65' + chr(0b1100011) + chr(0b10110 + 0o131) + chr(0b1100100) + chr(101))(chr(7409 - 7292) + chr(0b10011 + 0o141) + '\146' + '\055' + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def L6gu19DVXlJ4(OBe_w5cyzaUc) -> zBnV56fc6HrA[M8_cKLkHVB2V, R71nhlWr3XQi]: noBwtzb4MhfL = {} for (Wg2qSJfhMqyt, QmmgWUB13VCJ) in xafqLlk3kkUe(OBe_w5cyzaUc, xafqLlk3kkUe(SXOLrMavuUCe(b'\x92\x87\xdc\xbf\x01\xe2\xa15Y\x85\x15c'), chr(100) + chr(10113 - 10012) + chr(1076 - 977) + chr(111) + chr(0b1100100) + '\145')(chr(0b1001001 + 0o54) + chr(0b1101001 + 0o13) + chr(102) + chr(45) + chr(0b111000)))(): NsS1Rq9E13PS = noBwtzb4MhfL gIfWK5W_pmM4 = Wg2qSJfhMqyt.split(xafqLlk3kkUe(SXOLrMavuUCe(b'\xf2'), chr(0b1010101 + 0o17) + chr(0b1010001 + 0o24) + chr(0b111 + 0o134) + chr(111) + chr(0b1010101 + 0o17) + '\145')(chr(0b1110101) + chr(0b1110100) + chr(8865 - 8763) + '\055' + chr(0b1101 + 0o53))) for K3J4ZwSlE0sT in gIfWK5W_pmM4[:-ehT0Px3KOsy9(chr(48) + chr(111) + chr(1044 - 995), 48101 - 48093)]: qMUf4LBdSn2a = NsS1Rq9E13PS.get(K3J4ZwSlE0sT) if K3J4ZwSlE0sT not in NsS1Rq9E13PS: NsS1Rq9E13PS[K3J4ZwSlE0sT] = {} NsS1Rq9E13PS = NsS1Rq9E13PS[K3J4ZwSlE0sT] elif PlSM16l2KDPD(qMUf4LBdSn2a, wLqBDw8l0eIm): NsS1Rq9E13PS = qMUf4LBdSn2a else: raise h0iXqtiKVeKg(xafqLlk3kkUe(SXOLrMavuUCe(b'\xba\x91\xcb\xae<\xdd\xfc\x19Q\xf693\xc6\xd4\xbd\xd4C\x18\xac,\x06(\xcd_\xaa\xe3\x82\xa8\xcd\xe9Z'), chr(100) + chr(0b11100 + 0o111) + chr(99) + chr(10200 - 10089) + chr(0b1100100) + chr(4436 - 4335))(chr(0b1110101 + 0o0) + '\x74' + chr(102) + '\x2d' + chr(2868 - 2812))) if not PlSM16l2KDPD(NsS1Rq9E13PS, wLqBDw8l0eIm) or gIfWK5W_pmM4[-ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b1000101 + 0o52) + '\061', 8)] in NsS1Rq9E13PS: raise h0iXqtiKVeKg(xafqLlk3kkUe(SXOLrMavuUCe(b'\xba\x91\xcb\xae<\xdd\xfc\x19Q\xf693\xc6\xd4\xbd\xd4C\x18\xac,\x06(\xcd_\xaa\xe3\x82\xa8\xcd\xe9Z'), chr(6748 - 6648) + chr(0b1 + 0o144) + chr(0b1000000 + 0o43) + '\157' + '\x64' + chr(0b1000111 + 0o36))(chr(0b10100 + 0o141) + chr(2699 - 2583) + '\146' + chr(45) + chr(0b111000))) else: NsS1Rq9E13PS[gIfWK5W_pmM4[-ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b101 + 0o54), 8)]] = QmmgWUB13VCJ return noBwtzb4MhfL
allenai/allennlp
allennlp/common/params.py
with_fallback
def with_fallback(preferred: Dict[str, Any], fallback: Dict[str, Any]) -> Dict[str, Any]: """ Deep merge two dicts, preferring values from `preferred`. """ def merge(preferred_value: Any, fallback_value: Any) -> Any: if isinstance(preferred_value, dict) and isinstance(fallback_value, dict): return with_fallback(preferred_value, fallback_value) elif isinstance(preferred_value, dict) and isinstance(fallback_value, list): # treat preferred_value as a sparse list, where each key is an index to be overridden merged_list = fallback_value for elem_key, preferred_element in preferred_value.items(): try: index = int(elem_key) merged_list[index] = merge(preferred_element, fallback_value[index]) except ValueError: raise ConfigurationError("could not merge dicts - the preferred dict contains " f"invalid keys (key {elem_key} is not a valid list index)") except IndexError: raise ConfigurationError("could not merge dicts - the preferred dict contains " f"invalid keys (key {index} is out of bounds)") return merged_list else: return copy.deepcopy(preferred_value) preferred_keys = set(preferred.keys()) fallback_keys = set(fallback.keys()) common_keys = preferred_keys & fallback_keys merged: Dict[str, Any] = {} for key in preferred_keys - fallback_keys: merged[key] = copy.deepcopy(preferred[key]) for key in fallback_keys - preferred_keys: merged[key] = copy.deepcopy(fallback[key]) for key in common_keys: preferred_value = preferred[key] fallback_value = fallback[key] merged[key] = merge(preferred_value, fallback_value) return merged
python
def with_fallback(preferred: Dict[str, Any], fallback: Dict[str, Any]) -> Dict[str, Any]: """ Deep merge two dicts, preferring values from `preferred`. """ def merge(preferred_value: Any, fallback_value: Any) -> Any: if isinstance(preferred_value, dict) and isinstance(fallback_value, dict): return with_fallback(preferred_value, fallback_value) elif isinstance(preferred_value, dict) and isinstance(fallback_value, list): # treat preferred_value as a sparse list, where each key is an index to be overridden merged_list = fallback_value for elem_key, preferred_element in preferred_value.items(): try: index = int(elem_key) merged_list[index] = merge(preferred_element, fallback_value[index]) except ValueError: raise ConfigurationError("could not merge dicts - the preferred dict contains " f"invalid keys (key {elem_key} is not a valid list index)") except IndexError: raise ConfigurationError("could not merge dicts - the preferred dict contains " f"invalid keys (key {index} is out of bounds)") return merged_list else: return copy.deepcopy(preferred_value) preferred_keys = set(preferred.keys()) fallback_keys = set(fallback.keys()) common_keys = preferred_keys & fallback_keys merged: Dict[str, Any] = {} for key in preferred_keys - fallback_keys: merged[key] = copy.deepcopy(preferred[key]) for key in fallback_keys - preferred_keys: merged[key] = copy.deepcopy(fallback[key]) for key in common_keys: preferred_value = preferred[key] fallback_value = fallback[key] merged[key] = merge(preferred_value, fallback_value) return merged
[ "def", "with_fallback", "(", "preferred", ":", "Dict", "[", "str", ",", "Any", "]", ",", "fallback", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "def", "merge", "(", "preferred_value", ":", "Any", ",", "fallback_value", ":", "Any", ")", "->", "Any", ":", "if", "isinstance", "(", "preferred_value", ",", "dict", ")", "and", "isinstance", "(", "fallback_value", ",", "dict", ")", ":", "return", "with_fallback", "(", "preferred_value", ",", "fallback_value", ")", "elif", "isinstance", "(", "preferred_value", ",", "dict", ")", "and", "isinstance", "(", "fallback_value", ",", "list", ")", ":", "# treat preferred_value as a sparse list, where each key is an index to be overridden", "merged_list", "=", "fallback_value", "for", "elem_key", ",", "preferred_element", "in", "preferred_value", ".", "items", "(", ")", ":", "try", ":", "index", "=", "int", "(", "elem_key", ")", "merged_list", "[", "index", "]", "=", "merge", "(", "preferred_element", ",", "fallback_value", "[", "index", "]", ")", "except", "ValueError", ":", "raise", "ConfigurationError", "(", "\"could not merge dicts - the preferred dict contains \"", "f\"invalid keys (key {elem_key} is not a valid list index)\"", ")", "except", "IndexError", ":", "raise", "ConfigurationError", "(", "\"could not merge dicts - the preferred dict contains \"", "f\"invalid keys (key {index} is out of bounds)\"", ")", "return", "merged_list", "else", ":", "return", "copy", ".", "deepcopy", "(", "preferred_value", ")", "preferred_keys", "=", "set", "(", "preferred", ".", "keys", "(", ")", ")", "fallback_keys", "=", "set", "(", "fallback", ".", "keys", "(", ")", ")", "common_keys", "=", "preferred_keys", "&", "fallback_keys", "merged", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", "for", "key", "in", "preferred_keys", "-", "fallback_keys", ":", "merged", "[", "key", "]", "=", "copy", ".", "deepcopy", "(", "preferred", "[", "key", "]", ")", "for", "key", "in", "fallback_keys", "-", "preferred_keys", ":", "merged", "[", "key", "]", "=", "copy", ".", "deepcopy", "(", "fallback", "[", "key", "]", ")", "for", "key", "in", "common_keys", ":", "preferred_value", "=", "preferred", "[", "key", "]", "fallback_value", "=", "fallback", "[", "key", "]", "merged", "[", "key", "]", "=", "merge", "(", "preferred_value", ",", "fallback_value", ")", "return", "merged" ]
Deep merge two dicts, preferring values from `preferred`.
[ "Deep", "merge", "two", "dicts", "preferring", "values", "from", "preferred", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L121-L161
train
Deep merge two dicts preferring values from fallback.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pI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0,Rurm1zTRfSmY,reqGiMiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\157' + '\x31' + chr(0b10011 + 0o37) + chr(1095 - 1043), 62249 - 62241), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(2029 - 1975), ord("\x08")), ehT0Px3KOsy9('\060' + chr(975 - 864) + '\x32' + chr(48) + '\x36', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(1980 - 1930) + chr(0b100100 + 0o15) + '\060', 0b1000), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(111) + '\x36' + chr(1827 - 1774), 0b1000), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(0b110111 + 0o70) + chr(0b110001) + chr(0b10110 + 0o35), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(9177 - 9066) + chr(0b1111 + 0o44) + chr(0b100010 + 0o21) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110100) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1011000 + 0o27) + '\x32' + '\x32' + chr(1027 - 979), 19182 - 19174), ehT0Px3KOsy9('\060' + '\157' + chr(51) + '\x35' + '\x32', 0o10), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + chr(0b110001) + chr(0b10100 + 0o42) + '\064', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + chr(50) + chr(930 - 879), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + chr(0b110100) + chr(1158 - 1103), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(3756 - 3645) + '\062' + chr(2214 - 2166) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(48) + chr(8178 - 8067) + chr(49) + '\x33' + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(1992 - 1944) + chr(0b100001 + 0o116) + chr(0b1100 + 0o47) + chr(0b110111) + chr(0b11000 + 0o30), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110010) + chr(1690 - 1637) + chr(0b11011 + 0o27), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x37' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(514 - 465) + chr(1952 - 1901) + chr(0b110 + 0o57), ord("\x08")), ehT0Px3KOsy9(chr(1790 - 1742) + '\x6f' + chr(50) + chr(0b0 + 0o62) + chr(0b110110), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(53) + chr(0b100111 + 0o17), 0o10), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(111) + chr(0b110010) + chr(51), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x34' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(7641 - 7530) + '\x33' + chr(0b110 + 0o55) + chr(859 - 811), 24008 - 24000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x31' + '\x30' + chr(49), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\x35' + '\x31', 55431 - 55423), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100101 + 0o21) + chr(50), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(0b1111 + 0o41), 20434 - 20426), ehT0Px3KOsy9(chr(48) + chr(0b11101 + 0o122) + chr(0b110010) + '\x35' + chr(0b110000), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110000 + 0o3) + '\062' + '\060', 56957 - 56949), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + chr(54), 0o10), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\x6f' + chr(515 - 465) + chr(1544 - 1494) + '\060', 8), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(1027 - 976) + chr(0b110011), 0o10), ehT0Px3KOsy9('\x30' + chr(357 - 246) + '\x32' + chr(0b10011 + 0o44), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + chr(1997 - 1942) + chr(0b110011), 58453 - 58445), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + chr(48) + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\157' + chr(506 - 457) + chr(1072 - 1020) + '\x33', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001) + '\x32' + '\x30', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110111) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(974 - 926) + '\x6f' + chr(0b1010 + 0o47) + '\x37' + chr(0b10001 + 0o44), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + '\x6f' + chr(94 - 41) + chr(0b110000), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'z'), '\x64' + chr(0b1010 + 0o133) + chr(1031 - 932) + '\x6f' + chr(0b101101 + 0o67) + chr(627 - 526))(chr(2577 - 2460) + chr(0b1101100 + 0o10) + chr(0b100 + 0o142) + '\055' + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def RMpbQE9sq6dx(aH3XNK_PgGfh, jYowHifDediA) -> zBnV56fc6HrA[M8_cKLkHVB2V, R71nhlWr3XQi]: def mP5l0dPhBkus(GafT93OzoqXo, foZmYWhNBZ8Z) -> R71nhlWr3XQi: if PlSM16l2KDPD(GafT93OzoqXo, wLqBDw8l0eIm) and PlSM16l2KDPD(foZmYWhNBZ8Z, wLqBDw8l0eIm): return RMpbQE9sq6dx(GafT93OzoqXo, foZmYWhNBZ8Z) elif PlSM16l2KDPD(GafT93OzoqXo, wLqBDw8l0eIm) and PlSM16l2KDPD(foZmYWhNBZ8Z, YyaZ4tpXu4lf): Qn7zk7ngSdZi = foZmYWhNBZ8Z for (m4lGqxE_FOvH, OrmBE328fuR2) in xafqLlk3kkUe(GafT93OzoqXo, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1at\xf0\xed|Q\xecm\xfc\xb9<\xaa'), chr(100) + '\x65' + chr(2629 - 2530) + chr(0b10101 + 0o132) + chr(3695 - 3595) + '\145')(chr(0b10000 + 0o145) + chr(1497 - 1381) + '\146' + chr(0b1011 + 0o42) + chr(0b11010 + 0o36)))(): try: XdowRbJKZWL9 = ehT0Px3KOsy9(m4lGqxE_FOvH) Qn7zk7ngSdZi[XdowRbJKZWL9] = mP5l0dPhBkus(OrmBE328fuR2, foZmYWhNBZ8Z[XdowRbJKZWL9]) except q1QCh3W88sgk: raise h0iXqtiKVeKg(f'could not merge dicts - the preferred dict contains invalid keys (key {m4lGqxE_FOvH} is not a valid list index)') except _fsda0v2_OKU: raise h0iXqtiKVeKg(f'could not merge dicts - the preferred dict contains invalid keys (key {XdowRbJKZWL9} is out of bounds)') return Qn7zk7ngSdZi else: return xafqLlk3kkUe(igThHS4jwVsa, xafqLlk3kkUe(SXOLrMavuUCe(b'0k\xe3\xf8Vd\xaf]'), chr(0b1100100) + chr(0b1100101) + chr(0b1010001 + 0o22) + chr(0b1001010 + 0o45) + chr(0b1100100) + chr(101))('\165' + chr(0b1110100) + chr(9265 - 9163) + chr(0b10110 + 0o27) + '\070'))(GafT93OzoqXo) _8VjiFkr1Wjs = MVEN8G6CxlvR(aH3XNK_PgGfh.keys()) xMd1MNkx2Pxu = MVEN8G6CxlvR(jYowHifDediA.keys()) iJt8ss5PjU5m = _8VjiFkr1Wjs & xMd1MNkx2Pxu dEDdb0D1WnBU = {} for K3J4ZwSlE0sT in _8VjiFkr1Wjs - xMd1MNkx2Pxu: dEDdb0D1WnBU[K3J4ZwSlE0sT] = igThHS4jwVsa.deepcopy(aH3XNK_PgGfh[K3J4ZwSlE0sT]) for K3J4ZwSlE0sT in xMd1MNkx2Pxu - _8VjiFkr1Wjs: dEDdb0D1WnBU[K3J4ZwSlE0sT] = igThHS4jwVsa.deepcopy(jYowHifDediA[K3J4ZwSlE0sT]) for K3J4ZwSlE0sT in iJt8ss5PjU5m: GafT93OzoqXo = aH3XNK_PgGfh[K3J4ZwSlE0sT] foZmYWhNBZ8Z = jYowHifDediA[K3J4ZwSlE0sT] dEDdb0D1WnBU[K3J4ZwSlE0sT] = mP5l0dPhBkus(GafT93OzoqXo, foZmYWhNBZ8Z) return dEDdb0D1WnBU
allenai/allennlp
allennlp/common/params.py
pop_choice
def pop_choice(params: Dict[str, Any], key: str, choices: List[Any], default_to_first_choice: bool = False, history: str = "?.") -> Any: """ Performs the same function as :func:`Params.pop_choice`, but is required in order to deal with places that the Params object is not welcome, such as inside Keras layers. See the docstring of that method for more detail on how this function works. This method adds a ``history`` parameter, in the off-chance that you know it, so that we can reproduce :func:`Params.pop_choice` exactly. We default to using "?." if you don't know the history, so you'll have to fix that in the log if you want to actually recover the logged parameters. """ value = Params(params, history).pop_choice(key, choices, default_to_first_choice) return value
python
def pop_choice(params: Dict[str, Any], key: str, choices: List[Any], default_to_first_choice: bool = False, history: str = "?.") -> Any: """ Performs the same function as :func:`Params.pop_choice`, but is required in order to deal with places that the Params object is not welcome, such as inside Keras layers. See the docstring of that method for more detail on how this function works. This method adds a ``history`` parameter, in the off-chance that you know it, so that we can reproduce :func:`Params.pop_choice` exactly. We default to using "?." if you don't know the history, so you'll have to fix that in the log if you want to actually recover the logged parameters. """ value = Params(params, history).pop_choice(key, choices, default_to_first_choice) return value
[ "def", "pop_choice", "(", "params", ":", "Dict", "[", "str", ",", "Any", "]", ",", "key", ":", "str", ",", "choices", ":", "List", "[", "Any", "]", ",", "default_to_first_choice", ":", "bool", "=", "False", ",", "history", ":", "str", "=", "\"?.\"", ")", "->", "Any", ":", "value", "=", "Params", "(", "params", ",", "history", ")", ".", "pop_choice", "(", "key", ",", "choices", ",", "default_to_first_choice", ")", "return", "value" ]
Performs the same function as :func:`Params.pop_choice`, but is required in order to deal with places that the Params object is not welcome, such as inside Keras layers. See the docstring of that method for more detail on how this function works. This method adds a ``history`` parameter, in the off-chance that you know it, so that we can reproduce :func:`Params.pop_choice` exactly. We default to using "?." if you don't know the history, so you'll have to fix that in the log if you want to actually recover the logged parameters.
[ "Performs", "the", "same", "function", "as", ":", "func", ":", "Params", ".", "pop_choice", "but", "is", "required", "in", "order", "to", "deal", "with", "places", "that", "the", "Params", "object", "is", "not", "welcome", "such", "as", "inside", "Keras", "layers", ".", "See", "the", "docstring", "of", "that", "method", "for", "more", "detail", "on", "how", "this", "function", "works", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L518-L534
train
Pop a choice from a list of parameters.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,W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y8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(0b110101) + chr(0b100 + 0o60), ord("\x08")), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101111) + chr(1221 - 1172) + '\x37', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b100 + 0o55) + '\061' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(224 - 176) + chr(0b1101000 + 0o7) + chr(2379 - 2328) + chr(1451 - 1397) + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b111 + 0o150) + chr(51) + chr(2173 - 2125) + '\x35', 0o10), ehT0Px3KOsy9('\x30' + chr(0b101111 + 0o100) + chr(1359 - 1309) + chr(55) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(2059 - 2011) + chr(0b1001000 + 0o47) + chr(139 - 90) + chr(253 - 201) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(111) + chr(49) + chr(55), 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b11110 + 0o25) + chr(1540 - 1487), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(571 - 460) + chr(0b110011) + chr(0b110001 + 0o6) + chr(1083 - 1031), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b1011 + 0o47) + '\x33' + chr(0b11011 + 0o26), 1609 - 1601), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\067' + chr(49), 0o10), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\157' + chr(1781 - 1732) + '\x30' + chr(585 - 530), 0b1000), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(111) + chr(541 - 492) + chr(50) + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + '\063' + '\063', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\063' + '\061' + chr(0b110000), 5649 - 5641), ehT0Px3KOsy9(chr(1394 - 1346) + '\157' + '\062' + chr(0b101 + 0o60) + chr(0b10110 + 0o34), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b101001 + 0o106) + chr(0b110011) + chr(54) + chr(720 - 669), 42878 - 42870), ehT0Px3KOsy9(chr(897 - 849) + chr(111) + chr(0b10001 + 0o40) + '\x32' + '\062', ord("\x08")), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1101111) + chr(0b10011 + 0o37) + chr(0b100 + 0o56) + '\063', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + chr(742 - 690) + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1001001 + 0o46) + '\x37', 2183 - 2175), ehT0Px3KOsy9('\x30' + chr(285 - 174) + chr(0b10 + 0o62) + chr(49), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\x33' + chr(51) + chr(0b110001), 47979 - 47971), ehT0Px3KOsy9('\x30' + chr(8673 - 8562) + '\061', 50243 - 50235), ehT0Px3KOsy9(chr(254 - 206) + chr(0b10100 + 0o133) + '\x31' + chr(454 - 400) + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(50) + '\067' + chr(983 - 932), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + '\063', 0o10), ehT0Px3KOsy9(chr(0b1 + 0o57) + '\x6f' + '\063' + '\061' + chr(0b1000 + 0o51), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(9710 - 9599) + chr(50) + chr(0b110111) + chr(48), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b100 + 0o57) + '\x33' + chr(0b10010 + 0o37), 8), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + chr(0b101110 + 0o10) + '\065', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(977 - 926) + chr(54) + chr(0b10000 + 0o47), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(12132 - 12021) + chr(1438 - 1389) + chr(48), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(320 - 272), 46494 - 46486), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(111) + '\061' + chr(0b11000 + 0o30) + chr(52), 0o10), ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\157' + chr(0b110010) + chr(0b10000 + 0o47) + chr(0b11000 + 0o35), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + chr(0b101101 + 0o3) + chr(51), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + '\x33' + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(10462 - 10351) + chr(0b1110 + 0o45) + '\061' + '\x34', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(0b11111 + 0o120) + chr(53) + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc2'), chr(9468 - 9368) + chr(0b1001010 + 0o33) + chr(8124 - 8025) + chr(0b11101 + 0o122) + '\144' + chr(2234 - 2133))(chr(117) + '\164' + '\x66' + chr(0b11100 + 0o21) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def k9L24JPxcIn3(nEbJZ4wfte2w, K3J4ZwSlE0sT, XPnoMuK4S7nS, _jius2SkCpD2=ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\060', 8), sD1K7SLfPnDB=xafqLlk3kkUe(SXOLrMavuUCe(b'\xd3!'), chr(100) + chr(101) + chr(99) + chr(111) + chr(0b1100100) + chr(0b101011 + 0o72))('\165' + chr(0b1110100) + chr(4157 - 4055) + chr(45) + chr(1757 - 1701))) -> R71nhlWr3XQi: QmmgWUB13VCJ = pboYvIgFA4qm(nEbJZ4wfte2w, sD1K7SLfPnDB).pop_choice(K3J4ZwSlE0sT, XPnoMuK4S7nS, _jius2SkCpD2) return QmmgWUB13VCJ
allenai/allennlp
allennlp/common/params.py
Params.add_file_to_archive
def add_file_to_archive(self, name: str) -> None: """ Any class in its ``from_params`` method can request that some of its input files be added to the archive by calling this method. For example, if some class ``A`` had an ``input_file`` parameter, it could call ``` params.add_file_to_archive("input_file") ``` which would store the supplied value for ``input_file`` at the key ``previous.history.and.then.input_file``. The ``files_to_archive`` dict is shared with child instances via the ``_check_is_dict`` method, so that the final mapping can be retrieved from the top-level ``Params`` object. NOTE: You must call ``add_file_to_archive`` before you ``pop()`` the parameter, because the ``Params`` instance looks up the value of the filename inside itself. If the ``loading_from_archive`` flag is True, this will be a no-op. """ if not self.loading_from_archive: self.files_to_archive[f"{self.history}{name}"] = cached_path(self.get(name))
python
def add_file_to_archive(self, name: str) -> None: """ Any class in its ``from_params`` method can request that some of its input files be added to the archive by calling this method. For example, if some class ``A`` had an ``input_file`` parameter, it could call ``` params.add_file_to_archive("input_file") ``` which would store the supplied value for ``input_file`` at the key ``previous.history.and.then.input_file``. The ``files_to_archive`` dict is shared with child instances via the ``_check_is_dict`` method, so that the final mapping can be retrieved from the top-level ``Params`` object. NOTE: You must call ``add_file_to_archive`` before you ``pop()`` the parameter, because the ``Params`` instance looks up the value of the filename inside itself. If the ``loading_from_archive`` flag is True, this will be a no-op. """ if not self.loading_from_archive: self.files_to_archive[f"{self.history}{name}"] = cached_path(self.get(name))
[ "def", "add_file_to_archive", "(", "self", ",", "name", ":", "str", ")", "->", "None", ":", "if", "not", "self", ".", "loading_from_archive", ":", "self", ".", "files_to_archive", "[", "f\"{self.history}{name}\"", "]", "=", "cached_path", "(", "self", ".", "get", "(", "name", ")", ")" ]
Any class in its ``from_params`` method can request that some of its input files be added to the archive by calling this method. For example, if some class ``A`` had an ``input_file`` parameter, it could call ``` params.add_file_to_archive("input_file") ``` which would store the supplied value for ``input_file`` at the key ``previous.history.and.then.input_file``. The ``files_to_archive`` dict is shared with child instances via the ``_check_is_dict`` method, so that the final mapping can be retrieved from the top-level ``Params`` object. NOTE: You must call ``add_file_to_archive`` before you ``pop()`` the parameter, because the ``Params`` instance looks up the value of the filename inside itself. If the ``loading_from_archive`` flag is True, this will be a no-op.
[ "Any", "class", "in", "its", "from_params", "method", "can", "request", "that", "some", "of", "its", "input", "files", "be", "added", "to", "the", "archive", "by", "calling", "this", "method", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L209-L232
train
Add a file to the archive.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,q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8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b101 + 0o53) + '\157' + '\061' + chr(0b110111) + '\x37', 0b1000), ehT0Px3KOsy9('\x30' + chr(425 - 314) + chr(0b110010) + chr(0b1001 + 0o56) + chr(1054 - 1001), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b11011 + 0o124) + '\x31' + '\x35' + chr(0b110000 + 0o1), 2877 - 2869), ehT0Px3KOsy9('\060' + '\157' + chr(0b11010 + 0o30) + '\x33' + chr(0b1111 + 0o46), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + chr(0b1111 + 0o46) + chr(49), 30905 - 30897), ehT0Px3KOsy9(chr(0b11111 + 0o21) + '\x6f' + chr(2501 - 2450) + chr(0b110 + 0o55) + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(917 - 868) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + '\x32' + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(1340 - 1292) + chr(111) + '\x33' + chr(0b10010 + 0o40) + '\067', 0o10), ehT0Px3KOsy9('\060' + chr(4783 - 4672) + chr(248 - 197) + chr(1550 - 1499) + '\063', 8), ehT0Px3KOsy9(chr(1449 - 1401) + '\x6f' + chr(51) + chr(0b100110 + 0o14) + chr(1258 - 1207), 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + chr(0b10000 + 0o46) + '\064', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110011) + chr(1615 - 1565) + '\x37', 8), ehT0Px3KOsy9(chr(0b10011 + 0o35) + '\157' + chr(0b100011 + 0o20) + '\065' + chr(1385 - 1337), 60571 - 60563), ehT0Px3KOsy9('\x30' + '\157' + chr(51) + chr(49), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(1615 - 1566) + chr(0b10101 + 0o42) + chr(54), 42346 - 42338), ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\x6f' + '\x32' + '\x31' + chr(53), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x31' + chr(51) + chr(51), 0o10), ehT0Px3KOsy9(chr(706 - 658) + chr(111) + '\063' + '\x34' + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(1112 - 1064) + chr(8539 - 8428) + chr(51) + chr(0b100100 + 0o14), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(53), 0b1000), ehT0Px3KOsy9(chr(419 - 371) + chr(1656 - 1545) + chr(0b110110) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(1412 - 1364) + '\157' + chr(312 - 262) + chr(52) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\157' + '\x31' + '\065' + chr(1859 - 1807), 0o10), ehT0Px3KOsy9(chr(48) + chr(4236 - 4125) + chr(664 - 615) + '\x36' + '\x31', 44247 - 44239), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(4785 - 4674) + '\x32' + '\x34' + chr(0b100011 + 0o21), 8), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2158 - 2104) + chr(941 - 891), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(55) + '\064', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b110001 + 0o76) + '\x31' + '\064' + chr(0b110010), 16026 - 16018), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110111) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(2765 - 2654) + chr(0b110010) + chr(0b110111) + chr(0b110010), 0o10), ehT0Px3KOsy9('\x30' + chr(3699 - 3588) + chr(0b110010) + chr(0b11 + 0o57) + chr(0b110011), 0o10), ehT0Px3KOsy9('\060' + chr(0b1110 + 0o141) + chr(51) + chr(52) + chr(0b1101 + 0o47), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\062' + chr(0b100111 + 0o16) + chr(0b110100), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110011), 55830 - 55822), ehT0Px3KOsy9('\x30' + '\x6f' + chr(319 - 270) + chr(48) + chr(0b11010 + 0o32), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1000001 + 0o56) + chr(0b110011 + 0o0) + chr(0b110011) + '\064', 0o10), ehT0Px3KOsy9(chr(2184 - 2136) + '\x6f' + chr(0b110101) + '\x34', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(539 - 489) + chr(0b110001) + '\x31', 39569 - 39561), ehT0Px3KOsy9(chr(48) + chr(3978 - 3867) + chr(0b110011) + chr(2350 - 2301) + chr(0b11110 + 0o23), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(3033 - 2922) + '\x35' + '\060', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'Q'), chr(6338 - 6238) + '\x65' + '\x63' + chr(0b1101111) + '\x64' + '\x65')(chr(117) + '\x74' + '\x66' + chr(0b101101) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def eTdMKGJaXCbl(oVre8I6UXc3b, AIvJRzLdDfgF) -> None: if not xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x13\xd2\x08\xf9\xc0\xb5m\xc8\xb1\xa9\xbcY\x88\x89k\x1d\xe52\x96}'), '\144' + chr(0b11101 + 0o110) + '\x63' + chr(111) + chr(0b1100100) + '\x65')(chr(0b1010110 + 0o37) + chr(0b11100 + 0o130) + chr(9389 - 9287) + '\055' + chr(0b11 + 0o65))): oVre8I6UXc3b.pc43UazYMoMT[f'{oVre8I6UXc3b.sD1K7SLfPnDB}{AIvJRzLdDfgF}'] = MygwJnRV_fCw(oVre8I6UXc3b.get(AIvJRzLdDfgF))
allenai/allennlp
allennlp/common/params.py
Params.pop
def pop(self, key: str, default: Any = DEFAULT) -> Any: """ Performs the functionality associated with dict.pop(key), along with checking for returned dictionaries, replacing them with Param objects with an updated history. If ``key`` is not present in the dictionary, and no default was specified, we raise a ``ConfigurationError``, instead of the typical ``KeyError``. """ if default is self.DEFAULT: try: value = self.params.pop(key) except KeyError: raise ConfigurationError("key \"{}\" is required at location \"{}\"".format(key, self.history)) else: value = self.params.pop(key, default) if not isinstance(value, dict): logger.info(self.history + key + " = " + str(value)) # type: ignore return self._check_is_dict(key, value)
python
def pop(self, key: str, default: Any = DEFAULT) -> Any: """ Performs the functionality associated with dict.pop(key), along with checking for returned dictionaries, replacing them with Param objects with an updated history. If ``key`` is not present in the dictionary, and no default was specified, we raise a ``ConfigurationError``, instead of the typical ``KeyError``. """ if default is self.DEFAULT: try: value = self.params.pop(key) except KeyError: raise ConfigurationError("key \"{}\" is required at location \"{}\"".format(key, self.history)) else: value = self.params.pop(key, default) if not isinstance(value, dict): logger.info(self.history + key + " = " + str(value)) # type: ignore return self._check_is_dict(key, value)
[ "def", "pop", "(", "self", ",", "key", ":", "str", ",", "default", ":", "Any", "=", "DEFAULT", ")", "->", "Any", ":", "if", "default", "is", "self", ".", "DEFAULT", ":", "try", ":", "value", "=", "self", ".", "params", ".", "pop", "(", "key", ")", "except", "KeyError", ":", "raise", "ConfigurationError", "(", "\"key \\\"{}\\\" is required at location \\\"{}\\\"\"", ".", "format", "(", "key", ",", "self", ".", "history", ")", ")", "else", ":", "value", "=", "self", ".", "params", ".", "pop", "(", "key", ",", "default", ")", "if", "not", "isinstance", "(", "value", ",", "dict", ")", ":", "logger", ".", "info", "(", "self", ".", "history", "+", "key", "+", "\" = \"", "+", "str", "(", "value", ")", ")", "# type: ignore", "return", "self", ".", "_check_is_dict", "(", "key", ",", "value", ")" ]
Performs the functionality associated with dict.pop(key), along with checking for returned dictionaries, replacing them with Param objects with an updated history. If ``key`` is not present in the dictionary, and no default was specified, we raise a ``ConfigurationError``, instead of the typical ``KeyError``.
[ "Performs", "the", "functionality", "associated", "with", "dict", ".", "pop", "(", "key", ")", "along", "with", "checking", "for", "returned", "dictionaries", "replacing", "them", "with", "Param", "objects", "with", "an", "updated", "history", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L235-L252
train
Removes a key from the dictionary and returns it.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ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yaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(5537 - 5426) + chr(50) + chr(0b110000) + chr(0b11111 + 0o25), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b1101 + 0o45) + '\x33' + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1101111 + 0o0) + '\065' + chr(52), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101101 + 0o2) + chr(49) + chr(49) + chr(0b110011), 64976 - 64968), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + chr(0b1 + 0o66) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b101001 + 0o11) + '\x34' + '\063', 0o10), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(9173 - 9062) + '\x32' + chr(0b100101 + 0o15) + chr(1694 - 1645), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b101111 + 0o2) + chr(0b110101) + chr(1671 - 1618), 0b1000), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101111) + chr(676 - 626) + chr(0b11011 + 0o25) + chr(1943 - 1890), 0b1000), ehT0Px3KOsy9(chr(48) + chr(1480 - 1369) + chr(0b110010) + chr(0b110110) + chr(428 - 379), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(54) + '\x32', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\x33' + chr(0b110101) + chr(2185 - 2133), 39071 - 39063), ehT0Px3KOsy9('\060' + '\157' + chr(0b101010 + 0o13), 0o10), ehT0Px3KOsy9(chr(0b100001 + 0o17) + '\x6f' + chr(51) + chr(0b101101 + 0o11) + chr(1136 - 1087), 0o10), ehT0Px3KOsy9('\x30' + chr(10954 - 10843) + '\065' + chr(0b110100 + 0o3), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + chr(55) + chr(0b110010), 57420 - 57412), ehT0Px3KOsy9(chr(0b0 + 0o60) + '\x6f' + chr(0b110001) + chr(0b101011 + 0o7) + chr(0b110101), 22077 - 22069), ehT0Px3KOsy9(chr(1533 - 1485) + chr(0b101011 + 0o104) + chr(0b10110 + 0o35) + '\x35' + chr(0b101100 + 0o6), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(12008 - 11897) + chr(49) + chr(640 - 591) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + chr(7398 - 7287) + chr(50) + chr(0b0 + 0o64) + '\065', 37948 - 37940), ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\x6f' + '\x31' + '\062', 0o10), ehT0Px3KOsy9(chr(1791 - 1743) + chr(111) + chr(0b110010) + chr(0b10110 + 0o36) + '\x32', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(51) + chr(55), 56252 - 56244), ehT0Px3KOsy9('\x30' + chr(11416 - 11305) + '\x32' + chr(0b100101 + 0o22) + chr(0b100011 + 0o20), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(1805 - 1752), 8), ehT0Px3KOsy9(chr(48) + chr(111) + '\x37' + chr(0b1110 + 0o46), 62524 - 62516), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(426 - 377) + chr(0b110110) + chr(976 - 926), 10476 - 10468), ehT0Px3KOsy9(chr(48) + chr(0b11110 + 0o121) + chr(0b110101) + chr(2347 - 2296), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x35' + chr(1674 - 1623), 8), ehT0Px3KOsy9('\x30' + chr(1404 - 1293) + chr(1853 - 1802), 0b1000), ehT0Px3KOsy9(chr(576 - 528) + chr(0b101011 + 0o104) + chr(0b100000 + 0o21) + chr(0b10100 + 0o36) + chr(0b101 + 0o61), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + '\066' + chr(0b1110 + 0o44), 13374 - 13366), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(111) + '\x33' + chr(52) + '\x33', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b100 + 0o153) + '\x31' + chr(0b100111 + 0o20) + chr(55), 0o10), ehT0Px3KOsy9('\060' + chr(4136 - 4025) + chr(0b1100 + 0o45) + chr(1305 - 1250) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(0b1100101 + 0o12) + '\x33' + '\060' + chr(49), 62272 - 62264), ehT0Px3KOsy9(chr(48) + chr(0b101011 + 0o104) + chr(2259 - 2208) + '\061' + chr(0b101010 + 0o11), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b11010 + 0o27) + chr(0b110 + 0o55) + chr(0b110011), 25830 - 25822), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b11001 + 0o31) + '\067' + '\x31', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + chr(51) + chr(1234 - 1184), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(87 - 39) + chr(0b1101111) + chr(2464 - 2411) + chr(0b110000), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xaa'), chr(100) + chr(10123 - 10022) + chr(0b1100001 + 0o2) + chr(11442 - 11331) + '\x64' + chr(101))(chr(0b1001 + 0o154) + '\164' + chr(102) + chr(0b101101 + 0o0) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def gsHDmKyn_HiH(oVre8I6UXc3b, K3J4ZwSlE0sT, t1v7afVhe01t=qskXFveriimF) -> R71nhlWr3XQi: if t1v7afVhe01t is xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0\xdcj\n\xe9\xef\xc5'), chr(0b1100100) + chr(2480 - 2379) + chr(99) + chr(111) + '\x64' + '\x65')(chr(0b1101100 + 0o11) + '\x74' + chr(10207 - 10105) + chr(0b101101) + chr(56))): try: QmmgWUB13VCJ = oVre8I6UXc3b.params.pop(K3J4ZwSlE0sT) except RQ6CSRrFArYB: raise h0iXqtiKVeKg(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\xef\xfcUk\x9e\xd8\xecO\xa5\xd8A\xccw\x94^\x8f<\x98+\xc1*\xc3+\x9biS\x11J_j9\x9c\xc3]\x05\xbc\xe9'), chr(0b100101 + 0o77) + chr(0b1000000 + 0o45) + chr(6019 - 5920) + chr(0b1101111) + chr(1070 - 970) + chr(0b1100101))('\x75' + chr(0b100010 + 0o122) + '\146' + '\x2d' + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd2\xad^$\xf4\xc2\xc2^\xd5\xc1W\x86'), chr(0b1 + 0o143) + '\145' + chr(0b1100011) + '\157' + '\144' + chr(9579 - 9478))(chr(117) + chr(116) + chr(0b110100 + 0o62) + chr(0b101101) + chr(0b100 + 0o64)))(K3J4ZwSlE0sT, xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf7\xdd\x1d\x00\x8b\xf0\xdd\x0b\xd5\xdfv\xae'), chr(0b1100100) + chr(0b100011 + 0o102) + chr(99) + '\x6f' + chr(100) + chr(0b1100101))(chr(0b1001 + 0o154) + chr(0b1110100) + chr(0b1100110) + chr(0b1110 + 0o37) + '\x38')))) else: QmmgWUB13VCJ = oVre8I6UXc3b.params.pop(K3J4ZwSlE0sT, t1v7afVhe01t) if not PlSM16l2KDPD(QmmgWUB13VCJ, wLqBDw8l0eIm): xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7\xaed3\xc9\xc0\xf6Z\xef\xddh\x87'), chr(9720 - 9620) + chr(0b101100 + 0o71) + '\143' + chr(111) + chr(0b1100100) + '\145')('\x75' + chr(2065 - 1949) + chr(0b1100110) + '\055' + '\070'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf7\xdd\x1d\x00\x8b\xf0\xdd\x0b\xd5\xdfv\xae'), '\144' + chr(101) + chr(9157 - 9058) + chr(0b1001000 + 0o47) + '\144' + '\145')(chr(0b1110101) + chr(9602 - 9486) + '\146' + chr(2020 - 1975) + '\x38')) + K3J4ZwSlE0sT + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa4\xa4\x0c'), '\144' + chr(0b101000 + 0o75) + chr(0b111110 + 0o45) + chr(0b1011111 + 0o20) + chr(0b110010 + 0o62) + '\145')('\x75' + '\164' + chr(102) + chr(0b100000 + 0o15) + chr(0b111000)) + M8_cKLkHVB2V(QmmgWUB13VCJ)) return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xdb\xfaD.\xdf\xc8\xce\x04\xf6\xeeV\x85f\x85'), chr(0b1100100) + chr(4679 - 4578) + chr(99) + chr(0b1001000 + 0o47) + chr(0b1100100) + '\145')('\165' + chr(116) + chr(6855 - 6753) + chr(45) + chr(56)))(K3J4ZwSlE0sT, QmmgWUB13VCJ)
allenai/allennlp
allennlp/common/params.py
Params.pop_int
def pop_int(self, key: str, default: Any = DEFAULT) -> int: """ Performs a pop and coerces to an int. """ value = self.pop(key, default) if value is None: return None else: return int(value)
python
def pop_int(self, key: str, default: Any = DEFAULT) -> int: """ Performs a pop and coerces to an int. """ value = self.pop(key, default) if value is None: return None else: return int(value)
[ "def", "pop_int", "(", "self", ",", "key", ":", "str", ",", "default", ":", "Any", "=", "DEFAULT", ")", "->", "int", ":", "value", "=", "self", ".", "pop", "(", "key", ",", "default", ")", "if", "value", "is", "None", ":", "return", "None", "else", ":", "return", "int", "(", "value", ")" ]
Performs a pop and coerces to an int.
[ "Performs", "a", "pop", "and", "coerces", "to", "an", "int", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L254-L262
train
Takes a key and returns the corresponding int value.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0Zkat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dt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(0b1101000 + 0o7) + '\064' + '\066', 62519 - 62511), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(111) + chr(0b110011) + '\x33' + '\061', 0b1000), ehT0Px3KOsy9(chr(2041 - 1993) + '\157' + chr(792 - 742) + chr(0b110001) + '\x30', 0b1000), ehT0Px3KOsy9(chr(48) + chr(7671 - 7560) + '\x34' + chr(49), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1001 + 0o146) + '\062' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + chr(554 - 502) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(2179 - 2131) + '\x6f' + '\x31' + chr(0b110001) + '\060', 51668 - 51660), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + chr(0b110000) + '\x35', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(50) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(3999 - 3888) + '\061' + '\x35' + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + chr(53) + chr(73 - 25), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(1523 - 1468), 0o10), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(111) + '\063' + chr(0b110101), 48144 - 48136), ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\x6f' + '\x31' + chr(0b110110) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b101101 + 0o102) + chr(1885 - 1833) + chr(0b11111 + 0o23), 40547 - 40539), ehT0Px3KOsy9('\060' + chr(0b101000 + 0o107) + '\062' + '\x32' + chr(0b110100), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(2256 - 2206) + chr(2784 - 2729), 8), ehT0Px3KOsy9(chr(48) + chr(2438 - 2327) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b10 + 0o56) + '\x6f' + chr(51) + '\x37' + chr(2287 - 2238), 33762 - 33754), ehT0Px3KOsy9(chr(1747 - 1699) + chr(6168 - 6057) + chr(0b101001 + 0o15) + chr(1814 - 1761), 0o10), ehT0Px3KOsy9(chr(1592 - 1544) + '\157' + '\x32' + chr(0b1101 + 0o51), 0o10), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(12131 - 12020) + chr(0b110001) + chr(48) + '\062', 35914 - 35906), ehT0Px3KOsy9('\x30' + chr(0b1001000 + 0o47) + chr(50) + chr(328 - 277) + chr(0b10000 + 0o45), 14499 - 14491), ehT0Px3KOsy9(chr(48) + chr(5164 - 5053) + chr(0b110011) + '\x36' + chr(0b0 + 0o63), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(53) + chr(0b101101 + 0o11), 0o10), ehT0Px3KOsy9(chr(48) + chr(8451 - 8340) + chr(0b110001) + chr(50) + chr(0b11110 + 0o24), 61819 - 61811), ehT0Px3KOsy9('\x30' + chr(0b101101 + 0o102) + chr(966 - 916) + '\066' + '\x37', 11325 - 11317), ehT0Px3KOsy9(chr(48) + chr(0b1101100 + 0o3) + chr(0b0 + 0o62) + '\x37', 8), ehT0Px3KOsy9('\060' + chr(0b1000101 + 0o52) + '\063' + '\x36' + chr(2154 - 2104), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110011) + chr(0b110000) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(0b11100 + 0o24) + '\157' + '\062' + '\062' + '\x37', 17274 - 17266), ehT0Px3KOsy9('\x30' + chr(0b1000001 + 0o56) + '\062' + chr(637 - 588) + chr(0b110010), 48403 - 48395), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + '\x37' + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\061' + '\x33' + chr(50), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + '\x31' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1630 - 1581) + '\x31' + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110001 + 0o6) + '\x32', 0b1000), ehT0Px3KOsy9(chr(1793 - 1745) + chr(11501 - 11390) + '\x31' + chr(0b100111 + 0o15), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + chr(48) + chr(0b11001 + 0o31), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + chr(52) + chr(112 - 59), 61638 - 61630)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b11011 + 0o25) + '\x6f' + chr(0b110101) + chr(48), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x08'), chr(0b1100100) + chr(0b1100101) + '\143' + '\x6f' + '\144' + chr(0b1100101))(chr(0b1110101) + chr(9761 - 9645) + chr(0b111110 + 0o50) + '\055' + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def KJ77mKQYT2b9(oVre8I6UXc3b, K3J4ZwSlE0sT, t1v7afVhe01t=qskXFveriimF) -> ehT0Px3KOsy9: QmmgWUB13VCJ = oVre8I6UXc3b.pop(K3J4ZwSlE0sT, t1v7afVhe01t) if QmmgWUB13VCJ is None: return None else: return ehT0Px3KOsy9(QmmgWUB13VCJ)
allenai/allennlp
allennlp/common/params.py
Params.pop_float
def pop_float(self, key: str, default: Any = DEFAULT) -> float: """ Performs a pop and coerces to a float. """ value = self.pop(key, default) if value is None: return None else: return float(value)
python
def pop_float(self, key: str, default: Any = DEFAULT) -> float: """ Performs a pop and coerces to a float. """ value = self.pop(key, default) if value is None: return None else: return float(value)
[ "def", "pop_float", "(", "self", ",", "key", ":", "str", ",", "default", ":", "Any", "=", "DEFAULT", ")", "->", "float", ":", "value", "=", "self", ".", "pop", "(", "key", ",", "default", ")", "if", "value", "is", "None", ":", "return", "None", "else", ":", "return", "float", "(", "value", ")" ]
Performs a pop and coerces to a float.
[ "Performs", "a", "pop", "and", "coerces", "to", "a", "float", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L264-L272
train
Takes a string key and returns the float value.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,s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,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(12268 - 12157) + chr(54) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(9611 - 9500) + chr(49) + '\x35' + chr(55), 0o10), ehT0Px3KOsy9('\060' + chr(0b1000010 + 0o55) + chr(0b110011) + '\063' + '\061', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(8408 - 8297) + chr(520 - 471) + chr(0b1 + 0o60) + chr(0b111 + 0o57), 35389 - 35381), ehT0Px3KOsy9(chr(1656 - 1608) + '\x6f' + chr(49) + chr(0b100011 + 0o16) + chr(0b110011), 0o10), ehT0Px3KOsy9('\x30' + chr(11474 - 11363) + chr(2264 - 2215) + chr(0b110101) + chr(0b110000 + 0o5), 0o10), ehT0Px3KOsy9(chr(48) + chr(11883 - 11772) + chr(50) + '\061' + '\063', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + chr(50), 0b1000), ehT0Px3KOsy9('\060' + chr(0b100110 + 0o111) + chr(0b10 + 0o63) + chr(0b11 + 0o60), 0b1000), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\x6f' + chr(2164 - 2114) + chr(645 - 597) + chr(0b110010 + 0o5), ord("\x08")), ehT0Px3KOsy9(chr(1099 - 1051) + chr(111) + '\062' + '\x32' + '\062', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(0b110011) + '\064', 3043 - 3035), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b11101 + 0o26) + chr(0b10010 + 0o44) + chr(882 - 828), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + chr(54) + chr(0b110111), 32040 - 32032), ehT0Px3KOsy9(chr(767 - 719) + chr(0b1101111) + chr(0b110011) + '\x30' + '\x31', 58913 - 58905), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + '\060' + chr(942 - 893), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(54) + '\x37', 47957 - 47949), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + '\x31' + chr(0b11011 + 0o34), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110010) + '\065' + chr(53), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(118 - 7) + chr(0b110010) + chr(685 - 637), 0b1000), ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\157' + '\063' + '\x32' + chr(0b110001 + 0o6), ord("\x08")), ehT0Px3KOsy9(chr(0b10100 + 0o34) + '\157' + chr(1776 - 1727) + '\065' + chr(0b10100 + 0o34), 0b1000), ehT0Px3KOsy9(chr(921 - 873) + '\157' + '\062' + '\067' + chr(399 - 348), ord("\x08")), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\157' + chr(0b1111 + 0o42) + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + '\060' + '\067', 8), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(990 - 879) + chr(53) + '\060', 43136 - 43128), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110001) + chr(2381 - 2326) + chr(0b10110 + 0o37), 15974 - 15966), ehT0Px3KOsy9(chr(657 - 609) + chr(0b11100 + 0o123) + chr(1200 - 1149) + chr(0b100101 + 0o21) + chr(0b110101 + 0o2), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + '\066' + chr(0b11111 + 0o23), 14404 - 14396), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(111) + chr(51) + chr(1600 - 1545) + '\x37', 64540 - 64532), ehT0Px3KOsy9('\x30' + chr(6592 - 6481) + chr(0b110 + 0o54) + chr(96 - 45) + chr(2560 - 2507), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + chr(0b10000 + 0o45) + chr(0b10011 + 0o35), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(49) + chr(188 - 138) + chr(420 - 371), 1620 - 1612), ehT0Px3KOsy9(chr(2225 - 2177) + chr(111) + chr(51) + chr(0b110111) + chr(2124 - 2074), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(657 - 607) + chr(1772 - 1720) + chr(0b11 + 0o64), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(818 - 768), ord("\x08")), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(111) + chr(1514 - 1465) + chr(48) + chr(266 - 213), 30445 - 30437), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + '\064' + '\064', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(932 - 883) + chr(0b10100 + 0o36) + chr(993 - 942), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(4842 - 4731) + chr(0b1111 + 0o46) + chr(0b110000), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x1b'), '\144' + chr(1381 - 1280) + chr(3862 - 3763) + chr(0b10011 + 0o134) + chr(0b1010111 + 0o15) + chr(0b1100101))('\x75' + chr(11790 - 11674) + chr(0b111000 + 0o56) + chr(1804 - 1759) + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def W14PkqPmV1qc(oVre8I6UXc3b, K3J4ZwSlE0sT, t1v7afVhe01t=qskXFveriimF) -> kkSX4ccExqw4: QmmgWUB13VCJ = oVre8I6UXc3b.pop(K3J4ZwSlE0sT, t1v7afVhe01t) if QmmgWUB13VCJ is None: return None else: return kkSX4ccExqw4(QmmgWUB13VCJ)
allenai/allennlp
allennlp/common/params.py
Params.pop_bool
def pop_bool(self, key: str, default: Any = DEFAULT) -> bool: """ Performs a pop and coerces to a bool. """ value = self.pop(key, default) if value is None: return None elif isinstance(value, bool): return value elif value == "true": return True elif value == "false": return False else: raise ValueError("Cannot convert variable to bool: " + value)
python
def pop_bool(self, key: str, default: Any = DEFAULT) -> bool: """ Performs a pop and coerces to a bool. """ value = self.pop(key, default) if value is None: return None elif isinstance(value, bool): return value elif value == "true": return True elif value == "false": return False else: raise ValueError("Cannot convert variable to bool: " + value)
[ "def", "pop_bool", "(", "self", ",", "key", ":", "str", ",", "default", ":", "Any", "=", "DEFAULT", ")", "->", "bool", ":", "value", "=", "self", ".", "pop", "(", "key", ",", "default", ")", "if", "value", "is", "None", ":", "return", "None", "elif", "isinstance", "(", "value", ",", "bool", ")", ":", "return", "value", "elif", "value", "==", "\"true\"", ":", "return", "True", "elif", "value", "==", "\"false\"", ":", "return", "False", "else", ":", "raise", "ValueError", "(", "\"Cannot convert variable to bool: \"", "+", "value", ")" ]
Performs a pop and coerces to a bool.
[ "Performs", "a", "pop", "and", "coerces", "to", "a", "bool", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L274-L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mzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + '\157' + chr(1379 - 1329) + chr(0b110011) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b100 + 0o153) + chr(0b100101 + 0o16) + chr(0b110011) + chr(2409 - 2359), ord("\x08")), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(0b1010 + 0o145) + chr(50) + chr(0b110000 + 0o3) + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\063' + chr(352 - 298) + '\x32', 24927 - 24919), ehT0Px3KOsy9(chr(1892 - 1844) + chr(111) + chr(0b110011) + chr(1123 - 1069) + '\067', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + chr(0b11110 + 0o22) + chr(0b110000 + 0o5), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + chr(55) + '\x32', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(0b101111 + 0o2) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110110) + '\062', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + '\x37' + '\x30', 0b1000), ehT0Px3KOsy9(chr(1797 - 1749) + chr(0b100110 + 0o111) + chr(0b110010) + '\x34' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(2448 - 2337) + '\063' + chr(0b101110 + 0o2) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\157' + chr(815 - 765) + chr(48) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(442 - 394) + '\x6f' + chr(274 - 223) + '\067' + chr(50), 38254 - 38246), ehT0Px3KOsy9(chr(0b10100 + 0o34) + '\157' + '\066' + chr(2411 - 2360), 33741 - 33733), ehT0Px3KOsy9(chr(2289 - 2241) + chr(0b11110 + 0o121) + chr(0b100100 + 0o15) + chr(0b110010) + '\x36', 31932 - 31924), ehT0Px3KOsy9(chr(0b1 + 0o57) + '\157' + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b100110 + 0o111) + chr(0b110001) + chr(0b11100 + 0o27), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\063' + chr(51) + '\064', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1933 - 1884) + chr(50) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(489 - 441) + '\x6f' + '\066', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(4450 - 4339) + chr(0b101 + 0o54) + chr(260 - 206) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b110010) + '\x32' + chr(52), 54891 - 54883), ehT0Px3KOsy9(chr(1514 - 1466) + chr(111) + chr(0b11000 + 0o32) + chr(931 - 883) + chr(55), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101001 + 0o10) + chr(0b11111 + 0o26) + '\x31', 0o10), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\157' + chr(51) + chr(0b110110) + chr(1812 - 1762), 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + chr(0b101 + 0o60) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b1101111) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x31' + chr(0b110011) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(0b101001 + 0o106) + chr(1949 - 1899) + chr(0b110001) + chr(51), 57540 - 57532), ehT0Px3KOsy9(chr(48) + chr(0b10 + 0o155) + chr(49) + chr(0b110 + 0o60), 63119 - 63111), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(889 - 838) + '\066' + chr(50), 8), ehT0Px3KOsy9(chr(2245 - 2197) + '\x6f' + chr(2333 - 2283) + chr(0b110110) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(54) + chr(48), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\x36' + chr(0b110100), 47074 - 47066), ehT0Px3KOsy9(chr(48) + chr(7098 - 6987) + chr(288 - 238) + chr(52) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b1010 + 0o50) + '\x30' + chr(2633 - 2579), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b11011 + 0o124) + chr(50) + '\061' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b101110 + 0o2) + '\x6f' + '\x33' + chr(303 - 252) + '\x31', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(51) + chr(747 - 692) + chr(2278 - 2230), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11010 + 0o33) + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xb2'), chr(0b1100100) + '\145' + '\143' + chr(0b1101111) + '\x64' + '\145')(chr(2178 - 2061) + '\164' + chr(0b1100110) + chr(0b11100 + 0o21) + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def FcoYwe3hv7nx(oVre8I6UXc3b, K3J4ZwSlE0sT, t1v7afVhe01t=qskXFveriimF) -> WbBjf8Y7v9VN: QmmgWUB13VCJ = oVre8I6UXc3b.pop(K3J4ZwSlE0sT, t1v7afVhe01t) if QmmgWUB13VCJ is None: return None elif PlSM16l2KDPD(QmmgWUB13VCJ, WbBjf8Y7v9VN): return QmmgWUB13VCJ elif QmmgWUB13VCJ == xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8\xa8\xef\x97'), chr(0b100011 + 0o101) + chr(0b1000110 + 0o37) + chr(0b1001000 + 0o33) + chr(0b111101 + 0o62) + chr(100) + '\x65')(chr(12472 - 12355) + chr(0b1110100) + '\x66' + chr(0b101101) + chr(163 - 107)): return ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b101101 + 0o4), 8) elif QmmgWUB13VCJ == xafqLlk3kkUe(SXOLrMavuUCe(b'\xfa\xbb\xf6\x81\x92'), '\144' + chr(101) + '\x63' + chr(0b1101111) + '\144' + '\145')(chr(3909 - 3792) + '\x74' + chr(102) + '\055' + chr(0b10011 + 0o45)): return ehT0Px3KOsy9('\060' + '\157' + '\060', 26548 - 26540) else: raise q1QCh3W88sgk(xafqLlk3kkUe(SXOLrMavuUCe(b'\xdf\xbb\xf4\x9c\x98\xf1Z\xac]\x16\xd6\xa2\xf3\x8e\x13 `y\xb53d\x1c\xf1\xa7\x1d\x9dLg6\xe4b\xc8\x96'), chr(0b11010 + 0o112) + chr(0b111011 + 0o52) + chr(99) + '\157' + chr(0b1100100) + '\x65')('\x75' + '\164' + chr(7922 - 7820) + '\055' + chr(0b110000 + 0o10)) + QmmgWUB13VCJ)
allenai/allennlp
allennlp/common/params.py
Params.get
def get(self, key: str, default: Any = DEFAULT): """ Performs the functionality associated with dict.get(key) but also checks for returned dicts and returns a Params object in their place with an updated history. """ if default is self.DEFAULT: try: value = self.params.get(key) except KeyError: raise ConfigurationError("key \"{}\" is required at location \"{}\"".format(key, self.history)) else: value = self.params.get(key, default) return self._check_is_dict(key, value)
python
def get(self, key: str, default: Any = DEFAULT): """ Performs the functionality associated with dict.get(key) but also checks for returned dicts and returns a Params object in their place with an updated history. """ if default is self.DEFAULT: try: value = self.params.get(key) except KeyError: raise ConfigurationError("key \"{}\" is required at location \"{}\"".format(key, self.history)) else: value = self.params.get(key, default) return self._check_is_dict(key, value)
[ "def", "get", "(", "self", ",", "key", ":", "str", ",", "default", ":", "Any", "=", "DEFAULT", ")", ":", "if", "default", "is", "self", ".", "DEFAULT", ":", "try", ":", "value", "=", "self", ".", "params", ".", "get", "(", "key", ")", "except", "KeyError", ":", "raise", "ConfigurationError", "(", "\"key \\\"{}\\\" is required at location \\\"{}\\\"\"", ".", "format", "(", "key", ",", "self", ".", "history", ")", ")", "else", ":", "value", "=", "self", ".", "params", ".", "get", "(", "key", ",", "default", ")", "return", "self", ".", "_check_is_dict", "(", "key", ",", "value", ")" ]
Performs the functionality associated with dict.get(key) but also checks for returned dicts and returns a Params object in their place with an updated history.
[ "Performs", "the", "functionality", "associated", "with", "dict", ".", "get", "(", "key", ")", "but", "also", "checks", "for", "returned", "dicts", "and", "returns", "a", "Params", "object", "in", "their", "place", "with", "an", "updated", "history", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L291-L303
train
Returns a dict object for the given key.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0M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N,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(111) + '\x32' + '\x34' + chr(55), 0b1000), ehT0Px3KOsy9('\060' + chr(9793 - 9682) + chr(694 - 643) + chr(0b110101) + chr(1507 - 1457), 0b1000), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b1101111) + chr(0b1010 + 0o51) + chr(0b1100 + 0o50) + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b100110 + 0o14) + chr(2599 - 2545), 20319 - 20311), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(0b1101111) + '\063' + chr(614 - 560) + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1401 - 1352) + chr(49) + chr(0b10101 + 0o37), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + chr(0b1100 + 0o51) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1010 + 0o145) + chr(0b1010 + 0o53) + '\x34', 43900 - 43892), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\063' + '\x30' + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(48) + chr(7870 - 7759) + chr(0b110100) + '\066', 22215 - 22207), ehT0Px3KOsy9('\060' + chr(2477 - 2366) + chr(0b100010 + 0o21) + chr(0b110100) + '\061', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + chr(0b110110) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b11100 + 0o24) + '\x6f' + chr(0b1000 + 0o52) + chr(0b1001 + 0o55) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(0b1010110 + 0o31) + chr(2044 - 1993) + chr(0b110000) + '\x31', 25641 - 25633), ehT0Px3KOsy9(chr(438 - 390) + '\157' + chr(901 - 852) + chr(52) + chr(54), 0o10), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b1101111) + '\066', 0o10), ehT0Px3KOsy9('\060' + '\157' + '\066' + chr(2452 - 2401), 11287 - 11279), ehT0Px3KOsy9('\060' + chr(0b1010010 + 0o35) + '\063' + chr(1065 - 1010) + '\x35', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101101 + 0o10) + chr(48), 38435 - 38427), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + chr(0b110001 + 0o2), 0o10), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1100 + 0o143) + '\x31' + chr(54 - 4) + '\x30', 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + chr(1585 - 1531) + chr(0b1011 + 0o45), 0o10), ehT0Px3KOsy9('\060' + chr(7543 - 7432) + '\x34' + chr(0b1 + 0o62), 0b1000), ehT0Px3KOsy9(chr(663 - 615) + chr(116 - 5) + '\062' + '\060', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(49) + '\064' + chr(0b110 + 0o53), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000011 + 0o54) + '\063' + chr(1654 - 1600), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(2004 - 1893) + chr(1368 - 1318) + '\x33' + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + chr(6337 - 6226) + chr(0b100010 + 0o21) + chr(0b1110 + 0o45) + '\x36', 0o10), ehT0Px3KOsy9(chr(637 - 589) + chr(0b1101111) + chr(0b1110 + 0o43) + chr(50) + chr(2145 - 2095), 18472 - 18464), ehT0Px3KOsy9(chr(1931 - 1883) + '\x6f' + '\x33' + chr(0b110011 + 0o3) + chr(1431 - 1383), 25630 - 25622), ehT0Px3KOsy9(chr(0b110000) + chr(9784 - 9673) + chr(49) + chr(918 - 867) + chr(0b110001), 61106 - 61098), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(49) + '\062' + chr(55), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b101101 + 0o4) + '\067' + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(1516 - 1468) + chr(0b1011000 + 0o27) + chr(49) + chr(51) + chr(49), 8), ehT0Px3KOsy9(chr(0b110000) + chr(10679 - 10568) + chr(0b110001) + chr(0b11 + 0o64) + '\060', 65059 - 65051), ehT0Px3KOsy9(chr(0b110000) + chr(6301 - 6190) + chr(2225 - 2175) + '\x37' + chr(54), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\063' + chr(0b100 + 0o63) + '\x31', ord("\x08")), ehT0Px3KOsy9('\060' + chr(1030 - 919) + chr(0b110011) + chr(0b110 + 0o57) + chr(1652 - 1599), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + chr(54) + '\062', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001) + chr(54) + chr(51), 32148 - 32140)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(677 - 629) + chr(0b1101111) + chr(0b101001 + 0o14) + chr(48), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x89'), chr(0b10011 + 0o121) + '\x65' + '\x63' + '\x6f' + chr(9191 - 9091) + chr(101))(chr(117) + chr(2273 - 2157) + chr(0b110110 + 0o60) + '\055' + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def Q8b5UytA0vqH(oVre8I6UXc3b, K3J4ZwSlE0sT, t1v7afVhe01t=qskXFveriimF): if t1v7afVhe01t is xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3\xaf\xa1W\xa6\x00\xbf'), chr(0b111100 + 0o50) + '\145' + chr(0b1100011) + chr(0b1101111) + chr(5943 - 5843) + chr(4418 - 4317))(chr(117) + chr(116) + '\146' + chr(45) + chr(0b111000))): try: QmmgWUB13VCJ = oVre8I6UXc3b.params.get(K3J4ZwSlE0sT) except RQ6CSRrFArYB: raise h0iXqtiKVeKg(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\xcc\x8f\x9e6\xd17\x96\x0e\xe7O\x92\xd4\xc6\xa4\x17sZ\x8fM\x7fp\x11W0\rq\xfc\xbf&\x9969^{\x03\xc3\xdb'), chr(0b111101 + 0o47) + '\145' + chr(3933 - 3834) + '\157' + chr(0b101000 + 0o74) + '\145')(chr(0b1011111 + 0o26) + chr(0b1001100 + 0o50) + chr(0b1100110) + '\055' + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xf1\xde\x95y\xbb-\xb8\x1f\x97V\x84\x9e'), '\x64' + '\145' + chr(99) + chr(111) + '\144' + '\145')(chr(8696 - 8579) + chr(0b1110100) + chr(5951 - 5849) + chr(0b101101) + chr(0b10101 + 0o43)))(K3J4ZwSlE0sT, xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4\xae\xd6]\xc4\x1f\xa7J\x97H\xa5\xb6'), '\144' + '\145' + '\x63' + chr(111) + chr(843 - 743) + chr(101))(chr(117) + chr(0b1010 + 0o152) + chr(0b1000000 + 0o46) + '\055' + chr(0b100100 + 0o24))))) else: QmmgWUB13VCJ = oVre8I6UXc3b.params.get(K3J4ZwSlE0sT, t1v7afVhe01t) return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b"\xf8\x89\x8fs\x90'\xb4E\xb4y\x85\x9d\xd7\xb5"), chr(0b1100100) + chr(0b1100101) + chr(3140 - 3041) + chr(0b1101111) + chr(0b110110 + 0o56) + chr(0b1001010 + 0o33))(chr(117) + chr(0b1110100) + chr(102) + chr(45) + '\x38'))(K3J4ZwSlE0sT, QmmgWUB13VCJ)
allenai/allennlp
allennlp/common/params.py
Params.pop_choice
def pop_choice(self, key: str, choices: List[Any], default_to_first_choice: bool = False) -> Any: """ Gets the value of ``key`` in the ``params`` dictionary, ensuring that the value is one of the given choices. Note that this `pops` the key from params, modifying the dictionary, consistent with how parameters are processed in this codebase. Parameters ---------- key: str Key to get the value from in the param dictionary choices: List[Any] A list of valid options for values corresponding to ``key``. For example, if you're specifying the type of encoder to use for some part of your model, the choices might be the list of encoder classes we know about and can instantiate. If the value we find in the param dictionary is not in ``choices``, we raise a ``ConfigurationError``, because the user specified an invalid value in their parameter file. default_to_first_choice: bool, optional (default=False) If this is ``True``, we allow the ``key`` to not be present in the parameter dictionary. If the key is not present, we will use the return as the value the first choice in the ``choices`` list. If this is ``False``, we raise a ``ConfigurationError``, because specifying the ``key`` is required (e.g., you `have` to specify your model class when running an experiment, but you can feel free to use default settings for encoders if you want). """ default = choices[0] if default_to_first_choice else self.DEFAULT value = self.pop(key, default) if value not in choices: key_str = self.history + key message = '%s not in acceptable choices for %s: %s' % (value, key_str, str(choices)) raise ConfigurationError(message) return value
python
def pop_choice(self, key: str, choices: List[Any], default_to_first_choice: bool = False) -> Any: """ Gets the value of ``key`` in the ``params`` dictionary, ensuring that the value is one of the given choices. Note that this `pops` the key from params, modifying the dictionary, consistent with how parameters are processed in this codebase. Parameters ---------- key: str Key to get the value from in the param dictionary choices: List[Any] A list of valid options for values corresponding to ``key``. For example, if you're specifying the type of encoder to use for some part of your model, the choices might be the list of encoder classes we know about and can instantiate. If the value we find in the param dictionary is not in ``choices``, we raise a ``ConfigurationError``, because the user specified an invalid value in their parameter file. default_to_first_choice: bool, optional (default=False) If this is ``True``, we allow the ``key`` to not be present in the parameter dictionary. If the key is not present, we will use the return as the value the first choice in the ``choices`` list. If this is ``False``, we raise a ``ConfigurationError``, because specifying the ``key`` is required (e.g., you `have` to specify your model class when running an experiment, but you can feel free to use default settings for encoders if you want). """ default = choices[0] if default_to_first_choice else self.DEFAULT value = self.pop(key, default) if value not in choices: key_str = self.history + key message = '%s not in acceptable choices for %s: %s' % (value, key_str, str(choices)) raise ConfigurationError(message) return value
[ "def", "pop_choice", "(", "self", ",", "key", ":", "str", ",", "choices", ":", "List", "[", "Any", "]", ",", "default_to_first_choice", ":", "bool", "=", "False", ")", "->", "Any", ":", "default", "=", "choices", "[", "0", "]", "if", "default_to_first_choice", "else", "self", ".", "DEFAULT", "value", "=", "self", ".", "pop", "(", "key", ",", "default", ")", "if", "value", "not", "in", "choices", ":", "key_str", "=", "self", ".", "history", "+", "key", "message", "=", "'%s not in acceptable choices for %s: %s'", "%", "(", "value", ",", "key_str", ",", "str", "(", "choices", ")", ")", "raise", "ConfigurationError", "(", "message", ")", "return", "value" ]
Gets the value of ``key`` in the ``params`` dictionary, ensuring that the value is one of the given choices. Note that this `pops` the key from params, modifying the dictionary, consistent with how parameters are processed in this codebase. Parameters ---------- key: str Key to get the value from in the param dictionary choices: List[Any] A list of valid options for values corresponding to ``key``. For example, if you're specifying the type of encoder to use for some part of your model, the choices might be the list of encoder classes we know about and can instantiate. If the value we find in the param dictionary is not in ``choices``, we raise a ``ConfigurationError``, because the user specified an invalid value in their parameter file. default_to_first_choice: bool, optional (default=False) If this is ``True``, we allow the ``key`` to not be present in the parameter dictionary. If the key is not present, we will use the return as the value the first choice in the ``choices`` list. If this is ``False``, we raise a ``ConfigurationError``, because specifying the ``key`` is required (e.g., you `have` to specify your model class when running an experiment, but you can feel free to use default settings for encoders if you want).
[ "Gets", "the", "value", "of", "key", "in", "the", "params", "dictionary", "ensuring", "that", "the", "value", "is", "one", "of", "the", "given", "choices", ".", "Note", "that", "this", "pops", "the", "key", "from", "params", "modifying", "the", "dictionary", "consistent", "with", "how", "parameters", "are", "processed", "in", "this", "codebase", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L305-L335
train
Pop the value of key from the parameter dictionary ensuring that the value is one of the given choices.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmlu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,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10000 + 0o42) + chr(0b10010 + 0o43) + chr(1287 - 1236), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1001001 + 0o46) + chr(49) + '\062' + chr(0b100010 + 0o20), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x37' + chr(2495 - 2443), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + chr(206 - 154) + chr(136 - 81), 0b1000), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(111) + '\061' + chr(48), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + chr(55) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(1122 - 1074) + chr(1763 - 1652) + chr(0b0 + 0o63) + '\x31' + '\062', 17386 - 17378), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110010) + chr(221 - 169), 37448 - 37440), ehT0Px3KOsy9('\x30' + chr(0b1001000 + 0o47) + chr(50) + chr(48) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(111) + chr(49) + chr(856 - 807) + '\x31', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b101100 + 0o6) + '\x33' + chr(474 - 422), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + chr(0b110011) + '\x31', 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(350 - 299) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(146 - 97) + '\x34' + '\063', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + chr(995 - 946) + chr(1419 - 1364), 42689 - 42681), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + '\x32' + chr(2606 - 2554), 0b1000), ehT0Px3KOsy9('\x30' + chr(6132 - 6021) + '\061' + chr(1716 - 1662) + chr(0b0 + 0o60), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1110 - 1061) + '\065' + chr(53), 0b1000), ehT0Px3KOsy9(chr(0b0 + 0o60) + '\x6f' + chr(54) + '\x30', 42532 - 42524), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(5564 - 5453) + chr(50) + chr(729 - 678) + '\x35', 55359 - 55351), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101011 + 0o10) + '\067' + chr(0b110000), 3821 - 3813), ehT0Px3KOsy9(chr(48) + chr(111) + '\x31' + '\063' + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1047 - 997) + '\062' + chr(52), 8), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(448 - 397) + chr(52), 17122 - 17114), ehT0Px3KOsy9(chr(0b10111 + 0o31) + '\x6f' + '\063' + '\067' + chr(880 - 827), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b100 + 0o55) + chr(0b110010), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b101100 + 0o7) + chr(1158 - 1104) + '\060', 57250 - 57242), ehT0Px3KOsy9('\060' + chr(0b1100011 + 0o14) + '\x31' + chr(0b110110), 48341 - 48333), ehT0Px3KOsy9('\x30' + chr(0b11 + 0o154) + chr(0b10010 + 0o37) + '\x37' + chr(53), 62031 - 62023), ehT0Px3KOsy9(chr(48) + chr(111) + chr(483 - 433) + chr(1602 - 1553) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(11354 - 11243) + chr(0b101001 + 0o12) + '\062', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + '\x32' + chr(55), 25934 - 25926), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(12293 - 12182) + chr(487 - 436) + chr(0b110010) + chr(49), 0o10), ehT0Px3KOsy9('\060' + chr(0b1001110 + 0o41) + '\062' + '\x36' + '\063', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b11100 + 0o123) + chr(0b110010) + chr(622 - 574) + chr(0b100000 + 0o27), 8), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + '\062' + chr(0b10110 + 0o35) + chr(0b110101), 8), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(12010 - 11899) + chr(50) + chr(0b100100 + 0o14) + '\067', 8), ehT0Px3KOsy9('\x30' + chr(2743 - 2632) + '\x31' + '\x32' + chr(0b110010), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(54) + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + chr(1567 - 1456) + chr(0b101101 + 0o4) + chr(0b110000) + chr(0b11010 + 0o31), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1875 - 1827) + chr(6987 - 6876) + '\065' + chr(48), 19954 - 19946)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x85'), chr(100) + chr(0b110 + 0o137) + chr(0b1100011) + chr(3930 - 3819) + '\144' + chr(0b10 + 0o143))(chr(0b1110101) + chr(7160 - 7044) + chr(102) + chr(444 - 399) + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def k9L24JPxcIn3(oVre8I6UXc3b, K3J4ZwSlE0sT, XPnoMuK4S7nS, _jius2SkCpD2=ehT0Px3KOsy9(chr(48) + chr(111) + chr(48), 0o10)) -> R71nhlWr3XQi: t1v7afVhe01t = XPnoMuK4S7nS[ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1101101 + 0o2) + chr(0b110000), 8)] if _jius2SkCpD2 else oVre8I6UXc3b.DEFAULT QmmgWUB13VCJ = oVre8I6UXc3b.pop(K3J4ZwSlE0sT, t1v7afVhe01t) if QmmgWUB13VCJ not in XPnoMuK4S7nS: FVp84g6wwTmu = oVre8I6UXc3b.sD1K7SLfPnDB + K3J4ZwSlE0sT R2mbIkZzeu1B = xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e!\x1c\x89g\x8d\xea}\xe9i\xfd\xba\xb9\x06?\xe0\x11\x0f\\\xf8\xd8;\xfc3\x94i\x95}]\xe8u\xe5\xf1\x96\xf4\xa7\xa7w\x87'), '\x64' + '\145' + chr(99) + chr(0b1101111) + chr(0b1100100) + chr(7246 - 7145))(chr(0b1110101) + chr(9974 - 9858) + chr(0b1001100 + 0o32) + chr(45) + '\070') % (QmmgWUB13VCJ, FVp84g6wwTmu, M8_cKLkHVB2V(XPnoMuK4S7nS)) raise h0iXqtiKVeKg(R2mbIkZzeu1B) return QmmgWUB13VCJ
allenai/allennlp
allennlp/common/params.py
Params.as_dict
def as_dict(self, quiet: bool = False, infer_type_and_cast: bool = False): """ Sometimes we need to just represent the parameters as a dict, for instance when we pass them to PyTorch code. Parameters ---------- quiet: bool, optional (default = False) Whether to log the parameters before returning them as a dict. infer_type_and_cast : bool, optional (default = False) If True, we infer types and cast (e.g. things that look like floats to floats). """ if infer_type_and_cast: params_as_dict = infer_and_cast(self.params) else: params_as_dict = self.params if quiet: return params_as_dict def log_recursively(parameters, history): for key, value in parameters.items(): if isinstance(value, dict): new_local_history = history + key + "." log_recursively(value, new_local_history) else: logger.info(history + key + " = " + str(value)) logger.info("Converting Params object to dict; logging of default " "values will not occur when dictionary parameters are " "used subsequently.") logger.info("CURRENTLY DEFINED PARAMETERS: ") log_recursively(self.params, self.history) return params_as_dict
python
def as_dict(self, quiet: bool = False, infer_type_and_cast: bool = False): """ Sometimes we need to just represent the parameters as a dict, for instance when we pass them to PyTorch code. Parameters ---------- quiet: bool, optional (default = False) Whether to log the parameters before returning them as a dict. infer_type_and_cast : bool, optional (default = False) If True, we infer types and cast (e.g. things that look like floats to floats). """ if infer_type_and_cast: params_as_dict = infer_and_cast(self.params) else: params_as_dict = self.params if quiet: return params_as_dict def log_recursively(parameters, history): for key, value in parameters.items(): if isinstance(value, dict): new_local_history = history + key + "." log_recursively(value, new_local_history) else: logger.info(history + key + " = " + str(value)) logger.info("Converting Params object to dict; logging of default " "values will not occur when dictionary parameters are " "used subsequently.") logger.info("CURRENTLY DEFINED PARAMETERS: ") log_recursively(self.params, self.history) return params_as_dict
[ "def", "as_dict", "(", "self", ",", "quiet", ":", "bool", "=", "False", ",", "infer_type_and_cast", ":", "bool", "=", "False", ")", ":", "if", "infer_type_and_cast", ":", "params_as_dict", "=", "infer_and_cast", "(", "self", ".", "params", ")", "else", ":", "params_as_dict", "=", "self", ".", "params", "if", "quiet", ":", "return", "params_as_dict", "def", "log_recursively", "(", "parameters", ",", "history", ")", ":", "for", "key", ",", "value", "in", "parameters", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "new_local_history", "=", "history", "+", "key", "+", "\".\"", "log_recursively", "(", "value", ",", "new_local_history", ")", "else", ":", "logger", ".", "info", "(", "history", "+", "key", "+", "\" = \"", "+", "str", "(", "value", ")", ")", "logger", ".", "info", "(", "\"Converting Params object to dict; logging of default \"", "\"values will not occur when dictionary parameters are \"", "\"used subsequently.\"", ")", "logger", ".", "info", "(", "\"CURRENTLY DEFINED PARAMETERS: \"", ")", "log_recursively", "(", "self", ".", "params", ",", "self", ".", "history", ")", "return", "params_as_dict" ]
Sometimes we need to just represent the parameters as a dict, for instance when we pass them to PyTorch code. Parameters ---------- quiet: bool, optional (default = False) Whether to log the parameters before returning them as a dict. infer_type_and_cast : bool, optional (default = False) If True, we infer types and cast (e.g. things that look like floats to floats).
[ "Sometimes", "we", "need", "to", "just", "represent", "the", "parameters", "as", "a", "dict", "for", "instance", "when", "we", "pass", "them", "to", "PyTorch", "code", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params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SQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(817 - 769) + '\157' + '\x37' + chr(50), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(1813 - 1764) + '\x33' + '\061', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1001101 + 0o42) + chr(0b11000 + 0o31) + '\061' + chr(50), 0o10), ehT0Px3KOsy9(chr(48) + chr(8144 - 8033) + '\062' + chr(1979 - 1928), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(453 - 404) + chr(0b11000 + 0o35) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(51) + chr(0b100000 + 0o23) + chr(0b110001), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101100 + 0o6) + chr(0b1011 + 0o51) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + '\x32' + chr(0b1000 + 0o50), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + chr(1692 - 1640) + chr(902 - 850), 8), ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\157' + chr(50) + '\067' + chr(465 - 413), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11001 + 0o31) + chr(0b110111) + chr(0b10010 + 0o41), ord("\x08")), ehT0Px3KOsy9(chr(1180 - 1132) + chr(0b11101 + 0o122) + chr(50) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + chr(436 - 386) + chr(0b110001), 57049 - 57041), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(51) + chr(0b110100) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(1020 - 972) + '\157' + chr(0b10111 + 0o34) + '\063' + chr(50), 31760 - 31752), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b101101 + 0o4) + '\061' + chr(49), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1010010 + 0o35) + chr(52) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(1760 - 1712) + '\x6f' + chr(50) + chr(2457 - 2403) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(49) + chr(2236 - 2187) + chr(2050 - 1998), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b1101 + 0o44) + chr(1061 - 1012) + '\062', 8), ehT0Px3KOsy9('\x30' + chr(0b1001011 + 0o44) + chr(50) + '\x31' + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(1841 - 1793) + chr(10177 - 10066) + chr(0b110010) + chr(0b110010) + chr(825 - 773), 41145 - 41137), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(775 - 725) + chr(50) + '\x36', 43407 - 43399), ehT0Px3KOsy9(chr(215 - 167) + chr(3081 - 2970) + chr(0b100001 + 0o21) + chr(53) + chr(48), 46540 - 46532), ehT0Px3KOsy9('\060' + chr(111) + '\x33' + '\x36' + chr(69 - 20), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100 + 0o143) + '\x36' + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(291 - 243) + '\157' + '\x32', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1010100 + 0o33) + chr(49) + chr(0b11011 + 0o34) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1110 + 0o141) + chr(51) + chr(0b110110) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(413 - 365) + '\157' + '\x31' + chr(1891 - 1841) + chr(2416 - 2364), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + '\x32' + chr(1521 - 1466), 46162 - 46154), ehT0Px3KOsy9(chr(0b110000) + chr(0b110101 + 0o72) + '\x32' + chr(52) + chr(48), 5820 - 5812), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(49) + '\067', 61994 - 61986), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(0b1101111) + chr(2572 - 2517) + chr(0b10110 + 0o40), 35809 - 35801), ehT0Px3KOsy9(chr(1498 - 1450) + chr(0b11111 + 0o120) + chr(0b100011 + 0o20) + '\x37' + '\063', ord("\x08")), ehT0Px3KOsy9('\060' + chr(7586 - 7475) + '\x32' + '\067', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101000 + 0o7) + '\x33' + chr(0b110011) + chr(53), 0b1000), ehT0Px3KOsy9('\x30' + chr(7548 - 7437) + chr(0b110100) + '\066', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101101 + 0o2) + chr(862 - 811) + chr(219 - 166), 25714 - 25706), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110011) + '\062' + '\066', 11151 - 11143)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(522 - 474) + chr(0b1011101 + 0o22) + '\x35' + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x14'), chr(5242 - 5142) + chr(0b100 + 0o141) + chr(0b100000 + 0o103) + '\x6f' + chr(0b101 + 0o137) + chr(0b1100101))(chr(117) + '\164' + chr(0b1001110 + 0o30) + chr(0b101101) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def kV2IVGXCPozh(oVre8I6UXc3b, _yXggv7m96th=ehT0Px3KOsy9(chr(0b110000) + chr(12072 - 11961) + chr(48), 0o10), uvvs7GGYR9TE=ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100000 + 0o20), 8)): if uvvs7GGYR9TE: dKFAZGs25THs = IzIWaN_cBkXc(oVre8I6UXc3b.nEbJZ4wfte2w) else: dKFAZGs25THs = oVre8I6UXc3b.nEbJZ4wfte2w if _yXggv7m96th: return dKFAZGs25THs def zpXIKkMJIVRy(YwMyLskbiCrd, sD1K7SLfPnDB): for (K3J4ZwSlE0sT, QmmgWUB13VCJ) in xafqLlk3kkUe(YwMyLskbiCrd, xafqLlk3kkUe(SXOLrMavuUCe(b't#<v#\x83\x97\x99\xc8\xef\xf3+'), chr(100) + chr(101) + chr(7916 - 7817) + '\157' + chr(5815 - 5715) + chr(0b11000 + 0o115))('\x75' + chr(11137 - 11021) + chr(0b1100110) + chr(0b101101) + chr(0b111000)))(): if PlSM16l2KDPD(QmmgWUB13VCJ, wLqBDw8l0eIm): ixDEz1QbTJQ7 = sD1K7SLfPnDB + K3J4ZwSlE0sT + xafqLlk3kkUe(SXOLrMavuUCe(b'\x14'), chr(5017 - 4917) + chr(0b1100101) + chr(0b110000 + 0o63) + '\157' + '\x64' + chr(3134 - 3033))('\165' + '\164' + '\x66' + chr(264 - 219) + chr(0b110 + 0o62)) zpXIKkMJIVRy(QmmgWUB13VCJ, ixDEz1QbTJQ7) else: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'in\x02k\x1f\xba\xc3\xe7\xce\xd0\xe1y'), chr(0b1100100) + chr(0b1100101) + chr(0b1000011 + 0o40) + '\157' + '\x64' + chr(0b101010 + 0o73))(chr(8796 - 8679) + '\x74' + chr(0b11100 + 0o112) + '\x2d' + '\x38'))(sD1K7SLfPnDB + K3J4ZwSlE0sT + xafqLlk3kkUe(SXOLrMavuUCe(b'\x1adj'), chr(100) + chr(0b1010111 + 0o16) + '\x63' + chr(10657 - 10546) + chr(1609 - 1509) + '\x65')('\165' + chr(116) + chr(0b1100110) + '\x2d' + chr(0b111000 + 0o0)) + M8_cKLkHVB2V(QmmgWUB13VCJ)) xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'in\x02k\x1f\xba\xc3\xe7\xce\xd0\xe1y'), chr(6999 - 6899) + '\145' + chr(0b1100011) + chr(0b1101111) + chr(0b1100100 + 0o0) + chr(0b1100101))(chr(0b1110101) + chr(0b1110100) + '\146' + chr(45) + chr(0b111000)))(xafqLlk3kkUe(SXOLrMavuUCe(b'y6$e\x0f\xab\xd0\xb9\xca\xdb\x9bB\xb0\x92\xbb$W\x94#(\xe4\xf1\xf5\xdc\xd1Fm^\x93=\xf4\xd44\x1e\x97x\xbaAt\xb8]y%uJ\xbd\xc1\xb6\xc5\xc9\xd7f\xf1\x96\xbb%Q\xd1?j\xf9\xfd\xfa\xc4\xd1\\m\n\xd7;\xf4\xc3zL\xdb`\xb5Cs\xf6^0)g\x03\xb6\xca\xb1\xd6\xc5\x9bb\xb0\x92\xbb$A\xc0)8\xfd\xb4\xf7\xda\x94\x12w\r\x920\xb7\xd3z\\\x88r\xacSx\xb8N53='), chr(0b1100100) + '\145' + '\x63' + '\157' + '\144' + chr(0b110 + 0o137))('\x75' + chr(116) + chr(9135 - 9033) + chr(943 - 898) + chr(0b111000))) xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'in\x02k\x1f\xba\xc3\xe7\xce\xd0\xe1y'), '\144' + chr(0b1100101) + chr(0b1100011 + 0o0) + chr(4893 - 4782) + chr(0b1100100) + '\x65')(chr(117) + chr(116) + chr(6892 - 6790) + chr(149 - 104) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'y\x0c\x18A/\x97\xf0\x9c\xfd\x9c\xffW\x97\xa9\x94\x0c`\x94\x1c\x0b\xdc\xd5\xdb\xed\xa5wP-\xcdt'), chr(0b110111 + 0o55) + chr(0b101100 + 0o71) + chr(1598 - 1499) + chr(12050 - 11939) + chr(0b110 + 0o136) + '\x65')('\165' + chr(116) + chr(9742 - 9640) + chr(0b11010 + 0o23) + chr(2667 - 2611))) zpXIKkMJIVRy(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'T\x1c(Y0\xed\xd3\xb6\xd0\xd9\x89e'), chr(0b1100100) + chr(0b1011001 + 0o14) + chr(99) + '\x6f' + chr(100) + chr(2252 - 2151))('\x75' + '\x74' + '\146' + '\055' + chr(56))), xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'I\x1d{X]\x8a\xe8\xb6\xf4\xd2\xffP'), chr(0b1100100) + '\x65' + '\x63' + chr(10213 - 10102) + '\144' + '\x65')('\165' + chr(640 - 524) + '\146' + chr(0b1110 + 0o37) + '\070'))) return dKFAZGs25THs
allenai/allennlp
allennlp/common/params.py
Params.as_flat_dict
def as_flat_dict(self): """ Returns the parameters of a flat dictionary from keys to values. Nested structure is collapsed with periods. """ flat_params = {} def recurse(parameters, path): for key, value in parameters.items(): newpath = path + [key] if isinstance(value, dict): recurse(value, newpath) else: flat_params['.'.join(newpath)] = value recurse(self.params, []) return flat_params
python
def as_flat_dict(self): """ Returns the parameters of a flat dictionary from keys to values. Nested structure is collapsed with periods. """ flat_params = {} def recurse(parameters, path): for key, value in parameters.items(): newpath = path + [key] if isinstance(value, dict): recurse(value, newpath) else: flat_params['.'.join(newpath)] = value recurse(self.params, []) return flat_params
[ "def", "as_flat_dict", "(", "self", ")", ":", "flat_params", "=", "{", "}", "def", "recurse", "(", "parameters", ",", "path", ")", ":", "for", "key", ",", "value", "in", "parameters", ".", "items", "(", ")", ":", "newpath", "=", "path", "+", "[", "key", "]", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "recurse", "(", "value", ",", "newpath", ")", "else", ":", "flat_params", "[", "'.'", ".", "join", "(", "newpath", ")", "]", "=", "value", "recurse", "(", "self", ".", "params", ",", "[", "]", ")", "return", "flat_params" ]
Returns the parameters of a flat dictionary from keys to values. Nested structure is collapsed with periods.
[ "Returns", "the", "parameters", "of", "a", "flat", "dictionary", "from", "keys", "to", "values", ".", "Nested", "structure", "is", "collapsed", "with", "periods", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L372-L387
train
Returns the parameters of a flat dictionary from keys to values.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0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,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(2019 - 1971) + chr(0b1101111) + '\x31' + chr(0b110100) + chr(54), 34193 - 34185), ehT0Px3KOsy9(chr(48) + '\157' + '\x37' + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\x6f' + chr(1336 - 1285) + chr(1959 - 1904), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(49) + chr(0b110101) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(0b1101111) + chr(1052 - 1001) + '\063' + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(111) + chr(1021 - 972) + chr(48) + chr(0b110111), 28680 - 28672), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b1101111) + chr(0b110001) + chr(0b110100) + chr(0b110101), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1011110 + 0o21) + chr(51) + '\x31' + chr(0b100100 + 0o15), ord("\x08")), ehT0Px3KOsy9(chr(0b100001 + 0o17) + '\157' + chr(51) + '\062' + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(10364 - 10253) + chr(53) + chr(55), 0o10), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(9160 - 9049) + chr(52) + chr(705 - 657), 24580 - 24572), ehT0Px3KOsy9(chr(48) + chr(0b1101111 + 0o0) + chr(0b1011 + 0o50) + chr(0b110000) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b11111 + 0o120) + chr(0b110011) + chr(0b11101 + 0o24) + chr(0b11110 + 0o23), 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + chr(55) + chr(54), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1365 - 1315) + chr(0b101100 + 0o6) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(2168 - 2057) + '\x32' + chr(0b110001) + chr(0b110101), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(0b101010 + 0o14) + '\x33', 56605 - 56597), ehT0Px3KOsy9(chr(0b110000) + chr(0b10001 + 0o136) + chr(0b100110 + 0o14) + chr(53) + chr(531 - 483), 38450 - 38442), ehT0Px3KOsy9(chr(1656 - 1608) + chr(0b1101111) + '\062' + chr(986 - 933) + '\061', 28766 - 28758), ehT0Px3KOsy9(chr(0b101101 + 0o3) + '\157' + '\063' + chr(0b100011 + 0o20) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(210 - 161) + '\x30' + '\x37', 8), ehT0Px3KOsy9('\060' + '\157' + chr(50) + chr(0b110010) + chr(585 - 536), 8684 - 8676), ehT0Px3KOsy9(chr(0b100 + 0o54) + '\x6f' + '\063' + '\x31' + chr(552 - 499), 0o10), ehT0Px3KOsy9(chr(717 - 669) + chr(5419 - 5308) + chr(1676 - 1626) + chr(50) + chr(0b1100 + 0o52), 8), ehT0Px3KOsy9('\x30' + chr(2394 - 2283) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001110 + 0o41) + chr(2079 - 2028) + chr(0b100111 + 0o20) + chr(0b101010 + 0o15), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b101001 + 0o11) + '\x36', 59517 - 59509), ehT0Px3KOsy9(chr(749 - 701) + chr(0b1101111) + chr(52) + chr(2311 - 2262), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b100100 + 0o20) + '\x32', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001) + chr(240 - 190) + chr(0b110110), 0o10), ehT0Px3KOsy9('\x30' + chr(7918 - 7807) + '\063' + '\x31' + chr(0b110011), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(660 - 610) + '\065' + chr(1222 - 1171), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(54) + chr(49), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + chr(0b110110 + 0o1) + chr(328 - 278), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b100111 + 0o12) + chr(51) + '\067', 0o10), ehT0Px3KOsy9(chr(1303 - 1255) + chr(111) + chr(0b110000 + 0o2) + chr(0b110101) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b10011 + 0o35) + '\x6f' + '\063' + chr(0b110110) + chr(924 - 876), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(294 - 243) + chr(1669 - 1619) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1101111) + chr(637 - 587) + chr(0b10011 + 0o36) + chr(0b111 + 0o52), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(7708 - 7597) + chr(0b10 + 0o57) + chr(0b100101 + 0o17) + chr(1385 - 1337), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(111) + chr(0b100001 + 0o24) + chr(48), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'H'), chr(0b1001011 + 0o31) + chr(0b1100101) + '\x63' + '\157' + '\x64' + chr(0b1100101))('\x75' + chr(0b0 + 0o164) + '\146' + chr(0b101101) + chr(863 - 807)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def SNhF5G0qeS0h(oVre8I6UXc3b): CfxGEwSTy3yU = {} def Lt8NBqJCHzwp(YwMyLskbiCrd, EaCjyhZptSer): for (K3J4ZwSlE0sT, QmmgWUB13VCJ) in xafqLlk3kkUe(YwMyLskbiCrd, xafqLlk3kkUe(SXOLrMavuUCe(b'(Ci\t\x92\x1dV\x80\xbc|h\xfe'), chr(100) + '\145' + '\143' + chr(0b1101111) + chr(100) + chr(624 - 523))('\x75' + chr(0b1000101 + 0o57) + chr(0b1100110) + '\055' + chr(56)))(): keb0RbED49M9 = EaCjyhZptSer + [K3J4ZwSlE0sT] if PlSM16l2KDPD(QmmgWUB13VCJ, wLqBDw8l0eIm): Lt8NBqJCHzwp(QmmgWUB13VCJ, keb0RbED49M9) else: CfxGEwSTy3yU[xafqLlk3kkUe(SXOLrMavuUCe(b'H'), chr(100) + chr(101) + chr(0b1100011) + chr(0b1100011 + 0o14) + chr(0b1001100 + 0o30) + chr(0b1 + 0o144))('\x75' + '\164' + chr(0b11000 + 0o116) + chr(1374 - 1329) + chr(2730 - 2674))._oWXztVNnqHF(keb0RbED49M9)] = QmmgWUB13VCJ Lt8NBqJCHzwp(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x08|}&\x81s\x12\xaf\xa4J\x12\xb0'), chr(100) + '\x65' + chr(0b1100011) + '\x6f' + chr(100) + chr(900 - 799))('\165' + '\x74' + chr(8892 - 8790) + chr(235 - 190) + '\x38')), []) return CfxGEwSTy3yU
allenai/allennlp
allennlp/common/params.py
Params.assert_empty
def assert_empty(self, class_name: str): """ Raises a ``ConfigurationError`` if ``self.params`` is not empty. We take ``class_name`` as an argument so that the error message gives some idea of where an error happened, if there was one. ``class_name`` should be the name of the `calling` class, the one that got extra parameters (if there are any). """ if self.params: raise ConfigurationError("Extra parameters passed to {}: {}".format(class_name, self.params))
python
def assert_empty(self, class_name: str): """ Raises a ``ConfigurationError`` if ``self.params`` is not empty. We take ``class_name`` as an argument so that the error message gives some idea of where an error happened, if there was one. ``class_name`` should be the name of the `calling` class, the one that got extra parameters (if there are any). """ if self.params: raise ConfigurationError("Extra parameters passed to {}: {}".format(class_name, self.params))
[ "def", "assert_empty", "(", "self", ",", "class_name", ":", "str", ")", ":", "if", "self", ".", "params", ":", "raise", "ConfigurationError", "(", "\"Extra parameters passed to {}: {}\"", ".", "format", "(", "class_name", ",", "self", ".", "params", ")", ")" ]
Raises a ``ConfigurationError`` if ``self.params`` is not empty. We take ``class_name`` as an argument so that the error message gives some idea of where an error happened, if there was one. ``class_name`` should be the name of the `calling` class, the one that got extra parameters (if there are any).
[ "Raises", "a", "ConfigurationError", "if", "self", ".", "params", "is", "not", "empty", ".", "We", "take", "class_name", "as", "an", "argument", "so", "that", "the", "error", "message", "gives", "some", "idea", "of", "where", "an", "error", "happened", "if", "there", "was", "one", ".", "class_name", "should", "be", "the", "name", "of", "the", "calling", "class", "the", "one", "that", "got", "extra", "parameters", "(", "if", "there", "are", "any", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L396-L404
train
Raises a ConfigurationError if self. params is not empty.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1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OC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(2270 - 2219) + chr(55) + '\x31', 0o10), ehT0Px3KOsy9(chr(48) + chr(10431 - 10320) + '\063' + chr(0b11101 + 0o31) + '\065', 33354 - 33346), ehT0Px3KOsy9('\060' + chr(0b1101010 + 0o5) + chr(2112 - 2063) + chr(433 - 383) + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b110101 + 0o72) + '\061' + '\067' + chr(0b101111 + 0o1), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + chr(51) + '\063', 40064 - 40056), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\061' + '\060' + '\x36', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + chr(0b1010 + 0o54) + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b110100 + 0o73) + chr(50) + chr(54) + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(11137 - 11026) + chr(51) + chr(1803 - 1755), 0b1000), ehT0Px3KOsy9(chr(48) + chr(4151 - 4040) + chr(0b11001 + 0o32) + chr(0b110100) + chr(51), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(49) + chr(0b110111) + '\x37', 0b1000), ehT0Px3KOsy9('\x30' + chr(7391 - 7280) + '\x31' + chr(1875 - 1824) + chr(1363 - 1312), 8), ehT0Px3KOsy9(chr(1512 - 1464) + '\157' + '\x32' + chr(0b11010 + 0o26) + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + '\064' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + chr(1504 - 1455) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(0b1101111) + '\067' + chr(0b10 + 0o57), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + chr(52) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b10111 + 0o130) + chr(51) + chr(52), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\062' + '\x36', 42980 - 42972), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1606 - 1554) + '\063', 24911 - 24903), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(0b111101 + 0o62) + chr(50) + '\x36' + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(111) + chr(0b110001) + '\x32' + '\x35', 0o10), ehT0Px3KOsy9('\060' + chr(0b1011001 + 0o26) + '\061' + chr(0b110010) + chr(0b11011 + 0o32), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011100 + 0o23) + chr(739 - 690) + '\x31' + chr(2669 - 2616), 24155 - 24147), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b110101 + 0o72) + chr(187 - 137) + chr(0b1010 + 0o54) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b1110 + 0o43) + chr(54) + chr(261 - 209), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010101 + 0o32) + chr(0b1010 + 0o51) + chr(0b110010) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(1621 - 1573) + chr(0b111 + 0o150) + chr(51) + chr(0b110110) + chr(50), 29706 - 29698), ehT0Px3KOsy9('\x30' + chr(111) + chr(1274 - 1224) + chr(55) + chr(0b1111 + 0o45), 0b1000), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b1011110 + 0o21) + chr(0b110111) + '\066', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(1822 - 1772) + chr(1084 - 1029) + '\x34', 8), ehT0Px3KOsy9('\x30' + chr(8529 - 8418) + '\061' + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b100011 + 0o114) + chr(0b110100 + 0o1) + chr(1394 - 1339), 52144 - 52136), ehT0Px3KOsy9('\060' + '\157' + chr(2425 - 2375) + chr(52) + chr(0b1000 + 0o57), 0o10), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(5057 - 4946) + chr(0b10001 + 0o40) + chr(260 - 209) + '\x31', 28456 - 28448), ehT0Px3KOsy9(chr(849 - 801) + '\157' + '\061' + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101111) + chr(0b110010) + chr(0b110111) + chr(2340 - 2290), 0o10), ehT0Px3KOsy9(chr(0b10000 + 0o40) + '\157' + chr(0b110100) + chr(2182 - 2130), 0b1000), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b1101111) + '\062' + '\060' + chr(0b101110 + 0o10), ord("\x08")), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(0b1101111) + '\061' + chr(457 - 409) + '\067', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(0b1101111) + chr(0b10110 + 0o37) + '\060', 23612 - 23604)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7'), chr(0b11010 + 0o112) + chr(0b1100101) + chr(99) + chr(0b1101111) + '\144' + chr(0b110101 + 0o60))(chr(0b100 + 0o161) + chr(0b1000111 + 0o55) + chr(8857 - 8755) + chr(45) + chr(1071 - 1015)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def D1MvngjzFZjG(oVre8I6UXc3b, _oBLt_tbuDVq): if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x97\xb012\x01r\x01\xd1l\x86M,'), chr(0b1100100) + chr(8963 - 8862) + chr(99) + chr(0b1101111) + chr(2556 - 2456) + chr(101))(chr(0b1101000 + 0o15) + chr(116) + chr(0b1100110) + chr(1695 - 1650) + chr(56))): raise h0iXqtiKVeKg(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b"\xbc\x8d'\n:f\x06\xd6j\x82\x12>\xf7\x808J\xc1lwP\xc501m\xc5\x1b\xf5\x89\xc1\x04\x9cuR"), '\x64' + '\x65' + chr(1283 - 1184) + chr(0b1101111) + '\144' + '\x65')(chr(7361 - 7244) + '\x74' + chr(9615 - 9513) + '\055' + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b"\xaf\xc1!\x17\x13'%\x84H\x93\x1a1"), '\144' + chr(0b1100 + 0o131) + chr(0b1011100 + 0o7) + chr(9201 - 9090) + chr(0b1011000 + 0o14) + chr(0b1000001 + 0o44))('\165' + '\x74' + chr(102) + chr(0b101100 + 0o1) + '\x38'))(_oBLt_tbuDVq, xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x97\xb012\x01r\x01\xd1l\x86M,'), chr(0b1100100) + chr(101) + chr(0b1100011) + chr(0b11101 + 0o122) + chr(0b1011011 + 0o11) + chr(4610 - 4509))('\165' + chr(116) + chr(102) + '\055' + '\x38'))))
allenai/allennlp
allennlp/common/params.py
Params.from_file
def from_file(params_file: str, params_overrides: str = "", ext_vars: dict = None) -> 'Params': """ Load a `Params` object from a configuration file. Parameters ---------- params_file : ``str`` The path to the configuration file to load. params_overrides : ``str``, optional A dict of overrides that can be applied to final object. e.g. {"model.embedding_dim": 10} ext_vars : ``dict``, optional Our config files are Jsonnet, which allows specifying external variables for later substitution. Typically we substitute these using environment variables; however, you can also specify them here, in which case they take priority over environment variables. e.g. {"HOME_DIR": "/Users/allennlp/home"} """ if ext_vars is None: ext_vars = {} # redirect to cache, if necessary params_file = cached_path(params_file) ext_vars = {**_environment_variables(), **ext_vars} file_dict = json.loads(evaluate_file(params_file, ext_vars=ext_vars)) overrides_dict = parse_overrides(params_overrides) param_dict = with_fallback(preferred=overrides_dict, fallback=file_dict) return Params(param_dict)
python
def from_file(params_file: str, params_overrides: str = "", ext_vars: dict = None) -> 'Params': """ Load a `Params` object from a configuration file. Parameters ---------- params_file : ``str`` The path to the configuration file to load. params_overrides : ``str``, optional A dict of overrides that can be applied to final object. e.g. {"model.embedding_dim": 10} ext_vars : ``dict``, optional Our config files are Jsonnet, which allows specifying external variables for later substitution. Typically we substitute these using environment variables; however, you can also specify them here, in which case they take priority over environment variables. e.g. {"HOME_DIR": "/Users/allennlp/home"} """ if ext_vars is None: ext_vars = {} # redirect to cache, if necessary params_file = cached_path(params_file) ext_vars = {**_environment_variables(), **ext_vars} file_dict = json.loads(evaluate_file(params_file, ext_vars=ext_vars)) overrides_dict = parse_overrides(params_overrides) param_dict = with_fallback(preferred=overrides_dict, fallback=file_dict) return Params(param_dict)
[ "def", "from_file", "(", "params_file", ":", "str", ",", "params_overrides", ":", "str", "=", "\"\"", ",", "ext_vars", ":", "dict", "=", "None", ")", "->", "'Params'", ":", "if", "ext_vars", "is", "None", ":", "ext_vars", "=", "{", "}", "# redirect to cache, if necessary", "params_file", "=", "cached_path", "(", "params_file", ")", "ext_vars", "=", "{", "*", "*", "_environment_variables", "(", ")", ",", "*", "*", "ext_vars", "}", "file_dict", "=", "json", ".", "loads", "(", "evaluate_file", "(", "params_file", ",", "ext_vars", "=", "ext_vars", ")", ")", "overrides_dict", "=", "parse_overrides", "(", "params_overrides", ")", "param_dict", "=", "with_fallback", "(", "preferred", "=", "overrides_dict", ",", "fallback", "=", "file_dict", ")", "return", "Params", "(", "param_dict", ")" ]
Load a `Params` object from a configuration file. Parameters ---------- params_file : ``str`` The path to the configuration file to load. params_overrides : ``str``, optional A dict of overrides that can be applied to final object. e.g. {"model.embedding_dim": 10} ext_vars : ``dict``, optional Our config files are Jsonnet, which allows specifying external variables for later substitution. Typically we substitute these using environment variables; however, you can also specify them here, in which case they take priority over environment variables. e.g. {"HOME_DIR": "/Users/allennlp/home"}
[ "Load", "a", "Params", "object", "from", "a", "configuration", "file", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L436-L466
train
Load a Params object from a configuration file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufV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nh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1630 - 1582) + '\x6f' + chr(0b110001 + 0o1) + '\x31' + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(111) + chr(0b101111 + 0o3) + chr(0b110101) + '\x37', 60103 - 60095), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + chr(0b110001) + chr(49), 20319 - 20311), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(0b110000 + 0o4) + '\x37', 11029 - 11021), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + chr(0b11101 + 0o32) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(764 - 716) + chr(111) + chr(0b110010) + '\x31' + '\x30', 8), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + chr(0b110110) + chr(0b101100 + 0o7), 0b1000), ehT0Px3KOsy9('\060' + chr(1024 - 913) + '\x31' + chr(49) + chr(0b110011), 25016 - 25008), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + '\x37' + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(152 - 41) + chr(50) + chr(0b110111) + chr(0b111 + 0o55), 0b1000), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(1655 - 1544) + chr(0b100000 + 0o22) + chr(0b101001 + 0o15) + chr(0b100000 + 0o26), 0o10), ehT0Px3KOsy9('\x30' + chr(0b11 + 0o154) + '\x37' + chr(49), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + '\x35' + chr(0b110 + 0o54), 0b1000), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b111101 + 0o62) + chr(0b110001) + '\x30' + chr(0b10011 + 0o43), 20597 - 20589), ehT0Px3KOsy9('\060' + '\157' + '\x32' + '\064' + chr(1192 - 1144), 0b1000), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + chr(1329 - 1279) + chr(50) + '\063', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + '\060' + '\061', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + '\064' + chr(0b110000), 8), ehT0Px3KOsy9('\x30' + chr(111) + '\x34' + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(1867 - 1819) + chr(111) + chr(0b10111 + 0o32) + '\061' + chr(1673 - 1618), ord("\x08")), ehT0Px3KOsy9(chr(926 - 878) + chr(0b1001111 + 0o40) + chr(51) + chr(1421 - 1369) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(867 - 819) + chr(2350 - 2239) + chr(51) + '\065' + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(2022 - 1973) + chr(0b110101) + chr(351 - 303), ord("\x08")), ehT0Px3KOsy9(chr(0b10010 + 0o36) + '\157' + '\x33' + '\x33' + chr(214 - 161), 0b1000), ehT0Px3KOsy9(chr(1470 - 1422) + '\x6f' + '\062' + '\x37' + chr(0b101000 + 0o15), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1100 + 0o143) + chr(0b110111) + '\064', 0b1000), ehT0Px3KOsy9('\060' + chr(11222 - 11111) + chr(0b100001 + 0o21) + '\063' + chr(2239 - 2187), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(9521 - 9410) + chr(1562 - 1513) + '\061' + chr(55), 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(1519 - 1470) + chr(1826 - 1778) + '\062', 60449 - 60441), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + chr(0b10000 + 0o40) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(49) + chr(0b110000) + '\x34', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1011001 + 0o26) + '\x31' + chr(48) + '\062', 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010000 + 0o37) + '\062' + chr(0b10100 + 0o37) + chr(55), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b100111 + 0o13) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(2140 - 2092) + chr(0b11 + 0o154) + chr(0b110010) + '\065' + chr(55), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b111 + 0o53) + chr(48) + chr(1106 - 1056), ord("\x08")), ehT0Px3KOsy9(chr(718 - 670) + '\x6f' + chr(50) + chr(1770 - 1722) + chr(443 - 389), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101001 + 0o6) + chr(0b110001 + 0o6) + chr(51), 0b1000), ehT0Px3KOsy9(chr(48) + chr(10890 - 10779) + chr(49) + '\066' + chr(0b110001), ord("\x08")), ehT0Px3KOsy9('\060' + chr(3688 - 3577) + chr(0b1 + 0o60) + '\063' + chr(0b110000), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(6006 - 5895) + chr(0b101110 + 0o7) + chr(0b110000), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa6'), '\144' + chr(101) + '\x63' + '\x6f' + chr(0b1100100) + chr(6323 - 6222))(chr(13089 - 12972) + chr(116) + chr(102) + chr(151 - 106) + chr(0b110000 + 0o10)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def VgLkDK0ntFm1(dk9FBhGiUbti, F2zWDsJmfkhr=xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(5785 - 5685) + '\x65' + chr(2396 - 2297) + '\x6f' + chr(7921 - 7821) + '\145')('\x75' + chr(2888 - 2772) + chr(102) + chr(0b101101) + chr(0b111000)), OPojetqewZ2e=None) -> xafqLlk3kkUe(SXOLrMavuUCe(b'\xd8\xce\xfb\xc6\x95\xfb'), '\x64' + '\145' + chr(0b1100011) + chr(0b1101111) + chr(100) + '\145')(chr(2199 - 2082) + '\x74' + chr(102) + '\x2d' + chr(0b111000)): if OPojetqewZ2e is None: OPojetqewZ2e = {} dk9FBhGiUbti = MygwJnRV_fCw(dk9FBhGiUbti) OPojetqewZ2e = {**hGYpHXjjxp0x(), **OPojetqewZ2e} _t_Xv7ybuKKO = fXk443epxtd5.loads(bGgOwPUh9Jwv(dk9FBhGiUbti, ext_vars=OPojetqewZ2e)) IOSEfa_G3kxT = fAHnq8ef5vPR(F2zWDsJmfkhr) s1lQUFSQSjFT = RMpbQE9sq6dx(preferred=IOSEfa_G3kxT, fallback=_t_Xv7ybuKKO) return pboYvIgFA4qm(s1lQUFSQSjFT)
allenai/allennlp
allennlp/common/params.py
Params.as_ordered_dict
def as_ordered_dict(self, preference_orders: List[List[str]] = None) -> OrderedDict: """ Returns Ordered Dict of Params from list of partial order preferences. Parameters ---------- preference_orders: List[List[str]], optional ``preference_orders`` is list of partial preference orders. ["A", "B", "C"] means "A" > "B" > "C". For multiple preference_orders first will be considered first. Keys not found, will have last but alphabetical preference. Default Preferences: ``[["dataset_reader", "iterator", "model", "train_data_path", "validation_data_path", "test_data_path", "trainer", "vocabulary"], ["type"]]`` """ params_dict = self.as_dict(quiet=True) if not preference_orders: preference_orders = [] preference_orders.append(["dataset_reader", "iterator", "model", "train_data_path", "validation_data_path", "test_data_path", "trainer", "vocabulary"]) preference_orders.append(["type"]) def order_func(key): # Makes a tuple to use for ordering. The tuple is an index into each of the `preference_orders`, # followed by the key itself. This gives us integer sorting if you have a key in one of the # `preference_orders`, followed by alphabetical ordering if not. order_tuple = [order.index(key) if key in order else len(order) for order in preference_orders] return order_tuple + [key] def order_dict(dictionary, order_func): # Recursively orders dictionary according to scoring order_func result = OrderedDict() for key, val in sorted(dictionary.items(), key=lambda item: order_func(item[0])): result[key] = order_dict(val, order_func) if isinstance(val, dict) else val return result return order_dict(params_dict, order_func)
python
def as_ordered_dict(self, preference_orders: List[List[str]] = None) -> OrderedDict: """ Returns Ordered Dict of Params from list of partial order preferences. Parameters ---------- preference_orders: List[List[str]], optional ``preference_orders`` is list of partial preference orders. ["A", "B", "C"] means "A" > "B" > "C". For multiple preference_orders first will be considered first. Keys not found, will have last but alphabetical preference. Default Preferences: ``[["dataset_reader", "iterator", "model", "train_data_path", "validation_data_path", "test_data_path", "trainer", "vocabulary"], ["type"]]`` """ params_dict = self.as_dict(quiet=True) if not preference_orders: preference_orders = [] preference_orders.append(["dataset_reader", "iterator", "model", "train_data_path", "validation_data_path", "test_data_path", "trainer", "vocabulary"]) preference_orders.append(["type"]) def order_func(key): # Makes a tuple to use for ordering. The tuple is an index into each of the `preference_orders`, # followed by the key itself. This gives us integer sorting if you have a key in one of the # `preference_orders`, followed by alphabetical ordering if not. order_tuple = [order.index(key) if key in order else len(order) for order in preference_orders] return order_tuple + [key] def order_dict(dictionary, order_func): # Recursively orders dictionary according to scoring order_func result = OrderedDict() for key, val in sorted(dictionary.items(), key=lambda item: order_func(item[0])): result[key] = order_dict(val, order_func) if isinstance(val, dict) else val return result return order_dict(params_dict, order_func)
[ "def", "as_ordered_dict", "(", "self", ",", "preference_orders", ":", "List", "[", "List", "[", "str", "]", "]", "=", "None", ")", "->", "OrderedDict", ":", "params_dict", "=", "self", ".", "as_dict", "(", "quiet", "=", "True", ")", "if", "not", "preference_orders", ":", "preference_orders", "=", "[", "]", "preference_orders", ".", "append", "(", "[", "\"dataset_reader\"", ",", "\"iterator\"", ",", "\"model\"", ",", "\"train_data_path\"", ",", "\"validation_data_path\"", ",", "\"test_data_path\"", ",", "\"trainer\"", ",", "\"vocabulary\"", "]", ")", "preference_orders", ".", "append", "(", "[", "\"type\"", "]", ")", "def", "order_func", "(", "key", ")", ":", "# Makes a tuple to use for ordering. The tuple is an index into each of the `preference_orders`,", "# followed by the key itself. This gives us integer sorting if you have a key in one of the", "# `preference_orders`, followed by alphabetical ordering if not.", "order_tuple", "=", "[", "order", ".", "index", "(", "key", ")", "if", "key", "in", "order", "else", "len", "(", "order", ")", "for", "order", "in", "preference_orders", "]", "return", "order_tuple", "+", "[", "key", "]", "def", "order_dict", "(", "dictionary", ",", "order_func", ")", ":", "# Recursively orders dictionary according to scoring order_func", "result", "=", "OrderedDict", "(", ")", "for", "key", ",", "val", "in", "sorted", "(", "dictionary", ".", "items", "(", ")", ",", "key", "=", "lambda", "item", ":", "order_func", "(", "item", "[", "0", "]", ")", ")", ":", "result", "[", "key", "]", "=", "order_dict", "(", "val", ",", "order_func", ")", "if", "isinstance", "(", "val", ",", "dict", ")", "else", "val", "return", "result", "return", "order_dict", "(", "params_dict", ",", "order_func", ")" ]
Returns Ordered Dict of Params from list of partial order preferences. Parameters ---------- preference_orders: List[List[str]], optional ``preference_orders`` is list of partial preference orders. ["A", "B", "C"] means "A" > "B" > "C". For multiple preference_orders first will be considered first. Keys not found, will have last but alphabetical preference. Default Preferences: ``[["dataset_reader", "iterator", "model", "train_data_path", "validation_data_path", "test_data_path", "trainer", "vocabulary"], ["type"]]``
[ "Returns", "Ordered", "Dict", "of", "Params", "from", "list", "of", "partial", "order", "preferences", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L472-L507
train
Returns an OrderedDict of Params from the current instance.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0H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aORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(8454 - 8343) + '\x32' + chr(50) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\x6f' + '\066' + '\x33', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\061' + chr(1983 - 1933) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\x6f' + '\x32' + chr(0b100110 + 0o20) + chr(0b111 + 0o55), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1932 - 1883) + chr(0b10 + 0o65) + chr(49), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(1979 - 1928) + chr(923 - 873) + chr(0b100100 + 0o14), 59980 - 59972), ehT0Px3KOsy9(chr(886 - 838) + '\x6f' + chr(52) + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b10100 + 0o34) + '\157' + chr(0b110010) + chr(0b110110), 65212 - 65204), ehT0Px3KOsy9('\060' + chr(0b10011 + 0o134) + chr(1637 - 1586) + chr(0b11100 + 0o30) + chr(0b11011 + 0o30), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(1547 - 1436) + chr(50) + chr(0b110001) + chr(1287 - 1239), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\065' + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(1070 - 1022) + chr(0b1101000 + 0o7) + chr(0b1110 + 0o50) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(589 - 541) + chr(0b1101111) + chr(0b110001) + '\x35' + chr(0b110000 + 0o1), 0b1000), ehT0Px3KOsy9(chr(2058 - 2010) + '\157' + chr(872 - 821) + '\060' + chr(0b1111 + 0o44), 15731 - 15723), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + chr(0b110010) + '\x37' + chr(0b110000 + 0o4), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + chr(0b110111) + '\060', 0b1000), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b1101111) + chr(0b110001) + '\x35' + '\063', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1010101 + 0o32) + chr(1790 - 1741) + '\067' + '\067', 38032 - 38024), ehT0Px3KOsy9('\x30' + chr(2184 - 2073) + chr(0b110011) + chr(2467 - 2416) + chr(1102 - 1051), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(210 - 99) + '\061' + '\x33' + chr(2149 - 2094), 45752 - 45744), ehT0Px3KOsy9(chr(1473 - 1425) + '\x6f' + chr(0b101001 + 0o10) + '\x35', 0o10), ehT0Px3KOsy9('\x30' + chr(9276 - 9165) + chr(0b110011) + chr(48) + chr(54), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + chr(0b11100 + 0o32) + '\x37', 15586 - 15578), ehT0Px3KOsy9(chr(192 - 144) + chr(5897 - 5786) + chr(1250 - 1199) + '\x35' + chr(52), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(0b1000 + 0o55) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + chr(2120 - 2067) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110111) + chr(50), 6932 - 6924), ehT0Px3KOsy9(chr(48) + '\157' + chr(1247 - 1198) + chr(50) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(8644 - 8533) + chr(51) + chr(49) + '\065', 44163 - 44155), ehT0Px3KOsy9(chr(1596 - 1548) + chr(111) + '\061' + '\065' + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + chr(49) + chr(0b110011), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b1101 + 0o46) + chr(0b100101 + 0o13) + '\x36', 8), ehT0Px3KOsy9('\060' + chr(8594 - 8483) + chr(49) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(2448 - 2337) + '\x33' + chr(0b110000) + chr(54), 8), ehT0Px3KOsy9(chr(0b110000) + chr(2087 - 1976) + chr(50) + '\x30' + '\x30', 57315 - 57307), ehT0Px3KOsy9(chr(2245 - 2197) + '\x6f' + chr(49) + chr(516 - 461) + chr(54), 0o10), ehT0Px3KOsy9(chr(409 - 361) + chr(0b1101000 + 0o7) + chr(870 - 819), 46990 - 46982), ehT0Px3KOsy9(chr(0b101 + 0o53) + '\x6f' + '\062' + chr(0b11000 + 0o31), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110110) + chr(1614 - 1562), 37143 - 37135), ehT0Px3KOsy9(chr(1704 - 1656) + chr(0b1101111) + chr(49) + chr(0b110100) + chr(0b1111 + 0o44), 27921 - 27913)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(53) + '\060', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9'), '\144' + '\145' + chr(0b100 + 0o137) + '\x6f' + chr(0b1100100) + chr(0b1100101))(chr(0b1100010 + 0o23) + '\164' + '\x66' + chr(0b101101) + chr(2526 - 2470)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def Xy3S6nqV0bI6(oVre8I6UXc3b, Hx6Sk5ekinEi=None) -> dckoaRguRn3D: dIKGiCGu2yqR = oVre8I6UXc3b.as_dict(quiet=ehT0Px3KOsy9(chr(0b110000) + chr(2900 - 2789) + '\x31', 0o10)) if not Hx6Sk5ekinEi: Hx6Sk5ekinEi = [] xafqLlk3kkUe(Hx6Sk5ekinEi, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf6C%\xd1\x17\xb4'), chr(0b100000 + 0o104) + chr(0b110001 + 0o64) + '\x63' + '\x6f' + chr(0b110100 + 0o60) + '\145')(chr(7711 - 7594) + chr(116) + chr(0b1100110) + chr(45) + chr(0b111000)))([xafqLlk3kkUe(SXOLrMavuUCe(b'\xf3R!\xd5\n\xb5VI\x91\xedJU\x0c\xb1'), chr(0b1100100) + '\x65' + chr(0b1100011) + '\157' + '\x64' + chr(101))('\165' + chr(0b1110100) + chr(9996 - 9894) + chr(0b0 + 0o55) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xfeG0\xc6\x18\xa4Md'), chr(0b11111 + 0o105) + chr(101) + '\143' + '\x6f' + '\x64' + chr(0b1100101))('\x75' + '\x74' + chr(102) + chr(593 - 548) + chr(2708 - 2652)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xfa\\1\xd1\x15'), chr(0b1100100) + '\145' + chr(99) + chr(0b11110 + 0o121) + chr(100) + '\145')('\x75' + chr(0b1110100) + '\146' + chr(405 - 360) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3A4\xdd\x17\x8fFw\x97\xe9tA\x08\xb7\xd4'), chr(0b1100100) + chr(101) + chr(816 - 717) + chr(0b11001 + 0o126) + '\x64' + '\x65')('\165' + '\164' + '\x66' + chr(45) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b"\xe1R9\xdd\x1d\xb1V\x7f\x8c\xe6tU\x08\xb7\xdd'\x1b\x1e\xaf7"), chr(100) + chr(0b1100101) + '\143' + '\157' + '\x64' + '\x65')('\x75' + chr(0b1001001 + 0o53) + chr(0b1100110) + '\x2d' + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3V&\xc0&\xb4Cb\x82\xd7[P\x1d\xab'), chr(7700 - 7600) + chr(0b1100101) + chr(99) + '\x6f' + chr(100) + chr(101))(chr(0b1110101) + '\164' + '\x66' + chr(45) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3A4\xdd\x17\xb5P'), chr(0b1011111 + 0o5) + chr(0b1100101) + chr(0b1001110 + 0o25) + chr(111) + chr(100) + chr(0b1100101))('\x75' + chr(0b1110100) + chr(6644 - 6542) + chr(1261 - 1216) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xe1\\6\xd5\x1b\xa5Nw\x91\xf1'), chr(100) + '\x65' + '\x63' + '\157' + chr(0b1100100) + '\x65')(chr(0b101010 + 0o113) + '\164' + chr(0b1100110) + chr(0b101101) + '\070')]) xafqLlk3kkUe(Hx6Sk5ekinEi, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf6C%\xd1\x17\xb4'), chr(5980 - 5880) + chr(101) + chr(0b1001111 + 0o24) + chr(0b101001 + 0o106) + chr(0b111010 + 0o52) + chr(5012 - 4911))('\x75' + chr(0b1110100) + '\x66' + '\055' + chr(0b111000)))([xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3J%\xd1'), chr(0b1100100) + chr(0b1100101) + '\143' + chr(111) + chr(0b100101 + 0o77) + chr(4924 - 4823))(chr(0b1110001 + 0o4) + chr(0b1110100) + chr(0b1100110) + chr(917 - 872) + chr(0b11100 + 0o34))]) def lKMTwAhRZVlc(K3J4ZwSlE0sT): DrBdSCpRrg91 = [hO2LnONV9lny.XdowRbJKZWL9(K3J4ZwSlE0sT) if K3J4ZwSlE0sT in hO2LnONV9lny else c2A0yzQpDQB3(hO2LnONV9lny) for hO2LnONV9lny in Hx6Sk5ekinEi] return DrBdSCpRrg91 + [K3J4ZwSlE0sT] def dzXv1oDSM1Us(uGRoYQpWwd_a, lKMTwAhRZVlc): ShZmEKfTkAOZ = dckoaRguRn3D() for (K3J4ZwSlE0sT, pQxH2D_k9sXQ) in vUlqIvNSaRMa(xafqLlk3kkUe(uGRoYQpWwd_a, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd9I#\xd10\x8a\x11_\x8f\xdbc\x08'), chr(0b11100 + 0o110) + chr(0b100101 + 0o100) + '\143' + chr(0b1101111) + chr(0b1100100) + chr(0b110101 + 0o60))(chr(117) + '\x74' + chr(102) + '\x2d' + chr(0b111000)))(), key=lambda N7j7ePTXzzI0: lKMTwAhRZVlc(N7j7ePTXzzI0[ehT0Px3KOsy9('\060' + chr(0b1101000 + 0o7) + chr(0b10011 + 0o35), ord("\x08"))])): ShZmEKfTkAOZ[K3J4ZwSlE0sT] = dzXv1oDSM1Us(pQxH2D_k9sXQ, lKMTwAhRZVlc) if PlSM16l2KDPD(pQxH2D_k9sXQ, wLqBDw8l0eIm) else pQxH2D_k9sXQ return ShZmEKfTkAOZ return dzXv1oDSM1Us(dIKGiCGu2yqR, lKMTwAhRZVlc)
allenai/allennlp
allennlp/common/params.py
Params.get_hash
def get_hash(self) -> str: """ Returns a hash code representing the current state of this ``Params`` object. We don't want to implement ``__hash__`` because that has deeper python implications (and this is a mutable object), but this will give you a representation of the current state. """ return str(hash(json.dumps(self.params, sort_keys=True)))
python
def get_hash(self) -> str: """ Returns a hash code representing the current state of this ``Params`` object. We don't want to implement ``__hash__`` because that has deeper python implications (and this is a mutable object), but this will give you a representation of the current state. """ return str(hash(json.dumps(self.params, sort_keys=True)))
[ "def", "get_hash", "(", "self", ")", "->", "str", ":", "return", "str", "(", "hash", "(", "json", ".", "dumps", "(", "self", ".", "params", ",", "sort_keys", "=", "True", ")", ")", ")" ]
Returns a hash code representing the current state of this ``Params`` object. We don't want to implement ``__hash__`` because that has deeper python implications (and this is a mutable object), but this will give you a representation of the current state.
[ "Returns", "a", "hash", "code", "representing", "the", "current", "state", "of", "this", "Params", "object", ".", "We", "don", "t", "want", "to", "implement", "__hash__", "because", "that", "has", "deeper", "python", "implications", "(", "and", "this", "is", "a", "mutable", "object", ")", "but", "this", "will", "give", "you", "a", "representation", "of", "the", "current", "state", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/params.py#L509-L515
train
Returns a hash code representing the current state of this Params object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24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YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(59 - 11) + chr(111) + chr(0b110011 + 0o0) + '\063' + '\x32', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110011) + '\x37' + '\065', 0o10), ehT0Px3KOsy9(chr(514 - 466) + chr(0b101111 + 0o100) + chr(0b110010) + chr(49) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + '\064' + '\x32', 0b1000), ehT0Px3KOsy9(chr(271 - 223) + '\x6f' + '\x31' + chr(0b101101 + 0o3) + chr(559 - 509), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\061', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + '\064' + chr(48), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(2544 - 2493) + '\x35' + chr(1326 - 1277), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10001 + 0o40) + chr(1032 - 980) + chr(2218 - 2167), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(50) + chr(48) + chr(681 - 627), 0b1000), ehT0Px3KOsy9(chr(1725 - 1677) + chr(111) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(1834 - 1723) + chr(0b101 + 0o54) + chr(0b10010 + 0o43), 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\063' + chr(0b110 + 0o54) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b110010 + 0o75) + chr(0b11110 + 0o24) + chr(0b10110 + 0o32) + chr(0b10110 + 0o32), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b11111 + 0o22) + chr(1808 - 1756) + '\064', 0o10), ehT0Px3KOsy9('\x30' + chr(5249 - 5138) + chr(0b110011) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(2293 - 2245) + chr(0b1101111) + chr(55) + chr(54), 19713 - 19705), ehT0Px3KOsy9(chr(937 - 889) + chr(111) + chr(1447 - 1397) + chr(123 - 69) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(851 - 803) + '\x6f' + chr(2102 - 2052) + chr(0b11 + 0o62) + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1100000 + 0o17) + chr(1593 - 1542) + chr(0b110100) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + chr(0b110100) + chr(265 - 212), 0o10), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\x6f' + chr(0b110001) + chr(0b110011) + chr(2579 - 2525), 0b1000), ehT0Px3KOsy9(chr(2168 - 2120) + chr(111) + chr(1741 - 1690) + chr(0b110001) + chr(0b1011 + 0o45), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1096 - 1045) + chr(0b110100) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(0b10101 + 0o132) + '\061' + chr(0b1111 + 0o47) + '\x33', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101011 + 0o4) + chr(50) + '\064' + chr(0b100101 + 0o17), ord("\x08")), ehT0Px3KOsy9(chr(2298 - 2250) + chr(11557 - 11446) + chr(0b110 + 0o55) + chr(48) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(560 - 512) + chr(7495 - 7384) + chr(49) + chr(0b110010) + chr(0b110000 + 0o3), 0o10), ehT0Px3KOsy9('\x30' + chr(3946 - 3835) + chr(1438 - 1389) + '\065' + chr(1864 - 1811), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001 + 0o2) + chr(0b110111) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b110011) + chr(0b110011) + chr(0b110010), 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(177 - 128) + chr(0b100110 + 0o20) + chr(0b10 + 0o65), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(8323 - 8212) + chr(0b110010) + chr(541 - 490) + chr(0b110100), 24915 - 24907), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + '\065' + '\x36', 7712 - 7704), ehT0Px3KOsy9(chr(0b110000) + chr(2824 - 2713) + chr(0b110011) + '\062' + '\x31', 63883 - 63875), ehT0Px3KOsy9(chr(930 - 882) + '\157' + chr(1921 - 1870) + chr(0b10110 + 0o34) + chr(0b101001 + 0o11), 31107 - 31099), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + '\x37' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + '\066' + chr(52), 15112 - 15104), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + '\x37' + chr(719 - 667), 10268 - 10260), ehT0Px3KOsy9(chr(48) + chr(0b1100010 + 0o15) + '\x32' + '\x35' + chr(50), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1086 - 1038) + chr(7399 - 7288) + chr(0b110101) + chr(0b110000), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf4'), '\x64' + '\x65' + chr(0b1100011) + chr(111) + chr(0b101010 + 0o72) + chr(0b1000010 + 0o43))(chr(0b110001 + 0o104) + '\164' + '\x66' + chr(0b100110 + 0o7) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def sbCgyQXZcd0K(oVre8I6UXc3b) -> M8_cKLkHVB2V: return M8_cKLkHVB2V(xfhwxiBOH72k(xafqLlk3kkUe(fXk443epxtd5, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbe\x88\xe6\xd21'), chr(0b1100100) + chr(0b1100101) + chr(0b11001 + 0o112) + chr(111) + '\144' + '\x65')('\x75' + '\x74' + chr(0b1100110) + '\055' + chr(56)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb4\xb8\xe9\xe8\x185\x17\x8f\x17\xe34z'), '\144' + '\x65' + chr(0b101010 + 0o71) + chr(0b11011 + 0o124) + chr(3216 - 3116) + chr(0b1100101))(chr(3809 - 3692) + chr(981 - 865) + chr(0b1100110) + '\x2d' + chr(0b101011 + 0o15))), sort_keys=ehT0Px3KOsy9('\x30' + chr(5191 - 5080) + chr(967 - 918), 8))))
allenai/allennlp
allennlp/training/metric_tracker.py
MetricTracker.clear
def clear(self) -> None: """ Clears out the tracked metrics, but keeps the patience and should_decrease settings. """ self._best_so_far = None self._epochs_with_no_improvement = 0 self._is_best_so_far = True self._epoch_number = 0 self.best_epoch = None
python
def clear(self) -> None: """ Clears out the tracked metrics, but keeps the patience and should_decrease settings. """ self._best_so_far = None self._epochs_with_no_improvement = 0 self._is_best_so_far = True self._epoch_number = 0 self.best_epoch = None
[ "def", "clear", "(", "self", ")", "->", "None", ":", "self", ".", "_best_so_far", "=", "None", "self", ".", "_epochs_with_no_improvement", "=", "0", "self", ".", "_is_best_so_far", "=", "True", "self", ".", "_epoch_number", "=", "0", "self", ".", "best_epoch", "=", "None" ]
Clears out the tracked metrics, but keeps the patience and should_decrease settings.
[ "Clears", "out", "the", "tracked", "metrics", "but", "keeps", "the", "patience", "and", "should_decrease", "settings", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/training/metric_tracker.py#L59-L67
train
Clears out the current set of tracked metrics.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDz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,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b100101 + 0o13) + '\157' + chr(864 - 814) + chr(0b110110) + '\x36', 0b1000), ehT0Px3KOsy9(chr(1040 - 992) + chr(111) + '\x36', 50122 - 50114), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + '\x31' + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010010 + 0o35) + chr(49) + '\x36' + '\061', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(474 - 423) + chr(1010 - 955) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(11245 - 11134) + '\x33' + '\x37', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + chr(0b110110) + chr(778 - 727), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1406 - 1356) + chr(51) + chr(0b101 + 0o60), 6126 - 6118), ehT0Px3KOsy9(chr(0b110000) + chr(3775 - 3664) + chr(51) + '\063' + chr(392 - 337), 0b1000), ehT0Px3KOsy9(chr(1576 - 1528) + '\157' + '\062' + chr(0b110100) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(2063 - 2015) + chr(0b100 + 0o153) + chr(50) + '\065' + chr(0b110011), 26104 - 26096), ehT0Px3KOsy9('\060' + '\x6f' + '\x32' + chr(0b11011 + 0o27) + chr(0b10100 + 0o35), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(921 - 871) + '\x33' + chr(0b0 + 0o65), 8), ehT0Px3KOsy9(chr(755 - 707) + chr(0b1101111) + chr(0b1111 + 0o44) + chr(376 - 325) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(1708 - 1659) + chr(55) + chr(371 - 319), 0o10), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b1011111 + 0o20) + chr(51) + '\067' + chr(297 - 245), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(52) + chr(302 - 249), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110001) + chr(0b110010) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(2052 - 2001) + '\x34' + chr(50), 0o10), ehT0Px3KOsy9('\060' + chr(4632 - 4521) + chr(588 - 537) + '\061' + chr(55), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(9662 - 9551) + '\061' + chr(0b10101 + 0o41) + chr(0b110010), 33475 - 33467), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b1001 + 0o146) + chr(0b110101) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(3344 - 3233) + '\x34' + chr(2548 - 2496), 44725 - 44717), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x33' + chr(0b110111) + chr(1336 - 1285), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + chr(0b1101 + 0o44) + chr(917 - 868), ord("\x08")), ehT0Px3KOsy9(chr(2014 - 1966) + '\x6f' + chr(1518 - 1467) + chr(0b110011) + chr(0b10100 + 0o35), 0b1000), ehT0Px3KOsy9(chr(1506 - 1458) + '\157' + '\062' + '\067' + chr(0b10011 + 0o37), 0o10), ehT0Px3KOsy9(chr(1255 - 1207) + chr(111) + chr(0b100100 + 0o16), 0b1000), ehT0Px3KOsy9(chr(1300 - 1252) + '\157' + chr(0b111 + 0o54) + '\066' + chr(0b11111 + 0o25), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + '\062' + '\x30', 54341 - 54333), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001) + chr(0b110010) + chr(1291 - 1240), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b11000 + 0o31) + '\x35' + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101 + 0o142) + chr(0b110011) + chr(51) + chr(0b100011 + 0o21), ord("\x08")), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\157' + '\062' + chr(678 - 624), 0b1000), ehT0Px3KOsy9(chr(1345 - 1297) + chr(0b1101111) + '\x31' + chr(0b110000) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b100001 + 0o17) + '\157' + '\x37', 33599 - 33591), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + chr(0b110110), 8), ehT0Px3KOsy9('\060' + chr(6695 - 6584) + chr(0b110100) + chr(0b1110 + 0o46), 8), ehT0Px3KOsy9('\x30' + chr(7982 - 7871) + chr(0b10 + 0o61) + chr(0b100110 + 0o12) + chr(0b110010), 30922 - 30914)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(111) + '\x35' + '\x30', ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x98'), chr(1472 - 1372) + chr(5975 - 5874) + chr(9577 - 9478) + '\x6f' + chr(0b0 + 0o144) + chr(0b1010 + 0o133))('\165' + '\164' + chr(0b1100110) + chr(1462 - 1417) + chr(635 - 579)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def c67HZ7s0s6HK(oVre8I6UXc3b) -> None: oVre8I6UXc3b.QiARneucrBZg = None oVre8I6UXc3b.TtcyHFs_OmbD = ehT0Px3KOsy9(chr(1805 - 1757) + chr(111) + chr(136 - 88), 5876 - 5868) oVre8I6UXc3b.H97Yioie4lux = ehT0Px3KOsy9('\x30' + chr(0b101001 + 0o106) + chr(0b110001), 0b1000) oVre8I6UXc3b.yx9g1CYdwNrY = ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b101 + 0o53), 8) oVre8I6UXc3b.I_4lnf2etuVk = None
allenai/allennlp
allennlp/training/metric_tracker.py
MetricTracker.state_dict
def state_dict(self) -> Dict[str, Any]: """ A ``Trainer`` can use this to serialize the state of the metric tracker. """ return { "best_so_far": self._best_so_far, "patience": self._patience, "epochs_with_no_improvement": self._epochs_with_no_improvement, "is_best_so_far": self._is_best_so_far, "should_decrease": self._should_decrease, "best_epoch_metrics": self.best_epoch_metrics, "epoch_number": self._epoch_number, "best_epoch": self.best_epoch }
python
def state_dict(self) -> Dict[str, Any]: """ A ``Trainer`` can use this to serialize the state of the metric tracker. """ return { "best_so_far": self._best_so_far, "patience": self._patience, "epochs_with_no_improvement": self._epochs_with_no_improvement, "is_best_so_far": self._is_best_so_far, "should_decrease": self._should_decrease, "best_epoch_metrics": self.best_epoch_metrics, "epoch_number": self._epoch_number, "best_epoch": self.best_epoch }
[ "def", "state_dict", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "{", "\"best_so_far\"", ":", "self", ".", "_best_so_far", ",", "\"patience\"", ":", "self", ".", "_patience", ",", "\"epochs_with_no_improvement\"", ":", "self", ".", "_epochs_with_no_improvement", ",", "\"is_best_so_far\"", ":", "self", ".", "_is_best_so_far", ",", "\"should_decrease\"", ":", "self", ".", "_should_decrease", ",", "\"best_epoch_metrics\"", ":", "self", ".", "best_epoch_metrics", ",", "\"epoch_number\"", ":", "self", ".", "_epoch_number", ",", "\"best_epoch\"", ":", "self", ".", "best_epoch", "}" ]
A ``Trainer`` can use this to serialize the state of the metric tracker.
[ "A", "Trainer", "can", "use", "this", "to", "serialize", "the", "state", "of", "the", "metric", "tracker", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/training/metric_tracker.py#L69-L82
train
A dictionary that can be used to serialize the state of the metric tracker.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKt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Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1286 - 1238) + '\157' + chr(905 - 853) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\061' + chr(0b101100 + 0o6) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(8016 - 7905) + chr(0b110100) + chr(0b110100 + 0o3), 51211 - 51203), ehT0Px3KOsy9(chr(1655 - 1607) + chr(0b1101111) + chr(2089 - 2038) + chr(0b11011 + 0o32) + chr(49), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + chr(0b110011) + '\x31', 0o10), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(8792 - 8681) + chr(0b11110 + 0o23) + chr(0b100001 + 0o20) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(4122 - 4011) + '\x33' + chr(2245 - 2195) + '\060', ord("\x08")), ehT0Px3KOsy9('\060' + chr(4116 - 4005) + chr(51) + chr(0b110010) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(2325 - 2273) + '\061', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + chr(0b10101 + 0o35) + chr(0b110111), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(50) + chr(51) + '\061', 8), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001) + chr(998 - 944) + chr(0b110101), 55930 - 55922), ehT0Px3KOsy9(chr(1385 - 1337) + chr(111) + chr(2311 - 2260) + chr(0b110110) + '\065', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(0b101001 + 0o13) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(1444 - 1396) + chr(0b1101111 + 0o0) + '\061' + '\x31' + chr(0b100011 + 0o21), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011101 + 0o22) + '\062' + chr(0b110100) + chr(205 - 154), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10 + 0o61) + '\x37' + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(366 - 318) + chr(111) + chr(0b110011) + '\061' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(0b101100 + 0o5) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(2285 - 2237) + chr(5499 - 5388) + chr(0b11101 + 0o25) + '\x35' + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1010100 + 0o33) + chr(589 - 538) + '\067' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(603 - 553) + chr(0b100100 + 0o21) + chr(2838 - 2784), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(51) + chr(1088 - 1035) + chr(0b11100 + 0o30), ord("\x08")), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(0b1101111) + chr(2150 - 2099) + '\064' + '\x32', 0b1000), ehT0Px3KOsy9(chr(48) + chr(11153 - 11042) + chr(2034 - 1985) + '\063' + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(2431 - 2381) + chr(49) + '\062', 46934 - 46926), ehT0Px3KOsy9('\060' + chr(9553 - 9442) + '\063' + '\061' + chr(0b110011), 8), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(0b1101111) + chr(373 - 324), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + chr(0b110010) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(9951 - 9840) + chr(50) + chr(0b110001) + chr(50), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31' + chr(0b110010) + chr(246 - 191), 0o10), ehT0Px3KOsy9(chr(0b1001 + 0o47) + '\x6f' + chr(0b1001 + 0o50) + chr(1254 - 1200) + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + chr(9611 - 9500) + chr(0b110010) + chr(1670 - 1621) + chr(0b100101 + 0o15), 8), ehT0Px3KOsy9(chr(0b101110 + 0o2) + '\x6f' + '\x33' + chr(0b110110) + chr(0b10 + 0o56), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b110010) + '\x33' + chr(1249 - 1196), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + '\062', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(1017 - 967) + chr(55) + chr(0b101010 + 0o6), 32440 - 32432), ehT0Px3KOsy9(chr(0b110000) + chr(0b11 + 0o154) + chr(49) + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(1594 - 1483) + '\x35' + chr(0b100011 + 0o22), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001 + 0o1) + chr(1314 - 1265), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(111) + chr(549 - 496) + '\x30', 20101 - 20093)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x0b'), '\144' + '\145' + chr(0b1100011) + chr(0b10010 + 0o135) + chr(100) + chr(0b1100101))(chr(0b1110101) + chr(0b1110100) + '\146' + chr(45) + chr(0b100110 + 0o22)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def ibLOdkgHjo3t(oVre8I6UXc3b) -> zBnV56fc6HrA[M8_cKLkHVB2V, R71nhlWr3XQi]: return {xafqLlk3kkUe(SXOLrMavuUCe(b'G5T\x9d\xc6>\xbf\x8dG\xb6\xeb'), chr(0b1100100) + '\x65' + chr(99) + '\x6f' + chr(2257 - 2157) + chr(7944 - 7843))(chr(6997 - 6880) + chr(116) + chr(0b1100110) + chr(45) + chr(56)): xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b't9f\xbb\xf7(\xa5\xb1S\x95\xc3\x12'), chr(0b1100100) + chr(2190 - 2089) + chr(4334 - 4235) + chr(0b1101111) + chr(0b1100100) + chr(101))(chr(0b1110010 + 0o3) + chr(8854 - 8738) + '\x66' + chr(0b1000 + 0o45) + chr(56))), xafqLlk3kkUe(SXOLrMavuUCe(b'U1S\x80\xfc#\xb3\xb7'), '\x64' + '\x65' + chr(0b1010010 + 0o21) + '\x6f' + chr(9527 - 9427) + chr(0b1100101))(chr(1734 - 1617) + '\164' + '\146' + chr(45) + chr(0b10100 + 0o44)): xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'z F\x9d\xf0(\xbe\xb1D'), chr(100) + chr(0b100000 + 0o105) + chr(0b1000000 + 0o43) + '\x6f' + '\144' + chr(101))(chr(9254 - 9137) + '\164' + '\146' + chr(921 - 876) + '\070')), xafqLlk3kkUe(SXOLrMavuUCe(b'@ H\x8a\xf1>\x8f\xa5H\xa3\xf1*\x9b\xcb\x13\xca\x96\xbb\xfd\xc6\x8a\xcb\x81\x870\xfe'), '\x64' + '\145' + chr(935 - 836) + '\x6f' + chr(0b1100100) + '\x65')(chr(117) + chr(0b1110100) + chr(2005 - 1903) + chr(45) + '\070'): xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'q$D\x90\xd1\x0b\xa3\x8dn\xba\xfb1'), chr(0b1100100) + chr(0b1100101) + chr(0b10000 + 0o123) + '\x6f' + chr(0b111010 + 0o52) + chr(7312 - 7211))(chr(117) + chr(2168 - 2052) + '\146' + chr(0b1101 + 0o40) + chr(182 - 126))), xafqLlk3kkUe(SXOLrMavuUCe(b'L#x\x8b\xfc>\xa4\x8dR\xb8\xc6\x13\x94\xd6'), chr(1553 - 1453) + chr(7050 - 6949) + chr(0b10111 + 0o114) + '\x6f' + chr(2848 - 2748) + '\x65')('\165' + chr(0b11000 + 0o134) + chr(0b1000111 + 0o37) + chr(0b1000 + 0o45) + chr(0b111000)): xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'mi\x10\xb0\xf0"\xb9\xb7\x15\xbb\xec\r'), chr(0b1000110 + 0o36) + chr(101) + chr(0b1000101 + 0o36) + chr(0b1101111) + '\144' + chr(0b1010000 + 0o25))('\165' + chr(13082 - 12966) + '\146' + chr(0b10101 + 0o30) + chr(0b10 + 0o66))), xafqLlk3kkUe(SXOLrMavuUCe(b'V8H\x9c\xf5)\x8f\xb6D\xb4\xeb\x10\x94\xd7)'), '\144' + chr(0b11 + 0o142) + chr(0b1100011) + chr(111) + chr(8297 - 8197) + chr(4504 - 4403))(chr(0b11110 + 0o127) + chr(0b1001011 + 0o51) + chr(5652 - 5550) + '\055' + chr(0b111000)): xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'z#O\x86\xec!\xb4\x8dE\xb2\xfa\x07\x90\xc5?\xc6'), '\x64' + chr(0b1100101) + chr(99) + chr(0b1101111) + chr(100) + chr(0b1100101))(chr(9540 - 9423) + chr(11522 - 11406) + chr(2780 - 2678) + chr(1655 - 1610) + '\070')), xafqLlk3kkUe(SXOLrMavuUCe(b'G5T\x9d\xc6(\xa0\xbdB\xbf\xc6\x18\x90\xd0>\xca\x98\xb8'), chr(7179 - 7079) + chr(0b1100100 + 0o1) + chr(99) + chr(0b1101111) + chr(0b1100100) + chr(0b1001101 + 0o30))(chr(117) + chr(116) + '\146' + chr(45) + '\070'): xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'G5T\x9d\xc6(\xa0\xbdB\xbf\xc6\x18\x90\xd0>\xca\x98\xb8'), chr(0b111010 + 0o52) + chr(0b1100101) + chr(99) + '\x6f' + '\x64' + '\x65')(chr(0b1110101) + chr(116) + '\x66' + '\055' + chr(1913 - 1857))), xafqLlk3kkUe(SXOLrMavuUCe(b'@ H\x8a\xf1\x12\xbe\xa7L\xb5\xfc\x07'), chr(0b1 + 0o143) + '\145' + chr(982 - 883) + chr(0b1101111) + '\144' + chr(2406 - 2305))('\x75' + chr(13047 - 12931) + chr(0b1100110) + chr(363 - 318) + chr(56)): xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\\(\x1e\x8e\xa8\x0e\x89\xb6V\x99\xeb,'), '\x64' + chr(9403 - 9302) + chr(0b1100010 + 0o1) + chr(0b1101111) + chr(100) + chr(7285 - 7184))(chr(0b1001001 + 0o54) + '\164' + chr(0b100 + 0o142) + '\x2d' + '\070')), xafqLlk3kkUe(SXOLrMavuUCe(b'G5T\x9d\xc6(\xa0\xbdB\xbf'), '\144' + '\x65' + '\143' + chr(4667 - 4556) + '\144' + chr(3005 - 2904))(chr(0b1110101) + chr(0b1110100) + chr(0b100000 + 0o106) + '\055' + '\070'): xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'l\x0f\x13\x85\xf7+\xe2\xb7U\xa2\xcf\x1e'), chr(0b1100100) + chr(101) + chr(99) + chr(2475 - 2364) + '\x64' + chr(0b1010011 + 0o22))('\x75' + chr(7421 - 7305) + chr(0b101 + 0o141) + chr(0b101101) + chr(974 - 918)))}
allenai/allennlp
allennlp/training/metric_tracker.py
MetricTracker.add_metric
def add_metric(self, metric: float) -> None: """ Record a new value of the metric and update the various things that depend on it. """ new_best = ((self._best_so_far is None) or (self._should_decrease and metric < self._best_so_far) or (not self._should_decrease and metric > self._best_so_far)) if new_best: self.best_epoch = self._epoch_number self._is_best_so_far = True self._best_so_far = metric self._epochs_with_no_improvement = 0 else: self._is_best_so_far = False self._epochs_with_no_improvement += 1 self._epoch_number += 1
python
def add_metric(self, metric: float) -> None: """ Record a new value of the metric and update the various things that depend on it. """ new_best = ((self._best_so_far is None) or (self._should_decrease and metric < self._best_so_far) or (not self._should_decrease and metric > self._best_so_far)) if new_best: self.best_epoch = self._epoch_number self._is_best_so_far = True self._best_so_far = metric self._epochs_with_no_improvement = 0 else: self._is_best_so_far = False self._epochs_with_no_improvement += 1 self._epoch_number += 1
[ "def", "add_metric", "(", "self", ",", "metric", ":", "float", ")", "->", "None", ":", "new_best", "=", "(", "(", "self", ".", "_best_so_far", "is", "None", ")", "or", "(", "self", ".", "_should_decrease", "and", "metric", "<", "self", ".", "_best_so_far", ")", "or", "(", "not", "self", ".", "_should_decrease", "and", "metric", ">", "self", ".", "_best_so_far", ")", ")", "if", "new_best", ":", "self", ".", "best_epoch", "=", "self", ".", "_epoch_number", "self", ".", "_is_best_so_far", "=", "True", "self", ".", "_best_so_far", "=", "metric", "self", ".", "_epochs_with_no_improvement", "=", "0", "else", ":", "self", ".", "_is_best_so_far", "=", "False", "self", ".", "_epochs_with_no_improvement", "+=", "1", "self", ".", "_epoch_number", "+=", "1" ]
Record a new value of the metric and update the various things that depend on it.
[ "Record", "a", "new", "value", "of", "the", "metric", "and", "update", "the", "various", "things", "that", "depend", "on", "it", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/training/metric_tracker.py#L97-L113
train
Add a metric to the log.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTst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tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\157' + '\x31' + chr(55) + chr(1713 - 1662), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(50), 8065 - 8057), ehT0Px3KOsy9('\x30' + chr(111) + chr(2026 - 1975) + chr(0b110010 + 0o4), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1881 - 1830) + chr(0b110001) + '\x36', 31233 - 31225), ehT0Px3KOsy9('\060' + chr(111) + chr(0b101000 + 0o12) + chr(0b101110 + 0o11) + chr(52), 0b1000), ehT0Px3KOsy9(chr(202 - 154) + chr(111) + chr(1119 - 1068) + '\067' + chr(0b110010 + 0o2), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(582 - 533) + '\x37' + '\x31', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + chr(0b100111 + 0o11) + chr(686 - 632), 0b1000), ehT0Px3KOsy9(chr(48) + chr(7827 - 7716) + chr(54) + chr(55), 0o10), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(111) + '\063' + chr(53) + chr(0b1001 + 0o55), 20050 - 20042), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1110 + 0o47), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1000101 + 0o52) + chr(54) + chr(0b110111), 8), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11011 + 0o26) + '\066', 0b1000), ehT0Px3KOsy9(chr(1515 - 1467) + '\157' + '\x32' + chr(0b110001) + chr(0b101001 + 0o10), 26647 - 26639), ehT0Px3KOsy9('\x30' + '\157' + chr(832 - 779) + chr(0b11110 + 0o27), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b10000 + 0o41) + chr(0b110110) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(2017 - 1969) + chr(111) + chr(436 - 387) + '\x33', 0o10), ehT0Px3KOsy9(chr(2086 - 2038) + chr(111) + chr(373 - 323) + chr(0b1011 + 0o45) + chr(0b110111), 6124 - 6116), ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\x6f' + '\x32' + '\x31' + chr(0b11101 + 0o24), 8), ehT0Px3KOsy9('\060' + '\157' + chr(189 - 139) + chr(51) + chr(53), 62915 - 62907), ehT0Px3KOsy9(chr(48) + chr(0b111111 + 0o60) + chr(49) + '\063' + chr(55), 38342 - 38334), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(55) + '\x32', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(51) + '\062' + chr(0b110101), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(52) + chr(0b110111), 47027 - 47019), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(0b1101111) + '\x33' + chr(0b110101) + '\060', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b11110 + 0o23) + chr(643 - 592) + chr(1740 - 1690), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1100101 + 0o12) + '\x32' + chr(49) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(2281 - 2230) + chr(0b110111) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(1520 - 1472) + '\x6f' + '\x31' + '\x32' + chr(52), 0b1000), ehT0Px3KOsy9(chr(48) + chr(3250 - 3139) + chr(2429 - 2378) + chr(0b110001) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\060' + chr(9561 - 9450) + chr(0b10111 + 0o34) + chr(0b110001) + chr(2026 - 1975), 43359 - 43351), ehT0Px3KOsy9('\060' + chr(0b110110 + 0o71) + '\x33' + chr(0b110011) + chr(52), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110001) + chr(0b100010 + 0o25) + '\x36', 0b1000), ehT0Px3KOsy9('\060' + chr(9065 - 8954) + chr(0b1001 + 0o50) + chr(0b110000) + chr(0b110111), 18648 - 18640), ehT0Px3KOsy9('\x30' + chr(5696 - 5585) + '\061' + chr(0b1111 + 0o46) + chr(2350 - 2300), ord("\x08")), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(0b1011010 + 0o25) + '\x32' + '\x34' + chr(1649 - 1596), 16749 - 16741), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + chr(0b10110 + 0o32) + chr(49), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(55) + chr(0b10111 + 0o31), 0b1000), ehT0Px3KOsy9('\060' + chr(0b10111 + 0o130) + chr(50) + '\061' + chr(0b11 + 0o56), 8), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + chr(0b110101) + chr(53), 62160 - 62152)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100100 + 0o21) + chr(0b1101 + 0o43), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'U'), chr(0b11001 + 0o113) + '\145' + chr(0b1100011) + '\x6f' + '\144' + chr(0b1100101))(chr(0b10010 + 0o143) + '\x74' + chr(9871 - 9769) + chr(45) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def YRz3NI0JRC6A(oVre8I6UXc3b, UyTbk4dY9zDl) -> None: brWY6Y1_VLX5 = oVre8I6UXc3b.QiARneucrBZg is None or (oVre8I6UXc3b._should_decrease and UyTbk4dY9zDl < oVre8I6UXc3b.QiARneucrBZg) or (not oVre8I6UXc3b._should_decrease and UyTbk4dY9zDl > oVre8I6UXc3b.QiARneucrBZg) if brWY6Y1_VLX5: oVre8I6UXc3b.I_4lnf2etuVk = oVre8I6UXc3b.yx9g1CYdwNrY oVre8I6UXc3b.H97Yioie4lux = ehT0Px3KOsy9(chr(1944 - 1896) + '\x6f' + chr(244 - 195), ord("\x08")) oVre8I6UXc3b.QiARneucrBZg = UyTbk4dY9zDl oVre8I6UXc3b.TtcyHFs_OmbD = ehT0Px3KOsy9('\x30' + chr(3139 - 3028) + chr(48), 0b1000) else: oVre8I6UXc3b.H97Yioie4lux = ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(2130 - 2082), 8) oVre8I6UXc3b.TtcyHFs_OmbD += ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(1763 - 1714), 8) oVre8I6UXc3b.yx9g1CYdwNrY += ehT0Px3KOsy9(chr(48) + chr(7137 - 7026) + '\x31', 8)
allenai/allennlp
allennlp/training/metric_tracker.py
MetricTracker.add_metrics
def add_metrics(self, metrics: Iterable[float]) -> None: """ Helper to add multiple metrics at once. """ for metric in metrics: self.add_metric(metric)
python
def add_metrics(self, metrics: Iterable[float]) -> None: """ Helper to add multiple metrics at once. """ for metric in metrics: self.add_metric(metric)
[ "def", "add_metrics", "(", "self", ",", "metrics", ":", "Iterable", "[", "float", "]", ")", "->", "None", ":", "for", "metric", "in", "metrics", ":", "self", ".", "add_metric", "(", "metric", ")" ]
Helper to add multiple metrics at once.
[ "Helper", "to", "add", "multiple", "metrics", "at", "once", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/training/metric_t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eSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1547 - 1499) + chr(0b1001110 + 0o41) + chr(0b101000 + 0o12) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + chr(0b100100 + 0o20), 21230 - 21222), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b10111 + 0o130) + chr(0b10011 + 0o40) + chr(0b110110), 41345 - 41337), ehT0Px3KOsy9(chr(0b110000) + chr(238 - 127) + chr(0b110100) + chr(0b11110 + 0o31), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110 + 0o54) + chr(469 - 415) + chr(0b110001), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(2320 - 2271) + '\x35' + chr(48), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\062' + chr(735 - 683) + chr(602 - 554), 0b1000), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(111) + chr(1815 - 1766) + chr(0b110010 + 0o3) + chr(0b100001 + 0o22), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b11011 + 0o30) + '\x33' + '\x37', 0b1000), ehT0Px3KOsy9(chr(2129 - 2081) + chr(0b1101111) + chr(1392 - 1343) + chr(2254 - 2203) + chr(1132 - 1078), 0o10), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b1101111) + chr(0b110101 + 0o2) + '\x35', 0o10), ehT0Px3KOsy9('\060' + chr(3451 - 3340) + chr(0b110001) + chr(0b101101 + 0o10) + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(111) + chr(0b100100 + 0o15) + chr(648 - 595) + chr(52), 63950 - 63942), ehT0Px3KOsy9(chr(0b10111 + 0o31) + '\x6f' + chr(0b110001) + chr(0b110001) + chr(54), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110011) + '\x32' + '\063', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1865 - 1816) + chr(1432 - 1383) + chr(328 - 275), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x33' + chr(0b110101) + chr(2284 - 2233), ord("\x08")), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(0b1101100 + 0o3) + '\062' + chr(0b101 + 0o62) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b111011 + 0o64) + chr(0b101011 + 0o7) + '\064' + chr(0b110010), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(51) + chr(0b110001) + chr(2530 - 2477), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x33' + chr(710 - 662) + chr(396 - 344), 40587 - 40579), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(111) + '\063' + chr(0b110001) + chr(465 - 410), 0b1000), ehT0Px3KOsy9(chr(0b101010 + 0o6) + '\157' + '\x32' + chr(53) + chr(53), 12050 - 12042), ehT0Px3KOsy9('\060' + chr(111) + '\061' + chr(2748 - 2693) + chr(0b100101 + 0o14), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b110011) + chr(49) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(11302 - 11191) + '\x33' + chr(0b110101) + '\066', 8518 - 8510), ehT0Px3KOsy9(chr(1570 - 1522) + chr(0b1101111) + '\062' + chr(0b10011 + 0o44) + '\062', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(49) + chr(0b101001 + 0o10) + chr(123 - 75), 0o10), ehT0Px3KOsy9(chr(170 - 122) + '\x6f' + '\063' + '\065' + '\060', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(51) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(0b1000111 + 0o50) + '\x37' + chr(1540 - 1491), 764 - 756), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\157' + '\063' + chr(0b110101) + chr(0b110001), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(50) + chr(0b100001 + 0o22) + chr(49), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(1491 - 1442) + chr(54) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + '\064' + chr(0b110011), 41434 - 41426), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + '\x32' + chr(0b10001 + 0o45), 15140 - 15132), ehT0Px3KOsy9(chr(1381 - 1333) + '\x6f' + '\x33', 0o10), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(0b1101111) + chr(2340 - 2290) + chr(264 - 212) + chr(55), 39926 - 39918), ehT0Px3KOsy9(chr(880 - 832) + '\x6f' + chr(0b100101 + 0o16) + chr(2959 - 2904) + '\x32', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(9865 - 9754) + chr(0b1010 + 0o47) + chr(54) + '\x31', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(5414 - 5303) + '\x35' + chr(0b1100 + 0o44), 60419 - 60411)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'>'), chr(0b1100100) + chr(5061 - 4960) + chr(99) + chr(3774 - 3663) + chr(100) + '\x65')(chr(117) + chr(0b100011 + 0o121) + chr(0b10110 + 0o120) + chr(45) + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def UXmrFBK0LJxG(oVre8I6UXc3b, yYegMqDoSfs5) -> None: for UyTbk4dY9zDl in yYegMqDoSfs5: xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'qpzx\xdc\r\xd4\x19\xb6='), '\144' + '\145' + chr(0b1100011) + chr(2608 - 2497) + chr(0b1100100) + '\x65')('\165' + chr(10251 - 10135) + chr(102) + '\x2d' + '\x38'))(UyTbk4dY9zDl)
allenai/allennlp
allennlp/training/metric_tracker.py
MetricTracker.should_stop_early
def should_stop_early(self) -> bool: """ Returns true if improvement has stopped for long enough. """ if self._patience is None: return False else: return self._epochs_with_no_improvement >= self._patience
python
def should_stop_early(self) -> bool: """ Returns true if improvement has stopped for long enough. """ if self._patience is None: return False else: return self._epochs_with_no_improvement >= self._patience
[ "def", "should_stop_early", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "_patience", "is", "None", ":", "return", "False", "else", ":", "return", "self", ".", "_epochs_with_no_improvement", ">=", "self", ".", "_patience" ]
Returns true if improvement has stopped for long enough.
[ "Returns", "true", "if", "improvement", "has", "stopped", "for", "long", "enough", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/training/metric_tracker.py#L128-L135
train
Returns true if improvement has stopped for long enough.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0Z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KPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(384 - 336) + chr(0b1101111) + '\x31' + chr(0b101010 + 0o11) + '\066', 50233 - 50225), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b10011 + 0o37) + chr(2787 - 2732) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x33' + '\x37' + chr(2214 - 2160), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + '\x32' + chr(0b110100), 9287 - 9279), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110011) + chr(51) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(4742 - 4631) + chr(49) + chr(49) + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(111) + chr(0b110011) + chr(1323 - 1273) + chr(0b11111 + 0o23), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + chr(51), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + '\x34' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(9838 - 9727) + chr(1197 - 1146) + '\x34' + chr(994 - 943), ord("\x08")), ehT0Px3KOsy9(chr(0b111 + 0o51) + '\157' + chr(50) + '\062' + chr(415 - 360), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(8742 - 8631) + chr(49) + chr(0b100110 + 0o20) + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(0b10001 + 0o136) + chr(0b1 + 0o60) + '\x34' + '\067', 24821 - 24813), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(0b1010100 + 0o33) + chr(603 - 552) + chr(52) + '\x36', 20068 - 20060), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(3128 - 3017) + chr(0b11100 + 0o25) + '\x31' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + chr(0b10011 + 0o41) + chr(0b100111 + 0o14), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(245 - 193) + '\063', 0b1000), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b1010001 + 0o36) + chr(0b110001) + chr(0b110000 + 0o0) + chr(53), 40563 - 40555), ehT0Px3KOsy9(chr(48) + chr(915 - 804) + chr(1263 - 1212) + '\060' + chr(0b110100), 30336 - 30328), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(2310 - 2260) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(1298 - 1250) + chr(0b1101111) + '\x36', 0b1000), ehT0Px3KOsy9(chr(1131 - 1083) + '\157' + chr(0b11100 + 0o32) + chr(671 - 621), 16314 - 16306), ehT0Px3KOsy9(chr(656 - 608) + chr(0b1101111) + chr(0b110011) + chr(1129 - 1079), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + chr(1291 - 1236), 35027 - 35019), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b1101111) + chr(69 - 20) + chr(0b11100 + 0o26) + chr(1865 - 1812), 0o10), ehT0Px3KOsy9(chr(194 - 146) + '\x6f' + chr(1839 - 1788) + chr(1964 - 1910) + chr(0b1001 + 0o53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(52) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b101 + 0o152) + chr(0b110011) + chr(0b110101) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(974 - 926) + chr(0b1011110 + 0o21) + chr(961 - 911) + '\x30', 0o10), ehT0Px3KOsy9('\060' + '\157' + '\063' + '\065' + chr(2510 - 2456), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(1009 - 960), 56996 - 56988), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(3016 - 2905) + chr(50) + '\060' + chr(1861 - 1807), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(53) + chr(0b11010 + 0o35), 0o10), ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\x6f' + chr(0b110010) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b110110 + 0o71) + chr(1571 - 1521) + '\x37' + chr(598 - 544), 31157 - 31149), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2392 - 2342) + chr(0b110101) + chr(2034 - 1984), 19423 - 19415), ehT0Px3KOsy9(chr(581 - 533) + chr(6405 - 6294) + chr(50) + chr(1492 - 1442) + chr(0b110110), 48719 - 48711), ehT0Px3KOsy9('\x30' + chr(1074 - 963) + chr(55) + chr(0b1011 + 0o46), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(495 - 384) + '\x33' + '\067' + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(8073 - 7962) + chr(709 - 660) + '\065' + chr(51), 38516 - 38508)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(111) + chr(53) + chr(0b101000 + 0o10), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'p'), '\x64' + '\x65' + chr(8112 - 8013) + '\157' + chr(0b1100100) + '\x65')(chr(0b1110101) + '\x74' + '\146' + chr(206 - 161) + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def WHG4fBdnBbgV(oVre8I6UXc3b) -> WbBjf8Y7v9VN: if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x01\xcb\x9f\xe0\xb2/\xbcp\x00'), chr(0b1001111 + 0o25) + '\x65' + '\143' + chr(0b1101111) + chr(100) + chr(9938 - 9837))(chr(0b1110101) + chr(2769 - 2653) + chr(0b1100110) + chr(0b11 + 0o52) + '\070')) is None: return ehT0Px3KOsy9(chr(2187 - 2139) + chr(111) + chr(0b110000), 0o10) else: return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\n\xcf\x9d\xed\x93\x0c\xa1L*\x8e\xf57'), '\x64' + chr(4655 - 4554) + chr(0b1011001 + 0o12) + chr(0b1101111) + chr(0b101111 + 0o65) + chr(2354 - 2253))(chr(117) + chr(9341 - 9225) + chr(0b1100110) + chr(0b101101) + chr(56))) >= xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x01\xcb\x9f\xe0\xb2/\xbcp\x00'), '\x64' + chr(9674 - 9573) + chr(99) + '\157' + chr(100) + '\145')('\165' + chr(0b1110011 + 0o1) + '\x66' + '\055' + chr(0b10110 + 0o42)))
allenai/allennlp
allennlp/models/archival.py
archive_model
def archive_model(serialization_dir: str, weights: str = _DEFAULT_WEIGHTS, files_to_archive: Dict[str, str] = None, archive_path: str = None) -> None: """ Archive the model weights, its training configuration, and its vocabulary to `model.tar.gz`. Include the additional ``files_to_archive`` if provided. Parameters ---------- serialization_dir: ``str`` The directory where the weights and vocabulary are written out. weights: ``str``, optional (default=_DEFAULT_WEIGHTS) Which weights file to include in the archive. The default is ``best.th``. files_to_archive: ``Dict[str, str]``, optional (default=None) A mapping {flattened_key -> filename} of supplementary files to include in the archive. That is, if you wanted to include ``params['model']['weights']`` then you would specify the key as `"model.weights"`. archive_path : ``str``, optional, (default = None) A full path to serialize the model to. The default is "model.tar.gz" inside the serialization_dir. If you pass a directory here, we'll serialize the model to "model.tar.gz" inside the directory. """ weights_file = os.path.join(serialization_dir, weights) if not os.path.exists(weights_file): logger.error("weights file %s does not exist, unable to archive model", weights_file) return config_file = os.path.join(serialization_dir, CONFIG_NAME) if not os.path.exists(config_file): logger.error("config file %s does not exist, unable to archive model", config_file) # If there are files we want to archive, write out the mapping # so that we can use it during de-archiving. if files_to_archive: fta_filename = os.path.join(serialization_dir, _FTA_NAME) with open(fta_filename, 'w') as fta_file: fta_file.write(json.dumps(files_to_archive)) if archive_path is not None: archive_file = archive_path if os.path.isdir(archive_file): archive_file = os.path.join(archive_file, "model.tar.gz") else: archive_file = os.path.join(serialization_dir, "model.tar.gz") logger.info("archiving weights and vocabulary to %s", archive_file) with tarfile.open(archive_file, 'w:gz') as archive: archive.add(config_file, arcname=CONFIG_NAME) archive.add(weights_file, arcname=_WEIGHTS_NAME) archive.add(os.path.join(serialization_dir, "vocabulary"), arcname="vocabulary") # If there are supplemental files to archive: if files_to_archive: # Archive the { flattened_key -> original_filename } mapping. archive.add(fta_filename, arcname=_FTA_NAME) # And add each requested file to the archive. for key, filename in files_to_archive.items(): archive.add(filename, arcname=f"fta/{key}")
python
def archive_model(serialization_dir: str, weights: str = _DEFAULT_WEIGHTS, files_to_archive: Dict[str, str] = None, archive_path: str = None) -> None: """ Archive the model weights, its training configuration, and its vocabulary to `model.tar.gz`. Include the additional ``files_to_archive`` if provided. Parameters ---------- serialization_dir: ``str`` The directory where the weights and vocabulary are written out. weights: ``str``, optional (default=_DEFAULT_WEIGHTS) Which weights file to include in the archive. The default is ``best.th``. files_to_archive: ``Dict[str, str]``, optional (default=None) A mapping {flattened_key -> filename} of supplementary files to include in the archive. That is, if you wanted to include ``params['model']['weights']`` then you would specify the key as `"model.weights"`. archive_path : ``str``, optional, (default = None) A full path to serialize the model to. The default is "model.tar.gz" inside the serialization_dir. If you pass a directory here, we'll serialize the model to "model.tar.gz" inside the directory. """ weights_file = os.path.join(serialization_dir, weights) if not os.path.exists(weights_file): logger.error("weights file %s does not exist, unable to archive model", weights_file) return config_file = os.path.join(serialization_dir, CONFIG_NAME) if not os.path.exists(config_file): logger.error("config file %s does not exist, unable to archive model", config_file) # If there are files we want to archive, write out the mapping # so that we can use it during de-archiving. if files_to_archive: fta_filename = os.path.join(serialization_dir, _FTA_NAME) with open(fta_filename, 'w') as fta_file: fta_file.write(json.dumps(files_to_archive)) if archive_path is not None: archive_file = archive_path if os.path.isdir(archive_file): archive_file = os.path.join(archive_file, "model.tar.gz") else: archive_file = os.path.join(serialization_dir, "model.tar.gz") logger.info("archiving weights and vocabulary to %s", archive_file) with tarfile.open(archive_file, 'w:gz') as archive: archive.add(config_file, arcname=CONFIG_NAME) archive.add(weights_file, arcname=_WEIGHTS_NAME) archive.add(os.path.join(serialization_dir, "vocabulary"), arcname="vocabulary") # If there are supplemental files to archive: if files_to_archive: # Archive the { flattened_key -> original_filename } mapping. archive.add(fta_filename, arcname=_FTA_NAME) # And add each requested file to the archive. for key, filename in files_to_archive.items(): archive.add(filename, arcname=f"fta/{key}")
[ "def", "archive_model", "(", "serialization_dir", ":", "str", ",", "weights", ":", "str", "=", "_DEFAULT_WEIGHTS", ",", "files_to_archive", ":", "Dict", "[", "str", ",", "str", "]", "=", "None", ",", "archive_path", ":", "str", "=", "None", ")", "->", "None", ":", "weights_file", "=", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "weights", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "weights_file", ")", ":", "logger", ".", "error", "(", "\"weights file %s does not exist, unable to archive model\"", ",", "weights_file", ")", "return", "config_file", "=", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "CONFIG_NAME", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "config_file", ")", ":", "logger", ".", "error", "(", "\"config file %s does not exist, unable to archive model\"", ",", "config_file", ")", "# If there are files we want to archive, write out the mapping", "# so that we can use it during de-archiving.", "if", "files_to_archive", ":", "fta_filename", "=", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "_FTA_NAME", ")", "with", "open", "(", "fta_filename", ",", "'w'", ")", "as", "fta_file", ":", "fta_file", ".", "write", "(", "json", ".", "dumps", "(", "files_to_archive", ")", ")", "if", "archive_path", "is", "not", "None", ":", "archive_file", "=", "archive_path", "if", "os", ".", "path", ".", "isdir", "(", "archive_file", ")", ":", "archive_file", "=", "os", ".", "path", ".", "join", "(", "archive_file", ",", "\"model.tar.gz\"", ")", "else", ":", "archive_file", "=", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "\"model.tar.gz\"", ")", "logger", ".", "info", "(", "\"archiving weights and vocabulary to %s\"", ",", "archive_file", ")", "with", "tarfile", ".", "open", "(", "archive_file", ",", "'w:gz'", ")", "as", "archive", ":", "archive", ".", "add", "(", "config_file", ",", "arcname", "=", "CONFIG_NAME", ")", "archive", ".", "add", "(", "weights_file", ",", "arcname", "=", "_WEIGHTS_NAME", ")", "archive", ".", "add", "(", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "\"vocabulary\"", ")", ",", "arcname", "=", "\"vocabulary\"", ")", "# If there are supplemental files to archive:", "if", "files_to_archive", ":", "# Archive the { flattened_key -> original_filename } mapping.", "archive", ".", "add", "(", "fta_filename", ",", "arcname", "=", "_FTA_NAME", ")", "# And add each requested file to the archive.", "for", "key", ",", "filename", "in", "files_to_archive", ".", "items", "(", ")", ":", "archive", ".", "add", "(", "filename", ",", "arcname", "=", "f\"fta/{key}\"", ")" ]
Archive the model weights, its training configuration, and its vocabulary to `model.tar.gz`. Include the additional ``files_to_archive`` if provided. Parameters ---------- serialization_dir: ``str`` The directory where the weights and vocabulary are written out. weights: ``str``, optional (default=_DEFAULT_WEIGHTS) Which weights file to include in the archive. The default is ``best.th``. files_to_archive: ``Dict[str, str]``, optional (default=None) A mapping {flattened_key -> filename} of supplementary files to include in the archive. That is, if you wanted to include ``params['model']['weights']`` then you would specify the key as `"model.weights"`. archive_path : ``str``, optional, (default = None) A full path to serialize the model to. The default is "model.tar.gz" inside the serialization_dir. If you pass a directory here, we'll serialize the model to "model.tar.gz" inside the directory.
[ "Archive", "the", "model", "weights", "its", "training", "configuration", "and", "its", "vocabulary", "to", "model", ".", "tar", ".", "gz", ".", "Include", "the", "additional", "files_to_archive", "if", "provided", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/archival.py#L89-L148
train
Archive the model with the given weights and vocabulary.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXI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mUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\157' + '\061' + '\x35' + chr(52), 0b1000), ehT0Px3KOsy9(chr(1862 - 1814) + '\x6f' + '\x37' + chr(54), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1100001 + 0o16) + chr(50) + chr(0b110010) + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1110 + 0o141) + chr(55) + '\065', 61143 - 61135), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + chr(2360 - 2306) + '\065', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(50) + chr(48) + chr(0b110001), 49566 - 49558), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b1010 + 0o47) + chr(0b101 + 0o62), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110000 + 0o2) + chr(54) + '\x34', 27030 - 27022), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x33' + chr(0b10101 + 0o35) + '\063', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + chr(0b110111 + 0o0) + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b10100 + 0o36), 274 - 266), ehT0Px3KOsy9(chr(716 - 668) + '\157' + chr(0b101101 + 0o3), 65505 - 65497), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + chr(1818 - 1764) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\x37' + '\x33', 0o10), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(0b1101111) + chr(0b11101 + 0o25) + chr(0b110011) + '\066', 11193 - 11185), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(1839 - 1787) + chr(0b1111 + 0o46), ord("\x08")), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\x6f' + chr(0b10110 + 0o33) + chr(0b110 + 0o61) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b10001 + 0o41) + chr(54) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\067' + chr(55), 34694 - 34686), ehT0Px3KOsy9('\060' + '\157' + '\062' + '\061', 2037 - 2029), ehT0Px3KOsy9(chr(48) + chr(4581 - 4470) + '\065' + '\x32', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110000 + 0o1) + '\060' + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(50) + '\062' + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(787 - 739) + chr(1305 - 1194) + chr(2548 - 2494) + chr(50), 21410 - 21402), ehT0Px3KOsy9(chr(0b110000) + chr(1073 - 962) + '\x33' + chr(923 - 869) + chr(0b101110 + 0o6), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(11619 - 11508) + '\063' + '\x34' + '\067', 62918 - 62910), ehT0Px3KOsy9(chr(48) + chr(8558 - 8447) + '\063' + chr(2623 - 2568) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(55) + '\x34', 7750 - 7742), ehT0Px3KOsy9('\060' + chr(1748 - 1637) + '\063' + chr(0b100001 + 0o17), 29068 - 29060), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(0b110001) + chr(1703 - 1651), 0o10), ehT0Px3KOsy9(chr(1263 - 1215) + chr(7039 - 6928) + chr(0b0 + 0o63) + chr(0b0 + 0o61) + '\062', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(50) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(584 - 536) + '\x6f' + chr(0b110001) + chr(0b10010 + 0o45), 8), ehT0Px3KOsy9('\060' + chr(111) + chr(49) + chr(0b101010 + 0o10) + chr(180 - 132), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(6991 - 6880) + '\063' + chr(0b110001) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1001 + 0o146) + '\063' + chr(543 - 490) + '\060', 15493 - 15485), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(51) + chr(0b110001) + '\x30', 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1199 - 1144) + chr(0b110110), 8), ehT0Px3KOsy9('\x30' + chr(4160 - 4049) + chr(50) + chr(49) + chr(1981 - 1931), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b101101 + 0o5) + chr(0b101011 + 0o10) + chr(0b110100), 38404 - 38396)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110101) + chr(0b11100 + 0o24), 47174 - 47166)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'B'), chr(0b1100100) + '\145' + chr(0b1100011) + chr(111) + '\x64' + chr(0b1010 + 0o133))(chr(117) + '\x74' + chr(0b1100110) + chr(706 - 661) + chr(2425 - 2369)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def vKkKJlh0Qz4u(_NgEteHO5j9h, ZurHTci57aXw=sp8w6lUArCJR, pc43UazYMoMT=None, UHbEU_uzoL4X=None) -> None: lB0dvsL5cSLR = oqhJDdMJfuwx.path._oWXztVNnqHF(_NgEteHO5j9h, ZurHTci57aXw) if not xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\tF\xfeN\x01\xf2'), chr(0b10110 + 0o116) + chr(6366 - 6265) + chr(99) + '\x6f' + '\x64' + '\145')(chr(6620 - 6503) + chr(116) + '\x66' + chr(45) + chr(56)))(lB0dvsL5cSLR): xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b')k\xf3m\x14\xf5@\xe7\xe2\xccz0'), '\x64' + chr(0b1100101) + chr(99) + chr(0b1101111) + chr(3824 - 3724) + chr(101))('\165' + chr(0b1110100) + chr(0b1100110) + '\x2d' + chr(0b110111 + 0o1)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\x1b[\xfeZ\x1d\xf5|\x94\xb5\xd2ne\x95\x1e\xed\xc5\x1e\xd8Zb\n.\xfbF\xd4\x82\x86Uk\xf8\xe62z>\xa9\x8a\xa4[\xaa\xe8\x03\x1e\xf6O\x16\xe9f\xc2\xb6\x9boo\xd1^\xf2'), chr(0b1100100) + chr(5812 - 5711) + chr(5221 - 5122) + chr(0b10011 + 0o134) + '\x64' + chr(4365 - 4264))('\165' + chr(116) + chr(0b101010 + 0o74) + chr(0b11001 + 0o24) + chr(1061 - 1005)), lB0dvsL5cSLR) return umYO37c7rPBE = oqhJDdMJfuwx.path._oWXztVNnqHF(_NgEteHO5j9h, aalLhedSsWYM) if not xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\tF\xfeN\x01\xf2'), chr(7602 - 7502) + chr(9945 - 9844) + chr(0b10000 + 0o123) + '\157' + '\x64' + chr(5172 - 5071))(chr(725 - 608) + '\164' + chr(0b101000 + 0o76) + chr(0b101101) + chr(2085 - 2029)))(umYO37c7rPBE): xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b')k\xf3m\x14\xf5@\xe7\xe2\xccz0'), chr(0b1100100) + '\145' + chr(0b1011001 + 0o12) + '\157' + chr(100) + '\x65')(chr(117) + chr(116) + chr(5002 - 4900) + chr(45) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\x0fQ\xf9[\x1c\xe6/\xd2\xba\xd7g \x90H\xbe\x81\x15\xd2L1D/\xe0\x12\x91\x9f\x97Ol\xa0\xeaga1\xaa\x84\xad\x1e\xfe\xf3L_\xe5^\x1d\xe8y\xd1\xf3\xd6md\xd0W'), chr(0b1100100) + chr(0b1001101 + 0o30) + chr(6750 - 6651) + '\157' + '\x64' + '\x65')(chr(0b1011101 + 0o30) + '\164' + chr(102) + chr(45) + chr(56)), umYO37c7rPBE) if pc43UazYMoMT: bRPt7rUs68CV = oqhJDdMJfuwx.path._oWXztVNnqHF(_NgEteHO5j9h, b2642X2KirPD) with _fwkIVCGgtAN(bRPt7rUs68CV, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1b'), chr(0b1100100) + chr(0b100111 + 0o76) + chr(0b1100011) + chr(111) + chr(0b1010100 + 0o20) + chr(101))('\x75' + '\164' + '\x66' + '\x2d' + chr(56))) as Eiy16Fz1Chlt: xafqLlk3kkUe(Eiy16Fz1Chlt, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1bL\xfeI\x10'), chr(100) + '\x65' + chr(0b1100011) + chr(0b10001 + 0o136) + chr(0b100010 + 0o102) + '\145')(chr(117) + chr(0b1110100) + chr(0b1100110) + chr(0b100110 + 0o7) + '\070'))(xafqLlk3kkUe(fXk443epxtd5, xafqLlk3kkUe(SXOLrMavuUCe(b'\x08K\xfaM\x06'), chr(100) + chr(0b1100101) + '\143' + chr(0b1101111) + chr(100) + '\x65')('\165' + '\164' + chr(102) + chr(1772 - 1727) + chr(0b111000)))(pc43UazYMoMT)) if UHbEU_uzoL4X is not None: dyP4gOEkYnfH = UHbEU_uzoL4X if xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\x05M\xf3T\x07'), '\144' + chr(0b10 + 0o143) + chr(99) + '\x6f' + chr(0b1011110 + 0o6) + chr(2971 - 2870))(chr(0b1110101) + chr(0b1101111 + 0o5) + chr(5819 - 5717) + '\x2d' + chr(56)))(dyP4gOEkYnfH): dyP4gOEkYnfH = oqhJDdMJfuwx.path._oWXztVNnqHF(dyP4gOEkYnfH, xafqLlk3kkUe(SXOLrMavuUCe(b'\x01Q\xf3X\x19\xaf{\xd5\xa1\x95ez'), chr(100) + chr(5492 - 5391) + '\143' + chr(7811 - 7700) + chr(100) + '\145')('\x75' + chr(7881 - 7765) + chr(4231 - 4129) + chr(0b101101) + chr(56))) else: dyP4gOEkYnfH = oqhJDdMJfuwx.path._oWXztVNnqHF(_NgEteHO5j9h, xafqLlk3kkUe(SXOLrMavuUCe(b'\x01Q\xf3X\x19\xaf{\xd5\xa1\x95ez'), chr(100) + '\145' + chr(0b111001 + 0o52) + '\x6f' + chr(0b11101 + 0o107) + chr(101))(chr(117) + chr(12353 - 12237) + chr(3512 - 3410) + chr(45) + chr(0b111000 + 0o0))) xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'?\t\xdfE\x00\xe2h\x83\xb9\xd7Xk'), '\144' + chr(0b1100101) + '\143' + '\x6f' + chr(6395 - 6295) + chr(0b1100101))('\x75' + '\164' + chr(0b1010001 + 0o25) + chr(45) + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\rL\xf4U\x1c\xf7f\xda\xb4\x9bue\xdc\\\xf6\x91\t\x97^\x7fN`\xe2]\x97\x86\x9cIt\xed\xb8k/$\xa7\xc8\xedM'), chr(0b11 + 0o141) + chr(0b1000111 + 0o36) + '\x63' + chr(10001 - 9890) + chr(0b1100100) + '\x65')('\165' + chr(0b1110100) + '\146' + chr(0b101101) + chr(0b111000)), dyP4gOEkYnfH) with xafqLlk3kkUe(RxqDt8LqC5Ns, xafqLlk3kkUe(SXOLrMavuUCe(b'\x03N\xf2S'), chr(0b101100 + 0o70) + '\145' + '\x63' + '\x6f' + '\144' + chr(101))(chr(0b1110101) + chr(9223 - 9107) + chr(2835 - 2733) + '\x2d' + '\070'))(dyP4gOEkYnfH, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1b\x04\xf0G'), chr(0b101111 + 0o65) + chr(7052 - 6951) + '\143' + chr(0b1101111) + chr(0b100001 + 0o103) + '\145')('\x75' + chr(0b111001 + 0o73) + '\x66' + '\055' + chr(906 - 850))) as PlsPgRbNZBi4: xafqLlk3kkUe(PlsPgRbNZBi4, xafqLlk3kkUe(SXOLrMavuUCe(b'\x19t\xa7LL\xe2H\x81\x89\xf4P3'), chr(0b1100100) + '\x65' + chr(2989 - 2890) + chr(7993 - 7882) + chr(0b1001 + 0o133) + chr(4959 - 4858))(chr(11684 - 11567) + chr(0b1110100) + '\x66' + '\055' + chr(0b110000 + 0o10)))(umYO37c7rPBE, arcname=aalLhedSsWYM) xafqLlk3kkUe(PlsPgRbNZBi4, xafqLlk3kkUe(SXOLrMavuUCe(b'\x19t\xa7LL\xe2H\x81\x89\xf4P3'), chr(0b10101 + 0o117) + chr(101) + '\x63' + chr(0b1101111) + '\144' + chr(0b101101 + 0o70))(chr(0b1110101) + chr(0b1001100 + 0o50) + chr(0b110110 + 0o60) + '\055' + chr(0b111000)))(lB0dvsL5cSLR, arcname=t1BBlehw5NCm) xafqLlk3kkUe(PlsPgRbNZBi4, xafqLlk3kkUe(SXOLrMavuUCe(b'\x19t\xa7LL\xe2H\x81\x89\xf4P3'), chr(4568 - 4468) + chr(0b1001111 + 0o26) + '\x63' + chr(0b1010100 + 0o33) + '\144' + chr(0b1100101))(chr(0b1110101) + chr(116) + chr(9665 - 9563) + chr(45) + '\070'))(xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'3Q\xc0e\x0f\xf5Y\xfa\xbd\xcaJF'), '\x64' + '\145' + chr(99) + '\157' + '\x64' + chr(0b10111 + 0o116))(chr(2762 - 2645) + chr(0b1110100) + chr(9512 - 9410) + '\055' + chr(0b100110 + 0o22)))(_NgEteHO5j9h, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1aQ\xf4\\\x17\xf4c\xd5\xa1\xc2'), chr(100) + chr(101) + chr(2243 - 2144) + chr(111) + chr(100) + chr(0b11110 + 0o107))('\165' + chr(0b11111 + 0o125) + '\146' + chr(857 - 812) + chr(56))), arcname=xafqLlk3kkUe(SXOLrMavuUCe(b'\x1aQ\xf4\\\x17\xf4c\xd5\xa1\xc2'), chr(100) + chr(101) + chr(99) + '\157' + chr(1397 - 1297) + chr(5419 - 5318))(chr(117) + chr(0b1110100) + chr(0b1100110) + chr(974 - 929) + chr(318 - 262))) if pc43UazYMoMT: xafqLlk3kkUe(PlsPgRbNZBi4, xafqLlk3kkUe(SXOLrMavuUCe(b'\x19t\xa7LL\xe2H\x81\x89\xf4P3'), '\x64' + chr(0b1100101) + '\x63' + chr(111) + chr(5736 - 5636) + '\145')(chr(0b1001001 + 0o54) + chr(9626 - 9510) + chr(102) + chr(0b10010 + 0o33) + '\070'))(bRPt7rUs68CV, arcname=b2642X2KirPD) for (K3J4ZwSlE0sT, xw4DsBfIJ22E) in xafqLlk3kkUe(pc43UazYMoMT, xafqLlk3kkUe(SXOLrMavuUCe(b'"D\xe1X<\xdb<\xfd\xbf\xe8J9'), chr(9539 - 9439) + chr(0b1100101) + chr(1557 - 1458) + chr(9811 - 9700) + '\144' + '\x65')(chr(0b1110101) + chr(116) + chr(0b10000 + 0o126) + '\055' + chr(56)))(): xafqLlk3kkUe(PlsPgRbNZBi4, xafqLlk3kkUe(SXOLrMavuUCe(b'\x19t\xa7LL\xe2H\x81\x89\xf4P3'), '\144' + chr(101) + chr(99) + '\157' + chr(9447 - 9347) + chr(0b1100101))(chr(0b11011 + 0o132) + chr(0b1110100) + chr(102) + '\x2d' + chr(1300 - 1244)))(xw4DsBfIJ22E, arcname=f'fta/{K3J4ZwSlE0sT}')
allenai/allennlp
allennlp/models/archival.py
load_archive
def load_archive(archive_file: str, cuda_device: int = -1, overrides: str = "", weights_file: str = None) -> Archive: """ Instantiates an Archive from an archived `tar.gz` file. Parameters ---------- archive_file: ``str`` The archive file to load the model from. weights_file: ``str``, optional (default = None) The weights file to use. If unspecified, weights.th in the archive_file will be used. cuda_device: ``int``, optional (default = -1) If `cuda_device` is >= 0, the model will be loaded onto the corresponding GPU. Otherwise it will be loaded onto the CPU. overrides: ``str``, optional (default = "") JSON overrides to apply to the unarchived ``Params`` object. """ # redirect to the cache, if necessary resolved_archive_file = cached_path(archive_file) if resolved_archive_file == archive_file: logger.info(f"loading archive file {archive_file}") else: logger.info(f"loading archive file {archive_file} from cache at {resolved_archive_file}") if os.path.isdir(resolved_archive_file): serialization_dir = resolved_archive_file else: # Extract archive to temp dir tempdir = tempfile.mkdtemp() logger.info(f"extracting archive file {resolved_archive_file} to temp dir {tempdir}") with tarfile.open(resolved_archive_file, 'r:gz') as archive: archive.extractall(tempdir) # Postpone cleanup until exit in case the unarchived contents are needed outside # this function. atexit.register(_cleanup_archive_dir, tempdir) serialization_dir = tempdir # Check for supplemental files in archive fta_filename = os.path.join(serialization_dir, _FTA_NAME) if os.path.exists(fta_filename): with open(fta_filename, 'r') as fta_file: files_to_archive = json.loads(fta_file.read()) # Add these replacements to overrides replacements_dict: Dict[str, Any] = {} for key, original_filename in files_to_archive.items(): replacement_filename = os.path.join(serialization_dir, f"fta/{key}") if os.path.exists(replacement_filename): replacements_dict[key] = replacement_filename else: logger.warning(f"Archived file {replacement_filename} not found! At train time " f"this file was located at {original_filename}. This may be " "because you are loading a serialization directory. Attempting to " "load the file from its train-time location.") overrides_dict = parse_overrides(overrides) combined_dict = with_fallback(preferred=overrides_dict, fallback=unflatten(replacements_dict)) overrides = json.dumps(combined_dict) # Load config config = Params.from_file(os.path.join(serialization_dir, CONFIG_NAME), overrides) config.loading_from_archive = True if weights_file: weights_path = weights_file else: weights_path = os.path.join(serialization_dir, _WEIGHTS_NAME) # Fallback for serialization directories. if not os.path.exists(weights_path): weights_path = os.path.join(serialization_dir, _DEFAULT_WEIGHTS) # Instantiate model. Use a duplicate of the config, as it will get consumed. model = Model.load(config.duplicate(), weights_file=weights_path, serialization_dir=serialization_dir, cuda_device=cuda_device) return Archive(model=model, config=config)
python
def load_archive(archive_file: str, cuda_device: int = -1, overrides: str = "", weights_file: str = None) -> Archive: """ Instantiates an Archive from an archived `tar.gz` file. Parameters ---------- archive_file: ``str`` The archive file to load the model from. weights_file: ``str``, optional (default = None) The weights file to use. If unspecified, weights.th in the archive_file will be used. cuda_device: ``int``, optional (default = -1) If `cuda_device` is >= 0, the model will be loaded onto the corresponding GPU. Otherwise it will be loaded onto the CPU. overrides: ``str``, optional (default = "") JSON overrides to apply to the unarchived ``Params`` object. """ # redirect to the cache, if necessary resolved_archive_file = cached_path(archive_file) if resolved_archive_file == archive_file: logger.info(f"loading archive file {archive_file}") else: logger.info(f"loading archive file {archive_file} from cache at {resolved_archive_file}") if os.path.isdir(resolved_archive_file): serialization_dir = resolved_archive_file else: # Extract archive to temp dir tempdir = tempfile.mkdtemp() logger.info(f"extracting archive file {resolved_archive_file} to temp dir {tempdir}") with tarfile.open(resolved_archive_file, 'r:gz') as archive: archive.extractall(tempdir) # Postpone cleanup until exit in case the unarchived contents are needed outside # this function. atexit.register(_cleanup_archive_dir, tempdir) serialization_dir = tempdir # Check for supplemental files in archive fta_filename = os.path.join(serialization_dir, _FTA_NAME) if os.path.exists(fta_filename): with open(fta_filename, 'r') as fta_file: files_to_archive = json.loads(fta_file.read()) # Add these replacements to overrides replacements_dict: Dict[str, Any] = {} for key, original_filename in files_to_archive.items(): replacement_filename = os.path.join(serialization_dir, f"fta/{key}") if os.path.exists(replacement_filename): replacements_dict[key] = replacement_filename else: logger.warning(f"Archived file {replacement_filename} not found! At train time " f"this file was located at {original_filename}. This may be " "because you are loading a serialization directory. Attempting to " "load the file from its train-time location.") overrides_dict = parse_overrides(overrides) combined_dict = with_fallback(preferred=overrides_dict, fallback=unflatten(replacements_dict)) overrides = json.dumps(combined_dict) # Load config config = Params.from_file(os.path.join(serialization_dir, CONFIG_NAME), overrides) config.loading_from_archive = True if weights_file: weights_path = weights_file else: weights_path = os.path.join(serialization_dir, _WEIGHTS_NAME) # Fallback for serialization directories. if not os.path.exists(weights_path): weights_path = os.path.join(serialization_dir, _DEFAULT_WEIGHTS) # Instantiate model. Use a duplicate of the config, as it will get consumed. model = Model.load(config.duplicate(), weights_file=weights_path, serialization_dir=serialization_dir, cuda_device=cuda_device) return Archive(model=model, config=config)
[ "def", "load_archive", "(", "archive_file", ":", "str", ",", "cuda_device", ":", "int", "=", "-", "1", ",", "overrides", ":", "str", "=", "\"\"", ",", "weights_file", ":", "str", "=", "None", ")", "->", "Archive", ":", "# redirect to the cache, if necessary", "resolved_archive_file", "=", "cached_path", "(", "archive_file", ")", "if", "resolved_archive_file", "==", "archive_file", ":", "logger", ".", "info", "(", "f\"loading archive file {archive_file}\"", ")", "else", ":", "logger", ".", "info", "(", "f\"loading archive file {archive_file} from cache at {resolved_archive_file}\"", ")", "if", "os", ".", "path", ".", "isdir", "(", "resolved_archive_file", ")", ":", "serialization_dir", "=", "resolved_archive_file", "else", ":", "# Extract archive to temp dir", "tempdir", "=", "tempfile", ".", "mkdtemp", "(", ")", "logger", ".", "info", "(", "f\"extracting archive file {resolved_archive_file} to temp dir {tempdir}\"", ")", "with", "tarfile", ".", "open", "(", "resolved_archive_file", ",", "'r:gz'", ")", "as", "archive", ":", "archive", ".", "extractall", "(", "tempdir", ")", "# Postpone cleanup until exit in case the unarchived contents are needed outside", "# this function.", "atexit", ".", "register", "(", "_cleanup_archive_dir", ",", "tempdir", ")", "serialization_dir", "=", "tempdir", "# Check for supplemental files in archive", "fta_filename", "=", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "_FTA_NAME", ")", "if", "os", ".", "path", ".", "exists", "(", "fta_filename", ")", ":", "with", "open", "(", "fta_filename", ",", "'r'", ")", "as", "fta_file", ":", "files_to_archive", "=", "json", ".", "loads", "(", "fta_file", ".", "read", "(", ")", ")", "# Add these replacements to overrides", "replacements_dict", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", "for", "key", ",", "original_filename", "in", "files_to_archive", ".", "items", "(", ")", ":", "replacement_filename", "=", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "f\"fta/{key}\"", ")", "if", "os", ".", "path", ".", "exists", "(", "replacement_filename", ")", ":", "replacements_dict", "[", "key", "]", "=", "replacement_filename", "else", ":", "logger", ".", "warning", "(", "f\"Archived file {replacement_filename} not found! At train time \"", "f\"this file was located at {original_filename}. This may be \"", "\"because you are loading a serialization directory. Attempting to \"", "\"load the file from its train-time location.\"", ")", "overrides_dict", "=", "parse_overrides", "(", "overrides", ")", "combined_dict", "=", "with_fallback", "(", "preferred", "=", "overrides_dict", ",", "fallback", "=", "unflatten", "(", "replacements_dict", ")", ")", "overrides", "=", "json", ".", "dumps", "(", "combined_dict", ")", "# Load config", "config", "=", "Params", ".", "from_file", "(", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "CONFIG_NAME", ")", ",", "overrides", ")", "config", ".", "loading_from_archive", "=", "True", "if", "weights_file", ":", "weights_path", "=", "weights_file", "else", ":", "weights_path", "=", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "_WEIGHTS_NAME", ")", "# Fallback for serialization directories.", "if", "not", "os", ".", "path", ".", "exists", "(", "weights_path", ")", ":", "weights_path", "=", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "_DEFAULT_WEIGHTS", ")", "# Instantiate model. Use a duplicate of the config, as it will get consumed.", "model", "=", "Model", ".", "load", "(", "config", ".", "duplicate", "(", ")", ",", "weights_file", "=", "weights_path", ",", "serialization_dir", "=", "serialization_dir", ",", "cuda_device", "=", "cuda_device", ")", "return", "Archive", "(", "model", "=", "model", ",", "config", "=", "config", ")" ]
Instantiates an Archive from an archived `tar.gz` file. Parameters ---------- archive_file: ``str`` The archive file to load the model from. weights_file: ``str``, optional (default = None) The weights file to use. If unspecified, weights.th in the archive_file will be used. cuda_device: ``int``, optional (default = -1) If `cuda_device` is >= 0, the model will be loaded onto the corresponding GPU. Otherwise it will be loaded onto the CPU. overrides: ``str``, optional (default = "") JSON overrides to apply to the unarchived ``Params`` object.
[ "Instantiates", "an", "Archive", "from", "an", "archived", "tar", ".", "gz", "file", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/archival.py#L150-L232
train
Loads an archive file into a new object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,yg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iEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(2260 - 2212) + chr(0b1100000 + 0o17) + '\x31' + chr(2190 - 2142) + '\062', 0o10), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b1101101 + 0o2) + chr(49) + chr(728 - 678) + chr(0b10111 + 0o34), 0b1000), ehT0Px3KOsy9(chr(48) + chr(11521 - 11410) + chr(0b110100) + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b111001 + 0o66) + chr(0b110000 + 0o3) + chr(2596 - 2542) + chr(836 - 781), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(1023 - 974) + '\x36' + chr(0b101000 + 0o11), 0b1000), ehT0Px3KOsy9(chr(48) + chr(4817 - 4706) + chr(51) + chr(54) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11000 + 0o33) + chr(0b101101 + 0o5) + '\065', 0b1000), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(111) + chr(0b110110) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(53) + chr(548 - 494), 36878 - 36870), ehT0Px3KOsy9(chr(1170 - 1122) + '\x6f' + '\066' + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(2225 - 2177) + chr(111) + chr(1977 - 1926) + chr(2712 - 2658) + '\x30', 0o10), ehT0Px3KOsy9('\060' + chr(1906 - 1795) + '\065', 55541 - 55533), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(5146 - 5035) + chr(2138 - 2088) + chr(0b110000 + 0o1) + chr(49), 16564 - 16556), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + '\064' + chr(1124 - 1071), ord("\x08")), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(0b1010110 + 0o31) + '\x32' + '\x37' + chr(0b110001), 44139 - 44131), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + chr(50) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + '\061' + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\x6f' + chr(0b110001) + '\064', 18311 - 18303), ehT0Px3KOsy9(chr(182 - 134) + chr(111) + '\x33' + chr(48) + '\062', 36510 - 36502), ehT0Px3KOsy9(chr(2226 - 2178) + chr(111) + chr(2091 - 2042) + chr(1107 - 1057) + '\x32', 18558 - 18550), ehT0Px3KOsy9(chr(1092 - 1044) + chr(111) + chr(1104 - 1056), 11898 - 11890), ehT0Px3KOsy9(chr(793 - 745) + chr(111) + chr(0b110011) + chr(0b100 + 0o63) + chr(0b110010 + 0o4), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110011) + chr(54) + '\064', 8), ehT0Px3KOsy9(chr(48) + '\157' + '\x33' + '\x34', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x33' + '\x30', 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(1108 - 1058) + chr(0b1000 + 0o57) + chr(1089 - 1040), 8), ehT0Px3KOsy9(chr(158 - 110) + '\x6f' + '\062' + chr(51) + chr(55), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(214 - 161) + chr(717 - 668), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + chr(0b100000 + 0o23) + '\x36', 20626 - 20618), ehT0Px3KOsy9(chr(1851 - 1803) + chr(111) + chr(0b110001) + '\062' + chr(0b110101), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x32' + '\066' + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(496 - 448) + '\157' + '\x33', 0b1000), ehT0Px3KOsy9(chr(263 - 215) + chr(111) + '\063' + chr(1862 - 1813) + chr(0b11 + 0o60), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001011 + 0o44) + chr(1533 - 1483) + chr(517 - 468) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(49) + chr(2193 - 2143) + chr(1928 - 1873), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + '\061', 0b1000), ehT0Px3KOsy9(chr(426 - 378) + chr(0b11110 + 0o121) + chr(1198 - 1147) + chr(0b110001) + chr(0b110111), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(0b110100) + chr(0b110000), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + '\x34' + chr(415 - 361), 3249 - 3241), ehT0Px3KOsy9(chr(0b110000) + chr(6663 - 6552) + chr(956 - 906) + chr(0b110111) + chr(0b1010 + 0o54), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1461 - 1413) + '\157' + chr(53) + chr(1275 - 1227), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'l'), '\144' + chr(6687 - 6586) + chr(3815 - 3716) + chr(11419 - 11308) + chr(100) + chr(0b1100101))(chr(2509 - 2392) + '\164' + chr(0b1100110) + chr(0b101101) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def uRNmZTECVLCU(dyP4gOEkYnfH, jRcTRdiVAZAp=-ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001), ord("\x08")), de6iQhrbBQ5Y=xafqLlk3kkUe(SXOLrMavuUCe(b''), '\144' + chr(101) + '\x63' + chr(0b11101 + 0o122) + chr(7085 - 6985) + chr(0b1100101))('\x75' + '\164' + chr(0b1100110 + 0o0) + '\x2d' + chr(0b111 + 0o61)), lB0dvsL5cSLR=None) -> YynU_cZ_y2tc: Lvd0L841udCU = MygwJnRV_fCw(dyP4gOEkYnfH) if Lvd0L841udCU == dyP4gOEkYnfH: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x11dn\x8f\x04\x97\xb2\x04D[\xaan'), chr(740 - 640) + chr(101) + chr(0b1100011) + chr(0b11101 + 0o122) + '\x64' + chr(0b11101 + 0o110))(chr(0b1110101) + '\x74' + chr(9445 - 9343) + chr(0b100010 + 0o13) + chr(0b111000)))(f'loading archive file {dyP4gOEkYnfH}') else: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x11dn\x8f\x04\x97\xb2\x04D[\xaan'), chr(0b1000100 + 0o40) + chr(101) + '\143' + chr(111) + '\144' + '\x65')(chr(3070 - 2953) + chr(0b1110100) + '\146' + chr(1198 - 1153) + chr(0b111000)))(f'loading archive file {dyP4gOEkYnfH} from cache at {Lvd0L841udCU}') if xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'+ B\x9e\x03'), chr(100) + '\145' + chr(99) + chr(111) + '\x64' + '\145')('\165' + '\164' + '\x66' + chr(0b110 + 0o47) + chr(2902 - 2846)))(Lvd0L841udCU): _NgEteHO5j9h = Lvd0L841udCU else: OM2D9GIEjBay = IvD8hQuFpT7c.mkdtemp() xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x11dn\x8f\x04\x97\xb2\x04D[\xaan'), chr(100) + chr(101) + chr(0b1100011) + '\157' + chr(0b1100100) + chr(101))(chr(0b10011 + 0o142) + '\164' + chr(0b1000 + 0o136) + chr(0b11100 + 0o21) + chr(1816 - 1760)))(f'extracting archive file {Lvd0L841udCU} to temp dir {OM2D9GIEjBay}') with xafqLlk3kkUe(RxqDt8LqC5Ns, xafqLlk3kkUe(SXOLrMavuUCe(b'-#C\x99'), '\144' + chr(6911 - 6810) + '\143' + chr(10247 - 10136) + chr(5104 - 5004) + chr(0b1100101))('\165' + chr(116) + chr(0b1100110) + chr(1973 - 1928) + '\x38'))(Lvd0L841udCU, xafqLlk3kkUe(SXOLrMavuUCe(b'0iA\x8d'), chr(0b1100100) + chr(0b1100101) + chr(0b101 + 0o136) + chr(0b1101111) + chr(672 - 572) + chr(0b1100101))(chr(117) + chr(10146 - 10030) + chr(5700 - 5598) + '\055' + '\x38')) as PlsPgRbNZBi4: xafqLlk3kkUe(PlsPgRbNZBi4, xafqLlk3kkUe(SXOLrMavuUCe(b"'+R\x85\x10\x97\xa1RB["), '\x64' + '\145' + chr(99) + '\x6f' + chr(100) + chr(101))(chr(117) + chr(116) + chr(0b1010000 + 0o26) + chr(45) + chr(0b111000)))(OM2D9GIEjBay) xafqLlk3kkUe(nsfxZqya0kR1, xafqLlk3kkUe(SXOLrMavuUCe(b'06A\x9e\x02\x80\xb0A'), chr(6791 - 6691) + chr(0b1100101) + chr(3131 - 3032) + chr(0b1011111 + 0o20) + chr(100) + chr(101))(chr(3572 - 3455) + chr(0b1110100) + chr(6683 - 6581) + chr(1239 - 1194) + chr(2409 - 2353)))(PDIyi4yhZp83, OM2D9GIEjBay) _NgEteHO5j9h = OM2D9GIEjBay bRPt7rUs68CV = oqhJDdMJfuwx.path._oWXztVNnqHF(_NgEteHO5j9h, b2642X2KirPD) if xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b"'+O\x84\x05\x87"), chr(0b1010101 + 0o17) + chr(101) + chr(99) + chr(8193 - 8082) + '\x64' + chr(0b1100101))('\165' + chr(0b1110100) + chr(0b11100 + 0o112) + chr(45) + chr(0b111000)))(bRPt7rUs68CV): with _fwkIVCGgtAN(bRPt7rUs68CV, xafqLlk3kkUe(SXOLrMavuUCe(b'0'), chr(5307 - 5207) + '\145' + chr(1846 - 1747) + chr(111) + chr(100) + '\145')('\165' + chr(0b101001 + 0o113) + chr(0b1100110) + chr(1006 - 961) + '\070')) as Eiy16Fz1Chlt: pc43UazYMoMT = fXk443epxtd5.loads(Eiy16Fz1Chlt.U6MiWrhuCi2Y()) aOJJ6pTwT8RS = {} for (K3J4ZwSlE0sT, yRgp106982KU) in xafqLlk3kkUe(pc43UazYMoMT, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0c)P\x928\xae\xe6zBd\xb8<'), chr(7433 - 7333) + chr(101) + '\143' + chr(7767 - 7656) + chr(100) + chr(0b1100101))(chr(8204 - 8087) + chr(0b1110100) + chr(0b1000100 + 0o42) + chr(0b100001 + 0o14) + chr(0b111000)))(): akHWRuV9ukcm = oqhJDdMJfuwx.path._oWXztVNnqHF(_NgEteHO5j9h, f'fta/{K3J4ZwSlE0sT}') if xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b"'+O\x84\x05\x87"), chr(100) + chr(9540 - 9439) + '\143' + chr(0b1101111) + '\x64' + chr(7892 - 7791))('\165' + chr(0b101000 + 0o114) + chr(102) + '\055' + '\070'))(akHWRuV9ukcm): aOJJ6pTwT8RS[K3J4ZwSlE0sT] = akHWRuV9ukcm else: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'52T\x99\x18\x9a\xb2'), chr(100) + chr(0b1100101) + chr(0b1100011) + '\x6f' + chr(0b1100100) + chr(0b1001101 + 0o30))(chr(117) + chr(0b1110100) + chr(0b1001 + 0o135) + chr(1138 - 1093) + '\x38'))(f'Archived file {akHWRuV9ukcm} not found! At train time this file was located at {yRgp106982KU}. This may be because you are loading a serialization directory. Attempting to load the file from its train-time location.') IOSEfa_G3kxT = fAHnq8ef5vPR(de6iQhrbBQ5Y) G2IIOUlnGKY5 = RMpbQE9sq6dx(preferred=IOSEfa_G3kxT, fallback=L6gu19DVXlJ4(aOJJ6pTwT8RS)) de6iQhrbBQ5Y = fXk443epxtd5.dumps(G2IIOUlnGKY5) jAj7S20Ct06o = pboYvIgFA4qm.from_file(oqhJDdMJfuwx.path._oWXztVNnqHF(_NgEteHO5j9h, aalLhedSsWYM), de6iQhrbBQ5Y) jAj7S20Ct06o.EmNUiGj7ijgZ = ehT0Px3KOsy9(chr(0b110000) + chr(5361 - 5250) + '\061', 8) if lB0dvsL5cSLR: c7iAmD_UPVWI = lB0dvsL5cSLR else: c7iAmD_UPVWI = oqhJDdMJfuwx.path._oWXztVNnqHF(_NgEteHO5j9h, t1BBlehw5NCm) if not xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b"'+O\x84\x05\x87"), chr(100) + chr(0b1100101) + chr(99) + chr(11825 - 11714) + chr(0b1011110 + 0o6) + '\x65')(chr(0b1110101) + chr(116) + chr(102) + '\x2d' + '\070'))(c7iAmD_UPVWI): c7iAmD_UPVWI = oqhJDdMJfuwx.path._oWXztVNnqHF(_NgEteHO5j9h, sp8w6lUArCJR) FK0vqzZ5gPN6 = JC8lDcRGu6X6.mxtdQMeiwJZJ(jAj7S20Ct06o.duplicate(), weights_file=c7iAmD_UPVWI, serialization_dir=_NgEteHO5j9h, cuda_device=jRcTRdiVAZAp) return YynU_cZ_y2tc(model=FK0vqzZ5gPN6, config=jAj7S20Ct06o)
allenai/allennlp
allennlp/models/archival.py
Archive.extract_module
def extract_module(self, path: str, freeze: bool = True) -> Module: """ This method can be used to load a module from the pretrained model archive. It is also used implicitly in FromParams based construction. So instead of using standard params to construct a module, you can instead load a pretrained module from the model archive directly. For eg, instead of using params like {"type": "module_type", ...}, you can use the following template:: { "_pretrained": { "archive_file": "../path/to/model.tar.gz", "path": "path.to.module.in.model", "freeze": False } } If you use this feature with FromParams, take care of the following caveat: Call to initializer(self) at end of model initializer can potentially wipe the transferred parameters by reinitializing them. This can happen if you have setup initializer regex that also matches parameters of the transferred module. To safe-guard against this, you can either update your initializer regex to prevent conflicting match or add extra initializer:: [ [".*transferred_module_name.*", "prevent"]] ] Parameters ---------- path : ``str``, required Path of target module to be loaded from the model. Eg. "_textfield_embedder.token_embedder_tokens" freeze : ``bool``, optional (default=True) Whether to freeze the module parameters or not. """ modules_dict = {path: module for path, module in self.model.named_modules()} module = modules_dict.get(path, None) if not module: raise ConfigurationError(f"You asked to transfer module at path {path} from " f"the model {type(self.model)}. But it's not present.") if not isinstance(module, Module): raise ConfigurationError(f"The transferred object from model {type(self.model)} at path " f"{path} is not a PyTorch Module.") for parameter in module.parameters(): # type: ignore parameter.requires_grad_(not freeze) return module
python
def extract_module(self, path: str, freeze: bool = True) -> Module: """ This method can be used to load a module from the pretrained model archive. It is also used implicitly in FromParams based construction. So instead of using standard params to construct a module, you can instead load a pretrained module from the model archive directly. For eg, instead of using params like {"type": "module_type", ...}, you can use the following template:: { "_pretrained": { "archive_file": "../path/to/model.tar.gz", "path": "path.to.module.in.model", "freeze": False } } If you use this feature with FromParams, take care of the following caveat: Call to initializer(self) at end of model initializer can potentially wipe the transferred parameters by reinitializing them. This can happen if you have setup initializer regex that also matches parameters of the transferred module. To safe-guard against this, you can either update your initializer regex to prevent conflicting match or add extra initializer:: [ [".*transferred_module_name.*", "prevent"]] ] Parameters ---------- path : ``str``, required Path of target module to be loaded from the model. Eg. "_textfield_embedder.token_embedder_tokens" freeze : ``bool``, optional (default=True) Whether to freeze the module parameters or not. """ modules_dict = {path: module for path, module in self.model.named_modules()} module = modules_dict.get(path, None) if not module: raise ConfigurationError(f"You asked to transfer module at path {path} from " f"the model {type(self.model)}. But it's not present.") if not isinstance(module, Module): raise ConfigurationError(f"The transferred object from model {type(self.model)} at path " f"{path} is not a PyTorch Module.") for parameter in module.parameters(): # type: ignore parameter.requires_grad_(not freeze) return module
[ "def", "extract_module", "(", "self", ",", "path", ":", "str", ",", "freeze", ":", "bool", "=", "True", ")", "->", "Module", ":", "modules_dict", "=", "{", "path", ":", "module", "for", "path", ",", "module", "in", "self", ".", "model", ".", "named_modules", "(", ")", "}", "module", "=", "modules_dict", ".", "get", "(", "path", ",", "None", ")", "if", "not", "module", ":", "raise", "ConfigurationError", "(", "f\"You asked to transfer module at path {path} from \"", "f\"the model {type(self.model)}. But it's not present.\"", ")", "if", "not", "isinstance", "(", "module", ",", "Module", ")", ":", "raise", "ConfigurationError", "(", "f\"The transferred object from model {type(self.model)} at path \"", "f\"{path} is not a PyTorch Module.\"", ")", "for", "parameter", "in", "module", ".", "parameters", "(", ")", ":", "# type: ignore", "parameter", ".", "requires_grad_", "(", "not", "freeze", ")", "return", "module" ]
This method can be used to load a module from the pretrained model archive. It is also used implicitly in FromParams based construction. So instead of using standard params to construct a module, you can instead load a pretrained module from the model archive directly. For eg, instead of using params like {"type": "module_type", ...}, you can use the following template:: { "_pretrained": { "archive_file": "../path/to/model.tar.gz", "path": "path.to.module.in.model", "freeze": False } } If you use this feature with FromParams, take care of the following caveat: Call to initializer(self) at end of model initializer can potentially wipe the transferred parameters by reinitializing them. This can happen if you have setup initializer regex that also matches parameters of the transferred module. To safe-guard against this, you can either update your initializer regex to prevent conflicting match or add extra initializer:: [ [".*transferred_module_name.*", "prevent"]] ] Parameters ---------- path : ``str``, required Path of target module to be loaded from the model. Eg. "_textfield_embedder.token_embedder_tokens" freeze : ``bool``, optional (default=True) Whether to freeze the module parameters or not.
[ "This", "method", "can", "be", "used", "to", "load", "a", "module", "from", "the", "pretrained", "model", "archive", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/archival.py#L28-L76
train
This method extracts a module from the pretrained model archive.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsT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ssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(1367 - 1312) + chr(432 - 379), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(49) + '\061' + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + chr(55) + chr(1509 - 1461), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(10947 - 10836) + chr(715 - 664) + chr(2004 - 1951) + chr(0b110100 + 0o2), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x33' + '\067' + '\065', 0b1000), ehT0Px3KOsy9(chr(706 - 658) + chr(0b1010000 + 0o37) + '\062' + chr(918 - 867) + chr(0b1100 + 0o44), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(829 - 780) + chr(1719 - 1666) + chr(0b11011 + 0o25), 0o10), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(7766 - 7655) + '\063' + '\066' + chr(0b10000 + 0o40), 0b1000), ehT0Px3KOsy9(chr(2292 - 2244) + chr(4433 - 4322) + chr(690 - 640) + chr(163 - 114) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011010 + 0o25) + chr(49) + '\067' + '\x34', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b101110 + 0o6) + chr(0b110 + 0o53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(312 - 261) + '\x30' + chr(1896 - 1842), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b0 + 0o62), ord("\x08")), ehT0Px3KOsy9(chr(1424 - 1376) + '\157' + '\x32' + chr(0b110000 + 0o5) + '\x36', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001) + '\x37' + chr(0b10101 + 0o40), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110011) + chr(0b1101 + 0o51) + chr(1984 - 1930), 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\157' + '\x31' + chr(0b11110 + 0o24) + '\x37', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(55) + chr(0b101101 + 0o4), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000000 + 0o57) + chr(0b10100 + 0o35) + '\x32' + '\x33', 0b1000), ehT0Px3KOsy9(chr(439 - 391) + chr(5569 - 5458) + chr(0b1010 + 0o51) + chr(589 - 541) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\157' + chr(0b110011) + chr(55) + chr(48), 8), ehT0Px3KOsy9(chr(1110 - 1062) + chr(111) + '\062' + chr(0b10011 + 0o40) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(4180 - 4069) + '\062' + chr(1448 - 1394) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(111) + chr(0b110001) + chr(55) + chr(0b100010 + 0o17), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(2600 - 2489) + '\062' + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(6820 - 6709) + '\x31' + chr(203 - 152) + chr(0b101110 + 0o3), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(3689 - 3578) + chr(51) + chr(0b110101) + chr(1106 - 1057), 0b1000), ehT0Px3KOsy9(chr(0b100100 + 0o14) + '\157' + chr(1650 - 1600) + chr(408 - 359) + '\064', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x31' + '\x30' + '\060', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x31' + '\x33' + chr(2891 - 2836), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + '\062', 8), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + '\x35', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(49) + chr(946 - 896), 60127 - 60119), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b101 + 0o54) + chr(620 - 571) + '\064', 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + '\061' + chr(0b110110), 63029 - 63021), ehT0Px3KOsy9(chr(282 - 234) + chr(0b10010 + 0o135) + chr(0b100011 + 0o17) + chr(0b111 + 0o60) + '\065', 8), ehT0Px3KOsy9(chr(2053 - 2005) + '\x6f' + chr(0b111 + 0o52) + chr(0b101011 + 0o7), 8), ehT0Px3KOsy9(chr(1317 - 1269) + chr(0b1101011 + 0o4) + chr(967 - 916) + '\065' + '\x31', 8), ehT0Px3KOsy9('\060' + chr(0b1000001 + 0o56) + chr(2311 - 2261) + chr(1789 - 1740) + chr(1443 - 1388), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(0b101111 + 0o3) + chr(54), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\157' + '\065' + '\060', ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x93'), '\144' + chr(101) + '\x63' + '\x6f' + '\x64' + chr(101))(chr(6116 - 5999) + '\164' + chr(0b1100110) + chr(45) + chr(0b1110 + 0o52)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def p7oIVXK5EnBq(oVre8I6UXc3b, EaCjyhZptSer, hl0HeTmly1Ng=ehT0Px3KOsy9('\x30' + chr(10582 - 10471) + chr(158 - 109), ord("\x08"))) -> xUAoUBrV8Bpt: Xrc1kEGmFcFl = {EaCjyhZptSer: RqocVGOryNPv for (EaCjyhZptSer, RqocVGOryNPv) in oVre8I6UXc3b.model.named_modules()} RqocVGOryNPv = Xrc1kEGmFcFl.get(EaCjyhZptSer, None) if not RqocVGOryNPv: raise h0iXqtiKVeKg(f"You asked to transfer module at path {EaCjyhZptSer} from the model {wmQmyeWBmUpv(xafqLlk3kkUe(oVre8I6UXc3b, chr(0b100110 + 0o40) + chr(0b11100 + 0o57) + chr(0b110000) + chr(0b1110110) + chr(0b1110001) + chr(0b1111010) + chr(0b10100 + 0o106) + chr(0b11000 + 0o35) + chr(0b1100111) + chr(2156 - 2076) + chr(0b1001110) + chr(0b1111 + 0o47)))}. But it's not present.") if not PlSM16l2KDPD(RqocVGOryNPv, xUAoUBrV8Bpt): raise h0iXqtiKVeKg(f"The transferred object from model {wmQmyeWBmUpv(xafqLlk3kkUe(oVre8I6UXc3b, chr(70) + chr(75) + chr(48) + chr(1015 - 897) + chr(1746 - 1633) + chr(0b1010111 + 0o43) + chr(1720 - 1630) + chr(0b110101) + chr(0b1100011 + 0o4) + chr(719 - 639) + chr(0b1011 + 0o103) + chr(54)))} at path {EaCjyhZptSer} is not a PyTorch Module.") for Sur8CJUVRGCp in xafqLlk3kkUe(RqocVGOryNPv, xafqLlk3kkUe(SXOLrMavuUCe(b'\xcd-\x8a\x8f\x90\xfd\x1c\x95\xfa\x0f'), chr(2690 - 2590) + chr(101) + chr(0b100001 + 0o102) + chr(111) + '\x64' + chr(0b1100 + 0o131))(chr(1992 - 1875) + '\164' + chr(1609 - 1507) + '\055' + chr(3090 - 3034)))(): xafqLlk3kkUe(Sur8CJUVRGCp, xafqLlk3kkUe(SXOLrMavuUCe(b'\xcf)\x89\x9b\x94\xea\r\x83\xd7\x1bS\xa7f\xf1'), '\144' + '\x65' + '\x63' + '\x6f' + chr(100) + chr(0b11 + 0o142))(chr(0b1110101) + chr(0b1110100) + chr(0b1010101 + 0o21) + chr(45) + '\070'))(not hl0HeTmly1Ng) return RqocVGOryNPv
allenai/allennlp
allennlp/models/semantic_parsing/nlvr/nlvr_semantic_parser.py
NlvrSemanticParser._get_action_strings
def _get_action_strings(cls, possible_actions: List[List[ProductionRule]], action_indices: Dict[int, List[List[int]]]) -> List[List[List[str]]]: """ Takes a list of possible actions and indices of decoded actions into those possible actions for a batch and returns sequences of action strings. We assume ``action_indices`` is a dict mapping batch indices to k-best decoded sequence lists. """ all_action_strings: List[List[List[str]]] = [] batch_size = len(possible_actions) for i in range(batch_size): batch_actions = possible_actions[i] batch_best_sequences = action_indices[i] if i in action_indices else [] # This will append an empty list to ``all_action_strings`` if ``batch_best_sequences`` # is empty. action_strings = [[batch_actions[rule_id][0] for rule_id in sequence] for sequence in batch_best_sequences] all_action_strings.append(action_strings) return all_action_strings
python
def _get_action_strings(cls, possible_actions: List[List[ProductionRule]], action_indices: Dict[int, List[List[int]]]) -> List[List[List[str]]]: """ Takes a list of possible actions and indices of decoded actions into those possible actions for a batch and returns sequences of action strings. We assume ``action_indices`` is a dict mapping batch indices to k-best decoded sequence lists. """ all_action_strings: List[List[List[str]]] = [] batch_size = len(possible_actions) for i in range(batch_size): batch_actions = possible_actions[i] batch_best_sequences = action_indices[i] if i in action_indices else [] # This will append an empty list to ``all_action_strings`` if ``batch_best_sequences`` # is empty. action_strings = [[batch_actions[rule_id][0] for rule_id in sequence] for sequence in batch_best_sequences] all_action_strings.append(action_strings) return all_action_strings
[ "def", "_get_action_strings", "(", "cls", ",", "possible_actions", ":", "List", "[", "List", "[", "ProductionRule", "]", "]", ",", "action_indices", ":", "Dict", "[", "int", ",", "List", "[", "List", "[", "int", "]", "]", "]", ")", "->", "List", "[", "List", "[", "List", "[", "str", "]", "]", "]", ":", "all_action_strings", ":", "List", "[", "List", "[", "List", "[", "str", "]", "]", "]", "=", "[", "]", "batch_size", "=", "len", "(", "possible_actions", ")", "for", "i", "in", "range", "(", "batch_size", ")", ":", "batch_actions", "=", "possible_actions", "[", "i", "]", "batch_best_sequences", "=", "action_indices", "[", "i", "]", "if", "i", "in", "action_indices", "else", "[", "]", "# This will append an empty list to ``all_action_strings`` if ``batch_best_sequences``", "# is empty.", "action_strings", "=", "[", "[", "batch_actions", "[", "rule_id", "]", "[", "0", "]", "for", "rule_id", "in", "sequence", "]", "for", "sequence", "in", "batch_best_sequences", "]", "all_action_strings", ".", "append", "(", "action_strings", ")", "return", "all_action_strings" ]
Takes a list of possible actions and indices of decoded actions into those possible actions for a batch and returns sequences of action strings. We assume ``action_indices`` is a dict mapping batch indices to k-best decoded sequence lists.
[ "Takes", "a", "list", "of", "possible", "actions", "and", "indices", "of", "decoded", "actions", "into", "those", "possible", "actions", "for", "a", "batch", "and", "returns", "sequences", "of", "action", "strings", ".", "We", "assume", "action_indices", "is", "a", "dict", "mapping", "batch", "indices", "to", "k", "-", "best", "decoded", "sequence", "lists", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/semantic_parsing/nlvr/nlvr_semantic_parser.py#L122-L140
train
Takes a list of possible actions and indices of decoded actions into those possible actions and returns a list of all possible action strings.
Pu7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gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(0b1010001 + 0o36) + chr(0b110001 + 0o0) + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b11111 + 0o21) + '\157' + chr(1745 - 1695) + chr(2753 - 2700) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(1090 - 1042) + '\x6f' + chr(423 - 372) + chr(0b100110 + 0o21) + chr(0b110010), 55338 - 55330), ehT0Px3KOsy9('\x30' + '\157' + '\x31' + '\060' + '\067', 0b1000), ehT0Px3KOsy9('\x30' + chr(663 - 552) + chr(0b11110 + 0o24) + '\067' + chr(52), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\061' + chr(51) + '\064', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b100101 + 0o15) + '\x35' + '\065', 8), ehT0Px3KOsy9('\060' + chr(0b10001 + 0o136) + '\x32' + chr(0b1110 + 0o42), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(10822 - 10711) + chr(51) + chr(53) + chr(50), 57380 - 57372), ehT0Px3KOsy9('\x30' + '\x6f' + chr(581 - 531) + chr(0b11110 + 0o25), 0b1000), ehT0Px3KOsy9(chr(1671 - 1623) + '\x6f' + chr(0b10 + 0o57) + '\x33' + chr(1233 - 1185), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(338 - 290) + chr(0b100010 + 0o21), 0b1000), ehT0Px3KOsy9(chr(2048 - 2000) + chr(0b1101111) + chr(49) + chr(0b110000) + chr(1017 - 966), 0b1000), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\x6f' + chr(2322 - 2272) + chr(1518 - 1466) + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(0b1101111) + chr(1292 - 1243) + '\061' + '\x30', 0b1000), ehT0Px3KOsy9('\060' + chr(2984 - 2873) + chr(49) + chr(55) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(2948 - 2837) + '\x33' + '\065' + chr(0b100111 + 0o17), 53697 - 53689), ehT0Px3KOsy9(chr(1835 - 1787) + chr(5884 - 5773) + chr(0b110010) + chr(1528 - 1479) + '\066', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(373 - 322) + chr(885 - 830) + chr(0b110010 + 0o4), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(50) + chr(204 - 156) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b1011 + 0o45) + '\x6f' + '\x32' + chr(54) + '\x34', 46042 - 46034), ehT0Px3KOsy9(chr(48) + '\157' + '\065' + chr(1786 - 1737), ord("\x08")), ehT0Px3KOsy9(chr(1215 - 1167) + chr(0b1101001 + 0o6) + chr(79 - 28) + chr(0b110010) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(1023 - 975) + '\x6f' + '\062' + chr(54) + '\061', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + '\067' + '\x35', 0o10), ehT0Px3KOsy9(chr(1031 - 983) + '\157' + chr(0b110011) + chr(0b110111) + '\066', 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\061' + chr(0b101000 + 0o15) + '\065', 11314 - 11306), ehT0Px3KOsy9('\060' + chr(7790 - 7679) + '\x32' + chr(0b100100 + 0o15) + chr(780 - 726), 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(1392 - 1340) + '\x35', 0b1000), ehT0Px3KOsy9(chr(1789 - 1741) + chr(0b100 + 0o153) + chr(0b1011 + 0o52) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b1101111) + chr(0b10111 + 0o33) + chr(0b110011 + 0o2) + '\063', 27680 - 27672), ehT0Px3KOsy9(chr(48) + chr(0b1010111 + 0o30) + chr(0b101101 + 0o4) + chr(48) + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + chr(54) + '\061', 8), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(7764 - 7653) + chr(1462 - 1413) + chr(0b110100) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(693 - 645) + chr(111) + chr(0b110011) + '\x36' + chr(0b11 + 0o60), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x37' + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(111) + chr(0b10110 + 0o33) + chr(0b110000) + chr(2561 - 2507), 8), ehT0Px3KOsy9(chr(48) + chr(6070 - 5959) + '\063' + chr(0b11110 + 0o25) + chr(0b10011 + 0o36), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001 + 0o146) + '\x31' + chr(54) + chr(51), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + '\062', 43486 - 43478)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(833 - 785) + '\157' + '\065' + chr(48), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b' '), '\x64' + chr(0b1110 + 0o127) + chr(0b1100011) + '\x6f' + chr(0b100101 + 0o77) + chr(101))(chr(6851 - 6734) + chr(0b1110100) + chr(0b1100110) + chr(0b101101) + chr(0b110101 + 0o3)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def E_GA2PUZfX8w(NSstowUUZlxS, Y2JC8aVVeQ6a, qEb1_KEiN1Ud) -> qRxF7OQ0y39T[qRxF7OQ0y39T[qRxF7OQ0y39T[M8_cKLkHVB2V]]]: f7KvcCm6pz1N = [] ix9dZyeAmUxY = c2A0yzQpDQB3(Y2JC8aVVeQ6a) for WVxHKyX45z_L in vQr8gNKaIaWE(ix9dZyeAmUxY): zdSvh8kcqoNn = Y2JC8aVVeQ6a[WVxHKyX45z_L] NbGd0p_DR1L6 = qEb1_KEiN1Ud[WVxHKyX45z_L] if WVxHKyX45z_L in qEb1_KEiN1Ud else [] Q1LBVwjVLFmu = [[zdSvh8kcqoNn[HDMvQjAkWinl][ehT0Px3KOsy9('\x30' + chr(111) + chr(48), 40413 - 40405)] for HDMvQjAkWinl in blgtMYjOOQgD] for blgtMYjOOQgD in NbGd0p_DR1L6] xafqLlk3kkUe(f7KvcCm6pz1N, xafqLlk3kkUe(SXOLrMavuUCe(b'o\xdd\x8a"\xd28'), '\144' + chr(0b1100101) + chr(99) + chr(0b101000 + 0o107) + '\x64' + chr(1459 - 1358))('\165' + chr(116) + chr(8163 - 8061) + '\x2d' + chr(0b111000)))(Q1LBVwjVLFmu) return f7KvcCm6pz1N
allenai/allennlp
allennlp/models/semantic_parsing/nlvr/nlvr_semantic_parser.py
NlvrSemanticParser.decode
def decode(self, output_dict: Dict[str, torch.Tensor]) -> Dict[str, torch.Tensor]: """ This method overrides ``Model.decode``, which gets called after ``Model.forward``, at test time, to finalize predictions. We only transform the action string sequences into logical forms here. """ best_action_strings = output_dict["best_action_strings"] # Instantiating an empty world for getting logical forms. world = NlvrLanguage(set()) logical_forms = [] for instance_action_sequences in best_action_strings: instance_logical_forms = [] for action_strings in instance_action_sequences: if action_strings: instance_logical_forms.append(world.action_sequence_to_logical_form(action_strings)) else: instance_logical_forms.append('') logical_forms.append(instance_logical_forms) action_mapping = output_dict['action_mapping'] best_actions = output_dict['best_action_strings'] debug_infos = output_dict['debug_info'] batch_action_info = [] for batch_index, (predicted_actions, debug_info) in enumerate(zip(best_actions, debug_infos)): instance_action_info = [] for predicted_action, action_debug_info in zip(predicted_actions[0], debug_info): action_info = {} action_info['predicted_action'] = predicted_action considered_actions = action_debug_info['considered_actions'] probabilities = action_debug_info['probabilities'] actions = [] for action, probability in zip(considered_actions, probabilities): if action != -1: actions.append((action_mapping[(batch_index, action)], probability)) actions.sort() considered_actions, probabilities = zip(*actions) action_info['considered_actions'] = considered_actions action_info['action_probabilities'] = probabilities action_info['question_attention'] = action_debug_info.get('question_attention', []) instance_action_info.append(action_info) batch_action_info.append(instance_action_info) output_dict["predicted_actions"] = batch_action_info output_dict["logical_form"] = logical_forms return output_dict
python
def decode(self, output_dict: Dict[str, torch.Tensor]) -> Dict[str, torch.Tensor]: """ This method overrides ``Model.decode``, which gets called after ``Model.forward``, at test time, to finalize predictions. We only transform the action string sequences into logical forms here. """ best_action_strings = output_dict["best_action_strings"] # Instantiating an empty world for getting logical forms. world = NlvrLanguage(set()) logical_forms = [] for instance_action_sequences in best_action_strings: instance_logical_forms = [] for action_strings in instance_action_sequences: if action_strings: instance_logical_forms.append(world.action_sequence_to_logical_form(action_strings)) else: instance_logical_forms.append('') logical_forms.append(instance_logical_forms) action_mapping = output_dict['action_mapping'] best_actions = output_dict['best_action_strings'] debug_infos = output_dict['debug_info'] batch_action_info = [] for batch_index, (predicted_actions, debug_info) in enumerate(zip(best_actions, debug_infos)): instance_action_info = [] for predicted_action, action_debug_info in zip(predicted_actions[0], debug_info): action_info = {} action_info['predicted_action'] = predicted_action considered_actions = action_debug_info['considered_actions'] probabilities = action_debug_info['probabilities'] actions = [] for action, probability in zip(considered_actions, probabilities): if action != -1: actions.append((action_mapping[(batch_index, action)], probability)) actions.sort() considered_actions, probabilities = zip(*actions) action_info['considered_actions'] = considered_actions action_info['action_probabilities'] = probabilities action_info['question_attention'] = action_debug_info.get('question_attention', []) instance_action_info.append(action_info) batch_action_info.append(instance_action_info) output_dict["predicted_actions"] = batch_action_info output_dict["logical_form"] = logical_forms return output_dict
[ "def", "decode", "(", "self", ",", "output_dict", ":", "Dict", "[", "str", ",", "torch", ".", "Tensor", "]", ")", "->", "Dict", "[", "str", ",", "torch", ".", "Tensor", "]", ":", "best_action_strings", "=", "output_dict", "[", "\"best_action_strings\"", "]", "# Instantiating an empty world for getting logical forms.", "world", "=", "NlvrLanguage", "(", "set", "(", ")", ")", "logical_forms", "=", "[", "]", "for", "instance_action_sequences", "in", "best_action_strings", ":", "instance_logical_forms", "=", "[", "]", "for", "action_strings", "in", "instance_action_sequences", ":", "if", "action_strings", ":", "instance_logical_forms", ".", "append", "(", "world", ".", "action_sequence_to_logical_form", "(", "action_strings", ")", ")", "else", ":", "instance_logical_forms", ".", "append", "(", "''", ")", "logical_forms", ".", "append", "(", "instance_logical_forms", ")", "action_mapping", "=", "output_dict", "[", "'action_mapping'", "]", "best_actions", "=", "output_dict", "[", "'best_action_strings'", "]", "debug_infos", "=", "output_dict", "[", "'debug_info'", "]", "batch_action_info", "=", "[", "]", "for", "batch_index", ",", "(", "predicted_actions", ",", "debug_info", ")", "in", "enumerate", "(", "zip", "(", "best_actions", ",", "debug_infos", ")", ")", ":", "instance_action_info", "=", "[", "]", "for", "predicted_action", ",", "action_debug_info", "in", "zip", "(", "predicted_actions", "[", "0", "]", ",", "debug_info", ")", ":", "action_info", "=", "{", "}", "action_info", "[", "'predicted_action'", "]", "=", "predicted_action", "considered_actions", "=", "action_debug_info", "[", "'considered_actions'", "]", "probabilities", "=", "action_debug_info", "[", "'probabilities'", "]", "actions", "=", "[", "]", "for", "action", ",", "probability", "in", "zip", "(", "considered_actions", ",", "probabilities", ")", ":", "if", "action", "!=", "-", "1", ":", "actions", ".", "append", "(", "(", "action_mapping", "[", "(", "batch_index", ",", "action", ")", "]", ",", "probability", ")", ")", "actions", ".", "sort", "(", ")", "considered_actions", ",", "probabilities", "=", "zip", "(", "*", "actions", ")", "action_info", "[", "'considered_actions'", "]", "=", "considered_actions", "action_info", "[", "'action_probabilities'", "]", "=", "probabilities", "action_info", "[", "'question_attention'", "]", "=", "action_debug_info", ".", "get", "(", "'question_attention'", ",", "[", "]", ")", "instance_action_info", ".", "append", "(", "action_info", ")", "batch_action_info", ".", "append", "(", "instance_action_info", ")", "output_dict", "[", "\"predicted_actions\"", "]", "=", "batch_action_info", "output_dict", "[", "\"logical_form\"", "]", "=", "logical_forms", "return", "output_dict" ]
This method overrides ``Model.decode``, which gets called after ``Model.forward``, at test time, to finalize predictions. We only transform the action string sequences into logical forms here.
[ "This", "method", "overrides", "Model", ".", "decode", "which", "gets", "called", "after", "Model", ".", "forward", "at", "test", "time", "to", "finalize", "predictions", ".", "We", "only", "transform", "the", "action", "string", "sequences", "into", "logical", "forms", "here", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/semantic_parsing/nlvr/nlvr_semantic_parser.py#L201-L244
train
This method decodes the output dictionary into a list of logical forms.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88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xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(0b1101111) + '\061' + chr(55), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + '\x32' + '\x32', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + chr(0b11 + 0o60) + chr(52), 26322 - 26314), ehT0Px3KOsy9('\060' + chr(0b110101 + 0o72) + chr(0b101011 + 0o10) + chr(0b101100 + 0o6) + chr(53), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(0b10111 + 0o34) + chr(0b101110 + 0o4), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\064' + chr(1481 - 1433), 18680 - 18672), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b10110 + 0o33) + chr(1503 - 1452) + chr(0b0 + 0o64), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(231 - 181) + chr(1729 - 1680) + '\x32', 0b1000), ehT0Px3KOsy9(chr(267 - 219) + chr(0b1101111) + '\062' + chr(55) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(50) + '\065' + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(1456 - 1408) + chr(0b1101111) + '\x33' + chr(1619 - 1566), 0o10), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101111) + '\063' + chr(2231 - 2180) + chr(258 - 210), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(0b1111 + 0o45) + chr(0b110111), 15202 - 15194), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(111) + chr(657 - 606) + chr(0b100111 + 0o12) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(0b11101 + 0o122) + '\063' + '\066' + chr(0b110010), 17466 - 17458), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\157' + chr(0b110010) + '\x31' + chr(839 - 791), 0o10), ehT0Px3KOsy9(chr(0b10110 + 0o32) + '\157' + '\x31' + '\061' + chr(2579 - 2525), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b110110 + 0o71) + '\x33' + '\062' + chr(54), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b1 + 0o60) + chr(2493 - 2443) + chr(0b110001), 27285 - 27277), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11000 + 0o37) + '\x30', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\x33' + chr(0b110010) + chr(52), 0o10), ehT0Px3KOsy9(chr(2108 - 2060) + chr(0b1101111) + '\x33' + chr(0b11111 + 0o21) + chr(51), 0b1000), ehT0Px3KOsy9(chr(2000 - 1952) + chr(111) + '\x31' + chr(0b10000 + 0o47) + '\x33', 0b1000), ehT0Px3KOsy9('\060' + chr(0b111011 + 0o64) + '\067' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\064', 0b1000), ehT0Px3KOsy9(chr(822 - 774) + '\157' + chr(1453 - 1404) + chr(0b110001) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110011) + chr(1776 - 1723) + chr(2478 - 2424), 48082 - 48074), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1093 - 1043) + chr(847 - 795) + '\x35', 58006 - 57998), ehT0Px3KOsy9(chr(48) + '\157' + chr(50) + chr(49) + chr(246 - 198), 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + chr(0b110101 + 0o2) + chr(144 - 94), 48615 - 48607), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x31' + '\067' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + chr(0b11100 + 0o25) + chr(1279 - 1227), 8), ehT0Px3KOsy9(chr(48) + chr(7850 - 7739) + '\x32' + chr(0b101101 + 0o5) + chr(1869 - 1817), 0o10), ehT0Px3KOsy9(chr(1854 - 1806) + chr(111) + '\x33' + chr(2528 - 2476) + chr(0b101100 + 0o10), 35960 - 35952), ehT0Px3KOsy9(chr(1589 - 1541) + '\x6f' + '\x35' + chr(0b101000 + 0o15), 0b1000), ehT0Px3KOsy9(chr(300 - 252) + chr(0b1101111) + chr(0b11110 + 0o27) + chr(2760 - 2705), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(6850 - 6739) + chr(0b110001) + chr(0b110110) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b1001011 + 0o44) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(10589 - 10478) + '\x33' + chr(0b110111) + chr(0b1010 + 0o53), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(2153 - 2099) + '\060', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b100 + 0o54) + '\157' + chr(0b101010 + 0o13) + chr(0b101 + 0o53), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'!'), chr(4285 - 4185) + '\145' + chr(0b1100011) + chr(0b1101111) + '\144' + '\x65')(chr(0b1110101) + chr(0b1110100) + chr(162 - 60) + chr(45) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def RSziqSuj39r9(oVre8I6UXc3b, lLl7Ukcn67KO) -> zBnV56fc6HrA[M8_cKLkHVB2V, xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'[\xb7\xb2\xa6\xb5R'), chr(100) + chr(4757 - 4656) + chr(0b1000101 + 0o36) + chr(12116 - 12005) + '\x64' + chr(0b1100101))(chr(117) + '\x74' + chr(2412 - 2310) + chr(0b11110 + 0o17) + chr(0b111000)))]: LAoYABD_ow8n = lLl7Ukcn67KO[xafqLlk3kkUe(SXOLrMavuUCe(b'm\xb7\xaf\xa1\x85A?\xfe\xd7\xc3s\x87\xd4\xba\x80\xe1 \xb1"'), chr(961 - 861) + '\145' + chr(0b1001001 + 0o32) + chr(2631 - 2520) + '\144' + '\x65')('\165' + '\x74' + chr(0b1100110) + chr(0b11010 + 0o23) + chr(0b100111 + 0o21))] pxv6w2yhAgdj = oXfS8TD0v6gG(MVEN8G6CxlvR()) ghrilDEBtsWX = [] for nYCtaX6iBwsH in LAoYABD_ow8n: AwW2XdGj164a = [] for Q1LBVwjVLFmu in nYCtaX6iBwsH: if Q1LBVwjVLFmu: xafqLlk3kkUe(AwW2XdGj164a, xafqLlk3kkUe(SXOLrMavuUCe(b'n\xa2\xac\xb0\xb4D'), '\x64' + chr(0b1010 + 0o133) + '\x63' + chr(4615 - 4504) + '\x64' + '\145')(chr(117) + '\164' + '\146' + chr(0b1 + 0o54) + '\070'))(xafqLlk3kkUe(pxv6w2yhAgdj, xafqLlk3kkUe(SXOLrMavuUCe(b'n\xb1\xa8\xbc\xb5N\x03\xf9\xdb\xddh\xbd\xc9\xad\x97\xd7:\xb9\x0eT\xbb\xa4\x12^e \xb1\xc3\xe7\x88\x13'), '\x64' + chr(5467 - 5366) + chr(434 - 335) + '\x6f' + '\144' + '\145')('\165' + chr(116) + chr(0b10000 + 0o126) + '\055' + '\x38'))(Q1LBVwjVLFmu)) else: xafqLlk3kkUe(AwW2XdGj164a, xafqLlk3kkUe(SXOLrMavuUCe(b'n\xa2\xac\xb0\xb4D'), '\144' + chr(101) + chr(0b1100011) + chr(0b1101111) + chr(5227 - 5127) + chr(101))('\x75' + '\x74' + '\x66' + chr(0b101100 + 0o1) + '\x38'))(xafqLlk3kkUe(SXOLrMavuUCe(b''), '\x64' + '\145' + chr(0b11101 + 0o106) + chr(0b1101111) + chr(0b1100100) + chr(5968 - 5867))(chr(10555 - 10438) + chr(0b1110100) + chr(0b110001 + 0o65) + chr(169 - 124) + chr(0b11110 + 0o32))) xafqLlk3kkUe(ghrilDEBtsWX, xafqLlk3kkUe(SXOLrMavuUCe(b'n\xa2\xac\xb0\xb4D'), chr(100) + chr(0b1100101) + chr(0b11000 + 0o113) + chr(0b1101111) + chr(0b1100100) + chr(0b1100101))(chr(117) + chr(116) + chr(0b1011101 + 0o11) + chr(45) + chr(481 - 425)))(AwW2XdGj164a) mIDkMo7T3yII = lLl7Ukcn67KO[xafqLlk3kkUe(SXOLrMavuUCe(b'n\xb1\xa8\xbc\xb5N\x03\xe7\xdf\xdcm\xb1\xc9\xa9'), chr(8343 - 8243) + chr(0b1100101) + chr(4262 - 4163) + '\157' + '\144' + chr(101))('\165' + chr(6552 - 6436) + chr(0b1001011 + 0o33) + chr(0b101101) + chr(0b111000))] pKAJkeIVVfjq = lLl7Ukcn67KO[xafqLlk3kkUe(SXOLrMavuUCe(b'm\xb7\xaf\xa1\x85A?\xfe\xd7\xc3s\x87\xd4\xba\x80\xe1 \xb1"'), chr(100) + chr(101) + chr(99) + chr(0b1010000 + 0o37) + chr(0b1100100) + chr(0b1100101))('\x75' + chr(0b1110100) + '\x66' + chr(1199 - 1154) + '\x38')] F5wgcn9yhRc5 = lLl7Ukcn67KO[xafqLlk3kkUe(SXOLrMavuUCe(b'k\xb7\xbe\xa0\xbd\x7f5\xe4\xd8\xc3'), chr(0b1000011 + 0o41) + chr(0b1100101) + chr(99) + chr(6083 - 5972) + chr(0b1100011 + 0o1) + '\145')(chr(0b101100 + 0o111) + chr(116) + chr(3947 - 3845) + '\055' + chr(2026 - 1970))] hZnGjBfbLsce = [] for (Q3TVZeZzkrZ0, (fAoXoIWrOcXP, aqjarmPZPQeS)) in YlkZvXL8qwsX(pZ0NK2y6HRbn(pKAJkeIVVfjq, F5wgcn9yhRc5)): uu7ienyhfZVQ = [] for (QNofKOW9ItIK, butH3HwElqBD) in pZ0NK2y6HRbn(fAoXoIWrOcXP[ehT0Px3KOsy9(chr(48) + chr(3701 - 3590) + chr(48), 5942 - 5934)], aqjarmPZPQeS): dMkDguqfdz38 = {} dMkDguqfdz38[xafqLlk3kkUe(SXOLrMavuUCe(b'\x7f\xa0\xb9\xb1\xb3C(\xef\xda\xf3|\xbb\xd3\xa7\x9d\xe6'), chr(0b1100100) + chr(101) + '\143' + '\x6f' + '\x64' + chr(218 - 117))(chr(117) + chr(116) + '\x66' + chr(0b110 + 0o47) + chr(0b110101 + 0o3))] = QNofKOW9ItIK bGlylTOILCyp = butH3HwElqBD[xafqLlk3kkUe(SXOLrMavuUCe(b'l\xbd\xb2\xa6\xb3D9\xf8\xdb\xc8B\xb9\xc4\xba\x9b\xe7 \xa5'), chr(0b111 + 0o135) + chr(776 - 675) + '\143' + chr(0b100100 + 0o113) + '\144' + '\x65')(chr(0b100011 + 0o122) + chr(0b1110100) + chr(0b1100110) + chr(1862 - 1817) + chr(0b111000))] TFFTAqMklnaA = butH3HwElqBD[xafqLlk3kkUe(SXOLrMavuUCe(b'\x7f\xa0\xb3\xb7\xbbB5\xe6\xd7\xd8t\xbd\xd4'), chr(0b1100100) + chr(101) + chr(0b1100011) + '\x6f' + '\144' + '\145')('\x75' + '\x74' + chr(3612 - 3510) + chr(45) + '\x38')] WCl6VUkME_8I = [] for (vyskHDXig6uT, aYCdPHFLUbMp) in pZ0NK2y6HRbn(bGlylTOILCyp, TFFTAqMklnaA): if vyskHDXig6uT != -ehT0Px3KOsy9('\x30' + chr(111) + chr(1691 - 1642), ord("\x08")): xafqLlk3kkUe(WCl6VUkME_8I, xafqLlk3kkUe(SXOLrMavuUCe(b'n\xa2\xac\xb0\xb4D'), chr(0b10101 + 0o117) + chr(0b100010 + 0o103) + chr(9665 - 9566) + '\x6f' + chr(5234 - 5134) + '\145')('\165' + '\164' + '\x66' + '\055' + chr(0b111000)))((mIDkMo7T3yII[Q3TVZeZzkrZ0, vyskHDXig6uT], aYCdPHFLUbMp)) xafqLlk3kkUe(WCl6VUkME_8I, xafqLlk3kkUe(SXOLrMavuUCe(b'|\xbd\xae\xa1'), chr(0b110001 + 0o63) + '\145' + chr(99) + chr(7893 - 7782) + chr(7438 - 7338) + chr(101))(chr(0b1110101) + chr(5508 - 5392) + chr(0b11101 + 0o111) + chr(45) + '\070'))() (bGlylTOILCyp, TFFTAqMklnaA) = pZ0NK2y6HRbn(*WCl6VUkME_8I) dMkDguqfdz38[xafqLlk3kkUe(SXOLrMavuUCe(b'l\xbd\xb2\xa6\xb3D9\xf8\xdb\xc8B\xb9\xc4\xba\x9b\xe7 \xa5'), chr(0b1000111 + 0o35) + '\x65' + chr(1547 - 1448) + '\x6f' + chr(100) + '\x65')('\x75' + chr(0b1110100) + chr(0b1100110) + '\055' + '\070')] = bGlylTOILCyp dMkDguqfdz38[xafqLlk3kkUe(SXOLrMavuUCe(b'n\xb1\xa8\xbc\xb5N\x03\xfa\xcc\xc3\x7f\xb9\xc5\xa7\x9e\xe1:\xbf4K'), chr(2452 - 2352) + '\145' + '\x63' + chr(3270 - 3159) + '\144' + chr(0b1001 + 0o134))(chr(8764 - 8647) + '\x74' + chr(625 - 523) + chr(0b101101) + chr(828 - 772))] = TFFTAqMklnaA dMkDguqfdz38[xafqLlk3kkUe(SXOLrMavuUCe(b'~\xa7\xb9\xa6\xaeI3\xe4\xe1\xcdi\xac\xc2\xa0\x86\xe1!\xb8'), chr(0b1100100) + chr(5332 - 5231) + chr(99) + '\157' + '\x64' + chr(0b1100101))(chr(0b1110101) + '\x74' + chr(0b10001 + 0o125) + chr(138 - 93) + chr(341 - 285))] = butH3HwElqBD.get(xafqLlk3kkUe(SXOLrMavuUCe(b'~\xa7\xb9\xa6\xaeI3\xe4\xe1\xcdi\xac\xc2\xa0\x86\xe1!\xb8'), '\144' + '\145' + '\143' + chr(0b1001100 + 0o43) + chr(0b1100100) + chr(0b1100101))(chr(0b1011010 + 0o33) + '\x74' + chr(0b1100110) + chr(0b10101 + 0o30) + '\x38'), []) xafqLlk3kkUe(uu7ienyhfZVQ, xafqLlk3kkUe(SXOLrMavuUCe(b'n\xa2\xac\xb0\xb4D'), '\144' + '\x65' + '\x63' + '\157' + chr(0b101011 + 0o71) + '\145')('\x75' + chr(1459 - 1343) + chr(0b1100000 + 0o6) + chr(0b100 + 0o51) + chr(0b111000)))(dMkDguqfdz38) xafqLlk3kkUe(hZnGjBfbLsce, xafqLlk3kkUe(SXOLrMavuUCe(b'n\xa2\xac\xb0\xb4D'), chr(100) + chr(0b1100101) + chr(3363 - 3264) + chr(0b1101111) + chr(0b1100100) + chr(0b1100101))(chr(0b1110101 + 0o0) + '\164' + chr(0b101111 + 0o67) + '\x2d' + chr(0b111000)))(uu7ienyhfZVQ) lLl7Ukcn67KO[xafqLlk3kkUe(SXOLrMavuUCe(b'\x7f\xa0\xb9\xb1\xb3C(\xef\xda\xf3|\xbb\xd3\xa7\x9d\xe6='), chr(0b1100100) + chr(5843 - 5742) + '\143' + chr(0b1101111) + chr(5080 - 4980) + chr(0b111110 + 0o47))(chr(13636 - 13519) + chr(0b1110100) + chr(0b1100110) + chr(0b101101) + chr(0b100100 + 0o24))] = hZnGjBfbLsce lLl7Ukcn67KO[xafqLlk3kkUe(SXOLrMavuUCe(b'c\xbd\xbb\xbc\xb9A0\xd5\xd8\xc3o\xb5'), chr(0b110010 + 0o62) + chr(0b1001110 + 0o27) + '\x63' + '\x6f' + chr(100) + '\x65')('\165' + chr(0b1110100) + chr(4229 - 4127) + '\055' + chr(1719 - 1663))] = ghrilDEBtsWX return lLl7Ukcn67KO
allenai/allennlp
allennlp/models/semantic_parsing/nlvr/nlvr_semantic_parser.py
NlvrSemanticParser._check_state_denotations
def _check_state_denotations(self, state: GrammarBasedState, worlds: List[NlvrLanguage]) -> List[bool]: """ Returns whether action history in the state evaluates to the correct denotations over all worlds. Only defined when the state is finished. """ assert state.is_finished(), "Cannot compute denotations for unfinished states!" # Since this is a finished state, its group size must be 1. batch_index = state.batch_indices[0] instance_label_strings = state.extras[batch_index] history = state.action_history[0] all_actions = state.possible_actions[0] action_sequence = [all_actions[action][0] for action in history] return self._check_denotation(action_sequence, instance_label_strings, worlds)
python
def _check_state_denotations(self, state: GrammarBasedState, worlds: List[NlvrLanguage]) -> List[bool]: """ Returns whether action history in the state evaluates to the correct denotations over all worlds. Only defined when the state is finished. """ assert state.is_finished(), "Cannot compute denotations for unfinished states!" # Since this is a finished state, its group size must be 1. batch_index = state.batch_indices[0] instance_label_strings = state.extras[batch_index] history = state.action_history[0] all_actions = state.possible_actions[0] action_sequence = [all_actions[action][0] for action in history] return self._check_denotation(action_sequence, instance_label_strings, worlds)
[ "def", "_check_state_denotations", "(", "self", ",", "state", ":", "GrammarBasedState", ",", "worlds", ":", "List", "[", "NlvrLanguage", "]", ")", "->", "List", "[", "bool", "]", ":", "assert", "state", ".", "is_finished", "(", ")", ",", "\"Cannot compute denotations for unfinished states!\"", "# Since this is a finished state, its group size must be 1.", "batch_index", "=", "state", ".", "batch_indices", "[", "0", "]", "instance_label_strings", "=", "state", ".", "extras", "[", "batch_index", "]", "history", "=", "state", ".", "action_history", "[", "0", "]", "all_actions", "=", "state", ".", "possible_actions", "[", "0", "]", "action_sequence", "=", "[", "all_actions", "[", "action", "]", "[", "0", "]", "for", "action", "in", "history", "]", "return", "self", ".", "_check_denotation", "(", "action_sequence", ",", "instance_label_strings", ",", "worlds", ")" ]
Returns whether action history in the state evaluates to the correct denotations over all worlds. Only defined when the state is finished.
[ "Returns", "whether", "action", "history", "in", "the", "state", "evaluates", "to", "the", "correct", "denotations", "over", "all", "worlds", ".", "Only", "defined", "when", "the", "state", "is", "finished", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/semantic_parsing/nlvr/nlvr_semantic_parser.py#L246-L258
train
Returns whether the state evaluates to the correct denotations over all the worlds.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMy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IOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1458 - 1408) + chr(0b110100) + '\060', 62193 - 62185), ehT0Px3KOsy9('\x30' + chr(0b1010000 + 0o37) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101 + 0o54) + chr(0b110110) + '\x35', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b1010 + 0o51) + chr(51) + chr(0b110001), 46360 - 46352), ehT0Px3KOsy9(chr(1664 - 1616) + chr(9771 - 9660) + '\063' + '\x33' + chr(1984 - 1935), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b111001 + 0o66) + chr(2582 - 2531) + chr(48) + chr(52), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1000110 + 0o51) + chr(0b110010) + chr(0b110100) + chr(0b10001 + 0o41), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(4930 - 4819) + chr(0b110010) + '\061' + chr(0b110011), 16035 - 16027), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b1110 + 0o43) + chr(0b101101 + 0o5) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + '\x32' + chr(48), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + chr(54) + chr(2577 - 2524), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1315 - 1265) + chr(0b110100 + 0o3), 0o10), ehT0Px3KOsy9(chr(1240 - 1192) + chr(0b1101111) + chr(159 - 106) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b1010 + 0o52) + chr(48), 0o10), ehT0Px3KOsy9('\060' + '\157' + '\063' + chr(0b110111) + chr(0b11 + 0o64), ord("\x08")), ehT0Px3KOsy9(chr(1374 - 1326) + '\x6f' + chr(1030 - 979) + chr(2460 - 2407) + '\x35', 11790 - 11782), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b100101 + 0o16) + chr(54) + '\063', 55912 - 55904), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(2814 - 2703) + '\x33' + chr(1888 - 1839), 0o10), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\x6f' + chr(0b110010) + chr(52) + '\061', 45154 - 45146), ehT0Px3KOsy9('\x30' + '\157' + chr(50) + '\067' + chr(0b0 + 0o65), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110100) + chr(783 - 735), 8), ehT0Px3KOsy9(chr(0b110000) + chr(7749 - 7638) + chr(1199 - 1147) + chr(50), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b101101 + 0o4) + chr(0b110110) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(928 - 880) + '\x6f' + chr(50) + '\x36' + chr(0b101011 + 0o10), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b100110 + 0o111) + chr(50) + '\061' + chr(0b10 + 0o61), 8), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(3815 - 3704) + chr(504 - 449) + '\x34', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(2482 - 2432) + chr(0b110000 + 0o1) + chr(48), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + chr(55) + '\x34', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1001010 + 0o45) + chr(0b110010) + '\066' + '\062', 31699 - 31691), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110010) + chr(49) + '\x36', 10905 - 10897), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + chr(1719 - 1668) + '\067', 0b1000), ehT0Px3KOsy9(chr(1399 - 1351) + chr(0b1101111) + chr(0b1 + 0o66) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b1010 + 0o50) + '\x30' + '\063', 52497 - 52489), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(111) + '\061' + chr(0b11010 + 0o31) + chr(0b0 + 0o66), 0o10), ehT0Px3KOsy9('\x30' + chr(9339 - 9228) + '\063', 39610 - 39602), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b1101111) + chr(51) + chr(0b110011) + chr(895 - 842), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + chr(0b110010) + chr(867 - 818), 50339 - 50331), ehT0Px3KOsy9('\x30' + chr(0b1100010 + 0o15) + '\063' + chr(1873 - 1825) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(7944 - 7833) + chr(0b110011) + chr(0b11111 + 0o24) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\157' + chr(1667 - 1614) + chr(53), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(0b1101100 + 0o3) + '\065' + chr(285 - 237), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e'), '\x64' + chr(101) + chr(0b1100011) + chr(0b1011100 + 0o23) + '\x64' + '\145')(chr(0b1100100 + 0o21) + chr(116) + chr(7570 - 7468) + chr(0b100010 + 0o13) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def yrq83aFnySwc(oVre8I6UXc3b, KKFQISrGeiAm, bAEvLqWX737r) -> qRxF7OQ0y39T[WbBjf8Y7v9VN]: assert xafqLlk3kkUe(KKFQISrGeiAm, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc9v*\xbf\xb0\xaa\xcb\xf8:5\x91'), chr(5865 - 5765) + '\x65' + chr(2416 - 2317) + chr(0b1101111) + '\x64' + chr(5785 - 5684))(chr(0b111011 + 0o72) + chr(0b1110100) + chr(102) + '\x2d' + chr(2763 - 2707)))(), xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3d\x1b\xb7\xb6\xb0\x82\xe8==\x85bXE\xdf\x89\x96w\xce\xc9AV\x1f\xdc\xe5O\xa8\x1a\xdd\xfc\xffJ\xed8j\xb3\xf8\xb2\xb6H\xc4%\x06\xad\xb8\xb0\xc7\xf8s'), chr(0b1100100) + chr(0b1100101) + chr(0b1100011) + chr(0b1101111) + chr(0b100000 + 0o104) + '\x65')(chr(1166 - 1049) + chr(0b111011 + 0o71) + chr(0b101001 + 0o75) + chr(0b11110 + 0o17) + chr(1463 - 1407)) Q3TVZeZzkrZ0 = KKFQISrGeiAm.batch_indices[ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x30', 0o10)] lVK9FZvIAyN0 = KKFQISrGeiAm.extras[Q3TVZeZzkrZ0] sD1K7SLfPnDB = KKFQISrGeiAm.action_history[ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(7543 - 7432) + chr(0b10101 + 0o33), 8)] z5EYB6nilIpt = KKFQISrGeiAm.possible_actions[ehT0Px3KOsy9(chr(1656 - 1608) + chr(111) + chr(48), 8)] FXNJIrDAzcxy = [z5EYB6nilIpt[vyskHDXig6uT][ehT0Px3KOsy9(chr(48) + chr(8817 - 8706) + chr(1918 - 1870), 8)] for vyskHDXig6uT in sD1K7SLfPnDB] return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfff\x1d\xbc\xba\xaf\xfd\xef7>\x9acMT\x96\x82\x9d'), '\x64' + chr(0b1100101) + chr(9184 - 9085) + chr(0b1100000 + 0o17) + '\x64' + '\x65')(chr(0b1110101) + chr(116) + '\146' + chr(0b101101) + chr(0b11010 + 0o36)))(FXNJIrDAzcxy, lVK9FZvIAyN0, bAEvLqWX737r)
allenai/allennlp
allennlp/commands/find_learning_rate.py
find_learning_rate_from_args
def find_learning_rate_from_args(args: argparse.Namespace) -> None: """ Start learning rate finder for given args """ params = Params.from_file(args.param_path, args.overrides) find_learning_rate_model(params, args.serialization_dir, start_lr=args.start_lr, end_lr=args.end_lr, num_batches=args.num_batches, linear_steps=args.linear, stopping_factor=args.stopping_factor, force=args.force)
python
def find_learning_rate_from_args(args: argparse.Namespace) -> None: """ Start learning rate finder for given args """ params = Params.from_file(args.param_path, args.overrides) find_learning_rate_model(params, args.serialization_dir, start_lr=args.start_lr, end_lr=args.end_lr, num_batches=args.num_batches, linear_steps=args.linear, stopping_factor=args.stopping_factor, force=args.force)
[ "def", "find_learning_rate_from_args", "(", "args", ":", "argparse", ".", "Namespace", ")", "->", "None", ":", "params", "=", "Params", ".", "from_file", "(", "args", ".", "param_path", ",", "args", ".", "overrides", ")", "find_learning_rate_model", "(", "params", ",", "args", ".", "serialization_dir", ",", "start_lr", "=", "args", ".", "start_lr", ",", "end_lr", "=", "args", ".", "end_lr", ",", "num_batches", "=", "args", ".", "num_batches", ",", "linear_steps", "=", "args", ".", "linear", ",", "stopping_factor", "=", "args", ".", "stopping_factor", ",", "force", "=", "args", ".", "force", ")" ]
Start learning rate finder for given args
[ "Start", "learning", "rate", "finder", "for", "given", "args" ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/commands/find_learning_rate.py#L121-L132
train
Start learning rate finder for given args
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yD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3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(2073 - 2024) + chr(49) + '\x37', 16911 - 16903), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b10 + 0o60) + chr(0b101110 + 0o7) + chr(50), 55303 - 55295), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1759 - 1708) + chr(48) + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(50) + chr(0b110001) + '\x35', 0o10), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(6333 - 6222) + chr(49) + chr(0b110101) + '\067', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1011000 + 0o27) + chr(49) + chr(0b110011) + chr(53), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(2220 - 2169) + chr(50) + '\x36', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\x31' + '\x37' + '\x33', 0o10), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(239 - 128) + chr(1854 - 1802) + '\x36', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110 + 0o57) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(1749 - 1701) + chr(0b10110 + 0o131) + '\063' + '\x30' + chr(0b110 + 0o55), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(795 - 745) + '\067', 19686 - 19678), ehT0Px3KOsy9(chr(0b110000) + chr(11474 - 11363) + chr(0b110011) + chr(0b110100) + '\063', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b110011 + 0o74) + chr(608 - 557) + '\x30' + chr(0b101011 + 0o13), 54408 - 54400), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b1111 + 0o44) + '\x36' + chr(0b11010 + 0o33), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + chr(48) + chr(0b110110), 8), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\x6f' + '\062' + chr(1349 - 1297) + '\066', 0o10), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\x6f' + '\x31' + chr(966 - 914) + chr(53), 0b1000), ehT0Px3KOsy9(chr(785 - 737) + chr(5617 - 5506) + chr(49) + chr(1165 - 1114) + chr(0b101 + 0o56), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110010) + chr(217 - 169) + '\x37', 0b1000), ehT0Px3KOsy9(chr(1227 - 1179) + '\157' + chr(0b110011) + chr(0b110100) + chr(2007 - 1956), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110011) + chr(53) + '\064', 26785 - 26777), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(111) + chr(51) + '\x36' + '\063', 0b1000), ehT0Px3KOsy9(chr(956 - 908) + chr(0b1001111 + 0o40) + chr(49) + '\064' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b101110 + 0o2) + '\x6f' + chr(751 - 702) + '\065' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\157' + '\064' + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1010000 + 0o37) + chr(0b110011) + chr(0b110100) + chr(1276 - 1226), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1392 - 1342) + '\x34' + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(0b1101111) + chr(0b110001) + '\x31' + chr(2190 - 2138), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(2057 - 2008) + chr(0b110000) + chr(212 - 158), 7793 - 7785), ehT0Px3KOsy9(chr(1847 - 1799) + chr(11268 - 11157) + chr(0b100110 + 0o15) + chr(0b10101 + 0o40) + chr(54), 38786 - 38778), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110111), 17377 - 17369), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(9725 - 9614) + chr(277 - 223) + chr(1889 - 1834), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\067' + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(4281 - 4170) + chr(0b101 + 0o55) + chr(0b110000) + chr(0b100100 + 0o21), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b11011 + 0o124) + '\x32' + chr(0b110111) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110001) + chr(0b110110) + chr(0b11000 + 0o30), ord("\x08")), ehT0Px3KOsy9(chr(1703 - 1655) + chr(0b101011 + 0o104) + chr(0b11011 + 0o30) + chr(1987 - 1936) + '\x36', 0o10), ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\x6f' + '\x33' + '\x31' + '\064', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110011) + '\064' + chr(53), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1327 - 1279) + chr(1863 - 1752) + chr(0b1000 + 0o55) + chr(1394 - 1346), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'a'), chr(5630 - 5530) + '\x65' + '\x63' + chr(6506 - 6395) + chr(7501 - 7401) + chr(101))('\x75' + '\x74' + chr(2182 - 2080) + '\x2d' + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def YE8m_ICK2pOt(kJDRfRhcZHjS) -> None: nEbJZ4wfte2w = pboYvIgFA4qm.from_file(kJDRfRhcZHjS.param_path, kJDRfRhcZHjS.overrides) Mm8PIzEblYb_(nEbJZ4wfte2w, xafqLlk3kkUe(kJDRfRhcZHjS, xafqLlk3kkUe(SXOLrMavuUCe(b'<\xcf\xb7\xe4\x0e1\xbf\x01GY\xaax\x8d\x99\x91\xaf\xd4'), chr(4563 - 4463) + chr(0b1100101) + chr(4558 - 4459) + chr(0b1100100 + 0o13) + '\x64' + chr(0b100 + 0o141))(chr(0b101 + 0o160) + '\164' + chr(102) + chr(0b101101) + chr(0b10010 + 0o46))), start_lr=xafqLlk3kkUe(kJDRfRhcZHjS, xafqLlk3kkUe(SXOLrMavuUCe(b'<\xde\xa4\xff\x1b\x02\xba\t'), chr(1513 - 1413) + chr(0b11111 + 0o106) + chr(9676 - 9577) + '\157' + '\144' + chr(0b1100101))(chr(0b1110101) + chr(0b1010010 + 0o42) + chr(0b10000 + 0o126) + chr(0b1000 + 0o45) + '\070')), end_lr=xafqLlk3kkUe(kJDRfRhcZHjS, xafqLlk3kkUe(SXOLrMavuUCe(b'*\xc4\xa1\xd2\x03/'), chr(100) + chr(6197 - 6096) + '\x63' + chr(7273 - 7162) + '\x64' + '\145')(chr(117) + chr(116) + chr(102) + chr(0b11011 + 0o22) + chr(1335 - 1279))), num_batches=xafqLlk3kkUe(kJDRfRhcZHjS, xafqLlk3kkUe(SXOLrMavuUCe(b'!\xdf\xa8\xd2\r<\xa2\x18NH\xb0'), '\144' + '\x65' + chr(0b110101 + 0o56) + chr(0b11111 + 0o120) + '\x64' + chr(101))(chr(0b1001000 + 0o55) + chr(3359 - 3243) + chr(0b110110 + 0o60) + '\x2d' + chr(56))), linear_steps=xafqLlk3kkUe(kJDRfRhcZHjS, xafqLlk3kkUe(SXOLrMavuUCe(b'#\xc3\xab\xe8\x0e/'), '\x64' + chr(0b1 + 0o144) + chr(0b1011001 + 0o12) + chr(0b1101111) + chr(100) + '\145')(chr(117) + '\164' + chr(0b1100110) + chr(0b101101) + chr(1487 - 1431))), stopping_factor=xafqLlk3kkUe(kJDRfRhcZHjS, xafqLlk3kkUe(SXOLrMavuUCe(b'<\xde\xaa\xfd\x1f4\xb8\x1cyK\xa2t\x97\xa9\x87'), chr(0b1100100) + chr(0b1100101) + '\x63' + chr(111) + chr(100) + '\x65')(chr(117) + chr(0b1110010 + 0o2) + chr(0b1001001 + 0o35) + chr(0b10111 + 0o26) + '\070')), force=xafqLlk3kkUe(kJDRfRhcZHjS, xafqLlk3kkUe(SXOLrMavuUCe(b')\xc5\xb7\xee\n'), chr(0b1000011 + 0o41) + chr(101) + chr(3681 - 3582) + chr(111) + '\x64' + chr(0b1100101))('\x75' + chr(0b1110100) + '\146' + chr(1363 - 1318) + chr(0b10101 + 0o43))))
allenai/allennlp
allennlp/commands/find_learning_rate.py
find_learning_rate_model
def find_learning_rate_model(params: Params, serialization_dir: str, start_lr: float = 1e-5, end_lr: float = 10, num_batches: int = 100, linear_steps: bool = False, stopping_factor: float = None, force: bool = False) -> None: """ Runs learning rate search for given `num_batches` and saves the results in ``serialization_dir`` Parameters ---------- params : ``Params`` A parameter object specifying an AllenNLP Experiment. serialization_dir : ``str`` The directory in which to save results. start_lr: ``float`` Learning rate to start the search. end_lr: ``float`` Learning rate upto which search is done. num_batches: ``int`` Number of mini-batches to run Learning rate finder. linear_steps: ``bool`` Increase learning rate linearly if False exponentially. stopping_factor: ``float`` Stop the search when the current loss exceeds the best loss recorded by multiple of stopping factor. If ``None`` search proceeds till the ``end_lr`` force: ``bool`` If True and the serialization directory already exists, everything in it will be removed prior to finding the learning rate. """ if os.path.exists(serialization_dir) and force: shutil.rmtree(serialization_dir) if os.path.exists(serialization_dir) and os.listdir(serialization_dir): raise ConfigurationError(f'Serialization directory {serialization_dir} already exists and is ' f'not empty.') else: os.makedirs(serialization_dir, exist_ok=True) prepare_environment(params) cuda_device = params.params.get('trainer').get('cuda_device', -1) check_for_gpu(cuda_device) all_datasets = datasets_from_params(params) datasets_for_vocab_creation = set(params.pop("datasets_for_vocab_creation", all_datasets)) for dataset in datasets_for_vocab_creation: if dataset not in all_datasets: raise ConfigurationError(f"invalid 'dataset_for_vocab_creation' {dataset}") logger.info("From dataset instances, %s will be considered for vocabulary creation.", ", ".join(datasets_for_vocab_creation)) vocab = Vocabulary.from_params( params.pop("vocabulary", {}), (instance for key, dataset in all_datasets.items() for instance in dataset if key in datasets_for_vocab_creation) ) model = Model.from_params(vocab=vocab, params=params.pop('model')) iterator = DataIterator.from_params(params.pop("iterator")) iterator.index_with(vocab) train_data = all_datasets['train'] trainer_params = params.pop("trainer") no_grad_regexes = trainer_params.pop("no_grad", ()) for name, parameter in model.named_parameters(): if any(re.search(regex, name) for regex in no_grad_regexes): parameter.requires_grad_(False) trainer_choice = trainer_params.pop("type", "default") if trainer_choice != "default": raise ConfigurationError("currently find-learning-rate only works with the default Trainer") trainer = Trainer.from_params(model=model, serialization_dir=serialization_dir, iterator=iterator, train_data=train_data, validation_data=None, params=trainer_params, validation_iterator=None) logger.info(f'Starting learning rate search from {start_lr} to {end_lr} in {num_batches} iterations.') learning_rates, losses = search_learning_rate(trainer, start_lr=start_lr, end_lr=end_lr, num_batches=num_batches, linear_steps=linear_steps, stopping_factor=stopping_factor) logger.info(f'Finished learning rate search.') losses = _smooth(losses, 0.98) _save_plot(learning_rates, losses, os.path.join(serialization_dir, 'lr-losses.png'))
python
def find_learning_rate_model(params: Params, serialization_dir: str, start_lr: float = 1e-5, end_lr: float = 10, num_batches: int = 100, linear_steps: bool = False, stopping_factor: float = None, force: bool = False) -> None: """ Runs learning rate search for given `num_batches` and saves the results in ``serialization_dir`` Parameters ---------- params : ``Params`` A parameter object specifying an AllenNLP Experiment. serialization_dir : ``str`` The directory in which to save results. start_lr: ``float`` Learning rate to start the search. end_lr: ``float`` Learning rate upto which search is done. num_batches: ``int`` Number of mini-batches to run Learning rate finder. linear_steps: ``bool`` Increase learning rate linearly if False exponentially. stopping_factor: ``float`` Stop the search when the current loss exceeds the best loss recorded by multiple of stopping factor. If ``None`` search proceeds till the ``end_lr`` force: ``bool`` If True and the serialization directory already exists, everything in it will be removed prior to finding the learning rate. """ if os.path.exists(serialization_dir) and force: shutil.rmtree(serialization_dir) if os.path.exists(serialization_dir) and os.listdir(serialization_dir): raise ConfigurationError(f'Serialization directory {serialization_dir} already exists and is ' f'not empty.') else: os.makedirs(serialization_dir, exist_ok=True) prepare_environment(params) cuda_device = params.params.get('trainer').get('cuda_device', -1) check_for_gpu(cuda_device) all_datasets = datasets_from_params(params) datasets_for_vocab_creation = set(params.pop("datasets_for_vocab_creation", all_datasets)) for dataset in datasets_for_vocab_creation: if dataset not in all_datasets: raise ConfigurationError(f"invalid 'dataset_for_vocab_creation' {dataset}") logger.info("From dataset instances, %s will be considered for vocabulary creation.", ", ".join(datasets_for_vocab_creation)) vocab = Vocabulary.from_params( params.pop("vocabulary", {}), (instance for key, dataset in all_datasets.items() for instance in dataset if key in datasets_for_vocab_creation) ) model = Model.from_params(vocab=vocab, params=params.pop('model')) iterator = DataIterator.from_params(params.pop("iterator")) iterator.index_with(vocab) train_data = all_datasets['train'] trainer_params = params.pop("trainer") no_grad_regexes = trainer_params.pop("no_grad", ()) for name, parameter in model.named_parameters(): if any(re.search(regex, name) for regex in no_grad_regexes): parameter.requires_grad_(False) trainer_choice = trainer_params.pop("type", "default") if trainer_choice != "default": raise ConfigurationError("currently find-learning-rate only works with the default Trainer") trainer = Trainer.from_params(model=model, serialization_dir=serialization_dir, iterator=iterator, train_data=train_data, validation_data=None, params=trainer_params, validation_iterator=None) logger.info(f'Starting learning rate search from {start_lr} to {end_lr} in {num_batches} iterations.') learning_rates, losses = search_learning_rate(trainer, start_lr=start_lr, end_lr=end_lr, num_batches=num_batches, linear_steps=linear_steps, stopping_factor=stopping_factor) logger.info(f'Finished learning rate search.') losses = _smooth(losses, 0.98) _save_plot(learning_rates, losses, os.path.join(serialization_dir, 'lr-losses.png'))
[ "def", "find_learning_rate_model", "(", "params", ":", "Params", ",", "serialization_dir", ":", "str", ",", "start_lr", ":", "float", "=", "1e-5", ",", "end_lr", ":", "float", "=", "10", ",", "num_batches", ":", "int", "=", "100", ",", "linear_steps", ":", "bool", "=", "False", ",", "stopping_factor", ":", "float", "=", "None", ",", "force", ":", "bool", "=", "False", ")", "->", "None", ":", "if", "os", ".", "path", ".", "exists", "(", "serialization_dir", ")", "and", "force", ":", "shutil", ".", "rmtree", "(", "serialization_dir", ")", "if", "os", ".", "path", ".", "exists", "(", "serialization_dir", ")", "and", "os", ".", "listdir", "(", "serialization_dir", ")", ":", "raise", "ConfigurationError", "(", "f'Serialization directory {serialization_dir} already exists and is '", "f'not empty.'", ")", "else", ":", "os", ".", "makedirs", "(", "serialization_dir", ",", "exist_ok", "=", "True", ")", "prepare_environment", "(", "params", ")", "cuda_device", "=", "params", ".", "params", ".", "get", "(", "'trainer'", ")", ".", "get", "(", "'cuda_device'", ",", "-", "1", ")", "check_for_gpu", "(", "cuda_device", ")", "all_datasets", "=", "datasets_from_params", "(", "params", ")", "datasets_for_vocab_creation", "=", "set", "(", "params", ".", "pop", "(", "\"datasets_for_vocab_creation\"", ",", "all_datasets", ")", ")", "for", "dataset", "in", "datasets_for_vocab_creation", ":", "if", "dataset", "not", "in", "all_datasets", ":", "raise", "ConfigurationError", "(", "f\"invalid 'dataset_for_vocab_creation' {dataset}\"", ")", "logger", ".", "info", "(", "\"From dataset instances, %s will be considered for vocabulary creation.\"", ",", "\", \"", ".", "join", "(", "datasets_for_vocab_creation", ")", ")", "vocab", "=", "Vocabulary", ".", "from_params", "(", "params", ".", "pop", "(", "\"vocabulary\"", ",", "{", "}", ")", ",", "(", "instance", "for", "key", ",", "dataset", "in", "all_datasets", ".", "items", "(", ")", "for", "instance", "in", "dataset", "if", "key", "in", "datasets_for_vocab_creation", ")", ")", "model", "=", "Model", ".", "from_params", "(", "vocab", "=", "vocab", ",", "params", "=", "params", ".", "pop", "(", "'model'", ")", ")", "iterator", "=", "DataIterator", ".", "from_params", "(", "params", ".", "pop", "(", "\"iterator\"", ")", ")", "iterator", ".", "index_with", "(", "vocab", ")", "train_data", "=", "all_datasets", "[", "'train'", "]", "trainer_params", "=", "params", ".", "pop", "(", "\"trainer\"", ")", "no_grad_regexes", "=", "trainer_params", ".", "pop", "(", "\"no_grad\"", ",", "(", ")", ")", "for", "name", ",", "parameter", "in", "model", ".", "named_parameters", "(", ")", ":", "if", "any", "(", "re", ".", "search", "(", "regex", ",", "name", ")", "for", "regex", "in", "no_grad_regexes", ")", ":", "parameter", ".", "requires_grad_", "(", "False", ")", "trainer_choice", "=", "trainer_params", ".", "pop", "(", "\"type\"", ",", "\"default\"", ")", "if", "trainer_choice", "!=", "\"default\"", ":", "raise", "ConfigurationError", "(", "\"currently find-learning-rate only works with the default Trainer\"", ")", "trainer", "=", "Trainer", ".", "from_params", "(", "model", "=", "model", ",", "serialization_dir", "=", "serialization_dir", ",", "iterator", "=", "iterator", ",", "train_data", "=", "train_data", ",", "validation_data", "=", "None", ",", "params", "=", "trainer_params", ",", "validation_iterator", "=", "None", ")", "logger", ".", "info", "(", "f'Starting learning rate search from {start_lr} to {end_lr} in {num_batches} iterations.'", ")", "learning_rates", ",", "losses", "=", "search_learning_rate", "(", "trainer", ",", "start_lr", "=", "start_lr", ",", "end_lr", "=", "end_lr", ",", "num_batches", "=", "num_batches", ",", "linear_steps", "=", "linear_steps", ",", "stopping_factor", "=", "stopping_factor", ")", "logger", ".", "info", "(", "f'Finished learning rate search.'", ")", "losses", "=", "_smooth", "(", "losses", ",", "0.98", ")", "_save_plot", "(", "learning_rates", ",", "losses", ",", "os", ".", "path", ".", "join", "(", "serialization_dir", ",", "'lr-losses.png'", ")", ")" ]
Runs learning rate search for given `num_batches` and saves the results in ``serialization_dir`` Parameters ---------- params : ``Params`` A parameter object specifying an AllenNLP Experiment. serialization_dir : ``str`` The directory in which to save results. start_lr: ``float`` Learning rate to start the search. end_lr: ``float`` Learning rate upto which search is done. num_batches: ``int`` Number of mini-batches to run Learning rate finder. linear_steps: ``bool`` Increase learning rate linearly if False exponentially. stopping_factor: ``float`` Stop the search when the current loss exceeds the best loss recorded by multiple of stopping factor. If ``None`` search proceeds till the ``end_lr`` force: ``bool`` If True and the serialization directory already exists, everything in it will be removed prior to finding the learning rate.
[ "Runs", "learning", "rate", "search", "for", "given", "num_batches", "and", "saves", "the", "results", "in", "serialization_dir" ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/commands/find_learning_rate.py#L134-L229
train
Searches for a learning rate model in the given serialization directory.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ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,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1531 - 1483) + '\x6f' + '\x31' + '\065' + chr(0b11011 + 0o25), 61426 - 61418), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + '\x32' + chr(0b10110 + 0o35), 39518 - 39510), ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\x6f' + chr(0b110011) + chr(0b100100 + 0o16) + chr(2117 - 2065), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x33' + '\067' + chr(0b1000 + 0o53), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1010000 + 0o37) + chr(0b110011) + '\x34' + chr(0b110000), 14036 - 14028), ehT0Px3KOsy9(chr(1906 - 1858) + chr(5968 - 5857) + chr(0b110011) + '\x32' + chr(0b111 + 0o54), 8), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1001100 + 0o43) + '\x32' + chr(0b1000 + 0o57) + chr(51), 0o10), ehT0Px3KOsy9(chr(364 - 316) + chr(0b1101111) + chr(51) + chr(1393 - 1343) + '\063', 8), ehT0Px3KOsy9(chr(1501 - 1453) + chr(0b111111 + 0o60) + chr(0b110001) + chr(427 - 376) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1010110 + 0o31) + chr(0b1 + 0o66) + chr(54), 0b1000), ehT0Px3KOsy9(chr(616 - 568) + chr(111) + chr(1256 - 1206) + chr(0b110111) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(111) + chr(49) + chr(0b110010) + chr(51), 0b1000), ehT0Px3KOsy9(chr(990 - 942) + '\x6f' + chr(510 - 460) + '\x31' + chr(1372 - 1324), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b111 + 0o54) + chr(0b1010 + 0o51), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(2080 - 2029) + chr(0b110101) + chr(0b110011), 46215 - 46207), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + chr(55) + '\062', 41813 - 41805), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\065' + chr(0b10 + 0o62), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(2479 - 2368) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(0b1101111) + chr(55) + chr(0b110100), 12607 - 12599), ehT0Px3KOsy9('\060' + chr(0b111011 + 0o64) + '\x33' + chr(1804 - 1756), 0b1000), ehT0Px3KOsy9(chr(1161 - 1113) + chr(111) + '\061' + chr(143 - 88) + chr(0b101001 + 0o15), 36538 - 36530), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\x6f' + chr(0b110011) + chr(0b110000) + chr(48), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011010 + 0o25) + chr(51) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + chr(0b101110 + 0o4), 749 - 741), ehT0Px3KOsy9('\060' + chr(7523 - 7412) + chr(0b110001) + '\x36' + '\x34', 18119 - 18111), ehT0Px3KOsy9(chr(2206 - 2158) + chr(111) + chr(0b1 + 0o62) + chr(0b110101) + chr(818 - 768), 7458 - 7450), ehT0Px3KOsy9(chr(2206 - 2158) + '\x6f' + chr(1938 - 1889) + chr(0b100101 + 0o22) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + '\061' + chr(54), 49723 - 49715), ehT0Px3KOsy9(chr(48) + chr(2176 - 2065) + chr(0b101001 + 0o12) + chr(54) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(1408 - 1360) + '\157' + chr(71 - 22) + chr(0b1100 + 0o52) + chr(690 - 639), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011010 + 0o25) + chr(0b11011 + 0o27) + chr(0b1 + 0o66) + chr(53), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b10111 + 0o130) + '\061' + '\063' + chr(0b11001 + 0o35), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + '\x34' + chr(1057 - 1004), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(0b11101 + 0o31) + '\x34', 0o10), ehT0Px3KOsy9(chr(48) + chr(506 - 395) + chr(1917 - 1867) + chr(0b110100) + chr(0b100001 + 0o25), 55319 - 55311), ehT0Px3KOsy9(chr(2289 - 2241) + chr(12166 - 12055) + '\x32' + chr(0b110101) + chr(0b100010 + 0o16), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + chr(50) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\x6f' + '\063' + chr(0b111 + 0o57) + chr(0b101001 + 0o12), 0b1000), ehT0Px3KOsy9('\060' + chr(3040 - 2929) + '\x33' + chr(54) + chr(1476 - 1426), 0o10), ehT0Px3KOsy9('\060' + chr(2408 - 2297) + chr(1813 - 1762) + chr(54) + chr(0b100100 + 0o17), 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b1010100 + 0o33) + '\x35' + chr(48), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'F'), chr(0b1100100) + chr(101) + chr(99) + chr(0b10100 + 0o133) + chr(0b1100100) + chr(2253 - 2152))(chr(2378 - 2261) + chr(116) + '\x66' + chr(520 - 475) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def Mm8PIzEblYb_(nEbJZ4wfte2w, _NgEteHO5j9h, _cNvcHzqrk8H=1e-05, ofcM5qofdI_X=ehT0Px3KOsy9(chr(0b111 + 0o51) + '\x6f' + '\061' + '\062', 8), ISOsXl5B284v=ehT0Px3KOsy9(chr(48) + chr(6742 - 6631) + chr(49) + chr(0b101011 + 0o11) + '\064', 0o10), bH1Z5KrrdtVU=ehT0Px3KOsy9('\060' + chr(0b1000001 + 0o56) + chr(48), 20966 - 20958), BBZJFBkWNf0Q=None, oUXpZkWkSgMi=ehT0Px3KOsy9('\x30' + chr(0b10001 + 0o136) + chr(48), 8)) -> None: if xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\r\xab\xbd\x88\x94\xa0'), chr(8353 - 8253) + chr(0b10110 + 0o117) + chr(0b110101 + 0o56) + chr(2979 - 2868) + chr(3162 - 3062) + chr(101))('\x75' + chr(0b1110100) + chr(0b1100110) + chr(0b101101) + chr(0b111000)))(_NgEteHO5j9h) and oUXpZkWkSgMi: xafqLlk3kkUe(DSLq_IS6e6IX, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1a\xbe\xa0\x89\x85\xb6'), '\x64' + '\145' + '\x63' + chr(0b1101111) + chr(1631 - 1531) + chr(0b1100101))(chr(0b1101111 + 0o6) + '\164' + '\x66' + chr(639 - 594) + chr(0b10010 + 0o46)))(_NgEteHO5j9h) if xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\r\xab\xbd\x88\x94\xa0'), chr(100) + '\x65' + chr(99) + chr(111) + chr(0b1100100) + '\x65')(chr(0b10000 + 0o145) + chr(0b1111 + 0o145) + chr(0b1100110) + '\055' + chr(0b111000)))(_NgEteHO5j9h) and xafqLlk3kkUe(oqhJDdMJfuwx, xafqLlk3kkUe(SXOLrMavuUCe(b'\x04\xba\xa7\x8f\x84\xba\xc9'), chr(0b1100100) + chr(0b1100101) + '\x63' + chr(0b1101111) + chr(0b1000010 + 0o42) + '\x65')('\x75' + chr(0b1010110 + 0o36) + chr(0b1001100 + 0o32) + chr(0b100000 + 0o15) + chr(0b10010 + 0o46)))(_NgEteHO5j9h): raise h0iXqtiKVeKg(f'Serialization directory {_NgEteHO5j9h} already exists and is not empty.') else: xafqLlk3kkUe(oqhJDdMJfuwx, xafqLlk3kkUe(SXOLrMavuUCe(b'\x05\xb2\xbf\x9e\x84\xba\xc9\xa0'), '\144' + '\x65' + '\143' + chr(6154 - 6043) + chr(0b1100100) + '\145')('\165' + chr(116) + '\x66' + chr(0b1011 + 0o42) + chr(56)))(_NgEteHO5j9h, exist_ok=ehT0Px3KOsy9(chr(1424 - 1376) + chr(4721 - 4610) + '\x31', ord("\x08"))) WkKBR4DrlKb3(nEbJZ4wfte2w) jRcTRdiVAZAp = nEbJZ4wfte2w.params.get(xafqLlk3kkUe(SXOLrMavuUCe(b'\x1c\xa1\xb5\x92\x8e\xb6\xc9'), chr(1193 - 1093) + chr(0b1100101) + chr(99) + chr(0b1101111) + chr(0b1100100) + chr(5016 - 4915))('\165' + chr(0b1110100) + chr(0b11 + 0o143) + '\x2d' + '\070')).get(xafqLlk3kkUe(SXOLrMavuUCe(b'\x0b\xa6\xb0\x9a\xbf\xb7\xde\xa50]\xdb'), chr(5912 - 5812) + '\x65' + '\143' + chr(0b1000 + 0o147) + '\x64' + chr(1945 - 1844))('\165' + chr(116) + '\x66' + chr(0b101101) + chr(0b111000)), -ehT0Px3KOsy9(chr(48) + chr(9259 - 9148) + chr(0b110001), 8)) Cmvt9vJLE4EJ(jRcTRdiVAZAp) EffmrrViDbv5 = JZszfM8OZgGW(nEbJZ4wfte2w) ch47TDo1bHtA = MVEN8G6CxlvR(nEbJZ4wfte2w.pop(xafqLlk3kkUe(SXOLrMavuUCe(b'\x0c\xb2\xa0\x9a\x93\xb6\xcf\xa0\x06X\xd1!\xd7m\x84\x99Mdc{\x0c\xa5{~\x1d\x85\x11'), chr(0b111111 + 0o45) + chr(4253 - 4152) + chr(99) + '\157' + chr(7773 - 7673) + chr(101))('\165' + chr(0b1100 + 0o150) + chr(0b1100110) + chr(45) + '\x38'), EffmrrViDbv5)) for xQt6gV9VfTO3 in ch47TDo1bHtA: if xQt6gV9VfTO3 not in EffmrrViDbv5: raise h0iXqtiKVeKg(f"invalid 'dataset_for_vocab_creation' {xQt6gV9VfTO3}") xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b';\xe4\x9c\x83\x95\xb0\xdc\xe43R\xe48'), '\144' + chr(0b1100101) + chr(0b1100011) + chr(583 - 472) + '\144' + chr(0b10100 + 0o121))(chr(8458 - 8341) + chr(0b10110 + 0o136) + chr(1256 - 1154) + chr(0b101 + 0o50) + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b".\xa1\xbb\x96\xc0\xb7\xda\xa78M\xdb'\xa8r\x85\x89XgR{\x1b\xb36*Q\x99_\xb9\x9d\x1f\xd1~\xc7\xd1\x86\xcb\xbd\x9d\x81\x9a\x0c\xb6\xa6\x9e\x84\xf3\xdd\xbc+\x1e\xc8<\xebz\x89\x8f@gNa^\xa3ho\x15\x9e\x16\xa1\x9a]"), chr(0b1100100) + chr(101) + chr(0b110010 + 0o61) + chr(111) + '\x64' + '\145')(chr(117) + chr(363 - 247) + chr(102) + chr(0b101101) + chr(56)), xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'D\xf3'), '\x64' + '\x65' + chr(0b11001 + 0o112) + chr(10733 - 10622) + chr(9720 - 9620) + '\x65')(chr(0b100011 + 0o122) + chr(1701 - 1585) + chr(0b1100110) + chr(0b101101) + chr(1599 - 1543)), xafqLlk3kkUe(SXOLrMavuUCe(b'7\xbc\x83\xa3\x9a\xa7\xed\x9d7O\xf6\x15'), chr(0b101100 + 0o70) + chr(0b1100101) + chr(99) + '\x6f' + chr(100) + chr(0b0 + 0o145))(chr(0b10111 + 0o136) + chr(116) + '\146' + chr(834 - 789) + chr(56)))(ch47TDo1bHtA)) mSU6gEqYPk2T = IAZQXc71OGTl.from_params(nEbJZ4wfte2w.pop(xafqLlk3kkUe(SXOLrMavuUCe(b'\x1e\xbc\xb7\x9a\x82\xa6\xd7\xb2+G'), chr(100) + '\145' + chr(0b1011100 + 0o7) + '\x6f' + chr(0b110011 + 0o61) + chr(0b1010 + 0o133))(chr(2608 - 2491) + chr(0b1110100) + chr(0b1100110) + '\x2d' + chr(56)), {}), (SsX6bRqJdu1L for (K3J4ZwSlE0sT, xQt6gV9VfTO3) in EffmrrViDbv5.NzveIZ3IlSH9() for SsX6bRqJdu1L in xQt6gV9VfTO3 if K3J4ZwSlE0sT in ch47TDo1bHtA)) FK0vqzZ5gPN6 = JC8lDcRGu6X6.from_params(vocab=mSU6gEqYPk2T, params=nEbJZ4wfte2w.pop(xafqLlk3kkUe(SXOLrMavuUCe(b'\x05\xbc\xb0\x9e\x8c'), chr(0b1010001 + 0o23) + '\x65' + chr(0b1100011) + chr(12262 - 12151) + chr(100) + chr(0b110011 + 0o62))(chr(0b1110101) + chr(11891 - 11775) + '\x66' + '\x2d' + chr(0b111000)))) qS80gn7HOKhx = xhi4BHbLZKGU.from_params(nEbJZ4wfte2w.pop(xafqLlk3kkUe(SXOLrMavuUCe(b'\x01\xa7\xb1\x89\x81\xa7\xd4\xa1'), '\x64' + chr(101) + '\x63' + chr(0b100100 + 0o113) + '\144' + chr(0b1100101))(chr(6841 - 6724) + chr(0b1100100 + 0o20) + chr(102) + chr(0b101101) + '\070'))) xafqLlk3kkUe(qS80gn7HOKhx, xafqLlk3kkUe(SXOLrMavuUCe(b'\x01\xbd\xb0\x9e\x98\x8c\xcc\xba-V'), '\x64' + chr(101) + chr(99) + '\x6f' + '\x64' + chr(101))(chr(6434 - 6317) + chr(3144 - 3028) + chr(102) + '\x2d' + '\x38'))(mSU6gEqYPk2T) sW8AagBcZuuj = EffmrrViDbv5[xafqLlk3kkUe(SXOLrMavuUCe(b'\x1c\xa1\xb5\x92\x8e'), chr(2540 - 2440) + chr(0b1100101) + '\143' + chr(111) + chr(0b1100100) + chr(0b0 + 0o145))('\165' + chr(116) + chr(0b1100110) + chr(0b1 + 0o54) + chr(0b111000))] dnfJsjo9J7vN = nEbJZ4wfte2w.pop(xafqLlk3kkUe(SXOLrMavuUCe(b'\x1c\xa1\xb5\x92\x8e\xb6\xc9'), chr(100) + chr(0b1100101) + chr(8507 - 8408) + chr(0b1101111) + chr(0b1100100) + chr(6331 - 6230))('\165' + chr(0b101110 + 0o106) + '\x66' + '\x2d' + chr(382 - 326))) XFIgRrnHXXjt = dnfJsjo9J7vN.pop(xafqLlk3kkUe(SXOLrMavuUCe(b'\x06\xbc\x8b\x9c\x92\xb2\xdf'), chr(0b1100100) + '\x65' + '\143' + chr(0b1101111) + chr(6048 - 5948) + '\145')(chr(0b111110 + 0o67) + '\164' + chr(4186 - 4084) + chr(0b10110 + 0o27) + chr(0b110 + 0o62)), ()) for (AIvJRzLdDfgF, Sur8CJUVRGCp) in xafqLlk3kkUe(FK0vqzZ5gPN6, xafqLlk3kkUe(SXOLrMavuUCe(b'\x06\xb2\xb9\x9e\x84\x8c\xcb\xb2+_\xd36\xfc~\x99\x89'), '\x64' + chr(0b10011 + 0o122) + chr(99) + chr(11421 - 11310) + chr(100) + chr(0b101110 + 0o67))('\x75' + '\164' + chr(0b1100110) + '\x2d' + chr(56)))(): if UVSi4XW7eBIM((xafqLlk3kkUe(_7u55U49WwX2, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1b\xb6\xb5\x89\x83\xbb'), chr(100) + chr(0b1100101) + '\143' + chr(111) + chr(100) + '\x65')(chr(117) + chr(0b1110100) + chr(0b1000001 + 0o45) + chr(0b101101) + chr(98 - 42)))(nOkNRy7CeY4l, AIvJRzLdDfgF) for nOkNRy7CeY4l in XFIgRrnHXXjt)): xafqLlk3kkUe(Sur8CJUVRGCp, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1a\xb6\xa5\x8e\x89\xa1\xde\xa0\x06Y\xcc2\xecD'), chr(0b1100100) + '\145' + '\x63' + '\157' + chr(0b1001011 + 0o31) + chr(0b11 + 0o142))(chr(117) + '\164' + '\146' + chr(45) + chr(56)))(ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b1111 + 0o41), 8)) OnPgCayDHoh9 = dnfJsjo9J7vN.pop(xafqLlk3kkUe(SXOLrMavuUCe(b'\x1c\xaa\xa4\x9e'), chr(6455 - 6355) + '\x65' + '\x63' + chr(0b1010 + 0o145) + chr(100) + '\x65')(chr(117) + chr(0b1101011 + 0o11) + chr(102) + chr(0b10001 + 0o34) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x0c\xb6\xb2\x9a\x95\xbf\xcf'), chr(0b1100100) + chr(6688 - 6587) + chr(0b1100011) + '\157' + '\x64' + chr(2765 - 2664))(chr(0b1000000 + 0o65) + chr(2201 - 2085) + chr(0b1100110) + '\055' + chr(1920 - 1864))) if OnPgCayDHoh9 != xafqLlk3kkUe(SXOLrMavuUCe(b'\x0c\xb6\xb2\x9a\x95\xbf\xcf'), chr(3638 - 3538) + chr(101) + '\143' + chr(111) + chr(2105 - 2005) + '\x65')(chr(9532 - 9415) + chr(5032 - 4916) + chr(0b11100 + 0o112) + '\x2d' + chr(2114 - 2058)): raise h0iXqtiKVeKg(xafqLlk3kkUe(SXOLrMavuUCe(b"\x0b\xa6\xa6\x89\x85\xbd\xcf\xbf \x1e\xd8:\xe6\x7f\xc6\x96IgNv\x17\xae}'\x06\x8b\x0b\xab\xd4\x1c\xd32\xdc\x94\xd1\xc7\xa0\x98\x81\xd3\x1f\xba\xa0\x93\xc0\xa7\xd3\xb6yZ\xdb5\xe9n\x87\x8e\x0cRNy\x17\xae\x7fx"), chr(4847 - 4747) + '\x65' + chr(99) + chr(0b1 + 0o156) + '\x64' + chr(0b1001 + 0o134))(chr(0b1011101 + 0o30) + chr(0b1101110 + 0o6) + chr(0b1100110) + chr(0b11 + 0o52) + chr(3076 - 3020))) ehTF8dweL_Oo = hZriZHGNaIGA.from_params(model=FK0vqzZ5gPN6, serialization_dir=_NgEteHO5j9h, iterator=qS80gn7HOKhx, train_data=sW8AagBcZuuj, validation_data=None, params=dnfJsjo9J7vN, validation_iterator=None) xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b';\xe4\x9c\x83\x95\xb0\xdc\xe43R\xe48'), '\144' + chr(0b1100101) + chr(5245 - 5146) + '\x6f' + chr(0b1100100) + '\x65')(chr(117) + chr(0b1110100) + chr(102) + chr(0b101101) + chr(0b101110 + 0o12)))(f'Starting learning rate search from {_cNvcHzqrk8H} to {ofcM5qofdI_X} in {ISOsXl5B284v} iterations.') (wGSMhE9DB7dV, eJKWkHA7qzlZ) = yLvt5aEG7cij(ehTF8dweL_Oo, start_lr=_cNvcHzqrk8H, end_lr=ofcM5qofdI_X, num_batches=ISOsXl5B284v, linear_steps=bH1Z5KrrdtVU, stopping_factor=BBZJFBkWNf0Q) xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b';\xe4\x9c\x83\x95\xb0\xdc\xe43R\xe48'), chr(100) + chr(0b1100101) + '\x63' + chr(4139 - 4028) + chr(0b1001001 + 0o33) + chr(3958 - 3857))(chr(0b1101001 + 0o14) + '\164' + chr(102) + '\x2d' + '\x38'))(fchr(0b1000100 + 0o2) + chr(105) + chr(0b1101110) + chr(0b100 + 0o145) + chr(115) + chr(0b1001111 + 0o31) + chr(101) + chr(100) + chr(0b100000) + chr(0b1010011 + 0o31) + chr(6403 - 6302) + chr(0b1011001 + 0o10) + chr(6023 - 5909) + chr(110) + chr(0b1101001) + chr(0b1000110 + 0o50) + chr(0b1011111 + 0o10) + chr(0b100000) + chr(0b110010 + 0o100) + chr(0b1100001) + chr(116) + chr(218 - 117) + chr(0b100000) + chr(11509 - 11394) + chr(0b100011 + 0o102) + chr(0b10 + 0o137) + chr(0b100001 + 0o121) + chr(0b1010110 + 0o15) + chr(104) + chr(0b110 + 0o50)) eJKWkHA7qzlZ = PHBetMdASuIr(eJKWkHA7qzlZ, 0.98) p9_yuqborh7F(wGSMhE9DB7dV, eJKWkHA7qzlZ, xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'7\xbc\x83\xa3\x9a\xa7\xed\x9d7O\xf6\x15'), chr(100) + '\x65' + chr(270 - 171) + chr(0b1101111) + chr(0b1100100) + '\145')('\x75' + '\x74' + '\x66' + chr(0b101101) + chr(0b10000 + 0o50)))(_NgEteHO5j9h, xafqLlk3kkUe(SXOLrMavuUCe(b'\x04\xa1\xf9\x97\x8f\xa0\xc8\xb6*\x10\xce=\xef'), '\x64' + chr(0b10111 + 0o116) + chr(0b1100011) + chr(0b1001100 + 0o43) + '\x64' + '\x65')(chr(12214 - 12097) + chr(0b110111 + 0o75) + chr(102) + chr(0b101101) + chr(56))))
allenai/allennlp
allennlp/commands/find_learning_rate.py
search_learning_rate
def search_learning_rate(trainer: Trainer, start_lr: float = 1e-5, end_lr: float = 10, num_batches: int = 100, linear_steps: bool = False, stopping_factor: float = None) -> Tuple[List[float], List[float]]: """ Runs training loop on the model using :class:`~allennlp.training.trainer.Trainer` increasing learning rate from ``start_lr`` to ``end_lr`` recording the losses. Parameters ---------- trainer: :class:`~allennlp.training.trainer.Trainer` start_lr: ``float`` The learning rate to start the search. end_lr: ``float`` The learning rate upto which search is done. num_batches: ``int`` Number of batches to run the learning rate finder. linear_steps: ``bool`` Increase learning rate linearly if False exponentially. stopping_factor: ``float`` Stop the search when the current loss exceeds the best loss recorded by multiple of stopping factor. If ``None`` search proceeds till the ``end_lr`` Returns ------- (learning_rates, losses): ``Tuple[List[float], List[float]]`` Returns list of learning rates and corresponding losses. Note: The losses are recorded before applying the corresponding learning rate """ if num_batches <= 10: raise ConfigurationError('The number of iterations for learning rate finder should be greater than 10.') trainer.model.train() num_gpus = len(trainer._cuda_devices) # pylint: disable=protected-access raw_train_generator = trainer.iterator(trainer.train_data, shuffle=trainer.shuffle) train_generator = lazy_groups_of(raw_train_generator, num_gpus) train_generator_tqdm = Tqdm.tqdm(train_generator, total=num_batches) learning_rates = [] losses = [] best = 1e9 if linear_steps: lr_update_factor = (end_lr - start_lr) / num_batches else: lr_update_factor = (end_lr / start_lr) ** (1.0 / num_batches) for i, batch_group in enumerate(train_generator_tqdm): if linear_steps: current_lr = start_lr + (lr_update_factor * i) else: current_lr = start_lr * (lr_update_factor ** i) for param_group in trainer.optimizer.param_groups: param_group['lr'] = current_lr trainer.optimizer.zero_grad() loss = trainer.batch_loss(batch_group, for_training=True) loss.backward() loss = loss.detach().cpu().item() if stopping_factor is not None and (math.isnan(loss) or loss > stopping_factor * best): logger.info(f'Loss ({loss}) exceeds stopping_factor * lowest recorded loss.') break trainer.rescale_gradients() trainer.optimizer.step() learning_rates.append(current_lr) losses.append(loss) if loss < best and i > 10: best = loss if i == num_batches: break return learning_rates, losses
python
def search_learning_rate(trainer: Trainer, start_lr: float = 1e-5, end_lr: float = 10, num_batches: int = 100, linear_steps: bool = False, stopping_factor: float = None) -> Tuple[List[float], List[float]]: """ Runs training loop on the model using :class:`~allennlp.training.trainer.Trainer` increasing learning rate from ``start_lr`` to ``end_lr`` recording the losses. Parameters ---------- trainer: :class:`~allennlp.training.trainer.Trainer` start_lr: ``float`` The learning rate to start the search. end_lr: ``float`` The learning rate upto which search is done. num_batches: ``int`` Number of batches to run the learning rate finder. linear_steps: ``bool`` Increase learning rate linearly if False exponentially. stopping_factor: ``float`` Stop the search when the current loss exceeds the best loss recorded by multiple of stopping factor. If ``None`` search proceeds till the ``end_lr`` Returns ------- (learning_rates, losses): ``Tuple[List[float], List[float]]`` Returns list of learning rates and corresponding losses. Note: The losses are recorded before applying the corresponding learning rate """ if num_batches <= 10: raise ConfigurationError('The number of iterations for learning rate finder should be greater than 10.') trainer.model.train() num_gpus = len(trainer._cuda_devices) # pylint: disable=protected-access raw_train_generator = trainer.iterator(trainer.train_data, shuffle=trainer.shuffle) train_generator = lazy_groups_of(raw_train_generator, num_gpus) train_generator_tqdm = Tqdm.tqdm(train_generator, total=num_batches) learning_rates = [] losses = [] best = 1e9 if linear_steps: lr_update_factor = (end_lr - start_lr) / num_batches else: lr_update_factor = (end_lr / start_lr) ** (1.0 / num_batches) for i, batch_group in enumerate(train_generator_tqdm): if linear_steps: current_lr = start_lr + (lr_update_factor * i) else: current_lr = start_lr * (lr_update_factor ** i) for param_group in trainer.optimizer.param_groups: param_group['lr'] = current_lr trainer.optimizer.zero_grad() loss = trainer.batch_loss(batch_group, for_training=True) loss.backward() loss = loss.detach().cpu().item() if stopping_factor is not None and (math.isnan(loss) or loss > stopping_factor * best): logger.info(f'Loss ({loss}) exceeds stopping_factor * lowest recorded loss.') break trainer.rescale_gradients() trainer.optimizer.step() learning_rates.append(current_lr) losses.append(loss) if loss < best and i > 10: best = loss if i == num_batches: break return learning_rates, losses
[ "def", "search_learning_rate", "(", "trainer", ":", "Trainer", ",", "start_lr", ":", "float", "=", "1e-5", ",", "end_lr", ":", "float", "=", "10", ",", "num_batches", ":", "int", "=", "100", ",", "linear_steps", ":", "bool", "=", "False", ",", "stopping_factor", ":", "float", "=", "None", ")", "->", "Tuple", "[", "List", "[", "float", "]", ",", "List", "[", "float", "]", "]", ":", "if", "num_batches", "<=", "10", ":", "raise", "ConfigurationError", "(", "'The number of iterations for learning rate finder should be greater than 10.'", ")", "trainer", ".", "model", ".", "train", "(", ")", "num_gpus", "=", "len", "(", "trainer", ".", "_cuda_devices", ")", "# pylint: disable=protected-access", "raw_train_generator", "=", "trainer", ".", "iterator", "(", "trainer", ".", "train_data", ",", "shuffle", "=", "trainer", ".", "shuffle", ")", "train_generator", "=", "lazy_groups_of", "(", "raw_train_generator", ",", "num_gpus", ")", "train_generator_tqdm", "=", "Tqdm", ".", "tqdm", "(", "train_generator", ",", "total", "=", "num_batches", ")", "learning_rates", "=", "[", "]", "losses", "=", "[", "]", "best", "=", "1e9", "if", "linear_steps", ":", "lr_update_factor", "=", "(", "end_lr", "-", "start_lr", ")", "/", "num_batches", "else", ":", "lr_update_factor", "=", "(", "end_lr", "/", "start_lr", ")", "**", "(", "1.0", "/", "num_batches", ")", "for", "i", ",", "batch_group", "in", "enumerate", "(", "train_generator_tqdm", ")", ":", "if", "linear_steps", ":", "current_lr", "=", "start_lr", "+", "(", "lr_update_factor", "*", "i", ")", "else", ":", "current_lr", "=", "start_lr", "*", "(", "lr_update_factor", "**", "i", ")", "for", "param_group", "in", "trainer", ".", "optimizer", ".", "param_groups", ":", "param_group", "[", "'lr'", "]", "=", "current_lr", "trainer", ".", "optimizer", ".", "zero_grad", "(", ")", "loss", "=", "trainer", ".", "batch_loss", "(", "batch_group", ",", "for_training", "=", "True", ")", "loss", ".", "backward", "(", ")", "loss", "=", "loss", ".", "detach", "(", ")", ".", "cpu", "(", ")", ".", "item", "(", ")", "if", "stopping_factor", "is", "not", "None", "and", "(", "math", ".", "isnan", "(", "loss", ")", "or", "loss", ">", "stopping_factor", "*", "best", ")", ":", "logger", ".", "info", "(", "f'Loss ({loss}) exceeds stopping_factor * lowest recorded loss.'", ")", "break", "trainer", ".", "rescale_gradients", "(", ")", "trainer", ".", "optimizer", ".", "step", "(", ")", "learning_rates", ".", "append", "(", "current_lr", ")", "losses", ".", "append", "(", "loss", ")", "if", "loss", "<", "best", "and", "i", ">", "10", ":", "best", "=", "loss", "if", "i", "==", "num_batches", ":", "break", "return", "learning_rates", ",", "losses" ]
Runs training loop on the model using :class:`~allennlp.training.trainer.Trainer` increasing learning rate from ``start_lr`` to ``end_lr`` recording the losses. Parameters ---------- trainer: :class:`~allennlp.training.trainer.Trainer` start_lr: ``float`` The learning rate to start the search. end_lr: ``float`` The learning rate upto which search is done. num_batches: ``int`` Number of batches to run the learning rate finder. linear_steps: ``bool`` Increase learning rate linearly if False exponentially. stopping_factor: ``float`` Stop the search when the current loss exceeds the best loss recorded by multiple of stopping factor. If ``None`` search proceeds till the ``end_lr`` Returns ------- (learning_rates, losses): ``Tuple[List[float], List[float]]`` Returns list of learning rates and corresponding losses. Note: The losses are recorded before applying the corresponding learning rate
[ "Runs", "training", "loop", "on", "the", "model", "using", ":", "class", ":", "~allennlp", ".", "training", ".", "trainer", ".", "Trainer", "increasing", "learning", "rate", "from", "start_lr", "to", "end_lr", "recording", "the", "losses", ".", "Parameters", "----------", "trainer", ":", ":", "class", ":", "~allennlp", ".", "training", ".", "trainer", ".", "Trainer", "start_lr", ":", "float", "The", "learning", "rate", "to", "start", "the", "search", ".", "end_lr", ":", "float", "The", "learning", "rate", "upto", "which", "search", "is", "done", ".", "num_batches", ":", "int", "Number", "of", "batches", "to", "run", "the", "learning", "rate", "finder", ".", "linear_steps", ":", "bool", "Increase", "learning", "rate", "linearly", "if", "False", "exponentially", ".", "stopping_factor", ":", "float", "Stop", "the", "search", "when", "the", "current", "loss", "exceeds", "the", "best", "loss", "recorded", "by", "multiple", "of", "stopping", "factor", ".", "If", "None", "search", "proceeds", "till", "the", "end_lr", "Returns", "-------", "(", "learning_rates", "losses", ")", ":", "Tuple", "[", "List", "[", "float", "]", "List", "[", "float", "]]", "Returns", "list", "of", "learning", "rates", "and", "corresponding", "losses", ".", "Note", ":", "The", "losses", "are", "recorded", "before", "applying", "the", "corresponding", "learning", "rate" ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/commands/find_learning_rate.py#L231-L312
train
Search the learning rate finder.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3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,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + chr(0b101001 + 0o15) + chr(0b110010), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + chr(53) + chr(1092 - 1043), 0o10), ehT0Px3KOsy9(chr(118 - 70) + '\x6f' + chr(2536 - 2483) + '\x37', 0b1000), ehT0Px3KOsy9(chr(1408 - 1360) + chr(0b100001 + 0o116) + chr(0b101000 + 0o12) + '\x32' + chr(0b110101), 46601 - 46593), ehT0Px3KOsy9(chr(0b110000) + chr(0b101011 + 0o104) + '\061' + chr(1139 - 1086) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(730 - 619) + chr(0b110001) + chr(1522 - 1472) + '\x37', 52060 - 52052), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(817 - 765) + '\067', 37899 - 37891), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + '\065' + chr(365 - 314), 10217 - 10209), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b100 + 0o153) + chr(0b10110 + 0o34) + chr(52) + chr(1827 - 1778), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + chr(0b10010 + 0o36) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b0 + 0o60) + '\x6f' + chr(0b110001) + chr(1399 - 1350) + chr(48), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(51) + '\x34' + chr(0b11000 + 0o36), 0o10), ehT0Px3KOsy9('\x30' + chr(11512 - 11401) + chr(310 - 261) + chr(0b101 + 0o57) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + '\x30' + chr(0b11100 + 0o24), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b101101 + 0o6) + chr(0b10001 + 0o37) + chr(2488 - 2437), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(2216 - 2167) + chr(0b10000 + 0o44), 47581 - 47573), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b11111 + 0o120) + '\064', 0o10), ehT0Px3KOsy9(chr(2233 - 2185) + chr(4438 - 4327) + '\x31' + '\061' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(4671 - 4560) + chr(0b110 + 0o53) + chr(0b110111) + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\x6f' + '\x31' + '\064' + '\x30', 34330 - 34322), ehT0Px3KOsy9(chr(1638 - 1590) + '\157' + chr(1337 - 1287), 52957 - 52949), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b101000 + 0o13) + chr(0b110101) + '\x31', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(49) + chr(49) + chr(48), 8), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(6472 - 6361) + '\x37' + chr(2440 - 2388), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(3419 - 3308) + chr(49) + '\067' + chr(899 - 849), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1000111 + 0o50) + '\x32' + '\061' + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(2129 - 2076) + chr(0b110111), 44404 - 44396), ehT0Px3KOsy9(chr(48) + chr(3612 - 3501) + '\x32' + chr(726 - 678) + '\x32', 0b1000), ehT0Px3KOsy9('\060' + chr(0b111000 + 0o67) + '\x32' + chr(0b111 + 0o51) + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\157' + chr(54) + chr(0b1100 + 0o47), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + '\x33' + chr(51), 43317 - 43309), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b100010 + 0o20) + chr(1126 - 1075) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1100001 + 0o16) + chr(0b110001) + '\x34' + chr(0b110001), 8), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(3957 - 3846) + chr(0b110001) + '\067' + '\060', 32560 - 32552), ehT0Px3KOsy9(chr(48) + chr(6004 - 5893) + chr(51) + '\065' + '\x33', 54180 - 54172), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1011111 + 0o20) + chr(0b101010 + 0o12) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + chr(0b110010) + chr(1354 - 1303) + chr(0b111 + 0o55), 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(111) + '\063' + chr(1800 - 1748) + chr(0b100110 + 0o21), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + chr(1116 - 1061) + chr(48), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b101110 + 0o4) + '\066' + chr(52), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(111) + chr(53) + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x9c'), chr(0b101101 + 0o67) + '\x65' + chr(0b1100011) + chr(111) + chr(100) + chr(0b1100101))(chr(0b1001001 + 0o54) + '\164' + chr(0b1100110) + chr(0b11011 + 0o22) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def yLvt5aEG7cij(ehTF8dweL_Oo, _cNvcHzqrk8H=1e-05, ofcM5qofdI_X=ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + chr(2355 - 2305), 9325 - 9317), ISOsXl5B284v=ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49) + chr(52) + chr(0b110100), 3047 - 3039), bH1Z5KrrdtVU=ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(0b1101111) + '\060', ord("\x08")), BBZJFBkWNf0Q=None) -> MRK8Uzg2En3D[qRxF7OQ0y39T[kkSX4ccExqw4], qRxF7OQ0y39T[kkSX4ccExqw4]]: if ISOsXl5B284v <= ehT0Px3KOsy9('\060' + chr(0b1011110 + 0o21) + chr(49) + chr(0b110010), 8): raise h0iXqtiKVeKg(xafqLlk3kkUe(SXOLrMavuUCe(b'\xe6\xc1J\xb5\x01"\n\xc9\xc4\xb6h\x89\x07`\xaaxa?\x1f\x14k\x86&OZ\xee\x80\xf0\xa3_\xfe\xff\x13\x16\x82K\xfb\xc7\xca\xd5\xc6\xcc\x0f\xf3\x069\x03\xce\xd3\xe4;\x8e\x0e5\xafh$/\x1b@e\x9b-]\x0e\xed\x9d\xa2\xf7[\xfa\xf0AI\xdb\x0b'), chr(0b1100100) + '\x65' + '\x63' + chr(111) + '\x64' + chr(0b1100101))(chr(0b1110101) + chr(0b1011010 + 0o32) + chr(0b1100110) + '\x2d' + chr(0b100000 + 0o30))) xafqLlk3kkUe(ehTF8dweL_Oo.model, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7\x91\x1f\xf2=>\x08\xe8\xcb\xa0)\x92'), '\x64' + chr(0b1001011 + 0o32) + chr(0b1000011 + 0o40) + chr(111) + '\144' + chr(101))(chr(117) + '\164' + chr(102) + '\055' + '\x38'))() zcNH1ym8cZBx = c2A0yzQpDQB3(ehTF8dweL_Oo._cuda_devices) FtEIiAE6TnOw = ehTF8dweL_Oo.iterator(ehTF8dweL_Oo.train_data, shuffle=ehTF8dweL_Oo.shuffle) mufmXH_BoNJ4 = A7kxV2FuX2_9(FtEIiAE6TnOw, zcNH1ym8cZBx) K7upW6hPCM8G = l5DR0A5LiDJi.tqdm(mufmXH_BoNJ4, total=ISOsXl5B284v) wGSMhE9DB7dV = [] eJKWkHA7qzlZ = [] sNA2io01QetG = 1000000000.0 if bH1Z5KrrdtVU: xzFnmuaodTWn = (ofcM5qofdI_X - _cNvcHzqrk8H) / ISOsXl5B284v else: xzFnmuaodTWn = (ofcM5qofdI_X / _cNvcHzqrk8H) ** (1.0 / ISOsXl5B284v) for (WVxHKyX45z_L, sgPM82g9dq1g) in YlkZvXL8qwsX(K7upW6hPCM8G): if bH1Z5KrrdtVU: qsH7cR0vdCyZ = _cNvcHzqrk8H + xzFnmuaodTWn * WVxHKyX45z_L else: qsH7cR0vdCyZ = _cNvcHzqrk8H * xzFnmuaodTWn ** WVxHKyX45z_L for qRSYTto6pq42 in xafqLlk3kkUe(ehTF8dweL_Oo.optimizer, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc2\xc8]\xf4\x02\x08\x00\xd9\xce\xb18\x95'), chr(0b100110 + 0o76) + chr(0b0 + 0o145) + chr(0b1100011) + chr(0b1010101 + 0o32) + chr(0b10101 + 0o117) + chr(101))(chr(0b1110101) + chr(12345 - 12229) + chr(0b1100110) + '\055' + '\x38')): qRSYTto6pq42[xafqLlk3kkUe(SXOLrMavuUCe(b'\xde\xdb'), chr(100) + chr(7750 - 7649) + '\x63' + chr(0b1101111) + chr(0b1100100) + '\x65')(chr(3581 - 3464) + '\164' + chr(0b111010 + 0o54) + chr(0b101101) + chr(56))] = qsH7cR0vdCyZ xafqLlk3kkUe(ehTF8dweL_Oo.optimizer, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc8\xcc]\xfa00\x15\xca\xc5'), chr(0b1110 + 0o126) + chr(101) + chr(99) + chr(111) + chr(3625 - 3525) + chr(0b1101 + 0o130))(chr(0b1110101) + '\164' + chr(337 - 235) + chr(0b101101) + chr(56)))() YpO0BcZ6fMsf = ehTF8dweL_Oo.batch_loss(sgPM82g9dq1g, for_training=ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1819 - 1770), 44707 - 44699)) xafqLlk3kkUe(YpO0BcZ6fMsf, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0\xc8L\xfe\x186\x15\xcf'), chr(100) + chr(0b100110 + 0o77) + '\143' + chr(0b11100 + 0o123) + chr(7222 - 7122) + chr(1287 - 1186))('\x75' + '\164' + '\x66' + chr(0b101101) + chr(0b101000 + 0o20)))() YpO0BcZ6fMsf = YpO0BcZ6fMsf.detach().cpu().N7j7ePTXzzI0() if BBZJFBkWNf0Q is not None and (xafqLlk3kkUe(yhiZVkosCjBm, xafqLlk3kkUe(SXOLrMavuUCe(b'\xdb\xdaA\xf4\x01'), '\x64' + '\145' + chr(3864 - 3765) + chr(0b1100110 + 0o11) + '\x64' + '\x65')(chr(131 - 14) + chr(0b110011 + 0o101) + '\146' + chr(0b100110 + 0o7) + chr(0b1000 + 0o60)))(YpO0BcZ6fMsf) or YpO0BcZ6fMsf > BBZJFBkWNf0Q * sNA2io01QetG): xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe1\x9eg\xed\x1a4\x00\x9c\xcb\xa8\x12\x8d'), chr(100) + '\x65' + '\x63' + chr(0b10000 + 0o137) + chr(0b1100100) + chr(0b1100101))(chr(8784 - 8667) + '\164' + chr(0b1001 + 0o135) + chr(893 - 848) + chr(0b11010 + 0o36)))(f'Loss ({YpO0BcZ6fMsf}) exceeds stopping_factor * lowest recorded loss.') break xafqLlk3kkUe(ehTF8dweL_Oo, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0\xcc\\\xf6\x0e;\x02\xf4\xc6\xb6)\x82\x08%\xadxw'), chr(967 - 867) + chr(2068 - 1967) + chr(99) + chr(0b101100 + 0o103) + '\x64' + '\145')(chr(0b1011001 + 0o34) + '\x74' + '\146' + chr(0b101100 + 0o1) + '\070'))() xafqLlk3kkUe(ehTF8dweL_Oo.optimizer, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd9\xedZ\xd3\x1c\x16\x0f\xee\xc0\xb0+\xb3'), chr(0b1010011 + 0o21) + chr(0b1100101) + chr(99) + chr(0b101000 + 0o107) + '\144' + chr(0b10100 + 0o121))(chr(0b1110101) + chr(0b1110100) + chr(0b110101 + 0o61) + '\055' + '\070'))() xafqLlk3kkUe(wGSMhE9DB7dV, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd3\xd9_\xf0\x013'), chr(4567 - 4467) + chr(0b1100101) + chr(3507 - 3408) + chr(187 - 76) + chr(0b1100100) + '\x65')(chr(5043 - 4926) + '\x74' + chr(0b1100110) + chr(45) + chr(56)))(qsH7cR0vdCyZ) xafqLlk3kkUe(eJKWkHA7qzlZ, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd3\xd9_\xf0\x013'), chr(877 - 777) + chr(7027 - 6926) + '\x63' + chr(0b101011 + 0o104) + chr(0b1100100) + chr(0b1100101))('\165' + chr(6614 - 6498) + chr(2141 - 2039) + chr(953 - 908) + chr(2103 - 2047)))(YpO0BcZ6fMsf) if YpO0BcZ6fMsf < sNA2io01QetG and WVxHKyX45z_L > ehT0Px3KOsy9('\060' + chr(0b101001 + 0o106) + chr(799 - 750) + chr(366 - 316), 8): sNA2io01QetG = YpO0BcZ6fMsf if WVxHKyX45z_L == ISOsXl5B284v: break return (wGSMhE9DB7dV, eJKWkHA7qzlZ)
allenai/allennlp
allennlp/commands/find_learning_rate.py
_smooth
def _smooth(values: List[float], beta: float) -> List[float]: """ Exponential smoothing of values """ avg_value = 0. smoothed = [] for i, value in enumerate(values): avg_value = beta * avg_value + (1 - beta) * value smoothed.append(avg_value / (1 - beta ** (i + 1))) return smoothed
python
def _smooth(values: List[float], beta: float) -> List[float]: """ Exponential smoothing of values """ avg_value = 0. smoothed = [] for i, value in enumerate(values): avg_value = beta * avg_value + (1 - beta) * value smoothed.append(avg_value / (1 - beta ** (i + 1))) return smoothed
[ "def", "_smooth", "(", "values", ":", "List", "[", "float", "]", ",", "beta", ":", "float", ")", "->", "List", "[", "float", "]", ":", "avg_value", "=", "0.", "smoothed", "=", "[", "]", "for", "i", ",", "value", "in", "enumerate", "(", "values", ")", ":", "avg_value", "=", "beta", "*", "avg_value", "+", "(", "1", "-", "beta", ")", "*", "value", "smoothed", ".", "append", "(", "avg_value", "/", "(", "1", "-", "beta", "**", "(", "i", "+", "1", ")", ")", ")", "return", "smoothed" ]
Exponential smoothing of values
[ "Exponential", "smoothing", "of", "values" ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/commands/find_learning_rate.py#L315-L322
train
Exponential smoothing of values
Pu7Z6IJCgH3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LA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(54) + chr(0b100 + 0o63), 47451 - 47443), ehT0Px3KOsy9(chr(2002 - 1954) + chr(111) + '\x32' + chr(50), 0b1000), ehT0Px3KOsy9(chr(2003 - 1955) + chr(111) + chr(0b1000 + 0o53) + chr(542 - 494), 27794 - 27786), ehT0Px3KOsy9(chr(1168 - 1120) + chr(1592 - 1481) + chr(1193 - 1143) + chr(581 - 528) + chr(0b100000 + 0o27), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + '\061' + chr(0b101010 + 0o10), 610 - 602), ehT0Px3KOsy9('\x30' + chr(8525 - 8414) + chr(49) + '\x32' + '\064', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001), 11926 - 11918), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110110) + chr(0b1101 + 0o45), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(10818 - 10707) + '\x32' + chr(2267 - 2216) + chr(55 - 0), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101011 + 0o4) + '\x31' + chr(54) + chr(0b111 + 0o51), ord("\x08")), ehT0Px3KOsy9(chr(1060 - 1012) + chr(10251 - 10140) + chr(0b1100 + 0o47) + chr(562 - 511) + chr(573 - 521), 0b1000), ehT0Px3KOsy9(chr(48) + chr(10376 - 10265) + '\x32' + '\066' + chr(0b10011 + 0o42), 39525 - 39517), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(53) + chr(0b110011), 27917 - 27909), ehT0Px3KOsy9(chr(1183 - 1135) + '\x6f' + chr(0b110001) + chr(0b110011), 63335 - 63327), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b101110 + 0o101) + '\x31' + '\067' + '\067', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110110) + chr(572 - 517), 0o10), ehT0Px3KOsy9(chr(0b11100 + 0o24) + '\x6f' + chr(0b1011 + 0o47) + chr(50) + chr(515 - 464), 0o10), ehT0Px3KOsy9(chr(48) + chr(9094 - 8983) + chr(655 - 605) + chr(0b110110) + chr(699 - 649), 0o10), ehT0Px3KOsy9(chr(813 - 765) + chr(111) + chr(50) + chr(0b110010) + chr(49), 0o10), ehT0Px3KOsy9(chr(1933 - 1885) + chr(0b101011 + 0o104) + chr(0b111 + 0o54) + '\x31' + chr(0b110000), 0o10), ehT0Px3KOsy9('\x30' + chr(0b111110 + 0o61) + chr(0b110010) + chr(0b101110 + 0o5) + chr(50), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(2348 - 2295) + chr(50), 42345 - 42337), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110 + 0o54) + '\x31' + chr(0b11110 + 0o31), 0o10), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(2075 - 1964) + '\x32' + '\062', 8), ehT0Px3KOsy9(chr(0b110000) + chr(7732 - 7621) + '\061' + chr(0b110111) + chr(1762 - 1708), 0o10), ehT0Px3KOsy9(chr(1913 - 1865) + chr(0b110111 + 0o70) + '\063' + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b1000101 + 0o52) + chr(0b11 + 0o57) + chr(51) + '\063', 20508 - 20500), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1578 - 1525) + chr(1383 - 1328), 12731 - 12723), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(0b1111 + 0o46) + chr(0b101100 + 0o10), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b111 + 0o52) + chr(50) + chr(840 - 788), 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110000 + 0o2) + chr(0b101101 + 0o3) + chr(55), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b101000 + 0o12) + chr(0b110111) + '\x35', 0b1000), ehT0Px3KOsy9('\x30' + chr(7763 - 7652) + chr(49) + chr(128 - 76) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(49) + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b100 + 0o54) + '\x6f' + '\x32' + '\061' + '\063', 58830 - 58822), ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(111) + chr(0b110111) + '\x30', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001 + 0o146) + chr(0b110111) + chr(0b110000), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(50) + chr(50) + chr(55), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(1766 - 1712) + '\060', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101011 + 0o4) + '\x32' + '\060' + '\064', 57252 - 57244)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(3976 - 3865) + '\x35' + chr(48), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd9'), chr(100) + '\x65' + '\143' + chr(0b1101111) + chr(0b1100100) + chr(0b1011 + 0o132))(chr(12455 - 12338) + chr(8397 - 8281) + chr(0b101011 + 0o73) + chr(0b100000 + 0o15) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def PHBetMdASuIr(SPnCNu54H1db, FjcovgoHM1LG) -> qRxF7OQ0y39T[kkSX4ccExqw4]: pyHgcdvMtUu9 = 0.0 RoDjEMKgJEcF = [] for (WVxHKyX45z_L, QmmgWUB13VCJ) in YlkZvXL8qwsX(SPnCNu54H1db): pyHgcdvMtUu9 = FjcovgoHM1LG * pyHgcdvMtUu9 + (ehT0Px3KOsy9(chr(1600 - 1552) + chr(0b1101111) + chr(175 - 126), 8) - FjcovgoHM1LG) * QmmgWUB13VCJ xafqLlk3kkUe(RoDjEMKgJEcF, xafqLlk3kkUe(SXOLrMavuUCe(b'\x96bh\xca\xe40'), '\x64' + '\145' + '\x63' + chr(111) + chr(0b1011100 + 0o10) + chr(3266 - 3165))('\x75' + chr(116) + '\x66' + chr(0b101101) + '\x38'))(pyHgcdvMtUu9 / (ehT0Px3KOsy9(chr(1794 - 1746) + '\x6f' + chr(0b100110 + 0o13), 8) - FjcovgoHM1LG ** (WVxHKyX45z_L + ehT0Px3KOsy9(chr(48) + chr(6696 - 6585) + chr(49), 8)))) return RoDjEMKgJEcF
allenai/allennlp
allennlp/modules/scalar_mix.py
ScalarMix.forward
def forward(self, tensors: List[torch.Tensor], # pylint: disable=arguments-differ mask: torch.Tensor = None) -> torch.Tensor: """ Compute a weighted average of the ``tensors``. The input tensors an be any shape with at least two dimensions, but must all be the same shape. When ``do_layer_norm=True``, the ``mask`` is required input. If the ``tensors`` are dimensioned ``(dim_0, ..., dim_{n-1}, dim_n)``, then the ``mask`` is dimensioned ``(dim_0, ..., dim_{n-1})``, as in the typical case with ``tensors`` of shape ``(batch_size, timesteps, dim)`` and ``mask`` of shape ``(batch_size, timesteps)``. When ``do_layer_norm=False`` the ``mask`` is ignored. """ if len(tensors) != self.mixture_size: raise ConfigurationError("{} tensors were passed, but the module was initialized to " "mix {} tensors.".format(len(tensors), self.mixture_size)) def _do_layer_norm(tensor, broadcast_mask, num_elements_not_masked): tensor_masked = tensor * broadcast_mask mean = torch.sum(tensor_masked) / num_elements_not_masked variance = torch.sum(((tensor_masked - mean) * broadcast_mask)**2) / num_elements_not_masked return (tensor - mean) / torch.sqrt(variance + 1E-12) normed_weights = torch.nn.functional.softmax(torch.cat([parameter for parameter in self.scalar_parameters]), dim=0) normed_weights = torch.split(normed_weights, split_size_or_sections=1) if not self.do_layer_norm: pieces = [] for weight, tensor in zip(normed_weights, tensors): pieces.append(weight * tensor) return self.gamma * sum(pieces) else: mask_float = mask.float() broadcast_mask = mask_float.unsqueeze(-1) input_dim = tensors[0].size(-1) num_elements_not_masked = torch.sum(mask_float) * input_dim pieces = [] for weight, tensor in zip(normed_weights, tensors): pieces.append(weight * _do_layer_norm(tensor, broadcast_mask, num_elements_not_masked)) return self.gamma * sum(pieces)
python
def forward(self, tensors: List[torch.Tensor], # pylint: disable=arguments-differ mask: torch.Tensor = None) -> torch.Tensor: """ Compute a weighted average of the ``tensors``. The input tensors an be any shape with at least two dimensions, but must all be the same shape. When ``do_layer_norm=True``, the ``mask`` is required input. If the ``tensors`` are dimensioned ``(dim_0, ..., dim_{n-1}, dim_n)``, then the ``mask`` is dimensioned ``(dim_0, ..., dim_{n-1})``, as in the typical case with ``tensors`` of shape ``(batch_size, timesteps, dim)`` and ``mask`` of shape ``(batch_size, timesteps)``. When ``do_layer_norm=False`` the ``mask`` is ignored. """ if len(tensors) != self.mixture_size: raise ConfigurationError("{} tensors were passed, but the module was initialized to " "mix {} tensors.".format(len(tensors), self.mixture_size)) def _do_layer_norm(tensor, broadcast_mask, num_elements_not_masked): tensor_masked = tensor * broadcast_mask mean = torch.sum(tensor_masked) / num_elements_not_masked variance = torch.sum(((tensor_masked - mean) * broadcast_mask)**2) / num_elements_not_masked return (tensor - mean) / torch.sqrt(variance + 1E-12) normed_weights = torch.nn.functional.softmax(torch.cat([parameter for parameter in self.scalar_parameters]), dim=0) normed_weights = torch.split(normed_weights, split_size_or_sections=1) if not self.do_layer_norm: pieces = [] for weight, tensor in zip(normed_weights, tensors): pieces.append(weight * tensor) return self.gamma * sum(pieces) else: mask_float = mask.float() broadcast_mask = mask_float.unsqueeze(-1) input_dim = tensors[0].size(-1) num_elements_not_masked = torch.sum(mask_float) * input_dim pieces = [] for weight, tensor in zip(normed_weights, tensors): pieces.append(weight * _do_layer_norm(tensor, broadcast_mask, num_elements_not_masked)) return self.gamma * sum(pieces)
[ "def", "forward", "(", "self", ",", "tensors", ":", "List", "[", "torch", ".", "Tensor", "]", ",", "# pylint: disable=arguments-differ", "mask", ":", "torch", ".", "Tensor", "=", "None", ")", "->", "torch", ".", "Tensor", ":", "if", "len", "(", "tensors", ")", "!=", "self", ".", "mixture_size", ":", "raise", "ConfigurationError", "(", "\"{} tensors were passed, but the module was initialized to \"", "\"mix {} tensors.\"", ".", "format", "(", "len", "(", "tensors", ")", ",", "self", ".", "mixture_size", ")", ")", "def", "_do_layer_norm", "(", "tensor", ",", "broadcast_mask", ",", "num_elements_not_masked", ")", ":", "tensor_masked", "=", "tensor", "*", "broadcast_mask", "mean", "=", "torch", ".", "sum", "(", "tensor_masked", ")", "/", "num_elements_not_masked", "variance", "=", "torch", ".", "sum", "(", "(", "(", "tensor_masked", "-", "mean", ")", "*", "broadcast_mask", ")", "**", "2", ")", "/", "num_elements_not_masked", "return", "(", "tensor", "-", "mean", ")", "/", "torch", ".", "sqrt", "(", "variance", "+", "1E-12", ")", "normed_weights", "=", "torch", ".", "nn", ".", "functional", ".", "softmax", "(", "torch", ".", "cat", "(", "[", "parameter", "for", "parameter", "in", "self", ".", "scalar_parameters", "]", ")", ",", "dim", "=", "0", ")", "normed_weights", "=", "torch", ".", "split", "(", "normed_weights", ",", "split_size_or_sections", "=", "1", ")", "if", "not", "self", ".", "do_layer_norm", ":", "pieces", "=", "[", "]", "for", "weight", ",", "tensor", "in", "zip", "(", "normed_weights", ",", "tensors", ")", ":", "pieces", ".", "append", "(", "weight", "*", "tensor", ")", "return", "self", ".", "gamma", "*", "sum", "(", "pieces", ")", "else", ":", "mask_float", "=", "mask", ".", "float", "(", ")", "broadcast_mask", "=", "mask_float", ".", "unsqueeze", "(", "-", "1", ")", "input_dim", "=", "tensors", "[", "0", "]", ".", "size", "(", "-", "1", ")", "num_elements_not_masked", "=", "torch", ".", "sum", "(", "mask_float", ")", "*", "input_dim", "pieces", "=", "[", "]", "for", "weight", ",", "tensor", "in", "zip", "(", "normed_weights", ",", "tensors", ")", ":", "pieces", ".", "append", "(", "weight", "*", "_do_layer_norm", "(", "tensor", ",", "broadcast_mask", ",", "num_elements_not_masked", ")", ")", "return", "self", ".", "gamma", "*", "sum", "(", "pieces", ")" ]
Compute a weighted average of the ``tensors``. The input tensors an be any shape with at least two dimensions, but must all be the same shape. When ``do_layer_norm=True``, the ``mask`` is required input. If the ``tensors`` are dimensioned ``(dim_0, ..., dim_{n-1}, dim_n)``, then the ``mask`` is dimensioned ``(dim_0, ..., dim_{n-1})``, as in the typical case with ``tensors`` of shape ``(batch_size, timesteps, dim)`` and ``mask`` of shape ``(batch_size, timesteps)``. When ``do_layer_norm=False`` the ``mask`` is ignored.
[ "Compute", "a", "weighted", "average", "of", "the", "tensors", ".", "The", "input", "tensors", "an", "be", "any", "shape", "with", "at", "least", "two", "dimensions", "but", "must", "all", "be", "the", "same", "shape", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/scalar_mix.py#L38-L81
train
Computes the weighted average of the input tensors.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCe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6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\x6f' + chr(277 - 228) + chr(0b110111) + chr(0b11101 + 0o25), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110011) + chr(2302 - 2252) + '\066', 13964 - 13956), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(10002 - 9891) + chr(0b100110 + 0o12), 48750 - 48742), ehT0Px3KOsy9(chr(78 - 30) + chr(111) + chr(0b110000 + 0o2) + chr(0b110110) + chr(52), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + chr(0b110100) + '\x30', 0o10), ehT0Px3KOsy9(chr(443 - 395) + '\x6f' + chr(51) + '\060' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\157' + chr(49) + chr(0b100101 + 0o15), 0o10), ehT0Px3KOsy9(chr(0b111 + 0o51) + '\157' + '\x31' + '\061' + chr(51), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + '\060' + chr(0b101100 + 0o13), 46448 - 46440), ehT0Px3KOsy9('\x30' + '\157' + chr(51) + chr(1060 - 1007) + '\067', 0b1000), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(0b1101111) + '\x33' + chr(1394 - 1343) + chr(0b110110), 21996 - 21988), ehT0Px3KOsy9(chr(107 - 59) + chr(0b1101111) + '\063' + chr(0b100 + 0o55) + chr(2296 - 2241), 1069 - 1061), ehT0Px3KOsy9(chr(0b1 + 0o57) + '\157' + chr(50) + chr(0b110011) + chr(502 - 450), 32744 - 32736), ehT0Px3KOsy9('\x30' + chr(111) + chr(1513 - 1462) + '\x34' + '\064', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + '\x32', 0o10), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(9537 - 9426) + chr(241 - 192) + chr(51) + chr(0b10010 + 0o40), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(0b101 + 0o54) + chr(51), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001) + chr(48) + chr(0b11110 + 0o25), 6722 - 6714), ehT0Px3KOsy9(chr(2053 - 2005) + chr(0b110110 + 0o71) + chr(50) + chr(2234 - 2186), 0o10), ehT0Px3KOsy9(chr(751 - 703) + '\x6f' + '\x32' + chr(665 - 611), 60294 - 60286), ehT0Px3KOsy9(chr(0b11011 + 0o25) + '\x6f' + chr(1709 - 1659) + '\x32' + chr(51), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(49) + chr(0b11011 + 0o31), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + '\x31' + chr(54), 9410 - 9402), ehT0Px3KOsy9(chr(48) + chr(0b1011 + 0o144) + '\061' + chr(0b110010 + 0o0) + '\060', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b10000 + 0o42) + chr(52) + chr(0b10010 + 0o40), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011 + 0o0) + chr(49) + chr(1568 - 1519), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + chr(1271 - 1216) + '\067', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(50) + chr(55) + chr(746 - 697), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b100 + 0o56) + '\062' + '\061', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b100111 + 0o110) + chr(0b110011) + '\062' + '\x36', 8), ehT0Px3KOsy9(chr(1954 - 1906) + '\x6f' + '\061' + chr(1501 - 1452) + chr(1008 - 954), 8), ehT0Px3KOsy9(chr(793 - 745) + chr(0b1011101 + 0o22) + chr(0b1011 + 0o47) + chr(0b110100) + chr(55), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\064' + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + '\x34' + '\062', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + '\x37' + chr(55), 0b1000), ehT0Px3KOsy9(chr(704 - 656) + '\157' + chr(49) + '\067' + chr(0b110011), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b100011 + 0o24), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b101011 + 0o104) + chr(54) + '\x34', 41546 - 41538), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b0 + 0o157) + chr(0b110010) + chr(0b10000 + 0o42) + chr(0b1000 + 0o52), 11941 - 11933), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(154 - 43) + chr(0b110010) + chr(54) + chr(0b100010 + 0o20), 14738 - 14730)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\x6f' + chr(53) + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'T'), chr(2128 - 2028) + '\x65' + chr(8007 - 7908) + chr(0b1101111) + '\144' + chr(101))(chr(117) + chr(0b1101000 + 0o14) + chr(0b11 + 0o143) + '\x2d' + chr(0b101101 + 0o13)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def GbbcCHUNFMj5(oVre8I6UXc3b, Tyy4rche81dW, Iz1jSgUKZDvt=None) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'.\xb3n\xc7\xcf\xb3'), chr(100) + '\145' + chr(99) + '\157' + '\144' + chr(9651 - 9550))(chr(0b1110101) + '\164' + chr(2523 - 2421) + chr(45) + '\070')): if c2A0yzQpDQB3(Tyy4rche81dW) != xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x17\xbfx\xc0\xd5\xb3o\x144\x86\xa4\xaa'), '\144' + chr(101) + chr(99) + '\x6f' + chr(100) + '\x65')(chr(0b1110101) + chr(116) + chr(102) + chr(0b101000 + 0o5) + chr(0b100010 + 0o26))): raise h0iXqtiKVeKg(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\x01\xab \xc0\xc5\xafy$5\x9c\xfe\xb8\xf9\x96\x7fz;"ce\xf6\xe8bp\xc0\xbc\x8b\x99\xe5\xbe+\x87O\r\x1b\x0ekQ\xb2\xc5\x1b\xa5 \xdd\xce\xa8~"&\x83\xb7\xb5\xf9\x80:.$c}\x7f\xeb\xac5-\x82\xbd\x9a\xd7\xe2\xb9<\xd4\x0c'), '\x64' + '\145' + '\x63' + chr(0b1101111) + chr(4041 - 3941) + chr(0b1100101))(chr(117) + chr(116) + chr(0b1100011 + 0o3) + '\055' + chr(0b110101 + 0o3)), xafqLlk3kkUe(SXOLrMavuUCe(b',\xe2r\xdb\xe8\xa0Yx\x17\x9f\xbb\xa5'), chr(0b1011101 + 0o7) + chr(0b100111 + 0o76) + chr(4816 - 4717) + chr(111) + '\144' + chr(0b1000110 + 0o37))('\165' + chr(0b1110100) + '\146' + chr(0b101101) + chr(0b111000)))(c2A0yzQpDQB3(Tyy4rche81dW), xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x17\xbfx\xc0\xd5\xb3o\x144\x86\xa4\xaa'), chr(0b11111 + 0o105) + chr(101) + '\x63' + chr(0b1101111) + chr(100) + chr(0b11100 + 0o111))('\x75' + chr(10236 - 10120) + '\146' + chr(0b100100 + 0o11) + chr(0b111000))))) def fPHC9EXKYqJh(LK3cpXJU3UM0, gYBeoyDjK2Lq, kn6xZw1P96Lg): v2b2JYrbnqag = LK3cpXJU3UM0 * gYBeoyDjK2Lq aJhItC_Vawlw = cEkFpYktkSeK.xkxBmo49x2An(v2b2JYrbnqag) / kn6xZw1P96Lg nVKbP5sF7181 = cEkFpYktkSeK.xkxBmo49x2An(((v2b2JYrbnqag - aJhItC_Vawlw) * gYBeoyDjK2Lq) ** ehT0Px3KOsy9(chr(1127 - 1079) + chr(111) + chr(0b110010), 0o10)) / kn6xZw1P96Lg return (LK3cpXJU3UM0 - aJhItC_Vawlw) / xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\t\xa7r\xc0'), chr(100) + chr(0b1100101) + '\143' + chr(111) + '\x64' + '\145')(chr(0b1001000 + 0o55) + '\164' + '\146' + '\055' + chr(0b100 + 0o64)))(nVKbP5sF7181 + 1e-12) cK6M_74arNot = cEkFpYktkSeK.nn.functional.softmax(cEkFpYktkSeK.cat([Sur8CJUVRGCp for Sur8CJUVRGCp in oVre8I6UXc3b.scalar_parameters]), dim=ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\060', 8)) cK6M_74arNot = cEkFpYktkSeK.split(cK6M_74arNot, split_size_or_sections=ehT0Px3KOsy9(chr(839 - 791) + '\x6f' + '\x31', 0o10)) if not xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1e\xb9_\xd8\xc1\xb8o9\x18\x81\xb1\xbd\xf1'), '\x64' + chr(9212 - 9111) + '\x63' + chr(111) + chr(0b111011 + 0o51) + '\x65')('\165' + chr(0b1110100) + chr(7268 - 7166) + chr(0b101101) + chr(438 - 382))): X3b3u1PDVdmt = [] for (C0mVSPj6WjvB, LK3cpXJU3UM0) in pZ0NK2y6HRbn(cK6M_74arNot, Tyy4rche81dW): xafqLlk3kkUe(X3b3u1PDVdmt, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1b\xa6p\xd1\xce\xa5'), chr(0b1001000 + 0o34) + chr(5238 - 5137) + chr(0b1100011) + chr(2610 - 2499) + chr(0b1011010 + 0o12) + '\145')(chr(0b101101 + 0o110) + '\x74' + chr(3406 - 3304) + '\x2d' + '\x38'))(C0mVSPj6WjvB * LK3cpXJU3UM0) return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1d\xb7m\xd9\xc1'), chr(2057 - 1957) + chr(0b100111 + 0o76) + chr(0b1100011) + chr(111) + chr(100) + chr(0b10001 + 0o124))(chr(0b1110101) + chr(6621 - 6505) + chr(0b1100110) + chr(45) + chr(56))) * xkxBmo49x2An(X3b3u1PDVdmt) else: SC4D8nPYu7zQ = Iz1jSgUKZDvt.float() gYBeoyDjK2Lq = SC4D8nPYu7zQ.unsqueeze(-ehT0Px3KOsy9(chr(1765 - 1717) + chr(0b101000 + 0o107) + chr(2016 - 1967), 8)) O0Pt4_FWG7IN = Tyy4rche81dW[ehT0Px3KOsy9('\060' + chr(0b10011 + 0o134) + chr(0b11100 + 0o24), 8)].NLcc3BCJnQka(-ehT0Px3KOsy9('\060' + chr(111) + chr(49), 8)) kn6xZw1P96Lg = cEkFpYktkSeK.xkxBmo49x2An(SC4D8nPYu7zQ) * O0Pt4_FWG7IN X3b3u1PDVdmt = [] for (C0mVSPj6WjvB, LK3cpXJU3UM0) in pZ0NK2y6HRbn(cK6M_74arNot, Tyy4rche81dW): xafqLlk3kkUe(X3b3u1PDVdmt, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1b\xa6p\xd1\xce\xa5'), '\144' + chr(0b1100101) + '\x63' + '\157' + chr(7324 - 7224) + chr(101))('\x75' + chr(0b1110100 + 0o0) + '\x66' + chr(45) + chr(56)))(C0mVSPj6WjvB * fPHC9EXKYqJh(LK3cpXJU3UM0, gYBeoyDjK2Lq, kn6xZw1P96Lg)) return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1d\xb7m\xd9\xc1'), chr(100) + '\145' + chr(0b100110 + 0o75) + chr(9655 - 9544) + chr(100) + chr(101))(chr(0b1110101) + chr(1123 - 1007) + chr(0b1001111 + 0o27) + '\x2d' + chr(0b110001 + 0o7))) * xkxBmo49x2An(X3b3u1PDVdmt)
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
predicate_with_side_args
def predicate_with_side_args(side_arguments: List[str]) -> Callable: # pylint: disable=invalid-name """ Like :func:`predicate`, but used when some of the arguments to the function are meant to be provided by the decoder or other state, instead of from the language. For example, you might want to have a function use the decoder's attention over some input text when a terminal was predicted. That attention won't show up in the language productions. Use this decorator, and pass in the required state to :func:`DomainLanguage.execute_action_sequence`, if you need to ignore some arguments when doing grammar induction. In order for this to work out, the side arguments `must` be after any non-side arguments. This is because we use ``*args`` to pass the non-side arguments, and ``**kwargs`` to pass the side arguments, and python requires that ``*args`` be before ``**kwargs``. """ def decorator(function: Callable) -> Callable: setattr(function, '_side_arguments', side_arguments) return predicate(function) return decorator
python
def predicate_with_side_args(side_arguments: List[str]) -> Callable: # pylint: disable=invalid-name """ Like :func:`predicate`, but used when some of the arguments to the function are meant to be provided by the decoder or other state, instead of from the language. For example, you might want to have a function use the decoder's attention over some input text when a terminal was predicted. That attention won't show up in the language productions. Use this decorator, and pass in the required state to :func:`DomainLanguage.execute_action_sequence`, if you need to ignore some arguments when doing grammar induction. In order for this to work out, the side arguments `must` be after any non-side arguments. This is because we use ``*args`` to pass the non-side arguments, and ``**kwargs`` to pass the side arguments, and python requires that ``*args`` be before ``**kwargs``. """ def decorator(function: Callable) -> Callable: setattr(function, '_side_arguments', side_arguments) return predicate(function) return decorator
[ "def", "predicate_with_side_args", "(", "side_arguments", ":", "List", "[", "str", "]", ")", "->", "Callable", ":", "# pylint: disable=invalid-name", "def", "decorator", "(", "function", ":", "Callable", ")", "->", "Callable", ":", "setattr", "(", "function", ",", "'_side_arguments'", ",", "side_arguments", ")", "return", "predicate", "(", "function", ")", "return", "decorator" ]
Like :func:`predicate`, but used when some of the arguments to the function are meant to be provided by the decoder or other state, instead of from the language. For example, you might want to have a function use the decoder's attention over some input text when a terminal was predicted. That attention won't show up in the language productions. Use this decorator, and pass in the required state to :func:`DomainLanguage.execute_action_sequence`, if you need to ignore some arguments when doing grammar induction. In order for this to work out, the side arguments `must` be after any non-side arguments. This is because we use ``*args`` to pass the non-side arguments, and ``**kwargs`` to pass the side arguments, and python requires that ``*args`` be before ``**kwargs``.
[ "Like", ":", "func", ":", "predicate", "but", "used", "when", "some", "of", "the", "arguments", "to", "the", "function", "are", "meant", "to", "be", "provided", "by", "the", "decoder", "or", "other", "state", "instead", "of", "from", "the", "language", ".", "For", "example", "you", "might", "want", "to", "have", "a", "function", "use", "the", "decoder", "s", "attention", "over", "some", "input", "text", "when", "a", "terminal", "was", "predicted", ".", "That", "attention", "won", "t", "show", "up", "in", "the", "language", "productions", ".", "Use", "this", "decorator", "and", "pass", "in", "the", "required", "state", "to", ":", "func", ":", "DomainLanguage", ".", "execute_action_sequence", "if", "you", "need", "to", "ignore", "some", "arguments", "when", "doing", "grammar", "induction", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L182-L198
train
Decorator that returns a function that accepts side arguments.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sP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AbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\157' + chr(49) + chr(759 - 711), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(1771 - 1660) + chr(0b110001) + chr(50) + chr(451 - 398), 14178 - 14170), ehT0Px3KOsy9('\060' + chr(111) + chr(49) + '\066' + chr(0b110111), 8557 - 8549), ehT0Px3KOsy9(chr(48) + chr(0b101001 + 0o106) + '\062' + '\067' + '\065', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110010) + chr(0b110000 + 0o5) + '\x32', 14965 - 14957), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(2348 - 2237) + chr(51) + chr(2461 - 2407), 62365 - 62357), ehT0Px3KOsy9(chr(48) + chr(0b110010 + 0o75) + chr(51) + chr(0b110100), 53489 - 53481), ehT0Px3KOsy9(chr(2203 - 2155) + chr(0b1101111) + chr(0b101000 + 0o11) + chr(396 - 343) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(375 - 264) + '\x33' + chr(54) + chr(49), 27180 - 27172), ehT0Px3KOsy9('\060' + '\157' + chr(1124 - 1074) + chr(54), 0o10), ehT0Px3KOsy9(chr(1247 - 1199) + chr(442 - 331) + chr(1243 - 1192) + chr(55) + chr(0b110001), 53090 - 53082), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\157' + chr(51) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1111 + 0o44) + chr(0b11000 + 0o36) + chr(0b110001), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + chr(54) + chr(49), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b100110 + 0o111) + chr(0b110001 + 0o2) + '\x31' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(11989 - 11878) + chr(596 - 546) + chr(910 - 855) + chr(0b110001 + 0o6), 0b1000), ehT0Px3KOsy9(chr(1573 - 1525) + chr(0b1101111) + chr(2111 - 2058) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b1101110 + 0o1) + chr(0b110001) + '\060' + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b1100110 + 0o11) + chr(50) + '\066' + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(0b1101111) + chr(1849 - 1799) + chr(0b110110), 8), ehT0Px3KOsy9(chr(0b11110 + 0o22) + '\157' + '\x33' + '\067' + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + chr(12202 - 12091) + chr(2337 - 2288) + chr(617 - 568) + '\061', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\063' + chr(0b110001) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(11078 - 10967) + chr(0b110001) + chr(2564 - 2510) + chr(51), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(359 - 310) + chr(2255 - 2201) + '\x37', 8), ehT0Px3KOsy9('\060' + chr(5311 - 5200) + '\061' + '\063' + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(127 - 79) + chr(1932 - 1821) + '\062' + chr(0b10001 + 0o42) + chr(53), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x32' + chr(1481 - 1432) + chr(0b10001 + 0o37), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b100011 + 0o114) + '\063' + chr(51), 8), ehT0Px3KOsy9('\x30' + chr(5599 - 5488) + chr(1512 - 1463) + chr(2358 - 2309), 0o10), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(635 - 524) + chr(778 - 728) + chr(1451 - 1402) + '\x33', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11001 + 0o30) + chr(0b10000 + 0o42) + chr(0b1010 + 0o52), 22249 - 22241), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b1101 + 0o47) + '\x30', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(0b1111 + 0o47) + chr(1312 - 1262), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31' + '\064' + '\x33', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(2134 - 2085) + '\065' + chr(2653 - 2601), 31289 - 31281), ehT0Px3KOsy9('\060' + chr(111) + '\062' + chr(1531 - 1479) + chr(1963 - 1912), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(2034 - 1985) + chr(51) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(10799 - 10688) + chr(51) + chr(50) + chr(50), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\x6f' + chr(53) + chr(48), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'&'), '\x64' + chr(0b1100101) + '\143' + '\x6f' + chr(100) + chr(0b100100 + 0o101))(chr(117) + '\164' + chr(436 - 334) + chr(0b101101) + chr(2894 - 2838)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def wLCZQubWYE_S(Z33WzR1MnG4V) -> TPYMKCdTAycN: def aInxBLSrGyiI(bBC93MgSHzUB) -> TPYMKCdTAycN: t0rOMsrOC7R_(bBC93MgSHzUB, xafqLlk3kkUe(SXOLrMavuUCe(b'W&\x1e\xd9\xcfA}\x1d\x96c\x94~\x9f\xc5\xbd'), chr(9237 - 9137) + chr(4144 - 4043) + chr(99) + '\157' + '\144' + '\x65')(chr(0b1110101) + chr(0b1110100) + '\x66' + chr(0b101101) + chr(0b111000)), Z33WzR1MnG4V) return xvl4O0XhF8_e(bBC93MgSHzUB) return aInxBLSrGyiI
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
nltk_tree_to_logical_form
def nltk_tree_to_logical_form(tree: Tree) -> str: """ Given an ``nltk.Tree`` representing the syntax tree that generates a logical form, this method produces the actual (lisp-like) logical form, with all of the non-terminal symbols converted into the correct number of parentheses. This is used in the logic that converts action sequences back into logical forms. It's very unlikely that you will need this anywhere else. """ # nltk.Tree actually inherits from `list`, so you use `len()` to get the number of children. # We're going to be explicit about checking length, instead of using `if tree:`, just to avoid # any funny business nltk might have done (e.g., it's really odd if `if tree:` evaluates to # `False` if there's a single leaf node with no children). if len(tree) == 0: # pylint: disable=len-as-condition return tree.label() if len(tree) == 1: return tree[0].label() return '(' + ' '.join(nltk_tree_to_logical_form(child) for child in tree) + ')'
python
def nltk_tree_to_logical_form(tree: Tree) -> str: """ Given an ``nltk.Tree`` representing the syntax tree that generates a logical form, this method produces the actual (lisp-like) logical form, with all of the non-terminal symbols converted into the correct number of parentheses. This is used in the logic that converts action sequences back into logical forms. It's very unlikely that you will need this anywhere else. """ # nltk.Tree actually inherits from `list`, so you use `len()` to get the number of children. # We're going to be explicit about checking length, instead of using `if tree:`, just to avoid # any funny business nltk might have done (e.g., it's really odd if `if tree:` evaluates to # `False` if there's a single leaf node with no children). if len(tree) == 0: # pylint: disable=len-as-condition return tree.label() if len(tree) == 1: return tree[0].label() return '(' + ' '.join(nltk_tree_to_logical_form(child) for child in tree) + ')'
[ "def", "nltk_tree_to_logical_form", "(", "tree", ":", "Tree", ")", "->", "str", ":", "# nltk.Tree actually inherits from `list`, so you use `len()` to get the number of children.", "# We're going to be explicit about checking length, instead of using `if tree:`, just to avoid", "# any funny business nltk might have done (e.g., it's really odd if `if tree:` evaluates to", "# `False` if there's a single leaf node with no children).", "if", "len", "(", "tree", ")", "==", "0", ":", "# pylint: disable=len-as-condition", "return", "tree", ".", "label", "(", ")", "if", "len", "(", "tree", ")", "==", "1", ":", "return", "tree", "[", "0", "]", ".", "label", "(", ")", "return", "'('", "+", "' '", ".", "join", "(", "nltk_tree_to_logical_form", "(", "child", ")", "for", "child", "in", "tree", ")", "+", "')'" ]
Given an ``nltk.Tree`` representing the syntax tree that generates a logical form, this method produces the actual (lisp-like) logical form, with all of the non-terminal symbols converted into the correct number of parentheses. This is used in the logic that converts action sequences back into logical forms. It's very unlikely that you will need this anywhere else.
[ "Given", "an", "nltk", ".", "Tree", "representing", "the", "syntax", "tree", "that", "generates", "a", "logical", "form", "this", "method", "produces", "the", "actual", "(", "lisp", "-", "like", ")", "logical", "form", "with", "all", "of", "the", "non", "-", "terminal", "symbols", "converted", "into", "the", "correct", "number", "of", "parentheses", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_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wAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\157' + '\062' + chr(0b1 + 0o66) + '\x36', 0b1000), ehT0Px3KOsy9(chr(1586 - 1538) + chr(111) + chr(51) + chr(1964 - 1913) + chr(2212 - 2164), 0o10), ehT0Px3KOsy9(chr(1325 - 1277) + '\157' + '\063' + chr(0b10101 + 0o42) + chr(0b11011 + 0o26), 0b1000), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(2726 - 2615) + chr(0b110001) + chr(0b110001) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(1936 - 1888) + '\x6f' + chr(0b110001) + '\x33' + '\064', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b10110 + 0o33) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(50) + chr(0b10011 + 0o43) + chr(650 - 595), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(1606 - 1555) + '\x36' + chr(48), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b10100 + 0o133) + '\063' + chr(0b110110) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(2565 - 2454) + chr(2185 - 2135) + chr(49) + '\063', 0o10), ehT0Px3KOsy9(chr(0b10000 + 0o40) + '\157' + '\061' + '\061' + chr(0b110111), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + chr(932 - 879) + chr(0b110001), 65327 - 65319), ehT0Px3KOsy9(chr(48) + chr(0b1100011 + 0o14) + chr(0b101100 + 0o6) + '\x36' + chr(0b110100), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001 + 0o0) + '\x34' + chr(2218 - 2168), 0o10), ehT0Px3KOsy9(chr(228 - 180) + chr(0b1101111) + '\x31' + chr(0b0 + 0o61) + chr(53), 19016 - 19008), ehT0Px3KOsy9(chr(0b110000) + chr(3965 - 3854) + '\062' + chr(0b110000) + chr(0b110000), 46418 - 46410), ehT0Px3KOsy9(chr(2159 - 2111) + chr(10163 - 10052) + '\x33' + chr(50) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(911 - 863) + chr(2383 - 2272) + chr(0b100 + 0o57) + chr(0b10100 + 0o35) + chr(48), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + chr(0b101100 + 0o7) + chr(0b1010 + 0o50), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + '\x36' + chr(0b1 + 0o63), 8), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(51) + chr(0b110100) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(51) + chr(0b101110 + 0o5) + chr(921 - 867), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\063' + '\061' + chr(0b101110 + 0o5), 0o10), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(111) + chr(0b110010) + chr(985 - 935), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(2028 - 1978) + chr(0b1111 + 0o42) + chr(0b10011 + 0o36), 0o10), ehT0Px3KOsy9(chr(175 - 127) + '\x6f' + '\061' + '\067' + chr(52), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + '\062' + chr(52) + chr(588 - 537), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\x32' + chr(0b101100 + 0o7) + '\x35', 2630 - 2622), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11101 + 0o25) + '\064' + chr(0b101100 + 0o4), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b10 + 0o155) + chr(0b110010) + chr(0b110000) + '\067', 54832 - 54824), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + '\x37' + chr(55), 65196 - 65188), ehT0Px3KOsy9(chr(2030 - 1982) + '\157' + chr(49) + '\064' + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1669 - 1618) + chr(0b1110 + 0o45) + '\x31', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(51) + chr(1343 - 1295) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + chr(0b100111 + 0o17) + chr(2623 - 2568), ord("\x08")), ehT0Px3KOsy9(chr(1313 - 1265) + chr(11355 - 11244) + '\x31' + chr(0b110110), 26236 - 26228), ehT0Px3KOsy9(chr(1258 - 1210) + '\x6f' + chr(51) + chr(0b110000) + chr(54), 0o10), ehT0Px3KOsy9(chr(0b1110 + 0o42) + '\157' + chr(0b110011) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1811 - 1760) + chr(0b110001 + 0o6) + '\x34', 53042 - 53034), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(111) + chr(1997 - 1946) + '\x32' + chr(0b110110), 8)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\157' + chr(0b11011 + 0o32) + chr(0b10101 + 0o33), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x90'), '\144' + '\145' + chr(8399 - 8300) + chr(111) + '\144' + chr(0b1100101))('\165' + '\x74' + chr(102) + chr(45) + chr(1577 - 1521)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def go8qkK5qcgxB(ErHgKhTO5Wfb) -> M8_cKLkHVB2V: if c2A0yzQpDQB3(ErHgKhTO5Wfb) == ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\x6f' + chr(2068 - 2020), 0o10): return xafqLlk3kkUe(ErHgKhTO5Wfb, xafqLlk3kkUe(SXOLrMavuUCe(b'\xea\x8a\xac\x00\x10M\xfb\x85\xb0\xbbw\xd1'), chr(0b1001010 + 0o32) + '\x65' + chr(0b1100011) + chr(0b1101111) + chr(0b1100100) + chr(9122 - 9021))(chr(0b1110101) + chr(116) + chr(0b1010 + 0o134) + '\055' + '\070'))() if c2A0yzQpDQB3(ErHgKhTO5Wfb) == ehT0Px3KOsy9(chr(48) + chr(1696 - 1585) + '\x31', ord("\x08")): return xafqLlk3kkUe(ErHgKhTO5Wfb[ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110000), 8)], xafqLlk3kkUe(SXOLrMavuUCe(b'\xea\x8a\xac\x00\x10M\xfb\x85\xb0\xbbw\xd1'), chr(100) + '\x65' + '\143' + chr(0b1101111) + chr(1914 - 1814) + '\145')(chr(6271 - 6154) + chr(0b1110100) + chr(6098 - 5996) + '\055' + chr(0b101100 + 0o14)))() return xafqLlk3kkUe(SXOLrMavuUCe(b'\x96'), chr(146 - 46) + chr(0b1100101) + chr(0b1100011) + chr(0b1101111) + chr(0b1011111 + 0o5) + '\x65')(chr(117) + chr(0b1001101 + 0o47) + chr(102) + chr(0b101101) + '\070') + xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\x9e'), '\144' + chr(101) + chr(0b111001 + 0o52) + chr(111) + chr(100) + '\x65')(chr(0b110100 + 0o101) + '\x74' + chr(102) + chr(1942 - 1897) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xe1\xb7\xae\x17&\x7f\xe1\xbe\x9a\xfa\x07\xef'), chr(2345 - 2245) + '\145' + chr(6789 - 6690) + chr(111) + chr(0b1100100) + '\x65')(chr(0b110111 + 0o76) + chr(0b1110100) + '\146' + chr(1271 - 1226) + chr(56)))((go8qkK5qcgxB(X_w6uktosk4i) for X_w6uktosk4i in ErHgKhTO5Wfb)) + xafqLlk3kkUe(SXOLrMavuUCe(b'\x97'), '\x64' + chr(7213 - 7112) + chr(0b1100011) + chr(0b1010101 + 0o32) + '\x64' + '\145')(chr(8885 - 8768) + '\x74' + '\146' + chr(0b100 + 0o51) + chr(0b111000))
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
PredicateType.get_type
def get_type(type_: Type) -> 'PredicateType': """ Converts a python ``Type`` (as you might get from a type annotation) into a ``PredicateType``. If the ``Type`` is callable, this will return a ``FunctionType``; otherwise, it will return a ``BasicType``. ``BasicTypes`` have a single ``name`` parameter - we typically get this from ``type_.__name__``. This doesn't work for generic types (like ``List[str]``), so we handle those specially, so that the ``name`` for the ``BasicType`` remains ``List[str]``, as you would expect. """ if is_callable(type_): callable_args = type_.__args__ argument_types = [PredicateType.get_type(t) for t in callable_args[:-1]] return_type = PredicateType.get_type(callable_args[-1]) return FunctionType(argument_types, return_type) elif is_generic(type_): # This is something like List[int]. type_.__name__ doesn't do the right thing (and # crashes in python 3.7), so we need to do some magic here. name = get_generic_name(type_) else: name = type_.__name__ return BasicType(name)
python
def get_type(type_: Type) -> 'PredicateType': """ Converts a python ``Type`` (as you might get from a type annotation) into a ``PredicateType``. If the ``Type`` is callable, this will return a ``FunctionType``; otherwise, it will return a ``BasicType``. ``BasicTypes`` have a single ``name`` parameter - we typically get this from ``type_.__name__``. This doesn't work for generic types (like ``List[str]``), so we handle those specially, so that the ``name`` for the ``BasicType`` remains ``List[str]``, as you would expect. """ if is_callable(type_): callable_args = type_.__args__ argument_types = [PredicateType.get_type(t) for t in callable_args[:-1]] return_type = PredicateType.get_type(callable_args[-1]) return FunctionType(argument_types, return_type) elif is_generic(type_): # This is something like List[int]. type_.__name__ doesn't do the right thing (and # crashes in python 3.7), so we need to do some magic here. name = get_generic_name(type_) else: name = type_.__name__ return BasicType(name)
[ "def", "get_type", "(", "type_", ":", "Type", ")", "->", "'PredicateType'", ":", "if", "is_callable", "(", "type_", ")", ":", "callable_args", "=", "type_", ".", "__args__", "argument_types", "=", "[", "PredicateType", ".", "get_type", "(", "t", ")", "for", "t", "in", "callable_args", "[", ":", "-", "1", "]", "]", "return_type", "=", "PredicateType", ".", "get_type", "(", "callable_args", "[", "-", "1", "]", ")", "return", "FunctionType", "(", "argument_types", ",", "return_type", ")", "elif", "is_generic", "(", "type_", ")", ":", "# This is something like List[int]. type_.__name__ doesn't do the right thing (and", "# crashes in python 3.7), so we need to do some magic here.", "name", "=", "get_generic_name", "(", "type_", ")", "else", ":", "name", "=", "type_", ".", "__name__", "return", "BasicType", "(", "name", ")" ]
Converts a python ``Type`` (as you might get from a type annotation) into a ``PredicateType``. If the ``Type`` is callable, this will return a ``FunctionType``; otherwise, it will return a ``BasicType``. ``BasicTypes`` have a single ``name`` parameter - we typically get this from ``type_.__name__``. This doesn't work for generic types (like ``List[str]``), so we handle those specially, so that the ``name`` for the ``BasicType`` remains ``List[str]``, as you would expect.
[ "Converts", "a", "python", "Type", "(", "as", "you", "might", "get", "from", "a", "type", "annotation", ")", "into", "a", "PredicateType", ".", "If", "the", "Type", "is", "callable", "this", "will", "return", "a", "FunctionType", ";", "otherwise", "it", "will", "return", "a", "BasicType", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L60-L82
train
Converts a python type annotation into a predicate type.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5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,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\x6f' + chr(1388 - 1339) + chr(468 - 417) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(1662 - 1614) + chr(8581 - 8470) + '\x34' + chr(0b100000 + 0o21), 1358 - 1350), ehT0Px3KOsy9(chr(1914 - 1866) + chr(11685 - 11574) + '\x35' + chr(0b110000), 49185 - 49177), ehT0Px3KOsy9('\060' + '\157' + chr(48), 0b1000), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101111) + '\x31' + chr(0b10011 + 0o36) + '\063', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110010) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b100001 + 0o116) + '\063' + '\060' + '\061', 63318 - 63310), ehT0Px3KOsy9('\060' + chr(9496 - 9385) + chr(50) + '\x34' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(424 - 313) + '\066', 0o10), ehT0Px3KOsy9(chr(740 - 692) + '\157' + chr(49) + chr(0b110000 + 0o3) + chr(0b10100 + 0o37), 21570 - 21562), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\066' + '\x30', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b11110 + 0o24) + chr(49) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + chr(0b110101) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(11658 - 11547) + '\063' + '\065' + '\066', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + chr(0b100 + 0o54) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(278 - 230) + chr(0b100011 + 0o114) + chr(0b100011 + 0o22) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b10001 + 0o41) + chr(53) + '\x35', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10111 + 0o32) + '\062' + chr(0b100011 + 0o15), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1110 + 0o141) + '\061' + '\x30' + '\x37', 31352 - 31344), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101 + 0o142) + '\x37' + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(679 - 631) + '\x6f' + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b10110 + 0o131) + chr(0b110001) + chr(958 - 907) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001011 + 0o44) + '\061' + '\x32' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(906 - 856) + chr(1439 - 1389) + '\062', 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(111) + chr(0b110011) + '\x36' + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b10 + 0o155) + chr(1691 - 1640) + chr(2305 - 2250) + chr(52), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + chr(0b100010 + 0o22) + '\065', 34007 - 33999), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110011) + '\067' + chr(0b110111), 0o10), ehT0Px3KOsy9('\x30' + chr(7749 - 7638) + chr(0b1111 + 0o42) + chr(0b110101) + chr(54), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\061' + chr(0b110001) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + '\x32' + '\060', 18273 - 18265), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(52) + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b11000 + 0o127) + chr(0b110010) + chr(0b110010 + 0o1) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1181 - 1130) + chr(0b110111) + '\x30', 63325 - 63317), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(52) + chr(1715 - 1663), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1010110 + 0o31) + chr(0b110011) + '\x32' + chr(55), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1000001 + 0o56) + '\x33' + chr(0b1001 + 0o52) + '\060', 58770 - 58762), ehT0Px3KOsy9('\060' + chr(12168 - 12057) + chr(2080 - 2025) + chr(0b10001 + 0o43), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001000 + 0o47) + '\x31', 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + chr(0b110001) + '\061', 33883 - 33875)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1390 - 1342) + chr(111) + chr(0b110101) + chr(0b110000), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b't'), chr(175 - 75) + chr(9413 - 9312) + chr(0b1100001 + 0o2) + chr(0b1101111) + chr(0b1100100) + chr(0b1100011 + 0o2))('\x75' + chr(0b1110100) + '\x66' + chr(0b101101) + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def PJ7aH1CeEM15(wglhj4WQZuCT) -> xafqLlk3kkUe(SXOLrMavuUCe(b'\nSMd"p\xa0\xd4c\x0fI\xfe\x8f'), '\x64' + chr(0b1011101 + 0o10) + chr(99) + chr(0b1100111 + 0o10) + chr(100) + '\x65')('\165' + chr(7940 - 7824) + chr(0b111110 + 0o50) + '\x2d' + '\x38'): if P8ntWBOpJiWF(wglhj4WQZuCT): vF49VyBTvgCh = wglhj4WQZuCT.__args__ DjtzGpnspIKq = [YPmBFLkEKJVV.get_type(YeT3l7JgTbWR) for YeT3l7JgTbWR in vF49VyBTvgCh[:-ehT0Px3KOsy9(chr(48) + '\x6f' + chr(2116 - 2067), 8)]] ELL59KGwZKj3 = YPmBFLkEKJVV.get_type(vF49VyBTvgCh[-ehT0Px3KOsy9(chr(48) + chr(11237 - 11126) + '\x31', 8)]) return ric04wOk_EeU(DjtzGpnspIKq, ELL59KGwZKj3) elif JCzIq1k7H5pm(wglhj4WQZuCT): AIvJRzLdDfgF = NdiTqXLlgAl_(wglhj4WQZuCT) else: AIvJRzLdDfgF = wglhj4WQZuCT.Gbej4oZqKLA6 return Z_EeVpF1A9Qj(AIvJRzLdDfgF)
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage.execute
def execute(self, logical_form: str): """Executes a logical form, using whatever predicates you have defined.""" if not hasattr(self, '_functions'): raise RuntimeError("You must call super().__init__() in your Language constructor") logical_form = logical_form.replace(",", " ") expression = util.lisp_to_nested_expression(logical_form) return self._execute_expression(expression)
python
def execute(self, logical_form: str): """Executes a logical form, using whatever predicates you have defined.""" if not hasattr(self, '_functions'): raise RuntimeError("You must call super().__init__() in your Language constructor") logical_form = logical_form.replace(",", " ") expression = util.lisp_to_nested_expression(logical_form) return self._execute_expression(expression)
[ "def", "execute", "(", "self", ",", "logical_form", ":", "str", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_functions'", ")", ":", "raise", "RuntimeError", "(", "\"You must call super().__init__() in your Language constructor\"", ")", "logical_form", "=", "logical_form", ".", "replace", "(", "\",\"", ",", "\" \"", ")", "expression", "=", "util", ".", "lisp_to_nested_expression", "(", "logical_form", ")", "return", "self", ".", "_execute_expression", "(", "expression", ")" ]
Executes a logical form, using whatever predicates you have defined.
[ "Executes", "a", "logical", "form", "using", "whatever", "predicates", "you", "have", "defined", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L307-L313
train
Executes a logical form using the predicates you have defined.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0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h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + chr(49) + chr(50), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + '\x33' + chr(0b110100), 0o10), ehT0Px3KOsy9('\060' + '\157' + '\x32' + chr(0b10111 + 0o37) + chr(52), 38451 - 38443), ehT0Px3KOsy9(chr(48) + chr(7189 - 7078) + chr(0b110001) + '\x34' + chr(2447 - 2395), 0o10), ehT0Px3KOsy9(chr(1314 - 1266) + '\157' + '\063' + '\x36' + chr(0b110111), 29976 - 29968), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b11100 + 0o26) + chr(0b110100) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(52) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1010101 + 0o32) + chr(1027 - 974) + chr(0b11101 + 0o25), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(55) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(82 - 34) + '\157' + '\x33' + chr(0b110100) + chr(50), 0b1000), ehT0Px3KOsy9('\x30' + chr(5725 - 5614) + '\x31' + chr(49) + '\x35', 9423 - 9415), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1101111) + '\x31' + chr(0b1 + 0o66) + chr(50), 56575 - 56567), ehT0Px3KOsy9(chr(1274 - 1226) + '\157' + '\x31' + chr(0b10 + 0o61) + chr(0b11100 + 0o32), 0o10), ehT0Px3KOsy9(chr(1770 - 1722) + '\x6f' + chr(0b10110 + 0o33) + chr(0b110110) + chr(0b10010 + 0o45), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x33' + chr(50) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(566 - 518) + chr(111) + chr(0b110010) + chr(0b110100) + chr(0b110111), 8), ehT0Px3KOsy9('\x30' + chr(111) + chr(53) + chr(0b110101), 50830 - 50822), ehT0Px3KOsy9(chr(0b110000) + chr(0b101011 + 0o104) + chr(50) + '\x35' + chr(55), 0b1000), ehT0Px3KOsy9('\060' + chr(0b110110 + 0o71) + chr(50) + chr(0b110100) + '\x35', 14052 - 14044), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(111) + chr(544 - 494) + chr(1694 - 1646) + chr(0b101 + 0o56), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(53) + '\x37', 19689 - 19681), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + chr(0b110000) + chr(0b11110 + 0o22), 0b1000), ehT0Px3KOsy9(chr(1814 - 1766) + chr(111) + '\x33' + chr(1675 - 1623) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + chr(50) + chr(49) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(1495 - 1447) + chr(111) + chr(49) + chr(54) + chr(0b100010 + 0o17), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011101 + 0o22) + chr(0b100000 + 0o22) + chr(0b10111 + 0o32) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(184 - 135) + chr(1430 - 1375) + chr(984 - 934), 8), ehT0Px3KOsy9(chr(1684 - 1636) + chr(0b1011 + 0o144) + chr(0b110010) + '\x37', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1538 - 1487) + chr(0b110000) + chr(0b11101 + 0o32), 0o10), ehT0Px3KOsy9('\060' + chr(162 - 51) + chr(49) + chr(267 - 215) + chr(0b110011), 33548 - 33540), ehT0Px3KOsy9(chr(903 - 855) + chr(111) + '\x35', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(10824 - 10713) + chr(1386 - 1336) + '\067' + chr(53), 17711 - 17703), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + chr(0b110010) + chr(0b100001 + 0o23), ord("\x08")), ehT0Px3KOsy9(chr(2254 - 2206) + '\x6f' + '\061' + '\062' + chr(1827 - 1779), 0b1000), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(111) + chr(0b110101) + '\x31', 0b1000), ehT0Px3KOsy9('\x30' + chr(9497 - 9386) + '\x31' + chr(0b110110) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(2737 - 2684) + chr(0b110101), 8), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + chr(0b0 + 0o64) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(48) + chr(6578 - 6467) + '\x35' + chr(0b110010), 8), ehT0Px3KOsy9(chr(310 - 262) + chr(0b100111 + 0o110) + chr(512 - 461) + chr(0b1011 + 0o46) + chr(0b101011 + 0o10), 49024 - 49016)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(111) + '\x35' + chr(1509 - 1461), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa4'), '\x64' + chr(101) + '\x63' + chr(0b1101111) + '\144' + '\145')(chr(117) + chr(116) + chr(1540 - 1438) + chr(0b10101 + 0o30) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def TaiENS9_ww2W(oVre8I6UXc3b, kh68tYwZhgrY): if not lot1PSoAwYhj(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd5\xba\xc1\n\x94\xd3JEV\x91'), chr(0b1100100) + chr(6810 - 6709) + chr(99) + '\x6f' + chr(0b1100100) + '\x65')('\165' + chr(0b10 + 0o162) + '\x66' + chr(0b101101) + chr(0b111000))): raise n0ZkatoveZpF(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd3\xb3\xc1D\x9a\xd2P^\x18\x81,\x162W\xa6\xd2]\xca\xd7\xab\\%\x8f\xe9_\xd4%t\xab\x02v\xce\xcb\x0f\x05T^\x07F\xad\xa3\xf2\xeb;\x9e\xc9J^g\xbdeS~\x1e\xbb\x87T\xc0\xd0\xf1\x0f\x0c\x82\xe1\x16\xfe\x1bp\xa2Cf\xd2\xfa#]\x06X\x01^\xa4\xf8'), chr(5448 - 5348) + chr(2862 - 2761) + chr(7514 - 7415) + chr(0b1001111 + 0o40) + chr(100) + chr(0b1100101))(chr(0b1110101) + chr(0b1110100) + chr(102) + chr(45) + '\x38')) kh68tYwZhgrY = kh68tYwZhgrY.replace(xafqLlk3kkUe(SXOLrMavuUCe(b'\xa6'), '\x64' + chr(5674 - 5573) + '\143' + chr(0b1011000 + 0o27) + chr(0b1100100) + chr(0b1100101))(chr(0b1110101) + '\164' + '\x66' + '\055' + chr(0b1110 + 0o52)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xaa'), chr(0b100110 + 0o76) + '\145' + chr(3257 - 3158) + chr(0b1101111) + chr(3443 - 3343) + '\145')(chr(0b1110101) + chr(116) + chr(10386 - 10284) + chr(0b101101) + '\x38')) heJELtuJu3My = eb2I7aEma6r5.lisp_to_nested_expression(kh68tYwZhgrY) return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd5\xb9\xcc\x01\x94\xd2WOg\x875\n,\x12\xa6\xd4D\xc0\xcb'), chr(0b110 + 0o136) + chr(0b1000 + 0o135) + '\143' + chr(111) + chr(0b100101 + 0o77) + chr(0b1100101))(chr(11129 - 11012) + '\x74' + chr(102) + chr(0b101101) + '\x38'))(heJELtuJu3My)
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage.execute_action_sequence
def execute_action_sequence(self, action_sequence: List[str], side_arguments: List[Dict] = None): """ Executes the program defined by an action sequence directly, without needing the overhead of translating to a logical form first. For any given program, :func:`execute` and this function are equivalent, they just take different representations of the program, so you can use whichever is more efficient. Also, if you have state or side arguments associated with particular production rules (e.g., the decoder's attention on an input utterance when a predicate was predicted), you `must` use this function to execute the logical form, instead of :func:`execute`, so that we can match the side arguments with the right functions. """ # We'll strip off the first action, because it doesn't matter for execution. first_action = action_sequence[0] left_side = first_action.split(' -> ')[0] if left_side != '@start@': raise ExecutionError('invalid action sequence') remaining_side_args = side_arguments[1:] if side_arguments else None return self._execute_sequence(action_sequence[1:], remaining_side_args)[0]
python
def execute_action_sequence(self, action_sequence: List[str], side_arguments: List[Dict] = None): """ Executes the program defined by an action sequence directly, without needing the overhead of translating to a logical form first. For any given program, :func:`execute` and this function are equivalent, they just take different representations of the program, so you can use whichever is more efficient. Also, if you have state or side arguments associated with particular production rules (e.g., the decoder's attention on an input utterance when a predicate was predicted), you `must` use this function to execute the logical form, instead of :func:`execute`, so that we can match the side arguments with the right functions. """ # We'll strip off the first action, because it doesn't matter for execution. first_action = action_sequence[0] left_side = first_action.split(' -> ')[0] if left_side != '@start@': raise ExecutionError('invalid action sequence') remaining_side_args = side_arguments[1:] if side_arguments else None return self._execute_sequence(action_sequence[1:], remaining_side_args)[0]
[ "def", "execute_action_sequence", "(", "self", ",", "action_sequence", ":", "List", "[", "str", "]", ",", "side_arguments", ":", "List", "[", "Dict", "]", "=", "None", ")", ":", "# We'll strip off the first action, because it doesn't matter for execution.", "first_action", "=", "action_sequence", "[", "0", "]", "left_side", "=", "first_action", ".", "split", "(", "' -> '", ")", "[", "0", "]", "if", "left_side", "!=", "'@start@'", ":", "raise", "ExecutionError", "(", "'invalid action sequence'", ")", "remaining_side_args", "=", "side_arguments", "[", "1", ":", "]", "if", "side_arguments", "else", "None", "return", "self", ".", "_execute_sequence", "(", "action_sequence", "[", "1", ":", "]", ",", "remaining_side_args", ")", "[", "0", "]" ]
Executes the program defined by an action sequence directly, without needing the overhead of translating to a logical form first. For any given program, :func:`execute` and this function are equivalent, they just take different representations of the program, so you can use whichever is more efficient. Also, if you have state or side arguments associated with particular production rules (e.g., the decoder's attention on an input utterance when a predicate was predicted), you `must` use this function to execute the logical form, instead of :func:`execute`, so that we can match the side arguments with the right functions.
[ "Executes", "the", "program", "defined", "by", "an", "action", "sequence", "directly", "without", "needing", "the", "overhead", "of", "translating", "to", "a", "logical", "form", "first", ".", "For", "any", "given", "program", ":", "func", ":", "execute", "and", "this", "function", "are", "equivalent", "they", "just", "take", "different", "representations", "of", "the", "program", "so", "you", "can", "use", "whichever", "is", "more", "efficient", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L315-L333
train
Executes the action sequence.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,G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mS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(0b1010010 + 0o35) + '\x35' + '\x36', 872 - 864), ehT0Px3KOsy9('\x30' + chr(0b1000111 + 0o50) + chr(50) + '\066' + chr(900 - 850), ord("\x08")), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(8147 - 8036) + '\x31' + '\x31' + '\x33', 0b1000), ehT0Px3KOsy9(chr(742 - 694) + '\x6f' + chr(0b11110 + 0o25) + chr(49) + chr(0b101111 + 0o5), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + '\066' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\060' + chr(5954 - 5843) + chr(0b110110) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(205 - 154) + chr(0b10010 + 0o36), 33754 - 33746), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + chr(0b101101 + 0o11) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101111) + chr(0b110101), 47083 - 47075), ehT0Px3KOsy9(chr(451 - 403) + '\x6f' + chr(0b110001) + chr(51) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(841 - 793) + chr(4333 - 4222) + '\x33' + chr(48) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101101 + 0o2) + chr(0b10 + 0o64) + '\x30', 0b1000), ehT0Px3KOsy9(chr(594 - 546) + chr(6513 - 6402) + chr(0b101 + 0o60) + '\064', 29405 - 29397), ehT0Px3KOsy9(chr(48) + chr(0b111101 + 0o62) + chr(0b110011) + chr(0b110001) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + '\x33' + '\064', 39046 - 39038), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110010) + '\066' + '\060', 0o10), ehT0Px3KOsy9('\x30' + chr(11393 - 11282) + '\062' + chr(0b100010 + 0o23) + chr(51), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110010) + '\x36' + chr(48), 8), ehT0Px3KOsy9(chr(2198 - 2150) + chr(0b1000011 + 0o54) + chr(51) + '\x32' + chr(2232 - 2177), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(49) + chr(0b10010 + 0o45) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(1809 - 1761) + chr(5588 - 5477) + '\062' + chr(0b11 + 0o62) + chr(2522 - 2470), 0o10), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + chr(0b110101) + '\x36', 8), ehT0Px3KOsy9(chr(2149 - 2101) + '\x6f' + chr(514 - 466), 14316 - 14308), ehT0Px3KOsy9('\x30' + chr(9866 - 9755) + chr(50) + chr(52) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b1000 + 0o53) + '\064', 0b1000), ehT0Px3KOsy9('\060' + chr(12028 - 11917) + chr(0b110010) + chr(0b110001) + chr(1711 - 1659), 59804 - 59796), ehT0Px3KOsy9(chr(671 - 623) + chr(111) + chr(0b110100 + 0o3) + chr(0b110100 + 0o0), 35685 - 35677), ehT0Px3KOsy9(chr(328 - 280) + '\157' + chr(49) + chr(638 - 590) + chr(0b110101), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\x32' + chr(0b10100 + 0o40) + '\x37', 0o10), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(0b1010011 + 0o34) + chr(49) + chr(51) + chr(2357 - 2307), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\062' + chr(2974 - 2919) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(53), 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b1010 + 0o50) + '\067' + chr(52), 8), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\157' + '\x32' + '\x31' + chr(0b110101), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + '\064' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + chr(52) + '\061', 46043 - 46035), ehT0Px3KOsy9(chr(1203 - 1155) + chr(111) + chr(0b100011 + 0o17) + chr(1769 - 1714) + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(8616 - 8505) + chr(2071 - 2022) + chr(53) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101111 + 0o2) + '\065' + chr(2370 - 2317), 38601 - 38593), ehT0Px3KOsy9(chr(48) + chr(446 - 335) + '\062' + '\x33' + chr(52), 8)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b110110 + 0o71) + '\x35' + '\x30', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x00'), chr(4820 - 4720) + chr(101) + chr(99) + '\x6f' + chr(100) + chr(0b1100101))('\165' + '\x74' + chr(102) + '\x2d' + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def atl8eltl4FOv(oVre8I6UXc3b, FXNJIrDAzcxy, Z33WzR1MnG4V=None): h6F0IIBiouDQ = FXNJIrDAzcxy[ehT0Px3KOsy9(chr(1353 - 1305) + chr(0b1101111) + chr(0b11101 + 0o23), 8)] ULG77TjK80oU = h6F0IIBiouDQ.split(xafqLlk3kkUe(SXOLrMavuUCe(b'\x0e\x9fu\xec'), chr(974 - 874) + chr(0b11 + 0o142) + chr(99) + chr(0b10100 + 0o133) + '\144' + chr(0b1100101))(chr(0b1110101) + chr(116) + chr(0b1100110) + chr(0b100010 + 0o13) + chr(56)))[ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(577 - 529), 8)] if ULG77TjK80oU != xafqLlk3kkUe(SXOLrMavuUCe(b'n\xc1?\xad\xc4AX'), chr(3832 - 3732) + chr(0b1100101) + chr(0b1100011) + '\x6f' + chr(100) + chr(0b1100101))('\x75' + chr(116) + chr(102) + chr(45) + '\x38'): raise POyjkXRsHLE3(xafqLlk3kkUe(SXOLrMavuUCe(b'G\xdc=\xad\xda\\|\xd5d<\xb3YC\xa4\xbc\xc3\xce\xc1\xa2\x1d\xc2Me'), chr(1088 - 988) + chr(3311 - 3210) + '\143' + chr(111) + chr(0b1011001 + 0o13) + '\145')('\165' + chr(0b11001 + 0o133) + chr(1784 - 1682) + '\x2d' + chr(0b101000 + 0o20))) sKaSPAjiDChw = Z33WzR1MnG4V[ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061', 0o10):] if Z33WzR1MnG4V else None return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'q\xd73\xa9\xd5@l\x90Z,\xa2AY\xaf\xf2\xd3\xce'), '\x64' + chr(0b1100101) + '\143' + '\x6f' + chr(5441 - 5341) + chr(101))(chr(117) + chr(0b1100101 + 0o17) + '\x66' + chr(0b101101) + chr(0b111000)))(FXNJIrDAzcxy[ehT0Px3KOsy9(chr(803 - 755) + chr(111) + '\061', 8):], sKaSPAjiDChw)[ehT0Px3KOsy9('\x30' + '\157' + chr(0b100000 + 0o20), 8)]
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage.get_nonterminal_productions
def get_nonterminal_productions(self) -> Dict[str, List[str]]: """ Induces a grammar from the defined collection of predicates in this language and returns all productions in that grammar, keyed by the non-terminal they are expanding. This includes terminal productions implied by each predicate as well as productions for the `return type` of each defined predicate. For example, defining a "multiply" predicate adds a "<int,int:int> -> multiply" terminal production to the grammar, and `also` a "int -> [<int,int:int>, int, int]" non-terminal production, because I can use the "multiply" predicate to produce an int. """ if not self._nonterminal_productions: actions: Dict[str, Set[str]] = defaultdict(set) # If you didn't give us a set of valid start types, we'll assume all types we know # about (including functional types) are valid start types. if self._start_types: start_types = self._start_types else: start_types = set() for type_list in self._function_types.values(): start_types.update(type_list) for start_type in start_types: actions[START_SYMBOL].add(f"{START_SYMBOL} -> {start_type}") for name, function_type_list in self._function_types.items(): for function_type in function_type_list: actions[str(function_type)].add(f"{function_type} -> {name}") if isinstance(function_type, FunctionType): return_type = function_type.return_type arg_types = function_type.argument_types right_side = f"[{function_type}, {', '.join(str(arg_type) for arg_type in arg_types)}]" actions[str(return_type)].add(f"{return_type} -> {right_side}") self._nonterminal_productions = {key: sorted(value) for key, value in actions.items()} return self._nonterminal_productions
python
def get_nonterminal_productions(self) -> Dict[str, List[str]]: """ Induces a grammar from the defined collection of predicates in this language and returns all productions in that grammar, keyed by the non-terminal they are expanding. This includes terminal productions implied by each predicate as well as productions for the `return type` of each defined predicate. For example, defining a "multiply" predicate adds a "<int,int:int> -> multiply" terminal production to the grammar, and `also` a "int -> [<int,int:int>, int, int]" non-terminal production, because I can use the "multiply" predicate to produce an int. """ if not self._nonterminal_productions: actions: Dict[str, Set[str]] = defaultdict(set) # If you didn't give us a set of valid start types, we'll assume all types we know # about (including functional types) are valid start types. if self._start_types: start_types = self._start_types else: start_types = set() for type_list in self._function_types.values(): start_types.update(type_list) for start_type in start_types: actions[START_SYMBOL].add(f"{START_SYMBOL} -> {start_type}") for name, function_type_list in self._function_types.items(): for function_type in function_type_list: actions[str(function_type)].add(f"{function_type} -> {name}") if isinstance(function_type, FunctionType): return_type = function_type.return_type arg_types = function_type.argument_types right_side = f"[{function_type}, {', '.join(str(arg_type) for arg_type in arg_types)}]" actions[str(return_type)].add(f"{return_type} -> {right_side}") self._nonterminal_productions = {key: sorted(value) for key, value in actions.items()} return self._nonterminal_productions
[ "def", "get_nonterminal_productions", "(", "self", ")", "->", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", ":", "if", "not", "self", ".", "_nonterminal_productions", ":", "actions", ":", "Dict", "[", "str", ",", "Set", "[", "str", "]", "]", "=", "defaultdict", "(", "set", ")", "# If you didn't give us a set of valid start types, we'll assume all types we know", "# about (including functional types) are valid start types.", "if", "self", ".", "_start_types", ":", "start_types", "=", "self", ".", "_start_types", "else", ":", "start_types", "=", "set", "(", ")", "for", "type_list", "in", "self", ".", "_function_types", ".", "values", "(", ")", ":", "start_types", ".", "update", "(", "type_list", ")", "for", "start_type", "in", "start_types", ":", "actions", "[", "START_SYMBOL", "]", ".", "add", "(", "f\"{START_SYMBOL} -> {start_type}\"", ")", "for", "name", ",", "function_type_list", "in", "self", ".", "_function_types", ".", "items", "(", ")", ":", "for", "function_type", "in", "function_type_list", ":", "actions", "[", "str", "(", "function_type", ")", "]", ".", "add", "(", "f\"{function_type} -> {name}\"", ")", "if", "isinstance", "(", "function_type", ",", "FunctionType", ")", ":", "return_type", "=", "function_type", ".", "return_type", "arg_types", "=", "function_type", ".", "argument_types", "right_side", "=", "f\"[{function_type}, {', '.join(str(arg_type) for arg_type in arg_types)}]\"", "actions", "[", "str", "(", "return_type", ")", "]", ".", "add", "(", "f\"{return_type} -> {right_side}\"", ")", "self", ".", "_nonterminal_productions", "=", "{", "key", ":", "sorted", "(", "value", ")", "for", "key", ",", "value", "in", "actions", ".", "items", "(", ")", "}", "return", "self", ".", "_nonterminal_productions" ]
Induces a grammar from the defined collection of predicates in this language and returns all productions in that grammar, keyed by the non-terminal they are expanding. This includes terminal productions implied by each predicate as well as productions for the `return type` of each defined predicate. For example, defining a "multiply" predicate adds a "<int,int:int> -> multiply" terminal production to the grammar, and `also` a "int -> [<int,int:int>, int, int]" non-terminal production, because I can use the "multiply" predicate to produce an int.
[ "Induces", "a", "grammar", "from", "the", "defined", "collection", "of", "predicates", "in", "this", "language", "and", "returns", "all", "productions", "in", "that", "grammar", "keyed", "by", "the", "non", "-", "terminal", "they", "are", "expanding", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L335-L367
train
Induces a grammar from the defined collection of predicates in this language and returns all productions that are not in the grammar.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2Qao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ClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\157' + chr(2446 - 2396) + chr(0b10010 + 0o43) + '\x30', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110101) + chr(54), 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\061' + '\x36' + chr(0b101011 + 0o10), 3938 - 3930), ehT0Px3KOsy9(chr(48) + '\157' + '\063' + chr(0b110011) + chr(2859 - 2804), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1502 - 1453) + chr(50) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\x30' + chr(4435 - 4324) + chr(51) + chr(0b110011) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\x6f' + chr(49) + chr(0b110100) + chr(52), 14038 - 14030), ehT0Px3KOsy9(chr(1818 - 1770) + chr(2035 - 1924) + '\065', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(49) + '\063', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(2171 - 2120) + chr(0b101111 + 0o3) + chr(0b110001 + 0o1), 23684 - 23676), ehT0Px3KOsy9('\x30' + chr(5359 - 5248) + chr(49) + chr(0b110 + 0o53) + '\064', 0o10), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(0b1101111) + '\x32' + '\065' + '\063', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(49) + chr(0b111 + 0o52) + '\x37', 0o10), ehT0Px3KOsy9(chr(48) + chr(4853 - 4742) + '\062' + '\x30' + chr(0b1101 + 0o47), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b100000 + 0o117) + chr(0b110001) + chr(1008 - 955) + chr(0b110101), 58789 - 58781), ehT0Px3KOsy9('\060' + chr(5527 - 5416) + chr(49) + chr(54) + chr(498 - 443), 0o10), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b11110 + 0o121) + chr(0b11 + 0o57) + '\062', 59990 - 59982), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + chr(51) + chr(0b110000), 8), ehT0Px3KOsy9(chr(2038 - 1990) + '\x6f' + chr(0b110011) + chr(51) + '\061', 0o10), ehT0Px3KOsy9(chr(1285 - 1237) + chr(111) + '\x32' + chr(0b110001) + chr(0b1110 + 0o46), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(1110 - 1061) + '\060', 9400 - 9392), ehT0Px3KOsy9(chr(0b110000) + chr(921 - 810) + chr(0b110010 + 0o1) + chr(0b1000 + 0o56) + chr(50), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(144 - 94) + chr(0b1110 + 0o45), 23705 - 23697), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b11110 + 0o23) + chr(0b10110 + 0o33) + chr(0b1101 + 0o51), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(1175 - 1124) + chr(0b1000 + 0o57) + chr(50), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(2538 - 2484) + '\063', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\061' + chr(2749 - 2695) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + '\x35' + chr(0b110110), 2385 - 2377), ehT0Px3KOsy9('\060' + chr(11815 - 11704) + chr(0b110001) + chr(0b110001) + chr(0b101 + 0o62), 8), ehT0Px3KOsy9('\x30' + '\157' + chr(472 - 421) + '\066' + '\063', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(978 - 927) + chr(975 - 920), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(312 - 262) + '\x32' + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\x6f' + chr(0b110111) + chr(0b11110 + 0o26), 47832 - 47824), ehT0Px3KOsy9('\060' + chr(111) + chr(1366 - 1313) + chr(1938 - 1885), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\062' + chr(55) + chr(51), 0o10), ehT0Px3KOsy9('\060' + '\157' + '\x31' + '\x32' + chr(52), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + chr(50) + '\061', 46396 - 46388), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + chr(0b10101 + 0o35) + '\063', 0b1000), ehT0Px3KOsy9(chr(1319 - 1271) + chr(4677 - 4566) + '\x31' + '\x31' + chr(0b110100), 8)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b1101110 + 0o1) + chr(53) + chr(0b100011 + 0o15), 6490 - 6482)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x86'), '\144' + chr(0b10111 + 0o116) + '\x63' + chr(5544 - 5433) + chr(0b1000 + 0o134) + chr(4617 - 4516))(chr(117) + chr(0b1110100) + '\146' + chr(45) + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def GkerEVM8A7dm(oVre8I6UXc3b) -> zBnV56fc6HrA[M8_cKLkHVB2V, qRxF7OQ0y39T[M8_cKLkHVB2V]]: if not xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf7@\x1c\xb1"\xbd\x16h\xa2\xbc-\xc7\x10\xf4\x1f\x18v\xad\xba\xf8\xa1\x9d\xbd='), chr(0b111101 + 0o47) + chr(9151 - 9050) + '\143' + chr(111) + '\x64' + chr(0b1100101))('\165' + chr(116) + '\146' + '\055' + chr(0b10101 + 0o43))): WCl6VUkME_8I = rLgqW9imlCdX(MVEN8G6CxlvR) if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf7]\x07\xbe$\xac;q\xb2\xa2)\xd8'), chr(0b1100100) + '\145' + chr(0b1100011) + chr(0b1101111) + '\144' + '\145')(chr(0b100011 + 0o122) + chr(0b1110100) + '\x66' + chr(45) + '\070')): mW7hLZxV0Ilc = oVre8I6UXc3b._start_types else: mW7hLZxV0Ilc = MVEN8G6CxlvR() for tIqEQIOcOYwY in xafqLlk3kkUe(oVre8I6UXc3b._function_types, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb~\x1d\x9c\x18\xadQ1\x83\xe3(\xc9'), chr(0b1100100) + chr(0b101000 + 0o75) + chr(0b1100011) + chr(0b1001000 + 0o47) + chr(0b11101 + 0o107) + chr(9893 - 9792))(chr(11015 - 10898) + chr(0b1110100) + chr(102) + chr(711 - 666) + '\x38'))(): xafqLlk3kkUe(mW7hLZxV0Ilc, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf2Z2\x9a?\x96.k\xb2\xe6)\x9b'), '\x64' + chr(101) + chr(99) + chr(2371 - 2260) + chr(8529 - 8429) + chr(0b100011 + 0o102))(chr(0b1110101) + chr(9692 - 9576) + chr(8387 - 8285) + chr(0b1110 + 0o37) + chr(0b111000)))(tIqEQIOcOYwY) for lf2bGbZLmhhS in mW7hLZxV0Ilc: xafqLlk3kkUe(WCl6VUkME_8I[F_eLh1HbPbbZ], xafqLlk3kkUe(SXOLrMavuUCe(b'\xdddC\xaeo\xbb#0\x91\x9d\x1e\x98'), '\x64' + chr(0b1100101) + '\143' + chr(10405 - 10294) + '\x64' + '\145')(chr(9185 - 9068) + chr(0b111000 + 0o74) + '\x66' + chr(45) + chr(0b10001 + 0o47)))(f'{F_eLh1HbPbbZ} -> {lf2bGbZLmhhS}') for (AIvJRzLdDfgF, kx3ZgWSwReHV) in xafqLlk3kkUe(oVre8I6UXc3b._function_types, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe6T\x05\xba\x1f\x82WL\xa7\x81\x04\x92'), chr(0b111 + 0o135) + chr(0b111101 + 0o50) + '\143' + chr(111) + '\144' + chr(0b101 + 0o140))(chr(0b1110101) + '\164' + chr(0b111011 + 0o53) + '\x2d' + chr(0b111000)))(): for cid_uaYJYOSx in kx3ZgWSwReHV: xafqLlk3kkUe(WCl6VUkME_8I[M8_cKLkHVB2V(cid_uaYJYOSx)], xafqLlk3kkUe(SXOLrMavuUCe(b'\xdddC\xaeo\xbb#0\x91\x9d\x1e\x98'), '\144' + chr(0b1010000 + 0o25) + '\143' + '\x6f' + '\144' + chr(101))(chr(0b1110101) + chr(116) + chr(0b1100110) + chr(0b101101) + chr(0b111 + 0o61)))(f'{cid_uaYJYOSx} -> {AIvJRzLdDfgF}') if PlSM16l2KDPD(cid_uaYJYOSx, ric04wOk_EeU): ELL59KGwZKj3 = cid_uaYJYOSx.return_type WLkCKxcteYqC = cid_uaYJYOSx.argument_types ZhTWDDhoiRNo = f"[{cid_uaYJYOSx}, {chr(0b101100) + chr(734 - 702)._oWXztVNnqHF((M8_cKLkHVB2V(u88a6oLul0L6) for u88a6oLul0L6 in WLkCKxcteYqC))}]" xafqLlk3kkUe(WCl6VUkME_8I[M8_cKLkHVB2V(ELL59KGwZKj3)], xafqLlk3kkUe(SXOLrMavuUCe(b'\xdddC\xaeo\xbb#0\x91\x9d\x1e\x98'), chr(100) + chr(0b1100101) + '\x63' + chr(0b1101111) + chr(4330 - 4230) + chr(0b111001 + 0o54))(chr(0b1000100 + 0o61) + '\164' + chr(102) + chr(0b101101) + '\x38'))(f'{ELL59KGwZKj3} -> {ZhTWDDhoiRNo}') oVre8I6UXc3b.lBLquhj8e7NS = {K3J4ZwSlE0sT: vUlqIvNSaRMa(QmmgWUB13VCJ) for (K3J4ZwSlE0sT, QmmgWUB13VCJ) in WCl6VUkME_8I.NzveIZ3IlSH9()} return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc4l?\xae#\xb0\x0e=\xae\xe5\x02\xf8'), chr(0b1100100) + chr(101) + chr(6250 - 6151) + chr(111) + '\x64' + chr(1632 - 1531))(chr(0b1001010 + 0o53) + '\164' + '\146' + '\055' + chr(2878 - 2822)))
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage.all_possible_productions
def all_possible_productions(self) -> List[str]: """ Returns a sorted list of all production rules in the grammar induced by :func:`get_nonterminal_productions`. """ all_actions = set() for action_set in self.get_nonterminal_productions().values(): all_actions.update(action_set) return sorted(all_actions)
python
def all_possible_productions(self) -> List[str]: """ Returns a sorted list of all production rules in the grammar induced by :func:`get_nonterminal_productions`. """ all_actions = set() for action_set in self.get_nonterminal_productions().values(): all_actions.update(action_set) return sorted(all_actions)
[ "def", "all_possible_productions", "(", "self", ")", "->", "List", "[", "str", "]", ":", "all_actions", "=", "set", "(", ")", "for", "action_set", "in", "self", ".", "get_nonterminal_productions", "(", ")", ".", "values", "(", ")", ":", "all_actions", ".", "update", "(", "action_set", ")", "return", "sorted", "(", "all_actions", ")" ]
Returns a sorted list of all production rules in the grammar induced by :func:`get_nonterminal_productions`.
[ "Returns", "a", "sorted", "list", "of", "all", "production", "rules", "in", "the", "grammar", "induced", "by", ":", "func", ":", "get_nonterminal_productions", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L369-L377
train
Returns a list of all possible production rules in the grammar.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIA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2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x31' + chr(0b110011), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(49) + '\x32', 27622 - 27614), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1223 - 1173) + '\x36' + '\x36', 61873 - 61865), ehT0Px3KOsy9('\060' + chr(7500 - 7389) + '\061' + chr(51), 8), ehT0Px3KOsy9(chr(48) + chr(2454 - 2343) + '\066' + chr(0b11 + 0o56), 0o10), ehT0Px3KOsy9(chr(2203 - 2155) + chr(0b1101111) + chr(49) + chr(55) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + '\060' + '\x31', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1011001 + 0o26) + '\x34' + chr(52), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + chr(0b110011) + chr(52), 34975 - 34967), ehT0Px3KOsy9(chr(1499 - 1451) + chr(111) + chr(0b110111) + '\065', 7849 - 7841), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b111 + 0o54) + '\x36' + '\067', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1495 - 1446) + chr(49) + '\x32', 0o10), ehT0Px3KOsy9(chr(1795 - 1747) + chr(0b1001 + 0o146) + chr(2206 - 2157) + '\063' + chr(0b110100), 8), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + '\061' + chr(0b100011 + 0o17), 0b1000), ehT0Px3KOsy9(chr(2170 - 2122) + chr(6553 - 6442) + '\x33' + chr(52) + chr(0b10 + 0o64), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + '\x34' + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + chr(54) + '\x37', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + chr(0b10000 + 0o45) + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(0b101000 + 0o107) + '\063' + chr(54) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\060' + chr(6194 - 6083) + chr(1523 - 1473) + '\x33' + chr(2230 - 2177), 0b1000), ehT0Px3KOsy9(chr(82 - 34) + chr(0b1101111 + 0o0) + chr(50) + chr(0b110110) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001) + chr(262 - 211) + chr(354 - 304), 57306 - 57298), ehT0Px3KOsy9('\060' + '\157' + chr(51) + chr(0b110111) + chr(0b101010 + 0o14), 0b1000), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b110010 + 0o75) + '\063' + chr(0b110101) + chr(843 - 791), 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b1101111) + '\062' + chr(0b101011 + 0o6) + chr(0b110000), 64328 - 64320), ehT0Px3KOsy9(chr(0b110000) + chr(10270 - 10159) + chr(50) + '\062' + '\x31', 16236 - 16228), ehT0Px3KOsy9(chr(1523 - 1475) + chr(0b111010 + 0o65) + '\x33' + chr(0b110000) + chr(0b11 + 0o63), 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + chr(0b10011 + 0o41) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(1122 - 1074) + '\157' + chr(151 - 101) + chr(0b110001) + '\066', 32695 - 32687), ehT0Px3KOsy9('\060' + '\157' + chr(51) + '\065' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(48) + chr(2745 - 2634) + '\063' + '\x34' + chr(2913 - 2859), 8), ehT0Px3KOsy9(chr(1045 - 997) + '\x6f' + '\062' + chr(194 - 142) + chr(0b110111), 40848 - 40840), ehT0Px3KOsy9('\060' + chr(0b1011 + 0o144) + chr(0b11101 + 0o25) + '\061', 0b1000), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(7383 - 7272) + chr(1625 - 1575) + '\064' + chr(2061 - 2006), 8), ehT0Px3KOsy9('\060' + '\157' + chr(0b101111 + 0o2) + '\x33' + chr(0b10001 + 0o41), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + chr(54) + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b10 + 0o56) + '\157' + chr(0b110011) + '\x34' + '\067', 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b11001 + 0o32) + chr(55) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x30', 44964 - 44956), ehT0Px3KOsy9(chr(0b110000) + chr(7307 - 7196) + '\063' + chr(0b110011) + '\x32', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(8979 - 8868) + chr(53) + '\060', ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'%'), chr(0b110011 + 0o61) + '\145' + chr(0b1100011) + chr(6995 - 6884) + chr(0b1100100) + '\145')(chr(117) + chr(0b1110100) + chr(0b11011 + 0o113) + chr(1621 - 1576) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def fUzFvsRqcImt(oVre8I6UXc3b) -> qRxF7OQ0y39T[M8_cKLkHVB2V]: z5EYB6nilIpt = MVEN8G6CxlvR() for YwjMGmNpeL2t in xafqLlk3kkUe(oVre8I6UXc3b.get_nonterminal_productions(), xafqLlk3kkUe(SXOLrMavuUCe(b'XZ\xd8H\x7f\x0e\xb4\x10\x14\x0c\x93('), chr(953 - 853) + chr(0b1100101) + chr(0b1100011) + '\157' + chr(100) + chr(101))('\x75' + chr(0b1001101 + 0o47) + chr(102) + chr(0b10110 + 0o27) + chr(1164 - 1108)))(): xafqLlk3kkUe(z5EYB6nilIpt, xafqLlk3kkUe(SXOLrMavuUCe(b'Q~\xf7NX5\xcbJ%\t\x92z'), chr(0b1010111 + 0o15) + chr(101) + '\x63' + chr(0b100010 + 0o115) + '\144' + chr(0b1100101))(chr(4275 - 4158) + '\x74' + chr(102) + '\055' + chr(165 - 109)))(YwjMGmNpeL2t) return vUlqIvNSaRMa(z5EYB6nilIpt)
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage.logical_form_to_action_sequence
def logical_form_to_action_sequence(self, logical_form: str) -> List[str]: """ Converts a logical form into a linearization of the production rules from its abstract syntax tree. The linearization is top-down, depth-first. Each production rule is formatted as "LHS -> RHS", where "LHS" is a single non-terminal type, and RHS is either a terminal or a list of non-terminals (other possible values for RHS in a more general context-free grammar are not produced by our grammar induction logic). Non-terminals are `types` in the grammar, either basic types (like ``int``, ``str``, or some class that you define), or functional types, represented with angle brackets with a colon separating arguments from the return type. Multi-argument functions have commas separating their argument types. For example, ``<int:int>`` is a function that takes an integer and returns an integer, and ``<int,int:int>`` is a function that takes two integer arguments and returns an integer. As an example translation from logical form to complete action sequence, the logical form ``(add 2 3)`` would be translated to ``['@start@ -> int', 'int -> [<int,int:int>, int, int]', '<int,int:int> -> add', 'int -> 2', 'int -> 3']``. """ expression = util.lisp_to_nested_expression(logical_form) try: transitions, start_type = self._get_transitions(expression, expected_type=None) if self._start_types and start_type not in self._start_types: raise ParsingError(f"Expression had unallowed start type of {start_type}: {expression}") except ParsingError: logger.error(f'Error parsing logical form: {logical_form}') raise transitions.insert(0, f'@start@ -> {start_type}') return transitions
python
def logical_form_to_action_sequence(self, logical_form: str) -> List[str]: """ Converts a logical form into a linearization of the production rules from its abstract syntax tree. The linearization is top-down, depth-first. Each production rule is formatted as "LHS -> RHS", where "LHS" is a single non-terminal type, and RHS is either a terminal or a list of non-terminals (other possible values for RHS in a more general context-free grammar are not produced by our grammar induction logic). Non-terminals are `types` in the grammar, either basic types (like ``int``, ``str``, or some class that you define), or functional types, represented with angle brackets with a colon separating arguments from the return type. Multi-argument functions have commas separating their argument types. For example, ``<int:int>`` is a function that takes an integer and returns an integer, and ``<int,int:int>`` is a function that takes two integer arguments and returns an integer. As an example translation from logical form to complete action sequence, the logical form ``(add 2 3)`` would be translated to ``['@start@ -> int', 'int -> [<int,int:int>, int, int]', '<int,int:int> -> add', 'int -> 2', 'int -> 3']``. """ expression = util.lisp_to_nested_expression(logical_form) try: transitions, start_type = self._get_transitions(expression, expected_type=None) if self._start_types and start_type not in self._start_types: raise ParsingError(f"Expression had unallowed start type of {start_type}: {expression}") except ParsingError: logger.error(f'Error parsing logical form: {logical_form}') raise transitions.insert(0, f'@start@ -> {start_type}') return transitions
[ "def", "logical_form_to_action_sequence", "(", "self", ",", "logical_form", ":", "str", ")", "->", "List", "[", "str", "]", ":", "expression", "=", "util", ".", "lisp_to_nested_expression", "(", "logical_form", ")", "try", ":", "transitions", ",", "start_type", "=", "self", ".", "_get_transitions", "(", "expression", ",", "expected_type", "=", "None", ")", "if", "self", ".", "_start_types", "and", "start_type", "not", "in", "self", ".", "_start_types", ":", "raise", "ParsingError", "(", "f\"Expression had unallowed start type of {start_type}: {expression}\"", ")", "except", "ParsingError", ":", "logger", ".", "error", "(", "f'Error parsing logical form: {logical_form}'", ")", "raise", "transitions", ".", "insert", "(", "0", ",", "f'@start@ -> {start_type}'", ")", "return", "transitions" ]
Converts a logical form into a linearization of the production rules from its abstract syntax tree. The linearization is top-down, depth-first. Each production rule is formatted as "LHS -> RHS", where "LHS" is a single non-terminal type, and RHS is either a terminal or a list of non-terminals (other possible values for RHS in a more general context-free grammar are not produced by our grammar induction logic). Non-terminals are `types` in the grammar, either basic types (like ``int``, ``str``, or some class that you define), or functional types, represented with angle brackets with a colon separating arguments from the return type. Multi-argument functions have commas separating their argument types. For example, ``<int:int>`` is a function that takes an integer and returns an integer, and ``<int,int:int>`` is a function that takes two integer arguments and returns an integer. As an example translation from logical form to complete action sequence, the logical form ``(add 2 3)`` would be translated to ``['@start@ -> int', 'int -> [<int,int:int>, int, int]', '<int,int:int> -> add', 'int -> 2', 'int -> 3']``.
[ "Converts", "a", "logical", "form", "into", "a", "linearization", "of", "the", "production", "rules", "from", "its", "abstract", "syntax", "tree", ".", "The", "linearization", "is", "top", "-", "down", "depth", "-", "first", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L379-L409
train
Converts a logical form into a list of action sequences.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTxpD_zsEOh2,LgE_IO_tHXvM,Kk1hd194VKEC,OZYzwAeSQh7N,jF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aO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110011) + chr(1828 - 1773) + '\064', 50316 - 50308), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(111) + chr(0b110001) + '\061' + chr(2120 - 2066), 44917 - 44909), ehT0Px3KOsy9(chr(1170 - 1122) + '\157' + chr(0b11111 + 0o22) + '\x33' + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + chr(0b110010) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b101100 + 0o103) + '\062' + '\065' + chr(0b101101 + 0o3), 54587 - 54579), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(2462 - 2412) + chr(2158 - 2108) + chr(798 - 743), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + '\066', 41611 - 41603), ehT0Px3KOsy9(chr(108 - 60) + chr(12235 - 12124) + chr(0b101101 + 0o7) + chr(0b1101 + 0o45), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1010001 + 0o36) + '\x31' + chr(1428 - 1378) + '\x30', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\062' + chr(54) + chr(0b11010 + 0o35), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b1001 + 0o52) + chr(52) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b11111 + 0o22) + chr(2581 - 2530) + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(111) + chr(0b110110) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\157' + chr(1789 - 1739) + chr(1113 - 1060) + '\x35', 32584 - 32576), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + chr(0b110110 + 0o1) + chr(0b10111 + 0o33), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\062' + '\061' + '\060', ord("\x08")), ehT0Px3KOsy9(chr(1514 - 1466) + '\x6f' + chr(0b110011) + '\x35' + chr(53), 0b1000), ehT0Px3KOsy9('\060' + chr(7932 - 7821) + chr(50) + chr(0b100101 + 0o14) + '\x37', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x36' + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(3567 - 3456) + chr(0b110011) + chr(55) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + chr(766 - 713) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b11100 + 0o24) + '\x6f' + '\x32' + chr(0b110011), 32402 - 32394), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + '\066' + chr(1875 - 1827), 0b1000), ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(3394 - 3283) + chr(0b110011) + '\x36' + chr(318 - 270), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b11101 + 0o26) + chr(0b110010 + 0o3) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(11568 - 11457) + chr(0b110011) + '\067' + '\065', 43770 - 43762), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110 + 0o54) + '\x34' + chr(0b110101), 26618 - 26610), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + chr(48) + '\x32', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + chr(0b110111) + chr(51), 55709 - 55701), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110011) + chr(0b110010), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1559 - 1508) + chr(0b110010) + '\061', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + '\067' + chr(1020 - 972), 0b1000), ehT0Px3KOsy9(chr(1610 - 1562) + chr(111) + chr(0b110011) + chr(2051 - 1996), 47814 - 47806), ehT0Px3KOsy9(chr(2230 - 2182) + chr(0b1101111) + chr(0b110010) + chr(54) + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(0b11010 + 0o125) + chr(0b110011) + chr(54) + chr(0b1100 + 0o46), 0o10), ehT0Px3KOsy9('\060' + chr(0b1100010 + 0o15) + '\062' + '\064', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001) + chr(2131 - 2079) + chr(2129 - 2076), 0b1000), ehT0Px3KOsy9('\x30' + chr(1474 - 1363) + chr(0b110001) + chr(734 - 684) + chr(1665 - 1613), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001) + chr(1937 - 1883) + chr(1749 - 1698), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(451 - 340) + chr(0b110101) + chr(0b101001 + 0o7), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd2'), chr(6352 - 6252) + chr(6663 - 6562) + chr(99) + chr(12197 - 12086) + chr(2644 - 2544) + chr(101))(chr(117) + '\164' + chr(0b1011110 + 0o10) + chr(275 - 230) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def j19zwKQwpMwL(oVre8I6UXc3b, kh68tYwZhgrY) -> qRxF7OQ0y39T[M8_cKLkHVB2V]: heJELtuJu3My = eb2I7aEma6r5.lisp_to_nested_expression(kh68tYwZhgrY) try: (WI0Qv2bziBjm, lf2bGbZLmhhS) = oVre8I6UXc3b._get_transitions(heJELtuJu3My, expected_type=None) if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa3=+5\xda\xe3AV)\xc7\x85.'), chr(0b1100000 + 0o4) + chr(0b1100101) + chr(99) + chr(3299 - 3188) + '\144' + chr(6903 - 6802))(chr(117) + chr(0b1010110 + 0o36) + chr(0b1011000 + 0o16) + '\x2d' + chr(337 - 281))) and lf2bGbZLmhhS not in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa3=+5\xda\xe3AV)\xc7\x85.'), '\144' + '\145' + chr(99) + chr(111) + chr(100) + '\145')(chr(0b110100 + 0o101) + '\164' + chr(0b1100110) + chr(0b101101) + chr(56))): raise MO1jGuXEVWyF(f'Expression had unallowed start type of {lf2bGbZLmhhS}: {heJELtuJu3My}') except MO1jGuXEVWyF: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\x1b;\x04\xc9\xe3Qqa\xc0\x98m'), chr(0b1100100) + '\145' + chr(0b1100011) + chr(111) + '\x64' + chr(2536 - 2435))(chr(0b1000010 + 0o63) + '\164' + chr(102) + chr(0b100110 + 0o7) + '\x38'))(f'Error parsing logical form: {kh68tYwZhgrY}') raise xafqLlk3kkUe(WI0Qv2bziBjm, xafqLlk3kkUe(SXOLrMavuUCe(b'\x95 ,1\xda\xe3'), '\x64' + chr(0b1100101) + chr(99) + '\x6f' + '\x64' + '\145')(chr(0b1110101) + '\164' + chr(102) + '\x2d' + chr(56)))(ehT0Px3KOsy9('\x30' + '\x6f' + '\060', 62926 - 62918), f'@start@ -> {lf2bGbZLmhhS}') return WI0Qv2bziBjm
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage.action_sequence_to_logical_form
def action_sequence_to_logical_form(self, action_sequence: List[str]) -> str: """ Takes an action sequence as produced by :func:`logical_form_to_action_sequence`, which is a linearization of an abstract syntax tree, and reconstructs the logical form defined by that abstract syntax tree. """ # Basic outline: we assume that the bracketing that we get in the RHS of each action is the # correct bracketing for reconstructing the logical form. This is true when there is no # currying in the action sequence. Given this assumption, we just need to construct a tree # from the action sequence, then output all of the leaves in the tree, with brackets around # the children of all non-terminal nodes. remaining_actions = [action.split(" -> ") for action in action_sequence] tree = Tree(remaining_actions[0][1], []) try: remaining_actions = self._construct_node_from_actions(tree, remaining_actions[1:]) except ParsingError: logger.error("Error parsing action sequence: %s", action_sequence) raise if remaining_actions: logger.error("Error parsing action sequence: %s", action_sequence) logger.error("Remaining actions were: %s", remaining_actions) raise ParsingError("Extra actions in action sequence") return nltk_tree_to_logical_form(tree)
python
def action_sequence_to_logical_form(self, action_sequence: List[str]) -> str: """ Takes an action sequence as produced by :func:`logical_form_to_action_sequence`, which is a linearization of an abstract syntax tree, and reconstructs the logical form defined by that abstract syntax tree. """ # Basic outline: we assume that the bracketing that we get in the RHS of each action is the # correct bracketing for reconstructing the logical form. This is true when there is no # currying in the action sequence. Given this assumption, we just need to construct a tree # from the action sequence, then output all of the leaves in the tree, with brackets around # the children of all non-terminal nodes. remaining_actions = [action.split(" -> ") for action in action_sequence] tree = Tree(remaining_actions[0][1], []) try: remaining_actions = self._construct_node_from_actions(tree, remaining_actions[1:]) except ParsingError: logger.error("Error parsing action sequence: %s", action_sequence) raise if remaining_actions: logger.error("Error parsing action sequence: %s", action_sequence) logger.error("Remaining actions were: %s", remaining_actions) raise ParsingError("Extra actions in action sequence") return nltk_tree_to_logical_form(tree)
[ "def", "action_sequence_to_logical_form", "(", "self", ",", "action_sequence", ":", "List", "[", "str", "]", ")", "->", "str", ":", "# Basic outline: we assume that the bracketing that we get in the RHS of each action is the", "# correct bracketing for reconstructing the logical form. This is true when there is no", "# currying in the action sequence. Given this assumption, we just need to construct a tree", "# from the action sequence, then output all of the leaves in the tree, with brackets around", "# the children of all non-terminal nodes.", "remaining_actions", "=", "[", "action", ".", "split", "(", "\" -> \"", ")", "for", "action", "in", "action_sequence", "]", "tree", "=", "Tree", "(", "remaining_actions", "[", "0", "]", "[", "1", "]", ",", "[", "]", ")", "try", ":", "remaining_actions", "=", "self", ".", "_construct_node_from_actions", "(", "tree", ",", "remaining_actions", "[", "1", ":", "]", ")", "except", "ParsingError", ":", "logger", ".", "error", "(", "\"Error parsing action sequence: %s\"", ",", "action_sequence", ")", "raise", "if", "remaining_actions", ":", "logger", ".", "error", "(", "\"Error parsing action sequence: %s\"", ",", "action_sequence", ")", "logger", ".", "error", "(", "\"Remaining actions were: %s\"", ",", "remaining_actions", ")", "raise", "ParsingError", "(", "\"Extra actions in action sequence\"", ")", "return", "nltk_tree_to_logical_form", "(", "tree", ")" ]
Takes an action sequence as produced by :func:`logical_form_to_action_sequence`, which is a linearization of an abstract syntax tree, and reconstructs the logical form defined by that abstract syntax tree.
[ "Takes", "an", "action", "sequence", "as", "produced", "by", ":", "func", ":", "logical_form_to_action_sequence", "which", "is", "a", "linearization", "of", "an", "abstract", "syntax", "tree", "and", "reconstructs", "the", "logical", "form", "defined", "by", "that", "abstract", "syntax", "tree", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L411-L436
train
Takes an action sequence as produced by logical_form_to_action_sequence and reconstructs the logical form of that tree.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmq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KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(2132 - 2084) + chr(111) + chr(50) + '\x30' + chr(1680 - 1626), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1001111 + 0o40) + '\061' + chr(50) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\157' + '\x31' + chr(55) + '\067', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010 + 0o1) + chr(0b110101) + chr(0b1100 + 0o46), 54629 - 54621), ehT0Px3KOsy9(chr(0b110000) + chr(10687 - 10576) + '\x31' + '\067' + chr(232 - 183), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11001 + 0o31) + '\065' + '\x37', 42362 - 42354), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + chr(0b110001) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\x6f' + chr(0b11011 + 0o26) + chr(0b110001) + '\063', 29801 - 29793), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + chr(0b110010) + '\063', 0o10), ehT0Px3KOsy9('\x30' + chr(0b10011 + 0o134) + chr(0b110001) + chr(0b110100) + chr(2295 - 2243), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b0 + 0o157) + '\062' + '\067' + '\062', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(815 - 766) + chr(48) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(1418 - 1370) + '\x6f' + '\061' + chr(319 - 271) + chr(0b110100), 0b1000), ehT0Px3KOsy9('\x30' + chr(5098 - 4987) + chr(293 - 244) + chr(0b110001) + '\x31', 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\x31' + chr(0b101 + 0o55) + chr(1539 - 1491), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31' + chr(52) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(111) + chr(0b110100) + chr(74 - 19), 0b1000), ehT0Px3KOsy9('\x30' + chr(7219 - 7108) + '\062' + chr(0b110111) + chr(0b101110 + 0o11), 41629 - 41621), ehT0Px3KOsy9(chr(655 - 607) + chr(0b1000101 + 0o52) + chr(0b110000 + 0o2) + '\061', 11823 - 11815), ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(0b10 + 0o155) + chr(0b101100 + 0o6) + '\067' + chr(51), 0o10), ehT0Px3KOsy9(chr(1962 - 1914) + chr(0b1101111) + chr(0b110010) + '\x33' + '\x36', 0o10), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(7389 - 7278) + chr(0b11101 + 0o31) + chr(48), 53245 - 53237), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110001 + 0o0) + chr(0b110011) + chr(0b110000), 0o10), ehT0Px3KOsy9('\060' + chr(0b1010111 + 0o30) + chr(51) + '\063' + '\x34', 11803 - 11795), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100001 + 0o16) + '\063' + chr(0b110001) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + '\064' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(1051 - 1003) + '\x6f' + chr(0b1101 + 0o45) + chr(0b101100 + 0o7) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(963 - 909) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(49) + '\060' + chr(2522 - 2467), 0o10), ehT0Px3KOsy9(chr(0b1110 + 0o42) + '\157' + '\065' + chr(49), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001) + chr(0b110000) + '\064', 8), ehT0Px3KOsy9('\060' + chr(8984 - 8873) + chr(1375 - 1326) + chr(323 - 268) + '\x32', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1630 - 1581) + chr(53) + '\x30', 0o10), ehT0Px3KOsy9(chr(2184 - 2136) + '\157' + chr(1646 - 1597) + '\x30' + '\067', 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + chr(0b110011) + chr(0b10101 + 0o42), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b0 + 0o62) + chr(52) + chr(0b101010 + 0o7), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\063' + '\x37' + '\x36', 0o10), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1010011 + 0o34) + '\061' + chr(0b110110) + '\062', 51703 - 51695), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(0b1000101 + 0o52) + chr(53) + chr(48), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b1010 + 0o50), 43559 - 43551)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11110 + 0o27) + chr(48), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa8'), '\144' + chr(0b1011011 + 0o12) + chr(99) + chr(111) + chr(0b1100100) + chr(101))(chr(0b1110101) + '\x74' + chr(102) + chr(1340 - 1295) + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def jbd5oMNUZCSD(oVre8I6UXc3b, FXNJIrDAzcxy) -> M8_cKLkHVB2V: klkIVilDKnwv = [vyskHDXig6uT.split(xafqLlk3kkUe(SXOLrMavuUCe(b'\xa6~A\xca'), chr(676 - 576) + '\145' + chr(0b1100011) + chr(0b111101 + 0o62) + '\x64' + chr(0b10000 + 0o125))(chr(0b1001100 + 0o51) + chr(116) + '\x66' + chr(0b100010 + 0o13) + '\070')) for vyskHDXig6uT in FXNJIrDAzcxy] ErHgKhTO5Wfb = EkzIH99VGiMZ(klkIVilDKnwv[ehT0Px3KOsy9(chr(578 - 530) + chr(111) + chr(736 - 688), 0b1000)][ehT0Px3KOsy9(chr(48) + chr(111) + '\061', 0b1000)], []) try: klkIVilDKnwv = oVre8I6UXc3b._construct_node_from_actions(ErHgKhTO5Wfb, klkIVilDKnwv[ehT0Px3KOsy9('\060' + '\x6f' + '\x31', 8):]) except MO1jGuXEVWyF: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc3\x06\x1b\xba\x18\xdb\x87\x18\xe2\x13\xc2p'), chr(0b1100100) + chr(101) + chr(99) + chr(0b1101111) + '\x64' + '\145')('\x75' + '\x74' + '\x66' + '\055' + chr(0b111000)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc3!\r\x85\x0b\x8f\xb8*\xa1\x17\xd3.#i1\x06S\xd6~\xd5\xbeC=\xad\xbb\x80\xf4P"\x13d_\x1b'), chr(100) + chr(0b111000 + 0o55) + chr(0b1011001 + 0o12) + chr(0b11110 + 0o121) + '\144' + chr(0b11000 + 0o115))('\165' + chr(0b1110100) + '\x66' + '\x2d' + chr(0b111000)), FXNJIrDAzcxy) raise if klkIVilDKnwv: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc3\x06\x1b\xba\x18\xdb\x87\x18\xe2\x13\xc2p'), chr(100) + chr(101) + chr(0b10110 + 0o115) + chr(0b110011 + 0o74) + chr(0b101111 + 0o65) + '\145')(chr(8199 - 8082) + '\164' + '\146' + '\x2d' + chr(866 - 810)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc3!\r\x85\x0b\x8f\xb8*\xa1\x17\xd3.#i1\x06S\xd6~\xd5\xbeC=\xad\xbb\x80\xf4P"\x13d_\x1b'), chr(0b1100100) + chr(1227 - 1126) + chr(0b1010001 + 0o22) + chr(0b1010010 + 0o35) + chr(6566 - 6466) + '\x65')(chr(117) + '\164' + '\146' + chr(0b10010 + 0o33) + chr(145 - 89)), FXNJIrDAzcxy) xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc3\x06\x1b\xba\x18\xdb\x87\x18\xe2\x13\xc2p'), chr(100) + chr(0b1100101) + chr(7680 - 7581) + '\157' + '\144' + chr(101))(chr(0b1110101) + chr(0b1110100) + '\146' + chr(153 - 108) + chr(1861 - 1805)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd46\x12\x8b\x10\xc1\xa1%\xb4D\xdb#0 ?\x0bT\x9ff\xde\xecUb\xfc\xeb\x96'), chr(1210 - 1110) + chr(101) + chr(0b100011 + 0o100) + chr(0b1101111) + chr(100) + chr(101))(chr(117) + chr(7976 - 7860) + chr(0b100111 + 0o77) + chr(381 - 336) + chr(0b111000 + 0o0)), klkIVilDKnwv) raise MO1jGuXEVWyF(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc3+\x0b\x98\x18\x8f\xa9(\xa7\r\xd5.7i9\x0b\x07\xder\xcf\xf7_6\xfc\xbd\x80\xebF"G\'\x1f'), chr(0b1100100) + '\145' + chr(0b1100011) + chr(111) + chr(8773 - 8673) + chr(912 - 811))(chr(0b1110 + 0o147) + chr(116) + chr(102) + chr(45) + chr(56))) return go8qkK5qcgxB(ErHgKhTO5Wfb)
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage.add_predicate
def add_predicate(self, name: str, function: Callable, side_arguments: List[str] = None): """ Adds a predicate to this domain language. Typically you do this with the ``@predicate`` decorator on the methods in your class. But, if you need to for whatever reason, you can also call this function yourself with a (type-annotated) function to add it to your language. Parameters ---------- name : ``str`` The name that we will use in the induced language for this function. function : ``Callable`` The function that gets called when executing a predicate with the given name. side_arguments : ``List[str]``, optional If given, we will ignore these arguments for the purposes of grammar induction. This is to allow passing extra arguments from the decoder state that are not explicitly part of the language the decoder produces, such as the decoder's attention over the question when a terminal was predicted. If you use this functionality, you also `must` use ``language.execute_action_sequence()`` instead of ``language.execute()``, and you must pass the additional side arguments needed to that function. See :func:`execute_action_sequence` for more information. """ side_arguments = side_arguments or [] signature = inspect.signature(function) argument_types = [param.annotation for name, param in signature.parameters.items() if name not in side_arguments] return_type = signature.return_annotation argument_nltk_types: List[PredicateType] = [PredicateType.get_type(arg_type) for arg_type in argument_types] return_nltk_type = PredicateType.get_type(return_type) function_nltk_type = PredicateType.get_function_type(argument_nltk_types, return_nltk_type) self._functions[name] = function self._function_types[name].append(function_nltk_type)
python
def add_predicate(self, name: str, function: Callable, side_arguments: List[str] = None): """ Adds a predicate to this domain language. Typically you do this with the ``@predicate`` decorator on the methods in your class. But, if you need to for whatever reason, you can also call this function yourself with a (type-annotated) function to add it to your language. Parameters ---------- name : ``str`` The name that we will use in the induced language for this function. function : ``Callable`` The function that gets called when executing a predicate with the given name. side_arguments : ``List[str]``, optional If given, we will ignore these arguments for the purposes of grammar induction. This is to allow passing extra arguments from the decoder state that are not explicitly part of the language the decoder produces, such as the decoder's attention over the question when a terminal was predicted. If you use this functionality, you also `must` use ``language.execute_action_sequence()`` instead of ``language.execute()``, and you must pass the additional side arguments needed to that function. See :func:`execute_action_sequence` for more information. """ side_arguments = side_arguments or [] signature = inspect.signature(function) argument_types = [param.annotation for name, param in signature.parameters.items() if name not in side_arguments] return_type = signature.return_annotation argument_nltk_types: List[PredicateType] = [PredicateType.get_type(arg_type) for arg_type in argument_types] return_nltk_type = PredicateType.get_type(return_type) function_nltk_type = PredicateType.get_function_type(argument_nltk_types, return_nltk_type) self._functions[name] = function self._function_types[name].append(function_nltk_type)
[ "def", "add_predicate", "(", "self", ",", "name", ":", "str", ",", "function", ":", "Callable", ",", "side_arguments", ":", "List", "[", "str", "]", "=", "None", ")", ":", "side_arguments", "=", "side_arguments", "or", "[", "]", "signature", "=", "inspect", ".", "signature", "(", "function", ")", "argument_types", "=", "[", "param", ".", "annotation", "for", "name", ",", "param", "in", "signature", ".", "parameters", ".", "items", "(", ")", "if", "name", "not", "in", "side_arguments", "]", "return_type", "=", "signature", ".", "return_annotation", "argument_nltk_types", ":", "List", "[", "PredicateType", "]", "=", "[", "PredicateType", ".", "get_type", "(", "arg_type", ")", "for", "arg_type", "in", "argument_types", "]", "return_nltk_type", "=", "PredicateType", ".", "get_type", "(", "return_type", ")", "function_nltk_type", "=", "PredicateType", ".", "get_function_type", "(", "argument_nltk_types", ",", "return_nltk_type", ")", "self", ".", "_functions", "[", "name", "]", "=", "function", "self", ".", "_function_types", "[", "name", "]", ".", "append", "(", "function_nltk_type", ")" ]
Adds a predicate to this domain language. Typically you do this with the ``@predicate`` decorator on the methods in your class. But, if you need to for whatever reason, you can also call this function yourself with a (type-annotated) function to add it to your language. Parameters ---------- name : ``str`` The name that we will use in the induced language for this function. function : ``Callable`` The function that gets called when executing a predicate with the given name. side_arguments : ``List[str]``, optional If given, we will ignore these arguments for the purposes of grammar induction. This is to allow passing extra arguments from the decoder state that are not explicitly part of the language the decoder produces, such as the decoder's attention over the question when a terminal was predicted. If you use this functionality, you also `must` use ``language.execute_action_sequence()`` instead of ``language.execute()``, and you must pass the additional side arguments needed to that function. See :func:`execute_action_sequence` for more information.
[ "Adds", "a", "predicate", "to", "this", "domain", "language", ".", "Typically", "you", "do", "this", "with", "the", "@predicate", "decorator", "on", "the", "methods", "in", "your", "class", ".", "But", "if", "you", "need", "to", "for", "whatever", "reason", "you", "can", "also", "call", "this", "function", "yourself", "with", "a", "(", "type", "-", "annotated", ")", "function", "to", "add", "it", "to", "your", "language", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L438-L470
train
Adds a predicate to the internal dictionary.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E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EN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b10010 + 0o36) + '\157' + '\x33' + '\x32' + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(49) + '\x37' + chr(0b1100 + 0o45), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + chr(1318 - 1267) + chr(0b0 + 0o65), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b11010 + 0o32) + '\x34', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\062' + chr(998 - 943) + chr(1794 - 1742), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + chr(2160 - 2108) + '\062', 62456 - 62448), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(49), 13190 - 13182), ehT0Px3KOsy9('\x30' + chr(5877 - 5766) + chr(2144 - 2093) + chr(55) + '\x35', 14125 - 14117), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000101 + 0o52) + '\x36' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110010) + chr(192 - 143) + chr(0b110101), 0o10), ehT0Px3KOsy9('\x30' + chr(0b10100 + 0o133) + chr(50) + chr(1679 - 1625) + chr(0b1101 + 0o46), ord("\x08")), ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\x6f' + chr(1492 - 1441) + chr(650 - 595) + chr(0b11111 + 0o25), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(2588 - 2537) + chr(49) + chr(1201 - 1146), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + '\x33' + chr(297 - 242), 41808 - 41800), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110011) + '\x37' + chr(0b110001 + 0o0), 40444 - 40436), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\063' + '\x30' + '\x30', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(53) + '\x30', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b10011 + 0o134) + '\062' + '\062', 24019 - 24011), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(111) + chr(699 - 649) + '\066' + '\066', 49364 - 49356), ehT0Px3KOsy9(chr(526 - 478) + '\157' + chr(50) + '\x30', 33688 - 33680), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + chr(0b100101 + 0o22) + chr(49), 8), ehT0Px3KOsy9(chr(2156 - 2108) + chr(0b1010011 + 0o34) + chr(0b110001) + '\x34' + chr(0b110011), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10010 + 0o41) + chr(55) + chr(0b110010), 31881 - 31873), ehT0Px3KOsy9(chr(0b110000) + chr(11379 - 11268) + chr(2264 - 2215) + chr(0b101011 + 0o5) + chr(0b100100 + 0o15), 0b1000), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(0b1101111) + chr(0b11101 + 0o24) + '\x31' + chr(48), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000010 + 0o55) + chr(0b110001) + chr(0b110101) + chr(1318 - 1269), 0o10), ehT0Px3KOsy9(chr(601 - 553) + '\x6f' + '\x32' + '\060' + chr(0b110111), 0o10), ehT0Px3KOsy9('\060' + chr(7292 - 7181) + '\062' + '\x36' + chr(1283 - 1229), 8), ehT0Px3KOsy9('\x30' + chr(111) + chr(2537 - 2486), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111 + 0o0) + chr(995 - 946) + chr(52) + chr(536 - 481), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b100111 + 0o13) + '\x34' + chr(0b110000), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1100010 + 0o15) + chr(114 - 63) + chr(0b10010 + 0o36) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + chr(0b0 + 0o60) + chr(0b1100 + 0o53), 0b1000), ehT0Px3KOsy9(chr(0b11011 + 0o25) + '\x6f' + chr(0b110001) + chr(0b10010 + 0o40) + chr(1110 - 1059), 14214 - 14206), ehT0Px3KOsy9(chr(2040 - 1992) + '\x6f' + '\062' + '\x36' + '\062', 0o10), ehT0Px3KOsy9(chr(48) + chr(8050 - 7939) + chr(0b110101) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(2061 - 2013) + '\157' + chr(1052 - 1003) + '\x32', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b10 + 0o155) + chr(1205 - 1156) + chr(0b110000) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + '\067' + chr(706 - 656), 36821 - 36813), ehT0Px3KOsy9(chr(183 - 135) + '\x6f' + chr(49) + chr(0b110001) + '\x35', 65529 - 65521)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(0b1100100 + 0o13) + chr(53) + '\x30', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xfa'), chr(0b1001000 + 0o34) + '\145' + '\143' + chr(369 - 258) + '\x64' + chr(0b1000101 + 0o40))(chr(5883 - 5766) + chr(0b1011110 + 0o26) + '\146' + '\055' + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def hzgEd0rtjka3(oVre8I6UXc3b, AIvJRzLdDfgF, bBC93MgSHzUB, Z33WzR1MnG4V=None): Z33WzR1MnG4V = Z33WzR1MnG4V or [] W65V97aJT0Tb = kzXqv8ZZwm75.signature(bBC93MgSHzUB) DjtzGpnspIKq = [NOaGA2BHucaX.annotation for (AIvJRzLdDfgF, NOaGA2BHucaX) in W65V97aJT0Tb.parameters.NzveIZ3IlSH9() if AIvJRzLdDfgF not in Z33WzR1MnG4V] ELL59KGwZKj3 = W65V97aJT0Tb.return_annotation AyEyTm8BBbXf = [YPmBFLkEKJVV.get_type(u88a6oLul0L6) for u88a6oLul0L6 in DjtzGpnspIKq] nJhf8YcJoNrZ = YPmBFLkEKJVV.get_type(ELL59KGwZKj3) fSSINaeTPnit = YPmBFLkEKJVV.get_function_type(AyEyTm8BBbXf, nJhf8YcJoNrZ) oVre8I6UXc3b.Ggq5QBq2xVP8[AIvJRzLdDfgF] = bBC93MgSHzUB xafqLlk3kkUe(oVre8I6UXc3b._function_types[AIvJRzLdDfgF], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb5\t\xedA\xd2\xc6'), chr(0b1001001 + 0o33) + chr(0b1011010 + 0o13) + chr(7867 - 7768) + '\157' + chr(100) + chr(0b1000 + 0o135))('\x75' + '\x74' + chr(6058 - 5956) + chr(148 - 103) + chr(0b111000)))(fSSINaeTPnit)
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage.add_constant
def add_constant(self, name: str, value: Any, type_: Type = None): """ Adds a constant to this domain language. You would typically just pass in a list of constants to the ``super().__init__()`` call in your constructor, but you can also call this method to add constants if it is more convenient. Because we construct a grammar over this language for you, in order for the grammar to be finite we cannot allow arbitrary constants. Having a finite grammar is important when you're doing semantic parsing - we need to be able to search over this space, and compute normalized probability distributions. """ value_type = type_ if type_ else type(value) constant_type = PredicateType.get_type(value_type) self._functions[name] = lambda: value self._function_types[name].append(constant_type)
python
def add_constant(self, name: str, value: Any, type_: Type = None): """ Adds a constant to this domain language. You would typically just pass in a list of constants to the ``super().__init__()`` call in your constructor, but you can also call this method to add constants if it is more convenient. Because we construct a grammar over this language for you, in order for the grammar to be finite we cannot allow arbitrary constants. Having a finite grammar is important when you're doing semantic parsing - we need to be able to search over this space, and compute normalized probability distributions. """ value_type = type_ if type_ else type(value) constant_type = PredicateType.get_type(value_type) self._functions[name] = lambda: value self._function_types[name].append(constant_type)
[ "def", "add_constant", "(", "self", ",", "name", ":", "str", ",", "value", ":", "Any", ",", "type_", ":", "Type", "=", "None", ")", ":", "value_type", "=", "type_", "if", "type_", "else", "type", "(", "value", ")", "constant_type", "=", "PredicateType", ".", "get_type", "(", "value_type", ")", "self", ".", "_functions", "[", "name", "]", "=", "lambda", ":", "value", "self", ".", "_function_types", "[", "name", "]", ".", "append", "(", "constant_type", ")" ]
Adds a constant to this domain language. You would typically just pass in a list of constants to the ``super().__init__()`` call in your constructor, but you can also call this method to add constants if it is more convenient. Because we construct a grammar over this language for you, in order for the grammar to be finite we cannot allow arbitrary constants. Having a finite grammar is important when you're doing semantic parsing - we need to be able to search over this space, and compute normalized probability distributions.
[ "Adds", "a", "constant", "to", "this", "domain", "language", ".", "You", "would", "typically", "just", "pass", "in", "a", "list", "of", "constants", "to", "the", "super", "()", ".", "__init__", "()", "call", "in", "your", "constructor", "but", "you", "can", "also", "call", "this", "method", "to", "add", "constants", "if", "it", "is", "more", "convenient", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L472-L486
train
Adds a constant to this domain language.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU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8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b1111 + 0o42) + '\x37' + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b1001 + 0o47) + '\157' + '\x33' + '\x32' + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(111) + chr(0b11110 + 0o24) + chr(52) + '\065', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b111111 + 0o60) + '\x33' + '\063' + chr(48), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + chr(55) + chr(749 - 697), 8), ehT0Px3KOsy9(chr(1403 - 1355) + chr(6012 - 5901) + '\x31' + chr(0b1100 + 0o44) + chr(0b101010 + 0o14), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1011 + 0o144) + '\x31' + chr(53) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(1921 - 1873) + chr(111) + chr(431 - 380) + chr(0b100011 + 0o16), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001 + 0o0) + chr(0b110011 + 0o2) + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110101) + chr(1928 - 1877), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010001 + 0o36) + '\061' + '\061' + chr(53), 25869 - 25861), ehT0Px3KOsy9(chr(1574 - 1526) + chr(0b100110 + 0o111) + '\x32' + '\062' + chr(0b10101 + 0o35), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(49) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b11011 + 0o124) + chr(0b110010) + chr(0b11110 + 0o22), 49801 - 49793), ehT0Px3KOsy9('\060' + chr(111) + chr(0b11101 + 0o25) + chr(0b110100) + chr(1342 - 1291), 0o10), ehT0Px3KOsy9(chr(366 - 318) + '\157' + chr(756 - 705) + chr(49) + '\x35', 7300 - 7292), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(54) + '\061', 0o10), ehT0Px3KOsy9(chr(68 - 20) + '\x6f' + '\x31' + '\x31' + chr(0b100110 + 0o15), 0b1000), ehT0Px3KOsy9('\060' + chr(0b10101 + 0o132) + chr(1364 - 1315) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + '\x34' + '\064', 60293 - 60285), ehT0Px3KOsy9(chr(0b0 + 0o60) + '\157' + chr(767 - 717) + '\x31' + chr(506 - 457), 42908 - 42900), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(111) + chr(0b110011) + chr(2956 - 2901) + chr(1129 - 1074), ord("\x08")), ehT0Px3KOsy9(chr(879 - 831) + chr(0b1101111) + chr(0b110010) + '\x31' + '\x31', 8), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(0b100110 + 0o111) + '\063' + chr(811 - 759) + chr(0b100111 + 0o16), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(54) + chr(0b10100 + 0o42), 0o10), ehT0Px3KOsy9('\060' + '\157' + '\063' + '\x37', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(190 - 141) + '\067' + '\066', 0b1000), ehT0Px3KOsy9(chr(1578 - 1530) + chr(0b101111 + 0o100) + '\x33' + chr(1654 - 1603) + chr(1179 - 1130), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\x33' + chr(55) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(122 - 74) + chr(111) + chr(0b110011) + chr(0b110110) + chr(0b110100), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(55) + chr(0b110001 + 0o2), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + '\x32' + chr(0b1010 + 0o50), 8), ehT0Px3KOsy9(chr(1713 - 1665) + '\x6f' + '\062' + chr(1854 - 1806) + chr(54), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + '\x30' + chr(0b11011 + 0o32), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001) + chr(0b10000 + 0o41) + '\x33', 8), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(0b11 + 0o154) + '\x31' + '\062' + '\x37', 1803 - 1795), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(54) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + '\063' + chr(1481 - 1427) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(8307 - 8196) + chr(1822 - 1773) + chr(55), 0b1000), ehT0Px3KOsy9(chr(2262 - 2214) + '\157' + '\062' + chr(50) + chr(48), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(849 - 801) + chr(111) + '\065' + chr(0b101111 + 0o1), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'R'), '\x64' + chr(0b1111 + 0o126) + chr(0b1100011) + chr(0b1101111) + chr(0b1100100) + '\x65')(chr(0b1110101) + chr(116) + chr(0b1100110) + '\x2d' + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def Q3TmWTPdtwwX(oVre8I6UXc3b, AIvJRzLdDfgF, QmmgWUB13VCJ, wglhj4WQZuCT=None): Mkc1eSH9mVGe = wglhj4WQZuCT if wglhj4WQZuCT else wmQmyeWBmUpv(QmmgWUB13VCJ) Sv_PjCA164hG = YPmBFLkEKJVV.get_type(Mkc1eSH9mVGe) oVre8I6UXc3b.Ggq5QBq2xVP8[AIvJRzLdDfgF] = lambda : QmmgWUB13VCJ xafqLlk3kkUe(oVre8I6UXc3b._function_types[AIvJRzLdDfgF], xafqLlk3kkUe(SXOLrMavuUCe(b'\x1d\xa0\xd5\xbd\x12"'), chr(9997 - 9897) + '\x65' + chr(0b1100011) + chr(780 - 669) + chr(0b1100100) + chr(0b1100101))(chr(0b1101000 + 0o15) + chr(116) + chr(0b1000101 + 0o41) + chr(45) + chr(0b110010 + 0o6)))(Sv_PjCA164hG)
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage.is_nonterminal
def is_nonterminal(self, symbol: str) -> bool: """ Determines whether an input symbol is a valid non-terminal in the grammar. """ nonterminal_productions = self.get_nonterminal_productions() return symbol in nonterminal_productions
python
def is_nonterminal(self, symbol: str) -> bool: """ Determines whether an input symbol is a valid non-terminal in the grammar. """ nonterminal_productions = self.get_nonterminal_productions() return symbol in nonterminal_productions
[ "def", "is_nonterminal", "(", "self", ",", "symbol", ":", "str", ")", "->", "bool", ":", "nonterminal_productions", "=", "self", ".", "get_nonterminal_productions", "(", ")", "return", "symbol", "in", "nonterminal_productions" ]
Determines whether an input symbol is a valid non-terminal in the grammar.
[ "Determines", "whether", "an", "input", "symbol", "is", "a", "valid", "non", "-", "terminal", "in", "the", "grammar", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L488-L493
train
Determines whether an input symbol is a valid non - terminal in the grammar.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDz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,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(0b1001110 + 0o41) + chr(0b110001) + '\x34' + '\061', 0o10), ehT0Px3KOsy9(chr(523 - 475) + '\x6f' + chr(1519 - 1468), 0o10), ehT0Px3KOsy9('\060' + chr(6466 - 6355) + chr(320 - 269) + chr(2801 - 2746) + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + chr(2411 - 2300) + chr(49) + '\x34' + chr(0b100110 + 0o14), ord("\x08")), ehT0Px3KOsy9(chr(841 - 793) + chr(0b1000011 + 0o54) + chr(51) + '\x30' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(683 - 635) + chr(0b1101111) + '\062' + chr(0b110010) + '\x32', 0o10), ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\x6f' + chr(49) + chr(0b110101) + '\060', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + chr(54) + chr(52), 0o10), ehT0Px3KOsy9('\060' + chr(11369 - 11258) + chr(0b110001) + chr(51) + chr(0b10100 + 0o36), ord("\x08")), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1101111) + chr(49) + chr(0b110110) + '\061', 44173 - 44165), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(7232 - 7121) + chr(1703 - 1653) + chr(0b110000) + chr(0b110000), 59229 - 59221), ehT0Px3KOsy9('\x30' + chr(2876 - 2765) + chr(0b1001 + 0o51) + '\x36' + chr(1292 - 1239), 0o10), ehT0Px3KOsy9(chr(217 - 169) + chr(0b1000010 + 0o55) + chr(0b110001) + '\x34' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49) + '\x36' + chr(2180 - 2131), 8), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(111) + '\061' + '\x33' + chr(0b110100), 25191 - 25183), ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\157' + chr(1839 - 1789) + '\062', 36898 - 36890), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + chr(0b110011 + 0o2) + chr(55), 7254 - 7246), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b11000 + 0o32) + '\x33' + chr(54), 0b1000), ehT0Px3KOsy9(chr(2270 - 2222) + chr(111) + chr(51) + '\x37' + '\067', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(989 - 937) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\063' + '\x37' + '\060', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1001001 + 0o46) + '\x31' + '\066' + '\x33', 0b1000), ehT0Px3KOsy9(chr(508 - 460) + '\157' + chr(0b0 + 0o62) + chr(388 - 334) + '\066', 0b1000), ehT0Px3KOsy9(chr(1133 - 1085) + '\157' + '\062' + chr(0b100101 + 0o17) + '\060', 0o10), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b0 + 0o157) + chr(0b110001) + chr(54) + chr(0b1001 + 0o52), 8), ehT0Px3KOsy9('\x30' + chr(0b110100 + 0o73) + chr(50) + chr(2409 - 2358) + chr(0b110110), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(51) + chr(0b110101 + 0o0), 65019 - 65011), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011011 + 0o24) + '\063' + '\x34' + chr(53), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + '\067' + '\067', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b11100 + 0o123) + chr(946 - 895) + chr(0b1000 + 0o55) + '\063', 0o10), ehT0Px3KOsy9(chr(986 - 938) + chr(9583 - 9472) + chr(0b100100 + 0o15) + chr(0b111 + 0o51) + chr(0b101100 + 0o7), 0o10), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101101 + 0o2) + chr(50) + '\064' + '\063', 0o10), ehT0Px3KOsy9(chr(889 - 841) + chr(0b1101111) + chr(0b11 + 0o60) + chr(0b110000) + chr(908 - 860), 56855 - 56847), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(0b11111 + 0o23) + chr(50), 8), ehT0Px3KOsy9('\060' + chr(2340 - 2229) + chr(0b110100) + '\063', 0b1000), ehT0Px3KOsy9(chr(1451 - 1403) + '\x6f' + '\063' + '\064' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(337 - 289) + '\157' + chr(51) + chr(55) + chr(0b1000 + 0o55), ord("\x08")), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(5562 - 5451) + chr(569 - 519) + '\x36' + chr(0b10110 + 0o40), 8), ehT0Px3KOsy9(chr(48) + chr(0b1001000 + 0o47) + '\065' + chr(1492 - 1439), 0o10), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(0b1101111) + chr(337 - 286) + chr(0b110001) + '\061', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(2163 - 2115) + chr(0b1000101 + 0o52) + chr(0b100110 + 0o17) + '\060', 54776 - 54768)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'O'), chr(100) + '\145' + '\143' + chr(10714 - 10603) + chr(3270 - 3170) + chr(0b1100101))(chr(5298 - 5181) + chr(116) + chr(0b101011 + 0o73) + '\x2d' + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def iW4qfgQZQccm(oVre8I6UXc3b, Usr5ykvL2UZF) -> WbBjf8Y7v9VN: gnaHc3Jbqa8N = oVre8I6UXc3b.get_nonterminal_productions() return Usr5ykvL2UZF in gnaHc3Jbqa8N
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage._execute_expression
def _execute_expression(self, expression: Any): """ This does the bulk of the work of executing a logical form, recursively executing a single expression. Basically, if the expression is a function we know about, we evaluate its arguments then call the function. If it's a list, we evaluate all elements of the list. If it's a constant (or a zero-argument function), we evaluate the constant. """ # pylint: disable=too-many-return-statements if isinstance(expression, list): if isinstance(expression[0], list): function = self._execute_expression(expression[0]) elif expression[0] in self._functions: function = self._functions[expression[0]] else: if isinstance(expression[0], str): raise ExecutionError(f"Unrecognized function: {expression[0]}") else: raise ExecutionError(f"Unsupported expression type: {expression}") arguments = [self._execute_expression(arg) for arg in expression[1:]] try: return function(*arguments) except (TypeError, ValueError): traceback.print_exc() raise ExecutionError(f"Error executing expression {expression} (see stderr for stack trace)") elif isinstance(expression, str): if expression not in self._functions: raise ExecutionError(f"Unrecognized constant: {expression}") # This is a bit of a quirk in how we represent constants and zero-argument functions. # For consistency, constants are wrapped in a zero-argument lambda. So both constants # and zero-argument functions are callable in `self._functions`, and are `BasicTypes` # in `self._function_types`. For these, we want to return # `self._functions[expression]()` _calling_ the zero-argument function. If we get a # `FunctionType` in here, that means we're referring to the function as a first-class # object, instead of calling it (maybe as an argument to a higher-order function). In # that case, we return the function _without_ calling it. # Also, we just check the first function type here, because we assume you haven't # registered the same function with both a constant type and a `FunctionType`. if isinstance(self._function_types[expression][0], FunctionType): return self._functions[expression] else: return self._functions[expression]() return self._functions[expression] else: raise ExecutionError("Not sure how you got here. Please open a github issue with details.")
python
def _execute_expression(self, expression: Any): """ This does the bulk of the work of executing a logical form, recursively executing a single expression. Basically, if the expression is a function we know about, we evaluate its arguments then call the function. If it's a list, we evaluate all elements of the list. If it's a constant (or a zero-argument function), we evaluate the constant. """ # pylint: disable=too-many-return-statements if isinstance(expression, list): if isinstance(expression[0], list): function = self._execute_expression(expression[0]) elif expression[0] in self._functions: function = self._functions[expression[0]] else: if isinstance(expression[0], str): raise ExecutionError(f"Unrecognized function: {expression[0]}") else: raise ExecutionError(f"Unsupported expression type: {expression}") arguments = [self._execute_expression(arg) for arg in expression[1:]] try: return function(*arguments) except (TypeError, ValueError): traceback.print_exc() raise ExecutionError(f"Error executing expression {expression} (see stderr for stack trace)") elif isinstance(expression, str): if expression not in self._functions: raise ExecutionError(f"Unrecognized constant: {expression}") # This is a bit of a quirk in how we represent constants and zero-argument functions. # For consistency, constants are wrapped in a zero-argument lambda. So both constants # and zero-argument functions are callable in `self._functions`, and are `BasicTypes` # in `self._function_types`. For these, we want to return # `self._functions[expression]()` _calling_ the zero-argument function. If we get a # `FunctionType` in here, that means we're referring to the function as a first-class # object, instead of calling it (maybe as an argument to a higher-order function). In # that case, we return the function _without_ calling it. # Also, we just check the first function type here, because we assume you haven't # registered the same function with both a constant type and a `FunctionType`. if isinstance(self._function_types[expression][0], FunctionType): return self._functions[expression] else: return self._functions[expression]() return self._functions[expression] else: raise ExecutionError("Not sure how you got here. Please open a github issue with details.")
[ "def", "_execute_expression", "(", "self", ",", "expression", ":", "Any", ")", ":", "# pylint: disable=too-many-return-statements", "if", "isinstance", "(", "expression", ",", "list", ")", ":", "if", "isinstance", "(", "expression", "[", "0", "]", ",", "list", ")", ":", "function", "=", "self", ".", "_execute_expression", "(", "expression", "[", "0", "]", ")", "elif", "expression", "[", "0", "]", "in", "self", ".", "_functions", ":", "function", "=", "self", ".", "_functions", "[", "expression", "[", "0", "]", "]", "else", ":", "if", "isinstance", "(", "expression", "[", "0", "]", ",", "str", ")", ":", "raise", "ExecutionError", "(", "f\"Unrecognized function: {expression[0]}\"", ")", "else", ":", "raise", "ExecutionError", "(", "f\"Unsupported expression type: {expression}\"", ")", "arguments", "=", "[", "self", ".", "_execute_expression", "(", "arg", ")", "for", "arg", "in", "expression", "[", "1", ":", "]", "]", "try", ":", "return", "function", "(", "*", "arguments", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "traceback", ".", "print_exc", "(", ")", "raise", "ExecutionError", "(", "f\"Error executing expression {expression} (see stderr for stack trace)\"", ")", "elif", "isinstance", "(", "expression", ",", "str", ")", ":", "if", "expression", "not", "in", "self", ".", "_functions", ":", "raise", "ExecutionError", "(", "f\"Unrecognized constant: {expression}\"", ")", "# This is a bit of a quirk in how we represent constants and zero-argument functions.", "# For consistency, constants are wrapped in a zero-argument lambda. So both constants", "# and zero-argument functions are callable in `self._functions`, and are `BasicTypes`", "# in `self._function_types`. For these, we want to return", "# `self._functions[expression]()` _calling_ the zero-argument function. If we get a", "# `FunctionType` in here, that means we're referring to the function as a first-class", "# object, instead of calling it (maybe as an argument to a higher-order function). In", "# that case, we return the function _without_ calling it.", "# Also, we just check the first function type here, because we assume you haven't", "# registered the same function with both a constant type and a `FunctionType`.", "if", "isinstance", "(", "self", ".", "_function_types", "[", "expression", "]", "[", "0", "]", ",", "FunctionType", ")", ":", "return", "self", ".", "_functions", "[", "expression", "]", "else", ":", "return", "self", ".", "_functions", "[", "expression", "]", "(", ")", "return", "self", ".", "_functions", "[", "expression", "]", "else", ":", "raise", "ExecutionError", "(", "\"Not sure how you got here. Please open a github issue with details.\"", ")" ]
This does the bulk of the work of executing a logical form, recursively executing a single expression. Basically, if the expression is a function we know about, we evaluate its arguments then call the function. If it's a list, we evaluate all elements of the list. If it's a constant (or a zero-argument function), we evaluate the constant.
[ "This", "does", "the", "bulk", "of", "the", "work", "of", "executing", "a", "logical", "form", "recursively", "executing", "a", "single", "expression", ".", "Basically", "if", "the", "expression", "is", "a", "function", "we", "know", "about", "we", "evaluate", "its", "arguments", "then", "call", "the", "function", ".", "If", "it", "s", "a", "list", "we", "evaluate", "all", "elements", "of", "the", "list", ".", "If", "it", "s", "a", "constant", "(", "or", "a", "zero", "-", "argument", "function", ")", "we", "evaluate", "the", "constant", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L496-L539
train
Executes a logical form of expression.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF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rokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + '\x33' + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(5392 - 5281) + '\061' + chr(0b100 + 0o57) + chr(50), 0b1000), ehT0Px3KOsy9(chr(189 - 141) + chr(0b111000 + 0o67) + '\x33' + '\x31' + chr(50), 60428 - 60420), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + chr(0b110011) + chr(53) + chr(0b100110 + 0o15), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(891 - 780) + chr(0b110011) + '\065' + '\x37', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1000100 + 0o53) + '\x32' + chr(1739 - 1690) + chr(0b0 + 0o60), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(54) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1010100 + 0o33) + chr(554 - 504) + '\066' + chr(2646 - 2594), ord("\x08")), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(111) + chr(50) + chr(1908 - 1857) + chr(1829 - 1777), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b100000 + 0o117) + '\063' + chr(0b101100 + 0o5) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1100000 + 0o17) + chr(2075 - 2024) + '\064' + '\067', 0b1000), ehT0Px3KOsy9('\060' + chr(0b100011 + 0o114) + chr(50) + chr(0b11000 + 0o34) + chr(2327 - 2274), ord("\x08")), ehT0Px3KOsy9('\060' + chr(8455 - 8344) + '\x31' + chr(886 - 835) + chr(54), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(51) + chr(843 - 795) + chr(0b110101), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(50) + chr(55), 0o10), ehT0Px3KOsy9(chr(1271 - 1223) + chr(1161 - 1050) + '\065', 34709 - 34701), ehT0Px3KOsy9(chr(446 - 398) + '\157' + chr(0b110001) + chr(1369 - 1317) + '\061', 0o10), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(0b1100001 + 0o16) + '\x33' + '\x31' + chr(1745 - 1691), ord("\x08")), ehT0Px3KOsy9(chr(198 - 150) + chr(939 - 828) + chr(54) + '\x31', 0b1000), ehT0Px3KOsy9(chr(1042 - 994) + chr(0b11101 + 0o122) + chr(54) + chr(54), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(9594 - 9483) + '\061' + '\066', 60198 - 60190), ehT0Px3KOsy9(chr(48) + chr(1093 - 982) + '\x33' + chr(0b110001) + chr(0b110000), 8), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1011100 + 0o23) + chr(0b101110 + 0o3) + '\065' + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(1152 - 1099) + chr(1747 - 1696), 8), ehT0Px3KOsy9(chr(0b101010 + 0o6) + '\x6f' + chr(1438 - 1387) + chr(0b11 + 0o55) + chr(50), 0o10), ehT0Px3KOsy9(chr(712 - 664) + chr(0b1001111 + 0o40) + chr(1341 - 1292) + '\064' + chr(0b11101 + 0o30), 61798 - 61790), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b1100 + 0o47) + '\x35' + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(1841 - 1793) + chr(0b1101111) + chr(51) + '\x35' + '\066', 0o10), ehT0Px3KOsy9(chr(0b10111 + 0o31) + '\x6f' + chr(52) + '\060', 0b1000), ehT0Px3KOsy9(chr(774 - 726) + chr(0b1101111) + chr(0b110011) + chr(0b110100) + chr(0b101011 + 0o12), 58208 - 58200), ehT0Px3KOsy9(chr(48) + '\157' + chr(49) + '\064' + chr(51), 49292 - 49284), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(1717 - 1606) + chr(594 - 543) + chr(49) + '\x32', 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b110001 + 0o76) + chr(0b110011) + '\067' + chr(0b100110 + 0o16), 51736 - 51728), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1566 - 1516) + chr(0b110010) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(2047 - 1999) + '\157' + '\x31' + chr(0b100111 + 0o13) + chr(0b110111), 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + '\x34' + chr(53), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + chr(451 - 398) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(111) + chr(0b10111 + 0o34) + chr(0b110011) + '\x31', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b10111 + 0o34) + chr(48) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(156 - 108) + '\157' + chr(1462 - 1413), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(9637 - 9526) + chr(0b110101) + '\x30', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xb1'), chr(0b101010 + 0o72) + '\x65' + chr(99) + '\157' + '\x64' + chr(8469 - 8368))(chr(0b100001 + 0o124) + chr(12928 - 12812) + chr(3974 - 3872) + chr(1544 - 1499) + chr(1103 - 1047)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def NjkNHudkacsa(oVre8I6UXc3b, heJELtuJu3My): if PlSM16l2KDPD(heJELtuJu3My, YyaZ4tpXu4lf): if PlSM16l2KDPD(heJELtuJu3My[ehT0Px3KOsy9(chr(0b110000) + '\157' + '\060', 35376 - 35368)], YyaZ4tpXu4lf): bBC93MgSHzUB = oVre8I6UXc3b._execute_expression(heJELtuJu3My[ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(0b1010011 + 0o34) + '\x30', 8)]) elif heJELtuJu3My[ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + '\060', 8)] in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd8=\xbb\xde\xbe\xcaF\x86\xe4\x9e\xb7\x9d'), '\144' + '\145' + chr(2635 - 2536) + chr(0b1101101 + 0o2) + chr(0b1100100) + '\145')('\x75' + chr(116) + '\x66' + chr(0b100110 + 0o7) + chr(0b100101 + 0o23))): bBC93MgSHzUB = oVre8I6UXc3b.Ggq5QBq2xVP8[heJELtuJu3My[ehT0Px3KOsy9(chr(0b111 + 0o51) + '\157' + chr(48), 8)]] elif PlSM16l2KDPD(heJELtuJu3My[ehT0Px3KOsy9(chr(48) + chr(0b110111 + 0o70) + chr(48), 8)], M8_cKLkHVB2V): raise POyjkXRsHLE3(f'Unrecognized function: {heJELtuJu3My[0]}') else: raise POyjkXRsHLE3(f'Unsupported expression type: {heJELtuJu3My}') PSzOAxeRmbgw = [oVre8I6UXc3b._execute_expression(LTE9MPUbqSos) for LTE9MPUbqSos in heJELtuJu3My[ehT0Px3KOsy9(chr(541 - 493) + chr(111) + '\x31', 8):]] try: return bBC93MgSHzUB(*PSzOAxeRmbgw) except (sznFqDbNBHlx, q1QCh3W88sgk): xafqLlk3kkUe(CiXxQDnt84wa, xafqLlk3kkUe(SXOLrMavuUCe(b'\xef(\xa3\x85\x9b\xd7R\xcc\xff'), chr(100) + '\x65' + chr(0b100000 + 0o103) + '\x6f' + '\144' + '\145')('\x75' + chr(5507 - 5391) + chr(102) + '\055' + chr(0b10101 + 0o43)))() raise POyjkXRsHLE3(f'Error executing expression {heJELtuJu3My} (see stderr for stack trace)') elif PlSM16l2KDPD(heJELtuJu3My, M8_cKLkHVB2V): if heJELtuJu3My not in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd8=\xbb\xde\xbe\xcaF\x86\xe4\x9e\xb7\x9d'), '\144' + '\x65' + chr(99) + chr(0b111110 + 0o61) + chr(6246 - 6146) + chr(0b1100101))(chr(0b1110101) + chr(0b1110100) + chr(102) + chr(0b101101) + chr(763 - 707))): raise POyjkXRsHLE3(f'Unrecognized constant: {heJELtuJu3My}') if PlSM16l2KDPD(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0<\xbf\x85\x8c\xfc^\xdb\xf2\x97\x93\xdc.\xa0$'), chr(0b1011110 + 0o6) + chr(0b1000101 + 0o40) + chr(99) + chr(11021 - 10910) + chr(3764 - 3664) + chr(0b110011 + 0o62))(chr(117) + chr(0b1110100) + chr(0b1100110) + '\055' + chr(0b100111 + 0o21)))[heJELtuJu3My][ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(302 - 254), 8)], ric04wOk_EeU): return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd8=\xbb\xde\xbe\xcaF\x86\xe4\x9e\xb7\x9d'), chr(5346 - 5246) + chr(101) + chr(4437 - 4338) + chr(111) + chr(3335 - 3235) + '\x65')(chr(117) + '\164' + chr(313 - 211) + chr(0b100110 + 0o7) + '\x38'))[heJELtuJu3My] else: return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd8=\xbb\xde\xbe\xcaF\x86\xe4\x9e\xb7\x9d'), chr(100) + chr(0b10111 + 0o116) + '\x63' + chr(0b1100101 + 0o12) + chr(4345 - 4245) + chr(0b1100101))(chr(299 - 182) + chr(697 - 581) + chr(9704 - 9602) + chr(0b101101) + chr(0b111000)))[heJELtuJu3My]() return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd8=\xbb\xde\xbe\xcaF\x86\xe4\x9e\xb7\x9d'), '\x64' + '\x65' + '\143' + chr(111) + chr(100) + chr(101))(chr(0b1110101) + chr(0b1 + 0o163) + chr(0b1100110) + chr(45) + chr(0b100011 + 0o25)))[heJELtuJu3My] else: raise POyjkXRsHLE3(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd15\xbe\xcb\x9c\xfdE\xd1\xbc\xa0\x88\xd2~\xbc8pA\xa9^B.\xa0\x0b\x99\xa7K\xcd\xbeL\x80\x02\xb9\x99\xb58\x15\r\xb7\xe1`\xbf=\xa3\x9f\x87\xfdU\x94\xf5\xbb\x94\xd0;\xe5 l\x15\xa6\x11Rk\xbc\x0f\x82\xae\x16\xc3'), chr(0b1100100) + chr(0b1100101) + '\x63' + chr(0b1010011 + 0o34) + '\144' + '\x65')(chr(117) + chr(116) + '\146' + '\x2d' + '\x38'))
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage._execute_sequence
def _execute_sequence(self, action_sequence: List[str], side_arguments: List[Dict]) -> Tuple[Any, List[str], List[Dict]]: """ This does the bulk of the work of :func:`execute_action_sequence`, recursively executing the functions it finds and trimming actions off of the action sequence. The return value is a tuple of (execution, remaining_actions), where the second value is necessary to handle the recursion. """ first_action = action_sequence[0] remaining_actions = action_sequence[1:] remaining_side_args = side_arguments[1:] if side_arguments else None right_side = first_action.split(' -> ')[1] if right_side in self._functions: function = self._functions[right_side] # mypy doesn't like this check, saying that Callable isn't a reasonable thing to pass # here. But it works just fine; I'm not sure why mypy complains about it. if isinstance(function, Callable): # type: ignore function_arguments = inspect.signature(function).parameters if not function_arguments: # This was a zero-argument function / constant that was registered as a lambda # function, for consistency of execution in `execute()`. execution_value = function() elif side_arguments: kwargs = {} non_kwargs = [] for argument_name in function_arguments: if argument_name in side_arguments[0]: kwargs[argument_name] = side_arguments[0][argument_name] else: non_kwargs.append(argument_name) if kwargs and non_kwargs: # This is a function that has both side arguments and logical form # arguments - we curry the function so only the logical form arguments are # left. def curried_function(*args): return function(*args, **kwargs) execution_value = curried_function elif kwargs: # This is a function that _only_ has side arguments - we just call the # function and return a value. execution_value = function(**kwargs) else: # This is a function that has logical form arguments, but no side arguments # that match what we were given - just return the function itself. execution_value = function else: execution_value = function return execution_value, remaining_actions, remaining_side_args else: # This is a non-terminal expansion, like 'int -> [<int:int>, int, int]'. We need to # get the function and its arguments, then call the function with its arguments. # Because we linearize the abstract syntax tree depth first, left-to-right, we can just # recursively call `_execute_sequence` for the function and all of its arguments, and # things will just work. right_side_parts = right_side.split(', ') # We don't really need to know what the types are, just how many of them there are, so # we recurse the right number of times. function, remaining_actions, remaining_side_args = self._execute_sequence(remaining_actions, remaining_side_args) arguments = [] for _ in right_side_parts[1:]: argument, remaining_actions, remaining_side_args = self._execute_sequence(remaining_actions, remaining_side_args) arguments.append(argument) return function(*arguments), remaining_actions, remaining_side_args
python
def _execute_sequence(self, action_sequence: List[str], side_arguments: List[Dict]) -> Tuple[Any, List[str], List[Dict]]: """ This does the bulk of the work of :func:`execute_action_sequence`, recursively executing the functions it finds and trimming actions off of the action sequence. The return value is a tuple of (execution, remaining_actions), where the second value is necessary to handle the recursion. """ first_action = action_sequence[0] remaining_actions = action_sequence[1:] remaining_side_args = side_arguments[1:] if side_arguments else None right_side = first_action.split(' -> ')[1] if right_side in self._functions: function = self._functions[right_side] # mypy doesn't like this check, saying that Callable isn't a reasonable thing to pass # here. But it works just fine; I'm not sure why mypy complains about it. if isinstance(function, Callable): # type: ignore function_arguments = inspect.signature(function).parameters if not function_arguments: # This was a zero-argument function / constant that was registered as a lambda # function, for consistency of execution in `execute()`. execution_value = function() elif side_arguments: kwargs = {} non_kwargs = [] for argument_name in function_arguments: if argument_name in side_arguments[0]: kwargs[argument_name] = side_arguments[0][argument_name] else: non_kwargs.append(argument_name) if kwargs and non_kwargs: # This is a function that has both side arguments and logical form # arguments - we curry the function so only the logical form arguments are # left. def curried_function(*args): return function(*args, **kwargs) execution_value = curried_function elif kwargs: # This is a function that _only_ has side arguments - we just call the # function and return a value. execution_value = function(**kwargs) else: # This is a function that has logical form arguments, but no side arguments # that match what we were given - just return the function itself. execution_value = function else: execution_value = function return execution_value, remaining_actions, remaining_side_args else: # This is a non-terminal expansion, like 'int -> [<int:int>, int, int]'. We need to # get the function and its arguments, then call the function with its arguments. # Because we linearize the abstract syntax tree depth first, left-to-right, we can just # recursively call `_execute_sequence` for the function and all of its arguments, and # things will just work. right_side_parts = right_side.split(', ') # We don't really need to know what the types are, just how many of them there are, so # we recurse the right number of times. function, remaining_actions, remaining_side_args = self._execute_sequence(remaining_actions, remaining_side_args) arguments = [] for _ in right_side_parts[1:]: argument, remaining_actions, remaining_side_args = self._execute_sequence(remaining_actions, remaining_side_args) arguments.append(argument) return function(*arguments), remaining_actions, remaining_side_args
[ "def", "_execute_sequence", "(", "self", ",", "action_sequence", ":", "List", "[", "str", "]", ",", "side_arguments", ":", "List", "[", "Dict", "]", ")", "->", "Tuple", "[", "Any", ",", "List", "[", "str", "]", ",", "List", "[", "Dict", "]", "]", ":", "first_action", "=", "action_sequence", "[", "0", "]", "remaining_actions", "=", "action_sequence", "[", "1", ":", "]", "remaining_side_args", "=", "side_arguments", "[", "1", ":", "]", "if", "side_arguments", "else", "None", "right_side", "=", "first_action", ".", "split", "(", "' -> '", ")", "[", "1", "]", "if", "right_side", "in", "self", ".", "_functions", ":", "function", "=", "self", ".", "_functions", "[", "right_side", "]", "# mypy doesn't like this check, saying that Callable isn't a reasonable thing to pass", "# here. But it works just fine; I'm not sure why mypy complains about it.", "if", "isinstance", "(", "function", ",", "Callable", ")", ":", "# type: ignore", "function_arguments", "=", "inspect", ".", "signature", "(", "function", ")", ".", "parameters", "if", "not", "function_arguments", ":", "# This was a zero-argument function / constant that was registered as a lambda", "# function, for consistency of execution in `execute()`.", "execution_value", "=", "function", "(", ")", "elif", "side_arguments", ":", "kwargs", "=", "{", "}", "non_kwargs", "=", "[", "]", "for", "argument_name", "in", "function_arguments", ":", "if", "argument_name", "in", "side_arguments", "[", "0", "]", ":", "kwargs", "[", "argument_name", "]", "=", "side_arguments", "[", "0", "]", "[", "argument_name", "]", "else", ":", "non_kwargs", ".", "append", "(", "argument_name", ")", "if", "kwargs", "and", "non_kwargs", ":", "# This is a function that has both side arguments and logical form", "# arguments - we curry the function so only the logical form arguments are", "# left.", "def", "curried_function", "(", "*", "args", ")", ":", "return", "function", "(", "*", "args", ",", "*", "*", "kwargs", ")", "execution_value", "=", "curried_function", "elif", "kwargs", ":", "# This is a function that _only_ has side arguments - we just call the", "# function and return a value.", "execution_value", "=", "function", "(", "*", "*", "kwargs", ")", "else", ":", "# This is a function that has logical form arguments, but no side arguments", "# that match what we were given - just return the function itself.", "execution_value", "=", "function", "else", ":", "execution_value", "=", "function", "return", "execution_value", ",", "remaining_actions", ",", "remaining_side_args", "else", ":", "# This is a non-terminal expansion, like 'int -> [<int:int>, int, int]'. We need to", "# get the function and its arguments, then call the function with its arguments.", "# Because we linearize the abstract syntax tree depth first, left-to-right, we can just", "# recursively call `_execute_sequence` for the function and all of its arguments, and", "# things will just work.", "right_side_parts", "=", "right_side", ".", "split", "(", "', '", ")", "# We don't really need to know what the types are, just how many of them there are, so", "# we recurse the right number of times.", "function", ",", "remaining_actions", ",", "remaining_side_args", "=", "self", ".", "_execute_sequence", "(", "remaining_actions", ",", "remaining_side_args", ")", "arguments", "=", "[", "]", "for", "_", "in", "right_side_parts", "[", "1", ":", "]", ":", "argument", ",", "remaining_actions", ",", "remaining_side_args", "=", "self", ".", "_execute_sequence", "(", "remaining_actions", ",", "remaining_side_args", ")", "arguments", ".", "append", "(", "argument", ")", "return", "function", "(", "*", "arguments", ")", ",", "remaining_actions", ",", "remaining_side_args" ]
This does the bulk of the work of :func:`execute_action_sequence`, recursively executing the functions it finds and trimming actions off of the action sequence. The return value is a tuple of (execution, remaining_actions), where the second value is necessary to handle the recursion.
[ "This", "does", "the", "bulk", "of", "the", "work", "of", ":", "func", ":", "execute_action_sequence", "recursively", "executing", "the", "functions", "it", "finds", "and", "trimming", "actions", "off", "of", "the", "action", "sequence", ".", "The", "return", "value", "is", "a", "tuple", "of", "(", "execution", "remaining_actions", ")", "where", "the", "second", "value", "is", "necessary", "to", "handle", "the", "recursion", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L541-L607
train
This function executes the action sequence and returns the result of the function that was curried.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,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BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(285 - 237) + chr(11623 - 11512) + chr(0b110001) + chr(0b110111) + '\066', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + '\063' + chr(49), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\063' + chr(0b101111 + 0o3) + chr(571 - 523), 23302 - 23294), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + chr(2065 - 2014) + chr(52), 0o10), ehT0Px3KOsy9(chr(1373 - 1325) + '\x6f' + chr(0b101 + 0o55) + chr(0b100000 + 0o25) + '\065', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(1520 - 1472), 44624 - 44616), ehT0Px3KOsy9(chr(1619 - 1571) + chr(9860 - 9749) + '\x33' + chr(1960 - 1905) + chr(54), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b101 + 0o54) + chr(0b101011 + 0o7) + '\061', 0b1000), ehT0Px3KOsy9(chr(2178 - 2130) + chr(0b1011011 + 0o24) + chr(0b110010) + chr(53) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(798 - 750) + '\x6f' + chr(0b110010) + chr(0b110001) + chr(53), 0b1000), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(111) + chr(0b110001) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(7965 - 7854) + '\x31' + chr(54) + chr(0b101011 + 0o13), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x31' + '\063' + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b11011 + 0o27) + '\x32', 0o10), ehT0Px3KOsy9(chr(714 - 666) + chr(111) + '\063' + chr(0b110000) + chr(0b1 + 0o63), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(996 - 947) + chr(0b100001 + 0o22) + chr(2168 - 2116), 59119 - 59111), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + chr(0b110100) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(704 - 656) + '\x6f' + '\x32' + chr(0b110010) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(5286 - 5175) + chr(0b110011) + '\066' + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110011) + chr(54) + chr(55), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\061' + chr(48) + '\065', 0b1000), ehT0Px3KOsy9(chr(879 - 831) + chr(0b1011 + 0o144) + chr(0b11010 + 0o27) + chr(0b11110 + 0o23) + '\060', 0b1000), ehT0Px3KOsy9('\x30' + chr(6801 - 6690) + chr(0b101110 + 0o5) + chr(0b10011 + 0o41) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(0b1101111) + chr(2177 - 2123) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\157' + chr(51) + chr(0b10011 + 0o43) + chr(0b10011 + 0o44), 8), ehT0Px3KOsy9(chr(48) + '\157' + chr(2157 - 2107) + chr(50) + chr(0b110111), 47670 - 47662), ehT0Px3KOsy9(chr(0b10110 + 0o32) + '\157' + '\x33' + '\x34' + chr(49), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1000001 + 0o56) + '\063' + chr(48) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(5454 - 5343) + chr(0b10111 + 0o34) + chr(0b110001 + 0o1) + '\067', 49966 - 49958), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(552 - 504) + chr(52), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(2354 - 2299) + chr(50), 27685 - 27677), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(1202 - 1150) + chr(0b110000), 19507 - 19499), ehT0Px3KOsy9('\060' + chr(111) + '\x33' + chr(48), 293 - 285), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(2981 - 2870) + chr(0b110011) + chr(0b110011) + chr(0b10111 + 0o35), 41383 - 41375), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(0b1101111) + chr(1022 - 973) + chr(52) + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + chr(0b10101 + 0o132) + chr(0b11110 + 0o25) + chr(54) + chr(48), 8), ehT0Px3KOsy9('\x30' + chr(0b11101 + 0o122) + '\062' + chr(53) + '\066', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(53) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(2115 - 2065) + chr(0b110000) + chr(53), 48755 - 48747)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + '\157' + '\065' + chr(0b110000), 30838 - 30830)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'P'), '\144' + '\145' + '\143' + '\x6f' + chr(0b1100100) + chr(0b1100101))('\x75' + '\164' + chr(102) + '\055' + chr(1520 - 1464)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def eR_60ULsJT2Q(oVre8I6UXc3b, FXNJIrDAzcxy, Z33WzR1MnG4V) -> MRK8Uzg2En3D[R71nhlWr3XQi, qRxF7OQ0y39T[M8_cKLkHVB2V], qRxF7OQ0y39T[zBnV56fc6HrA]]: h6F0IIBiouDQ = FXNJIrDAzcxy[ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110000), 8)] klkIVilDKnwv = FXNJIrDAzcxy[ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(111) + '\061', 0b1000):] sKaSPAjiDChw = Z33WzR1MnG4V[ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b100101 + 0o112) + chr(0b101 + 0o54), 8):] if Z33WzR1MnG4V else None ZhTWDDhoiRNo = h6F0IIBiouDQ.split(xafqLlk3kkUe(SXOLrMavuUCe(b'^\xb4\xee\xbc'), chr(100) + chr(0b1100101) + chr(0b1011001 + 0o12) + '\157' + '\144' + chr(0b1100101))(chr(117) + '\x74' + '\x66' + '\x2d' + chr(768 - 712)))[ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061', 8)] if ZhTWDDhoiRNo in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'9\xfe\xa1\xa9\xfcB\x8fc\xd2\xdb^N'), chr(500 - 400) + chr(0b1000101 + 0o40) + chr(99) + '\157' + chr(0b1100100) + chr(0b1110 + 0o127))(chr(0b1110101) + chr(12808 - 12692) + chr(6311 - 6209) + '\055' + chr(0b111000))): bBC93MgSHzUB = oVre8I6UXc3b.Ggq5QBq2xVP8[ZhTWDDhoiRNo] if PlSM16l2KDPD(bBC93MgSHzUB, TPYMKCdTAycN): K_pRe_1LaOxp = kzXqv8ZZwm75.signature(bBC93MgSHzUB).parameters if not K_pRe_1LaOxp: oa2oBlPtLtIo = bBC93MgSHzUB() elif Z33WzR1MnG4V: M8EIoTs2GJXE = {} VEMzZxvj06yk = [] for VaaE6cE9Q8ZL in K_pRe_1LaOxp: if VaaE6cE9Q8ZL in Z33WzR1MnG4V[ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(965 - 917), 8)]: M8EIoTs2GJXE[VaaE6cE9Q8ZL] = Z33WzR1MnG4V[ehT0Px3KOsy9('\x30' + '\157' + chr(0b110000), 8)][VaaE6cE9Q8ZL] else: xafqLlk3kkUe(VEMzZxvj06yk, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f\xe9\xa0\xf9\xc3d'), '\144' + chr(0b1011111 + 0o6) + chr(0b1100011) + chr(0b1101111) + '\x64' + '\x65')(chr(13198 - 13081) + '\x74' + chr(102) + chr(1776 - 1731) + chr(1009 - 953)))(VaaE6cE9Q8ZL) if M8EIoTs2GJXE and VEMzZxvj06yk: def QR_TVm4X_6SK(*kJDRfRhcZHjS): return bBC93MgSHzUB(*kJDRfRhcZHjS, **M8EIoTs2GJXE) oa2oBlPtLtIo = QR_TVm4X_6SK elif M8EIoTs2GJXE: oa2oBlPtLtIo = bBC93MgSHzUB(**M8EIoTs2GJXE) else: oa2oBlPtLtIo = bBC93MgSHzUB else: oa2oBlPtLtIo = bBC93MgSHzUB return (oa2oBlPtLtIo, klkIVilDKnwv, sKaSPAjiDChw) else: FaFg2VlpzKWD = ZhTWDDhoiRNo.split(xafqLlk3kkUe(SXOLrMavuUCe(b'R\xb9'), '\x64' + '\145' + '\x63' + chr(0b101110 + 0o101) + '\x64' + chr(1858 - 1757))(chr(117) + '\164' + '\146' + '\055' + chr(56))) (bBC93MgSHzUB, klkIVilDKnwv, sKaSPAjiDChw) = oVre8I6UXc3b._execute_sequence(klkIVilDKnwv, sKaSPAjiDChw) PSzOAxeRmbgw = [] for VNGQdHSFPrso in FaFg2VlpzKWD[ehT0Px3KOsy9(chr(0b110000) + chr(4742 - 4631) + '\061', 8):]: (Rr5GJryJs6xR, klkIVilDKnwv, sKaSPAjiDChw) = oVre8I6UXc3b._execute_sequence(klkIVilDKnwv, sKaSPAjiDChw) xafqLlk3kkUe(PSzOAxeRmbgw, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f\xe9\xa0\xf9\xc3d'), '\144' + '\x65' + chr(9746 - 9647) + chr(0b10001 + 0o136) + chr(100) + '\145')(chr(2031 - 1914) + chr(116) + chr(0b11110 + 0o110) + chr(0b100111 + 0o6) + chr(56)))(Rr5GJryJs6xR) return (bBC93MgSHzUB(*PSzOAxeRmbgw), klkIVilDKnwv, sKaSPAjiDChw)
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage._get_transitions
def _get_transitions(self, expression: Any, expected_type: PredicateType) -> Tuple[List[str], PredicateType]: """ This is used when converting a logical form into an action sequence. This piece recursively translates a lisp expression into an action sequence, making sure we match the expected type (or using the expected type to get the right type for constant expressions). """ if isinstance(expression, (list, tuple)): function_transitions, return_type, argument_types = self._get_function_transitions(expression[0], expected_type) if len(argument_types) != len(expression[1:]): raise ParsingError(f'Wrong number of arguments for function in {expression}') argument_transitions = [] for argument_type, subexpression in zip(argument_types, expression[1:]): argument_transitions.extend(self._get_transitions(subexpression, argument_type)[0]) return function_transitions + argument_transitions, return_type elif isinstance(expression, str): if expression not in self._functions: raise ParsingError(f"Unrecognized constant: {expression}") constant_types = self._function_types[expression] if len(constant_types) == 1: constant_type = constant_types[0] # This constant had only one type; that's the easy case. if expected_type and expected_type != constant_type: raise ParsingError(f'{expression} did not have expected type {expected_type} ' f'(found {constant_type})') return [f'{constant_type} -> {expression}'], constant_type else: if not expected_type: raise ParsingError('With no expected type and multiple types to pick from ' f"I don't know what type to use (constant was {expression})") if expected_type not in constant_types: raise ParsingError(f'{expression} did not have expected type {expected_type} ' f'(found these options: {constant_types}; none matched)') return [f'{expected_type} -> {expression}'], expected_type else: raise ParsingError('Not sure how you got here. Please open an issue on github with details.')
python
def _get_transitions(self, expression: Any, expected_type: PredicateType) -> Tuple[List[str], PredicateType]: """ This is used when converting a logical form into an action sequence. This piece recursively translates a lisp expression into an action sequence, making sure we match the expected type (or using the expected type to get the right type for constant expressions). """ if isinstance(expression, (list, tuple)): function_transitions, return_type, argument_types = self._get_function_transitions(expression[0], expected_type) if len(argument_types) != len(expression[1:]): raise ParsingError(f'Wrong number of arguments for function in {expression}') argument_transitions = [] for argument_type, subexpression in zip(argument_types, expression[1:]): argument_transitions.extend(self._get_transitions(subexpression, argument_type)[0]) return function_transitions + argument_transitions, return_type elif isinstance(expression, str): if expression not in self._functions: raise ParsingError(f"Unrecognized constant: {expression}") constant_types = self._function_types[expression] if len(constant_types) == 1: constant_type = constant_types[0] # This constant had only one type; that's the easy case. if expected_type and expected_type != constant_type: raise ParsingError(f'{expression} did not have expected type {expected_type} ' f'(found {constant_type})') return [f'{constant_type} -> {expression}'], constant_type else: if not expected_type: raise ParsingError('With no expected type and multiple types to pick from ' f"I don't know what type to use (constant was {expression})") if expected_type not in constant_types: raise ParsingError(f'{expression} did not have expected type {expected_type} ' f'(found these options: {constant_types}; none matched)') return [f'{expected_type} -> {expression}'], expected_type else: raise ParsingError('Not sure how you got here. Please open an issue on github with details.')
[ "def", "_get_transitions", "(", "self", ",", "expression", ":", "Any", ",", "expected_type", ":", "PredicateType", ")", "->", "Tuple", "[", "List", "[", "str", "]", ",", "PredicateType", "]", ":", "if", "isinstance", "(", "expression", ",", "(", "list", ",", "tuple", ")", ")", ":", "function_transitions", ",", "return_type", ",", "argument_types", "=", "self", ".", "_get_function_transitions", "(", "expression", "[", "0", "]", ",", "expected_type", ")", "if", "len", "(", "argument_types", ")", "!=", "len", "(", "expression", "[", "1", ":", "]", ")", ":", "raise", "ParsingError", "(", "f'Wrong number of arguments for function in {expression}'", ")", "argument_transitions", "=", "[", "]", "for", "argument_type", ",", "subexpression", "in", "zip", "(", "argument_types", ",", "expression", "[", "1", ":", "]", ")", ":", "argument_transitions", ".", "extend", "(", "self", ".", "_get_transitions", "(", "subexpression", ",", "argument_type", ")", "[", "0", "]", ")", "return", "function_transitions", "+", "argument_transitions", ",", "return_type", "elif", "isinstance", "(", "expression", ",", "str", ")", ":", "if", "expression", "not", "in", "self", ".", "_functions", ":", "raise", "ParsingError", "(", "f\"Unrecognized constant: {expression}\"", ")", "constant_types", "=", "self", ".", "_function_types", "[", "expression", "]", "if", "len", "(", "constant_types", ")", "==", "1", ":", "constant_type", "=", "constant_types", "[", "0", "]", "# This constant had only one type; that's the easy case.", "if", "expected_type", "and", "expected_type", "!=", "constant_type", ":", "raise", "ParsingError", "(", "f'{expression} did not have expected type {expected_type} '", "f'(found {constant_type})'", ")", "return", "[", "f'{constant_type} -> {expression}'", "]", ",", "constant_type", "else", ":", "if", "not", "expected_type", ":", "raise", "ParsingError", "(", "'With no expected type and multiple types to pick from '", "f\"I don't know what type to use (constant was {expression})\"", ")", "if", "expected_type", "not", "in", "constant_types", ":", "raise", "ParsingError", "(", "f'{expression} did not have expected type {expected_type} '", "f'(found these options: {constant_types}; none matched)'", ")", "return", "[", "f'{expected_type} -> {expression}'", "]", ",", "expected_type", "else", ":", "raise", "ParsingError", "(", "'Not sure how you got here. Please open an issue on github with details.'", ")" ]
This is used when converting a logical form into an action sequence. This piece recursively translates a lisp expression into an action sequence, making sure we match the expected type (or using the expected type to get the right type for constant expressions).
[ "This", "is", "used", "when", "converting", "a", "logical", "form", "into", "an", "action", "sequence", ".", "This", "piece", "recursively", "translates", "a", "lisp", "expression", "into", "an", "action", "sequence", "making", "sure", "we", "match", "the", "expected", "type", "(", "or", "using", "the", "expected", "type", "to", "get", "the", "right", "type", "for", "constant", "expressions", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L609-L645
train
This is used when converting a logical form into an action sequence. This is used when converting a logical form into an action sequence. This is used when converting a logical form into an action sequence.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWY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4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(111) + chr(2086 - 2037) + chr(0b100101 + 0o15) + chr(0b110 + 0o55), 48509 - 48501), ehT0Px3KOsy9(chr(0b110000) + chr(9246 - 9135) + chr(53) + chr(55), 0o10), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\x6f' + '\x33' + chr(0b110101) + chr(0b1110 + 0o46), 0o10), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\x6f' + chr(1624 - 1574) + chr(0b110101) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1 + 0o60) + chr(0b100101 + 0o13) + chr(0b100011 + 0o15), 49262 - 49254), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x35' + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(1519 - 1471) + chr(0b1001 + 0o146) + chr(49) + chr(49) + chr(0b110010), 33482 - 33474), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1101111) + chr(0b11101 + 0o25) + chr(0b110001) + chr(0b10001 + 0o44), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110011) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110101) + chr(55), 8), ehT0Px3KOsy9(chr(1679 - 1631) + chr(111) + '\x33' + chr(0b10010 + 0o40) + chr(0b1100 + 0o44), 7928 - 7920), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11001 + 0o31) + chr(48) + chr(0b101011 + 0o7), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(65 - 16) + '\065' + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b111001 + 0o66) + '\x32' + chr(555 - 506) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(1204 - 1156) + chr(111) + chr(0b110010) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(0b110111 + 0o70) + chr(1151 - 1101) + chr(0b110011 + 0o0) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\063' + '\x30' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b100 + 0o54) + '\157' + '\x35' + '\061', 10567 - 10559), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100101 + 0o15) + chr(0b110001) + chr(52), 8), ehT0Px3KOsy9('\060' + chr(0b1100101 + 0o12) + chr(0b110 + 0o61) + chr(0b101101 + 0o6), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001 + 0o146) + chr(0b110010) + chr(0b110000) + chr(0b110010), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011111 + 0o20) + '\x33' + chr(0b101111 + 0o2) + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10000 + 0o41) + '\065' + '\x34', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(866 - 815) + '\061' + chr(48), 43995 - 43987), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + '\061', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(51) + chr(0b100101 + 0o20) + '\x31', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(928 - 878) + chr(0b111 + 0o56) + chr(0b11110 + 0o30), 8), ehT0Px3KOsy9('\060' + chr(10410 - 10299) + chr(859 - 808) + chr(50) + chr(1410 - 1360), 30380 - 30372), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + chr(0b110001) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(438 - 390) + '\x6f' + chr(0b11011 + 0o30) + '\066' + chr(762 - 708), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(9671 - 9560) + chr(54) + chr(0b110111), 32666 - 32658), ehT0Px3KOsy9(chr(1358 - 1310) + chr(839 - 728) + chr(0b110111) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + '\x37' + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\063' + chr(461 - 412) + chr(0b11 + 0o55), 8), ehT0Px3KOsy9('\060' + chr(0b100111 + 0o110) + '\063' + chr(0b10100 + 0o34) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(48) + chr(4685 - 4574) + chr(0b110011) + '\x35' + '\x31', 8), ehT0Px3KOsy9('\x30' + chr(0b1100111 + 0o10) + chr(1999 - 1944) + chr(728 - 677), 8), ehT0Px3KOsy9('\060' + chr(111) + chr(0b1111 + 0o43) + chr(50) + chr(1099 - 1051), 44712 - 44704), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + chr(0b10010 + 0o37) + chr(1529 - 1480), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b101011 + 0o12) + chr(0b110000), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'}'), chr(0b111111 + 0o45) + '\x65' + chr(0b11000 + 0o113) + chr(0b1101111) + chr(0b1100100) + '\x65')('\x75' + chr(116) + chr(8886 - 8784) + '\x2d' + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def _DxuEn51hbif(oVre8I6UXc3b, heJELtuJu3My, UX_PCD33fO95) -> MRK8Uzg2En3D[qRxF7OQ0y39T[M8_cKLkHVB2V], YPmBFLkEKJVV]: if PlSM16l2KDPD(heJELtuJu3My, (YyaZ4tpXu4lf, KNyTy8rYcwji)): (tUUH1KpQSiKU, ELL59KGwZKj3, DjtzGpnspIKq) = oVre8I6UXc3b._get_function_transitions(heJELtuJu3My[ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(111) + chr(0b110000 + 0o0), ord("\x08"))], UX_PCD33fO95) if c2A0yzQpDQB3(DjtzGpnspIKq) != c2A0yzQpDQB3(heJELtuJu3My[ehT0Px3KOsy9(chr(0b10 + 0o56) + '\x6f' + chr(1315 - 1266), 8):]): raise MO1jGuXEVWyF(f'Wrong number of arguments for function in {heJELtuJu3My}') m8_2MxGPdOC5 = [] for (x0D0KPKeQ2G1, URlyKcV3D6yi) in pZ0NK2y6HRbn(DjtzGpnspIKq, heJELtuJu3My[ehT0Px3KOsy9(chr(48) + chr(0b1111 + 0o140) + chr(0b11110 + 0o23), 8):]): xafqLlk3kkUe(m8_2MxGPdOC5, xafqLlk3kkUe(SXOLrMavuUCe(b'6W\x98\xcb.N'), '\x64' + '\x65' + chr(0b1100011) + '\157' + chr(0b1000101 + 0o37) + '\x65')('\165' + '\x74' + chr(102) + chr(0b101101) + '\070'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0cH\x89\xda\x1f^8\xecq\\\xb9\xf6\x03\xe3~\xef'), chr(0b1100100) + '\145' + chr(0b1100011) + chr(0b110110 + 0o71) + chr(3888 - 3788) + '\145')('\x75' + chr(116) + chr(0b1100001 + 0o5) + '\055' + '\x38'))(URlyKcV3D6yi, x0D0KPKeQ2G1)[ehT0Px3KOsy9(chr(48) + chr(0b1001 + 0o146) + chr(48), 8)]) return (tUUH1KpQSiKU + m8_2MxGPdOC5, ELL59KGwZKj3) elif PlSM16l2KDPD(heJELtuJu3My, M8_cKLkHVB2V): if heJELtuJu3My not in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x14H\x9d\x9b\x11h;\xbfgy\x80\xba'), '\x64' + chr(0b1100101) + chr(0b1100011) + chr(111) + '\144' + chr(101))('\165' + chr(0b1110100) + chr(0b1100110) + chr(64 - 19) + chr(2941 - 2885))): raise MO1jGuXEVWyF(f'Unrecognized constant: {heJELtuJu3My}') retpvcyCnbjQ = oVre8I6UXc3b._function_types[heJELtuJu3My] if c2A0yzQpDQB3(retpvcyCnbjQ) == ehT0Px3KOsy9('\x30' + '\x6f' + '\x31', 8): Sv_PjCA164hG = retpvcyCnbjQ[ehT0Px3KOsy9(chr(2135 - 2087) + chr(4376 - 4265) + '\060', 8)] if UX_PCD33fO95 and UX_PCD33fO95 != Sv_PjCA164hG: raise MO1jGuXEVWyF(f'{heJELtuJu3My} did not have expected type {UX_PCD33fO95} (found {Sv_PjCA164hG})') return ([f'{Sv_PjCA164hG} -> {heJELtuJu3My}'], Sv_PjCA164hG) else: if not UX_PCD33fO95: raise MO1jGuXEVWyF(f"With no expected type and multiple types to pick from I don't know what type to use (constant was {heJELtuJu3My})") if UX_PCD33fO95 not in retpvcyCnbjQ: raise MO1jGuXEVWyF(f'{heJELtuJu3My} did not have expected type {UX_PCD33fO95} (found these options: {retpvcyCnbjQ}; none matched)') return ([f'{UX_PCD33fO95} -> {heJELtuJu3My}'], UX_PCD33fO95) else: raise MO1jGuXEVWyF(xafqLlk3kkUe(SXOLrMavuUCe(b'\x1d@\x98\x8e3_8\xe8?G\xbf\xf5J\xf5\x7f\xe9\xe4N\xe3O\xa2\xa6\t\xbal\xc7\x8e\x82\xe3\x93VI\xdf\xe8\xa8\x99^\xfe!(=\x0f\x85\xdd3_/\xadpA\xf0\xe5\x03\xf8x\xe9\xa6\t\xfbR\xf6\xa6L\xacl\x9d\xcf\xbb\xe3\x85\x19'), chr(100) + chr(0b1100101) + chr(0b1100011) + chr(111) + chr(3900 - 3800) + chr(101))(chr(117) + '\164' + chr(0b1001 + 0o135) + chr(0b101101) + chr(0b100101 + 0o23)))
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage._get_function_transitions
def _get_function_transitions(self, expression: Union[str, List], expected_type: PredicateType) -> Tuple[List[str], PredicateType, List[PredicateType]]: """ A helper method for ``_get_transitions``. This gets the transitions for the predicate itself in a function call. If we only had simple functions (e.g., "(add 2 3)"), this would be pretty straightforward and we wouldn't need a separate method to handle it. We split it out into its own method because handling higher-order functions is complicated (e.g., something like "((negate add) 2 3)"). """ # This first block handles getting the transitions and function type (and some error # checking) _just for the function itself_. If this is a simple function, this is easy; if # it's a higher-order function, it involves some recursion. if isinstance(expression, list): # This is a higher-order function. TODO(mattg): we'll just ignore type checking on # higher-order functions, for now. transitions, function_type = self._get_transitions(expression, None) elif expression in self._functions: name = expression function_types = self._function_types[expression] if len(function_types) != 1: raise ParsingError(f"{expression} had multiple types; this is not yet supported for functions") function_type = function_types[0] transitions = [f'{function_type} -> {name}'] else: if isinstance(expression, str): raise ParsingError(f"Unrecognized function: {expression[0]}") else: raise ParsingError(f"Unsupported expression type: {expression}") if not isinstance(function_type, FunctionType): raise ParsingError(f'Zero-arg function or constant called with arguments: {name}') # Now that we have the transitions for the function itself, and the function's type, we can # get argument types and do the rest of the transitions. argument_types = function_type.argument_types return_type = function_type.return_type right_side = f'[{function_type}, {", ".join(str(arg) for arg in argument_types)}]' first_transition = f'{return_type} -> {right_side}' transitions.insert(0, first_transition) if expected_type and expected_type != return_type: raise ParsingError(f'{expression} did not have expected type {expected_type} ' f'(found {return_type})') return transitions, return_type, argument_types
python
def _get_function_transitions(self, expression: Union[str, List], expected_type: PredicateType) -> Tuple[List[str], PredicateType, List[PredicateType]]: """ A helper method for ``_get_transitions``. This gets the transitions for the predicate itself in a function call. If we only had simple functions (e.g., "(add 2 3)"), this would be pretty straightforward and we wouldn't need a separate method to handle it. We split it out into its own method because handling higher-order functions is complicated (e.g., something like "((negate add) 2 3)"). """ # This first block handles getting the transitions and function type (and some error # checking) _just for the function itself_. If this is a simple function, this is easy; if # it's a higher-order function, it involves some recursion. if isinstance(expression, list): # This is a higher-order function. TODO(mattg): we'll just ignore type checking on # higher-order functions, for now. transitions, function_type = self._get_transitions(expression, None) elif expression in self._functions: name = expression function_types = self._function_types[expression] if len(function_types) != 1: raise ParsingError(f"{expression} had multiple types; this is not yet supported for functions") function_type = function_types[0] transitions = [f'{function_type} -> {name}'] else: if isinstance(expression, str): raise ParsingError(f"Unrecognized function: {expression[0]}") else: raise ParsingError(f"Unsupported expression type: {expression}") if not isinstance(function_type, FunctionType): raise ParsingError(f'Zero-arg function or constant called with arguments: {name}') # Now that we have the transitions for the function itself, and the function's type, we can # get argument types and do the rest of the transitions. argument_types = function_type.argument_types return_type = function_type.return_type right_side = f'[{function_type}, {", ".join(str(arg) for arg in argument_types)}]' first_transition = f'{return_type} -> {right_side}' transitions.insert(0, first_transition) if expected_type and expected_type != return_type: raise ParsingError(f'{expression} did not have expected type {expected_type} ' f'(found {return_type})') return transitions, return_type, argument_types
[ "def", "_get_function_transitions", "(", "self", ",", "expression", ":", "Union", "[", "str", ",", "List", "]", ",", "expected_type", ":", "PredicateType", ")", "->", "Tuple", "[", "List", "[", "str", "]", ",", "PredicateType", ",", "List", "[", "PredicateType", "]", "]", ":", "# This first block handles getting the transitions and function type (and some error", "# checking) _just for the function itself_. If this is a simple function, this is easy; if", "# it's a higher-order function, it involves some recursion.", "if", "isinstance", "(", "expression", ",", "list", ")", ":", "# This is a higher-order function. TODO(mattg): we'll just ignore type checking on", "# higher-order functions, for now.", "transitions", ",", "function_type", "=", "self", ".", "_get_transitions", "(", "expression", ",", "None", ")", "elif", "expression", "in", "self", ".", "_functions", ":", "name", "=", "expression", "function_types", "=", "self", ".", "_function_types", "[", "expression", "]", "if", "len", "(", "function_types", ")", "!=", "1", ":", "raise", "ParsingError", "(", "f\"{expression} had multiple types; this is not yet supported for functions\"", ")", "function_type", "=", "function_types", "[", "0", "]", "transitions", "=", "[", "f'{function_type} -> {name}'", "]", "else", ":", "if", "isinstance", "(", "expression", ",", "str", ")", ":", "raise", "ParsingError", "(", "f\"Unrecognized function: {expression[0]}\"", ")", "else", ":", "raise", "ParsingError", "(", "f\"Unsupported expression type: {expression}\"", ")", "if", "not", "isinstance", "(", "function_type", ",", "FunctionType", ")", ":", "raise", "ParsingError", "(", "f'Zero-arg function or constant called with arguments: {name}'", ")", "# Now that we have the transitions for the function itself, and the function's type, we can", "# get argument types and do the rest of the transitions.", "argument_types", "=", "function_type", ".", "argument_types", "return_type", "=", "function_type", ".", "return_type", "right_side", "=", "f'[{function_type}, {\", \".join(str(arg) for arg in argument_types)}]'", "first_transition", "=", "f'{return_type} -> {right_side}'", "transitions", ".", "insert", "(", "0", ",", "first_transition", ")", "if", "expected_type", "and", "expected_type", "!=", "return_type", ":", "raise", "ParsingError", "(", "f'{expression} did not have expected type {expected_type} '", "f'(found {return_type})'", ")", "return", "transitions", ",", "return_type", ",", "argument_types" ]
A helper method for ``_get_transitions``. This gets the transitions for the predicate itself in a function call. If we only had simple functions (e.g., "(add 2 3)"), this would be pretty straightforward and we wouldn't need a separate method to handle it. We split it out into its own method because handling higher-order functions is complicated (e.g., something like "((negate add) 2 3)").
[ "A", "helper", "method", "for", "_get_transitions", ".", "This", "gets", "the", "transitions", "for", "the", "predicate", "itself", "in", "a", "function", "call", ".", "If", "we", "only", "had", "simple", "functions", "(", "e", ".", "g", ".", "(", "add", "2", "3", ")", ")", "this", "would", "be", "pretty", "straightforward", "and", "we", "wouldn", "t", "need", "a", "separate", "method", "to", "handle", "it", ".", "We", "split", "it", "out", "into", "its", "own", "method", "because", "handling", "higher", "-", "order", "functions", "is", "complicated", "(", "e", ".", "g", ".", "something", "like", "((", "negate", "add", ")", "2", "3", ")", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse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,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1491 - 1443) + chr(0b1101111) + chr(2151 - 2100) + '\067' + chr(875 - 821), 0o10), ehT0Px3KOsy9(chr(1734 - 1686) + '\157' + chr(0b100100 + 0o21) + chr(0b11010 + 0o26), 0o10), ehT0Px3KOsy9(chr(771 - 723) + '\x6f' + chr(0b100101 + 0o16) + chr(51) + '\x37', 0o10), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\157' + '\063' + chr(0b110100 + 0o1) + chr(0b110100), 2565 - 2557), ehT0Px3KOsy9(chr(1184 - 1136) + '\x6f' + chr(0b10101 + 0o35) + chr(2086 - 2031) + chr(52), 0o10), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(4070 - 3959) + '\x34' + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(0b110110) + '\x32', 61175 - 61167), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + '\x34' + chr(48), 0o10), ehT0Px3KOsy9('\060' + chr(0b101110 + 0o101) + chr(0b11001 + 0o30) + chr(0b110101) + '\066', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1754 - 1704) + chr(2058 - 2006) + '\060', 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1668 - 1617) + chr(629 - 575) + chr(411 - 359), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(3811 - 3700) + chr(54) + chr(0b110100), 0b1000), ehT0Px3KOsy9('\060' + chr(0b111001 + 0o66) + chr(1378 - 1329) + '\061' + '\x36', 0o10), ehT0Px3KOsy9('\060' + chr(3604 - 3493) + chr(1773 - 1723) + chr(55) + chr(518 - 470), 0o10), ehT0Px3KOsy9(chr(306 - 258) + chr(111) + chr(0b0 + 0o62) + chr(0b110011 + 0o3) + chr(50), 8), ehT0Px3KOsy9('\x30' + chr(0b1100001 + 0o16) + chr(294 - 244) + '\x35' + chr(54), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\063' + chr(0b110110) + chr(0b110001), 54935 - 54927), ehT0Px3KOsy9(chr(48) + '\157' + chr(1892 - 1842) + '\x34' + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(111) + chr(0b100011 + 0o17) + chr(50) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\x30' + chr(8606 - 8495) + chr(0b1 + 0o62) + '\060' + '\062', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b100001 + 0o21) + chr(0b10110 + 0o35) + chr(0b110010 + 0o5), 0b1000), ehT0Px3KOsy9(chr(323 - 275) + chr(4083 - 3972) + chr(0b100100 + 0o16) + '\x37' + chr(1526 - 1471), 5057 - 5049), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\x6f' + chr(0b101 + 0o56) + chr(806 - 757), 42081 - 42073), ehT0Px3KOsy9(chr(750 - 702) + chr(111) + chr(952 - 901) + '\x33' + '\060', 0b1000), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(111) + chr(51) + '\x33' + '\067', 8), ehT0Px3KOsy9('\x30' + chr(0b1001101 + 0o42) + chr(1627 - 1577) + '\x33', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + chr(50), 64685 - 64677), ehT0Px3KOsy9(chr(0b110000) + chr(0b100 + 0o153) + chr(0b110011) + '\x33' + chr(0b10010 + 0o45), 8), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + chr(48) + chr(48), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(49) + chr(0b110011) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + chr(0b100100 + 0o22) + '\x33', 24177 - 24169), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(0b1101111) + chr(1515 - 1465) + chr(2598 - 2544) + '\x30', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(8688 - 8577) + chr(0b101 + 0o55) + '\066', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101011 + 0o4) + '\x33' + chr(0b11110 + 0o25) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101010 + 0o5) + chr(982 - 933) + chr(54) + chr(171 - 116), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\063' + chr(51) + chr(49), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1000001 + 0o56) + chr(0b110010) + '\067' + chr(1864 - 1813), 0o10), ehT0Px3KOsy9(chr(870 - 822) + chr(0b1010100 + 0o33) + chr(0b110001) + chr(57 - 7) + '\x33', 0o10), ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(3026 - 2915) + '\x33' + chr(1273 - 1225) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(1897 - 1849) + chr(111) + chr(0b110010) + chr(734 - 686) + chr(1496 - 1445), 32290 - 32282)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(111) + chr(0b1111 + 0o46) + '\x30', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0'), chr(0b1100001 + 0o3) + chr(101) + chr(0b1100001 + 0o2) + chr(0b10000 + 0o137) + '\x64' + chr(0b1100101))('\x75' + chr(0b111110 + 0o66) + chr(0b110011 + 0o63) + '\x2d' + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def CrhiCZwvjR7y(oVre8I6UXc3b, heJELtuJu3My, UX_PCD33fO95) -> MRK8Uzg2En3D[qRxF7OQ0y39T[M8_cKLkHVB2V], YPmBFLkEKJVV, qRxF7OQ0y39T[YPmBFLkEKJVV]]: if PlSM16l2KDPD(heJELtuJu3My, YyaZ4tpXu4lf): (WI0Qv2bziBjm, cid_uaYJYOSx) = oVre8I6UXc3b._get_transitions(heJELtuJu3My, None) elif heJELtuJu3My in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9O\xae\xd9\xede\xc3\x92\x16\xf6\xa4\x0c'), chr(0b1100100) + '\145' + chr(0b1100011) + '\x6f' + '\x64' + '\x65')(chr(0b101010 + 0o113) + chr(11009 - 10893) + chr(102) + chr(130 - 85) + '\x38')): AIvJRzLdDfgF = heJELtuJu3My aLwkU_iL6qgZ = oVre8I6UXc3b._function_types[heJELtuJu3My] if c2A0yzQpDQB3(aLwkU_iL6qgZ) != ehT0Px3KOsy9(chr(1890 - 1842) + '\157' + chr(0b110001), 0b1000): raise MO1jGuXEVWyF(f'{heJELtuJu3My} had multiple types; this is not yet supported for functions') cid_uaYJYOSx = aLwkU_iL6qgZ[ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x30', 0b1000)] WI0Qv2bziBjm = [f'{cid_uaYJYOSx} -> {AIvJRzLdDfgF}'] elif PlSM16l2KDPD(heJELtuJu3My, M8_cKLkHVB2V): raise MO1jGuXEVWyF(f'Unrecognized function: {heJELtuJu3My[0]}') else: raise MO1jGuXEVWyF(f'Unsupported expression type: {heJELtuJu3My}') if not PlSM16l2KDPD(cid_uaYJYOSx, ric04wOk_EeU): raise MO1jGuXEVWyF(f'Zero-arg function or constant called with arguments: {AIvJRzLdDfgF}') DjtzGpnspIKq = cid_uaYJYOSx.argument_types ELL59KGwZKj3 = cid_uaYJYOSx.return_type ZhTWDDhoiRNo = f"[{cid_uaYJYOSx}, {chr(0b11 + 0o51) + chr(0b100000)._oWXztVNnqHF((M8_cKLkHVB2V(LTE9MPUbqSos) for LTE9MPUbqSos in DjtzGpnspIKq))}]" kcgHboYY_6gB = f'{ELL59KGwZKj3} -> {ZhTWDDhoiRNo}' xafqLlk3kkUe(WI0Qv2bziBjm, xafqLlk3kkUe(SXOLrMavuUCe(b'\x97F\xac\x89\xceS'), chr(1375 - 1275) + chr(101) + chr(99) + chr(9770 - 9659) + '\144' + chr(0b1100101))('\165' + chr(4506 - 4390) + chr(3907 - 3805) + chr(0b100111 + 0o6) + '\070'))(ehT0Px3KOsy9(chr(48) + chr(0b11010 + 0o125) + '\060', 8), kcgHboYY_6gB) if UX_PCD33fO95 and UX_PCD33fO95 != ELL59KGwZKj3: raise MO1jGuXEVWyF(f'{heJELtuJu3My} did not have expected type {UX_PCD33fO95} (found {ELL59KGwZKj3})') return (WI0Qv2bziBjm, ELL59KGwZKj3, DjtzGpnspIKq)
allenai/allennlp
allennlp/semparse/domain_languages/domain_language.py
DomainLanguage._construct_node_from_actions
def _construct_node_from_actions(self, current_node: Tree, remaining_actions: List[List[str]]) -> List[List[str]]: """ Given a current node in the logical form tree, and a list of actions in an action sequence, this method fills in the children of the current node from the action sequence, then returns whatever actions are left. For example, we could get a node with type ``c``, and an action sequence that begins with ``c -> [<r,c>, r]``. This method will add two children to the input node, consuming actions from the action sequence for nodes of type ``<r,c>`` (and all of its children, recursively) and ``r`` (and all of its children, recursively). This method assumes that action sequences are produced `depth-first`, so all actions for the subtree under ``<r,c>`` appear before actions for the subtree under ``r``. If there are any actions in the action sequence after the ``<r,c>`` and ``r`` subtrees have terminated in leaf nodes, they will be returned. """ if not remaining_actions: logger.error("No actions left to construct current node: %s", current_node) raise ParsingError("Incomplete action sequence") left_side, right_side = remaining_actions.pop(0) if left_side != current_node.label(): logger.error("Current node: %s", current_node) logger.error("Next action: %s -> %s", left_side, right_side) logger.error("Remaining actions were: %s", remaining_actions) raise ParsingError("Current node does not match next action") if right_side[0] == '[': # This is a non-terminal expansion, with more than one child node. for child_type in right_side[1:-1].split(', '): child_node = Tree(child_type, []) current_node.append(child_node) # you add a child to an nltk.Tree with `append` # For now, we assume that all children in a list like this are non-terminals, so we # recurse on them. I'm pretty sure that will always be true for the way our # grammar induction works. We can revisit this later if we need to. remaining_actions = self._construct_node_from_actions(child_node, remaining_actions) else: # The current node is a pre-terminal; we'll add a single terminal child. By # construction, the right-hand side of our production rules are only ever terminal # productions or lists of non-terminals. current_node.append(Tree(right_side, [])) # you add a child to an nltk.Tree with `append` return remaining_actions
python
def _construct_node_from_actions(self, current_node: Tree, remaining_actions: List[List[str]]) -> List[List[str]]: """ Given a current node in the logical form tree, and a list of actions in an action sequence, this method fills in the children of the current node from the action sequence, then returns whatever actions are left. For example, we could get a node with type ``c``, and an action sequence that begins with ``c -> [<r,c>, r]``. This method will add two children to the input node, consuming actions from the action sequence for nodes of type ``<r,c>`` (and all of its children, recursively) and ``r`` (and all of its children, recursively). This method assumes that action sequences are produced `depth-first`, so all actions for the subtree under ``<r,c>`` appear before actions for the subtree under ``r``. If there are any actions in the action sequence after the ``<r,c>`` and ``r`` subtrees have terminated in leaf nodes, they will be returned. """ if not remaining_actions: logger.error("No actions left to construct current node: %s", current_node) raise ParsingError("Incomplete action sequence") left_side, right_side = remaining_actions.pop(0) if left_side != current_node.label(): logger.error("Current node: %s", current_node) logger.error("Next action: %s -> %s", left_side, right_side) logger.error("Remaining actions were: %s", remaining_actions) raise ParsingError("Current node does not match next action") if right_side[0] == '[': # This is a non-terminal expansion, with more than one child node. for child_type in right_side[1:-1].split(', '): child_node = Tree(child_type, []) current_node.append(child_node) # you add a child to an nltk.Tree with `append` # For now, we assume that all children in a list like this are non-terminals, so we # recurse on them. I'm pretty sure that will always be true for the way our # grammar induction works. We can revisit this later if we need to. remaining_actions = self._construct_node_from_actions(child_node, remaining_actions) else: # The current node is a pre-terminal; we'll add a single terminal child. By # construction, the right-hand side of our production rules are only ever terminal # productions or lists of non-terminals. current_node.append(Tree(right_side, [])) # you add a child to an nltk.Tree with `append` return remaining_actions
[ "def", "_construct_node_from_actions", "(", "self", ",", "current_node", ":", "Tree", ",", "remaining_actions", ":", "List", "[", "List", "[", "str", "]", "]", ")", "->", "List", "[", "List", "[", "str", "]", "]", ":", "if", "not", "remaining_actions", ":", "logger", ".", "error", "(", "\"No actions left to construct current node: %s\"", ",", "current_node", ")", "raise", "ParsingError", "(", "\"Incomplete action sequence\"", ")", "left_side", ",", "right_side", "=", "remaining_actions", ".", "pop", "(", "0", ")", "if", "left_side", "!=", "current_node", ".", "label", "(", ")", ":", "logger", ".", "error", "(", "\"Current node: %s\"", ",", "current_node", ")", "logger", ".", "error", "(", "\"Next action: %s -> %s\"", ",", "left_side", ",", "right_side", ")", "logger", ".", "error", "(", "\"Remaining actions were: %s\"", ",", "remaining_actions", ")", "raise", "ParsingError", "(", "\"Current node does not match next action\"", ")", "if", "right_side", "[", "0", "]", "==", "'['", ":", "# This is a non-terminal expansion, with more than one child node.", "for", "child_type", "in", "right_side", "[", "1", ":", "-", "1", "]", ".", "split", "(", "', '", ")", ":", "child_node", "=", "Tree", "(", "child_type", ",", "[", "]", ")", "current_node", ".", "append", "(", "child_node", ")", "# you add a child to an nltk.Tree with `append`", "# For now, we assume that all children in a list like this are non-terminals, so we", "# recurse on them. I'm pretty sure that will always be true for the way our", "# grammar induction works. We can revisit this later if we need to.", "remaining_actions", "=", "self", ".", "_construct_node_from_actions", "(", "child_node", ",", "remaining_actions", ")", "else", ":", "# The current node is a pre-terminal; we'll add a single terminal child. By", "# construction, the right-hand side of our production rules are only ever terminal", "# productions or lists of non-terminals.", "current_node", ".", "append", "(", "Tree", "(", "right_side", ",", "[", "]", ")", ")", "# you add a child to an nltk.Tree with `append`", "return", "remaining_actions" ]
Given a current node in the logical form tree, and a list of actions in an action sequence, this method fills in the children of the current node from the action sequence, then returns whatever actions are left. For example, we could get a node with type ``c``, and an action sequence that begins with ``c -> [<r,c>, r]``. This method will add two children to the input node, consuming actions from the action sequence for nodes of type ``<r,c>`` (and all of its children, recursively) and ``r`` (and all of its children, recursively). This method assumes that action sequences are produced `depth-first`, so all actions for the subtree under ``<r,c>`` appear before actions for the subtree under ``r``. If there are any actions in the action sequence after the ``<r,c>`` and ``r`` subtrees have terminated in leaf nodes, they will be returned.
[ "Given", "a", "current", "node", "in", "the", "logical", "form", "tree", "and", "a", "list", "of", "actions", "in", "an", "action", "sequence", "this", "method", "fills", "in", "the", "children", "of", "the", "current", "node", "from", "the", "action", "sequence", "then", "returns", "whatever", "actions", "are", "left", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L693-L733
train
This method constructs a node from a list of actions in an action sequence and returns the list of actions that are left in the action sequence.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqM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KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(0b111011 + 0o64) + chr(0b110010) + '\060' + chr(49), 0o10), ehT0Px3KOsy9(chr(654 - 606) + chr(111) + chr(0b100110 + 0o13) + chr(50) + chr(0b100011 + 0o24), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(50) + chr(0b110111) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(1586 - 1538) + chr(111) + chr(2171 - 2116), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(438 - 384), 670 - 662), ehT0Px3KOsy9('\x30' + '\157' + chr(1340 - 1289) + chr(2320 - 2270) + chr(2450 - 2397), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b1110 + 0o45) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b101111 + 0o3) + chr(0b100101 + 0o15) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(945 - 896) + '\x31', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\x32' + chr(0b101101 + 0o7) + chr(0b101001 + 0o12), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1979 - 1930) + chr(0b100001 + 0o26) + chr(0b1 + 0o64), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + chr(55) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(932 - 884) + '\157' + '\061' + '\066' + chr(0b110001 + 0o6), 0b1000), ehT0Px3KOsy9(chr(1778 - 1730) + chr(0b1000010 + 0o55) + chr(0b110111 + 0o0), 8), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + '\x31' + chr(53), 53844 - 53836), ehT0Px3KOsy9('\x30' + chr(1388 - 1277) + chr(412 - 361) + chr(0b110000) + chr(0b110001), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + chr(52) + chr(53), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b1000 + 0o57) + chr(0b100101 + 0o13), 0o10), ehT0Px3KOsy9(chr(279 - 231) + chr(0b1101111) + chr(1860 - 1810) + chr(0b110100) + chr(2750 - 2697), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(50) + chr(55) + '\x36', 62613 - 62605), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1001110 + 0o41) + chr(0b110001 + 0o1) + chr(1073 - 1023) + chr(0b10110 + 0o36), 60950 - 60942), ehT0Px3KOsy9(chr(1362 - 1314) + chr(0b1101110 + 0o1) + '\x31' + '\063' + chr(0b10 + 0o57), ord("\x08")), ehT0Px3KOsy9(chr(549 - 501) + '\x6f' + chr(0b1101 + 0o51), 8), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(0b1101111) + chr(0b110010) + '\064' + chr(324 - 273), 8), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + '\063' + '\x33', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b101110 + 0o101) + chr(49) + '\060' + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(3774 - 3663) + chr(0b11001 + 0o34) + '\x36', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(0b11110 + 0o26) + chr(0b100000 + 0o26), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100000 + 0o23) + '\x35' + chr(0b100001 + 0o26), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(2690 - 2636) + chr(1352 - 1302), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + chr(1692 - 1644) + chr(0b101010 + 0o14), 22015 - 22007), ehT0Px3KOsy9(chr(1930 - 1882) + '\157' + chr(0b101110 + 0o5) + chr(55) + chr(515 - 466), 47725 - 47717), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(2198 - 2149) + chr(0b10111 + 0o33) + chr(2251 - 2201), 8104 - 8096), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11111 + 0o23) + '\x34' + chr(742 - 688), 0o10), ehT0Px3KOsy9(chr(1821 - 1773) + chr(0b1101111) + chr(50) + '\066' + chr(196 - 144), 0o10), ehT0Px3KOsy9(chr(48) + chr(7077 - 6966) + '\x32' + chr(53) + '\x33', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(0b110110) + '\x34', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(323 - 272) + chr(556 - 501) + chr(2177 - 2125), 41042 - 41034), ehT0Px3KOsy9(chr(1922 - 1874) + chr(0b1101111) + '\061' + chr(1239 - 1185) + chr(0b1000 + 0o52), 29018 - 29010)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\157' + chr(53) + chr(0b11100 + 0o24), 42680 - 42672)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xaf'), '\144' + '\145' + '\143' + '\x6f' + chr(100) + '\x65')('\165' + chr(0b1010010 + 0o42) + chr(5314 - 5212) + '\x2d' + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def iFysPtR_VYa4(oVre8I6UXc3b, ivhwUfDWYTWy, klkIVilDKnwv) -> qRxF7OQ0y39T[qRxF7OQ0y39T[M8_cKLkHVB2V]]: if not klkIVilDKnwv: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc4\x02\xdfWsr\x9aN\xa3~\xdbM'), chr(656 - 556) + chr(0b1000110 + 0o37) + chr(99) + '\x6f' + '\144' + chr(3652 - 3551))(chr(8232 - 8115) + '\164' + '\146' + chr(0b101101) + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xcf8\x9bfqr\xbcr\xfcz\x83\x11\x1c\x11s\xed\xb5\xca\x18\xc6\xd1\xfa*r\xd1.%ZF\x8c\x87\xb4\x8b7\xc8\xc0\x8b\x1a\x93\x16\xe4m\x9b"a'), '\144' + '\x65' + chr(0b1100011) + chr(0b11000 + 0o127) + '\144' + chr(0b1100101))(chr(0b111100 + 0o71) + '\164' + chr(102) + chr(466 - 421) + chr(0b101111 + 0o11)), ivhwUfDWYTWy) raise MO1jGuXEVWyF(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc89\xd8h\x7fv\xb9x\xe6l\x83\x1c\x1a\x03n\xa2\xaf\x85K\xc0\xcf\xe1<h\xc0>'), chr(100) + chr(101) + '\143' + chr(3773 - 3662) + chr(0b1100100) + chr(0b11 + 0o142))(chr(117) + chr(116) + chr(0b10001 + 0o125) + chr(1254 - 1209) + chr(0b10110 + 0o42))) (ULG77TjK80oU, ZhTWDDhoiRNo) = klkIVilDKnwv.pop(ehT0Px3KOsy9(chr(435 - 387) + '\157' + '\060', ord("\x08"))) if ULG77TjK80oU != xafqLlk3kkUe(ivhwUfDWYTWy, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd5\x05\xeeH^@\x99h\xd69\x9b\x05'), chr(6035 - 5935) + '\145' + '\143' + '\x6f' + '\x64' + '\145')('\165' + chr(10700 - 10584) + chr(0b110101 + 0o61) + chr(1229 - 1184) + chr(0b111000)))(): xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc4\x02\xdfWsr\x9aN\xa3~\xdbM'), chr(100) + chr(101) + '\143' + chr(0b100011 + 0o114) + chr(0b101011 + 0o71) + '\145')(chr(9227 - 9110) + chr(116) + chr(102) + '\055' + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc2"\xc9uwh\xa1=\xfcf\xc7\x18CW"\xbe'), '\x64' + chr(0b101011 + 0o72) + chr(0b1000000 + 0o43) + chr(111) + '\144' + '\x65')('\165' + chr(0b1110100) + '\x66' + '\x2d' + chr(56)), ivhwUfDWYTWy) xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc4\x02\xdfWsr\x9aN\xa3~\xdbM'), chr(100) + '\145' + chr(0b1100011) + chr(0b1101111 + 0o0) + '\x64' + '\145')(chr(0b1010100 + 0o41) + chr(116) + chr(0b1100000 + 0o6) + chr(45) + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xcf2\xc3s2g\xb6i\xfbf\xcdGYRt\xed\xec\x9b\x18\x80\xcd'), chr(0b101111 + 0o65) + chr(0b1 + 0o144) + chr(0b1100011) + chr(111) + chr(6297 - 6197) + chr(101))('\x75' + chr(4577 - 4461) + chr(3199 - 3097) + '\055' + chr(0b11100 + 0o34)), ULG77TjK80oU, ZhTWDDhoiRNo) xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc4\x02\xdfWsr\x9aN\xa3~\xdbM'), chr(0b1100100) + chr(101) + '\143' + '\157' + '\144' + '\145')(chr(0b1110101) + chr(0b1110100) + chr(0b1011001 + 0o15) + '\055' + '\x38'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd32\xd6f{h\xbcs\xf5)\xc2\x1e\r\x1eh\xa3\xb2\x85O\xc0\xcc\xf1c&\x86('), '\144' + chr(0b1100101) + chr(99) + chr(0b1101111) + '\x64' + chr(101))(chr(8917 - 8800) + chr(116) + chr(0b101010 + 0o74) + chr(45) + chr(0b111000)), klkIVilDKnwv) raise MO1jGuXEVWyF(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc2"\xc9uwh\xa1=\xfcf\xc7\x18Y\x13h\xa8\xb2\x85V\xca\xca\xb44g\xd78.\x0e\x08\x8a\x8a\xb2\xd93\xc5\xc0\xc2\x1b\x92'), '\x64' + chr(0b1100101) + chr(99) + chr(111) + chr(0b1100100) + chr(4778 - 4677))(chr(117) + chr(0b1100001 + 0o23) + chr(726 - 624) + chr(245 - 200) + '\070')) if ZhTWDDhoiRNo[ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\x6f' + '\060', 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xda'), chr(100) + '\x65' + '\143' + '\157' + '\144' + '\x65')('\x75' + chr(0b1110100) + chr(0b1100110) + '\x2d' + chr(3096 - 3040)): for iWzolnnIYOhc in xafqLlk3kkUe(ZhTWDDhoiRNo[ehT0Px3KOsy9('\060' + chr(11479 - 11368) + chr(0b110001), 0o10):-ehT0Px3KOsy9('\x30' + '\157' + chr(0b100000 + 0o21), 8)], xafqLlk3kkUe(SXOLrMavuUCe(b"\xf2'\xd7nf"), '\144' + chr(101) + chr(2168 - 2069) + '\157' + chr(100) + chr(0b1100101))(chr(0b1110101) + chr(6136 - 6020) + '\x66' + '\055' + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xadw'), chr(1175 - 1075) + '\x65' + chr(9005 - 8906) + chr(0b10010 + 0o135) + chr(100) + '\x65')(chr(117) + '\164' + chr(102) + chr(45) + chr(56))): KmnFuUFz61HL = EkzIH99VGiMZ(iWzolnnIYOhc, []) xafqLlk3kkUe(ivhwUfDWYTWy, xafqLlk3kkUe(SXOLrMavuUCe(b"\xe0'\xcbb|b"), chr(8097 - 7997) + chr(0b101101 + 0o70) + chr(0b100110 + 0o75) + '\157' + chr(8402 - 8302) + '\145')(chr(0b1110101) + chr(0b1110100) + chr(0b11011 + 0o113) + chr(45) + chr(56)))(KmnFuUFz61HL) klkIVilDKnwv = oVre8I6UXc3b._construct_node_from_actions(KmnFuUFz61HL, klkIVilDKnwv) else: xafqLlk3kkUe(ivhwUfDWYTWy, xafqLlk3kkUe(SXOLrMavuUCe(b"\xe0'\xcbb|b"), chr(6220 - 6120) + '\x65' + '\143' + '\157' + chr(100) + chr(0b111111 + 0o46))(chr(0b10000 + 0o145) + '\164' + chr(102) + chr(0b101101) + chr(1507 - 1451)))(EkzIH99VGiMZ(ZhTWDDhoiRNo, [])) return klkIVilDKnwv
allenai/allennlp
allennlp/modules/sampled_softmax_loss.py
_choice
def _choice(num_words: int, num_samples: int) -> Tuple[np.ndarray, int]: """ Chooses ``num_samples`` samples without replacement from [0, ..., num_words). Returns a tuple (samples, num_tries). """ num_tries = 0 num_chosen = 0 def get_buffer() -> np.ndarray: log_samples = np.random.rand(num_samples) * np.log(num_words + 1) samples = np.exp(log_samples).astype('int64') - 1 return np.clip(samples, a_min=0, a_max=num_words - 1) sample_buffer = get_buffer() buffer_index = 0 samples: Set[int] = set() while num_chosen < num_samples: num_tries += 1 # choose sample sample_id = sample_buffer[buffer_index] if sample_id not in samples: samples.add(sample_id) num_chosen += 1 buffer_index += 1 if buffer_index == num_samples: # Reset the buffer sample_buffer = get_buffer() buffer_index = 0 return np.array(list(samples)), num_tries
python
def _choice(num_words: int, num_samples: int) -> Tuple[np.ndarray, int]: """ Chooses ``num_samples`` samples without replacement from [0, ..., num_words). Returns a tuple (samples, num_tries). """ num_tries = 0 num_chosen = 0 def get_buffer() -> np.ndarray: log_samples = np.random.rand(num_samples) * np.log(num_words + 1) samples = np.exp(log_samples).astype('int64') - 1 return np.clip(samples, a_min=0, a_max=num_words - 1) sample_buffer = get_buffer() buffer_index = 0 samples: Set[int] = set() while num_chosen < num_samples: num_tries += 1 # choose sample sample_id = sample_buffer[buffer_index] if sample_id not in samples: samples.add(sample_id) num_chosen += 1 buffer_index += 1 if buffer_index == num_samples: # Reset the buffer sample_buffer = get_buffer() buffer_index = 0 return np.array(list(samples)), num_tries
[ "def", "_choice", "(", "num_words", ":", "int", ",", "num_samples", ":", "int", ")", "->", "Tuple", "[", "np", ".", "ndarray", ",", "int", "]", ":", "num_tries", "=", "0", "num_chosen", "=", "0", "def", "get_buffer", "(", ")", "->", "np", ".", "ndarray", ":", "log_samples", "=", "np", ".", "random", ".", "rand", "(", "num_samples", ")", "*", "np", ".", "log", "(", "num_words", "+", "1", ")", "samples", "=", "np", ".", "exp", "(", "log_samples", ")", ".", "astype", "(", "'int64'", ")", "-", "1", "return", "np", ".", "clip", "(", "samples", ",", "a_min", "=", "0", ",", "a_max", "=", "num_words", "-", "1", ")", "sample_buffer", "=", "get_buffer", "(", ")", "buffer_index", "=", "0", "samples", ":", "Set", "[", "int", "]", "=", "set", "(", ")", "while", "num_chosen", "<", "num_samples", ":", "num_tries", "+=", "1", "# choose sample", "sample_id", "=", "sample_buffer", "[", "buffer_index", "]", "if", "sample_id", "not", "in", "samples", ":", "samples", ".", "add", "(", "sample_id", ")", "num_chosen", "+=", "1", "buffer_index", "+=", "1", "if", "buffer_index", "==", "num_samples", ":", "# Reset the buffer", "sample_buffer", "=", "get_buffer", "(", ")", "buffer_index", "=", "0", "return", "np", ".", "array", "(", "list", "(", "samples", ")", ")", ",", "num_tries" ]
Chooses ``num_samples`` samples without replacement from [0, ..., num_words). Returns a tuple (samples, num_tries).
[ "Chooses", "num_samples", "samples", "without", "replacement", "from", "[", "0", "...", "num_words", ")", ".", "Returns", "a", "tuple", "(", "samples", "num_tries", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/sampled_softmax_loss.py#L11-L42
train
Return a random set of num_samples samples with replacement from [ 0... num_words ).
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj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,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(885 - 837) + chr(111) + '\x31' + chr(0b0 + 0o64), 42765 - 42757), ehT0Px3KOsy9(chr(1578 - 1530) + '\157' + chr(0b11001 + 0o31) + chr(50) + chr(51), 0b1000), ehT0Px3KOsy9(chr(1649 - 1601) + chr(111) + '\064' + chr(0b110101), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1011101 + 0o22) + chr(49) + '\061' + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(1492 - 1444) + chr(0b111010 + 0o65) + chr(1195 - 1144) + chr(0b110010) + '\x30', 0b1000), ehT0Px3KOsy9(chr(747 - 699) + chr(0b1101111) + chr(1352 - 1301) + '\062' + chr(1781 - 1726), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(54), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b11001 + 0o126) + '\x35' + chr(0b110101), 64872 - 64864), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + chr(0b110111) + '\060', 0b1000), ehT0Px3KOsy9('\060' + chr(4079 - 3968) + chr(50) + chr(0b1111 + 0o50) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\x6f' + '\065' + chr(53), 8), ehT0Px3KOsy9(chr(0b110000) + chr(3452 - 3341) + chr(0b10010 + 0o37) + chr(1683 - 1632) + chr(404 - 354), 61188 - 61180), ehT0Px3KOsy9(chr(1771 - 1723) + '\x6f' + chr(0b110001) + '\x32' + chr(1267 - 1216), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + '\x32' + chr(52), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1011010 + 0o25) + chr(0b110001) + chr(55) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\x6f' + '\062' + chr(0b100110 + 0o14) + chr(2582 - 2530), ord("\x08")), ehT0Px3KOsy9(chr(1321 - 1273) + '\x6f' + chr(1651 - 1600) + chr(511 - 456) + chr(955 - 903), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\x32' + chr(2275 - 2227) + chr(0b111 + 0o52), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1100100 + 0o13) + chr(0b10111 + 0o32) + chr(0b110000) + chr(0b110101), 33936 - 33928), ehT0Px3KOsy9(chr(0b110000) + chr(8885 - 8774) + chr(848 - 799) + chr(0b110110) + chr(2223 - 2169), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b11001 + 0o126) + '\067' + chr(0b10000 + 0o41), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x31' + '\061' + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b101110 + 0o5) + chr(0b110001) + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(512 - 401) + chr(49) + '\062', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(839 - 789) + '\061' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(1863 - 1815) + chr(0b1101111) + chr(1681 - 1631) + '\x34' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b110110 + 0o71) + chr(0b110001) + '\x31' + '\x34', 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\064' + chr(0b101 + 0o57), ord("\x08")), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1100001 + 0o16) + chr(0b110001) + '\x35' + chr(104 - 50), ord("\x08")), ehT0Px3KOsy9(chr(345 - 297) + '\157' + chr(0b100000 + 0o21) + '\063' + chr(53), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b11101 + 0o26) + '\064' + '\x31', 0o10), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(111) + '\x33' + '\064' + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\060', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101 + 0o142) + '\063' + '\063' + chr(0b11100 + 0o24), 30949 - 30941), ehT0Px3KOsy9(chr(1037 - 989) + '\x6f' + '\x36' + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(867 - 816) + chr(0b101100 + 0o4) + chr(554 - 500), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101010 + 0o11) + chr(49) + '\x30', 56267 - 56259), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b1101111) + '\062' + chr(1645 - 1591) + chr(839 - 785), 14212 - 14204), ehT0Px3KOsy9(chr(0b110000) + chr(818 - 707) + chr(51) + '\061' + chr(0b110101), 44760 - 44752), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110101) + '\067', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(912 - 864) + '\x6f' + chr(1973 - 1920) + chr(61 - 13), 45515 - 45507)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'"'), chr(100) + '\x65' + chr(0b1100011) + chr(0b111100 + 0o63) + chr(100) + chr(0b1011 + 0o132))('\165' + chr(0b1011111 + 0o25) + chr(9262 - 9160) + chr(1178 - 1133) + chr(1534 - 1478)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def pE3A77uBWi84(qj__vTk2GDta, Wuetkhsbidt0) -> MRK8Uzg2En3D[xafqLlk3kkUe(WqUC3KWvYVup, xafqLlk3kkUe(SXOLrMavuUCe(b'b\xf7D>\xa2\xb6\x7f'), chr(100) + chr(101) + chr(0b1100011) + chr(111) + chr(4721 - 4621) + '\145')(chr(0b1110101) + '\164' + '\146' + chr(0b101101) + chr(0b111000))), ehT0Px3KOsy9]: J5hmqA0MpN_u = ehT0Px3KOsy9('\x30' + '\x6f' + '\x30', 8) Dis0J9lCCVuw = ehT0Px3KOsy9(chr(1608 - 1560) + chr(4842 - 4731) + chr(0b110000), 8) def nRjNCG5My74U() -> xafqLlk3kkUe(WqUC3KWvYVup, xafqLlk3kkUe(SXOLrMavuUCe(b'b\xf7D>\xa2\xb6\x7f'), '\144' + '\x65' + chr(0b1100011) + chr(0b1101111) + chr(5007 - 4907) + chr(2544 - 2443))('\165' + chr(0b10010 + 0o142) + chr(352 - 250) + chr(45) + chr(0b101001 + 0o17))): IDA_DuLQFKjN = WqUC3KWvYVup.random.rand(Wuetkhsbidt0) * WqUC3KWvYVup.log(qj__vTk2GDta + ehT0Px3KOsy9(chr(0b110000) + chr(0b101001 + 0o106) + chr(0b110001), ord("\x08"))) db1_IZvznkcy = WqUC3KWvYVup.exp(IDA_DuLQFKjN).astype(xafqLlk3kkUe(SXOLrMavuUCe(b'e\xfdQz\xe4'), chr(1124 - 1024) + chr(8371 - 8270) + chr(525 - 426) + chr(0b1101111) + chr(6903 - 6803) + '\x65')(chr(0b1110001 + 0o4) + '\164' + chr(3244 - 3142) + chr(0b101101) + chr(56))) - ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110001), 8) return xafqLlk3kkUe(WqUC3KWvYVup, xafqLlk3kkUe(SXOLrMavuUCe(b'D\xabm\x19\x81\xbaOH\x8a\xda_m'), chr(0b110101 + 0o57) + chr(0b1001001 + 0o34) + '\x63' + '\157' + chr(0b101010 + 0o72) + chr(0b10101 + 0o120))(chr(0b1110101) + '\164' + chr(102) + '\x2d' + chr(0b11 + 0o65)))(db1_IZvznkcy, a_min=ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110000), 8), a_max=qj__vTk2GDta - ehT0Px3KOsy9(chr(0b110000) + chr(1264 - 1153) + chr(0b110001), 8)) zK2Lq1NMci9t = nRjNCG5My74U() Fu3c7_4_jhS8 = ehT0Px3KOsy9('\060' + chr(2349 - 2238) + chr(0b101001 + 0o7), 8) db1_IZvznkcy = MVEN8G6CxlvR() while Dis0J9lCCVuw < Wuetkhsbidt0: J5hmqA0MpN_u += ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(111) + '\x31', 8) uYSRtekgWl52 = zK2Lq1NMci9t[Fu3c7_4_jhS8] if uYSRtekgWl52 not in db1_IZvznkcy: xafqLlk3kkUe(db1_IZvznkcy, xafqLlk3kkUe(SXOLrMavuUCe(b'y\xd9\x15=\xe9\xb4A\x18\xa2\xf0\x7fi'), chr(100) + chr(0b1100101) + chr(99) + chr(0b110111 + 0o70) + chr(0b1010010 + 0o22) + chr(0b1100101))(chr(0b1000111 + 0o56) + chr(4050 - 3934) + chr(0b1100110) + chr(0b10000 + 0o35) + chr(0b111000)))(uYSRtekgWl52) Dis0J9lCCVuw += ehT0Px3KOsy9(chr(1084 - 1036) + '\157' + '\x31', 8) Fu3c7_4_jhS8 += ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1100001 + 0o16) + chr(49), 8) if Fu3c7_4_jhS8 == Wuetkhsbidt0: zK2Lq1NMci9t = nRjNCG5My74U() Fu3c7_4_jhS8 = ehT0Px3KOsy9('\060' + '\157' + chr(102 - 54), 8) return (xafqLlk3kkUe(WqUC3KWvYVup, xafqLlk3kkUe(SXOLrMavuUCe(b'N\xa3@\x1c\x94\xbfv\\\x80\xf1\x184'), chr(0b110100 + 0o60) + chr(0b1011011 + 0o12) + '\x63' + chr(111) + '\x64' + '\145')(chr(117) + chr(0b1110100) + chr(9274 - 9172) + chr(45) + chr(56)))(YyaZ4tpXu4lf(db1_IZvznkcy)), J5hmqA0MpN_u)
allenai/allennlp
allennlp/data/token_indexers/token_indexer.py
TokenIndexer.tokens_to_indices
def tokens_to_indices(self, tokens: List[Token], vocabulary: Vocabulary, index_name: str) -> Dict[str, List[TokenType]]: """ Takes a list of tokens and converts them to one or more sets of indices. This could be just an ID for each token from the vocabulary. Or it could split each token into characters and return one ID per character. Or (for instance, in the case of byte-pair encoding) there might not be a clean mapping from individual tokens to indices. """ raise NotImplementedError
python
def tokens_to_indices(self, tokens: List[Token], vocabulary: Vocabulary, index_name: str) -> Dict[str, List[TokenType]]: """ Takes a list of tokens and converts them to one or more sets of indices. This could be just an ID for each token from the vocabulary. Or it could split each token into characters and return one ID per character. Or (for instance, in the case of byte-pair encoding) there might not be a clean mapping from individual tokens to indices. """ raise NotImplementedError
[ "def", "tokens_to_indices", "(", "self", ",", "tokens", ":", "List", "[", "Token", "]", ",", "vocabulary", ":", "Vocabulary", ",", "index_name", ":", "str", ")", "->", "Dict", "[", "str", ",", "List", "[", "TokenType", "]", "]", ":", "raise", "NotImplementedError" ]
Takes a list of tokens and converts them to one or more sets of indices. This could be just an ID for each token from the vocabulary. Or it could split each token into characters and return one ID per character. Or (for instance, in the case of byte-pair encoding) there might not be a clean mapping from individual tokens to indices.
[ "Takes", "a", "list", "of", "tokens", "and", "converts", "them", "to", "one", "or", "more", "sets", "of", "indices", ".", "This", "could", "be", "just", "an", "ID", "for", "each", "token", "from", "the", "vocabulary", ".", "Or", "it", "could", "split", "each", "token", "into", "characters", "and", "return", "one", "ID", "per", "character", ".", "Or", "(", "for", "instance", "in", "the", "case", "of", "byte", "-", "pair", "encoding", ")", "there", "might", "not", "be", "a", "clean", "mapping", "from", "individual", "tokens", "to", "indices", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/token_indexers/token_indexer.py#L33-L44
train
Takes a list of tokens and converts them to one or more sets of indices.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMu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WE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\x6f' + '\062' + '\x32' + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(1199 - 1151) + chr(0b1010100 + 0o33) + chr(302 - 251) + '\x31' + chr(0b110001), 13067 - 13059), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + chr(0b100010 + 0o22) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(865 - 815) + chr(0b1100 + 0o45) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + '\x34' + chr(0b110001), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b101100 + 0o103) + chr(0b100101 + 0o15) + chr(49) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b110010 + 0o75) + chr(51) + chr(0b110010) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(988 - 937) + '\064' + chr(48), 14715 - 14707), ehT0Px3KOsy9(chr(48) + '\157' + chr(49) + chr(50) + chr(1739 - 1684), 0o10), ehT0Px3KOsy9(chr(2275 - 2227) + chr(481 - 370) + chr(0b11110 + 0o24) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1110 + 0o141) + '\x31' + '\064' + '\064', 30938 - 30930), ehT0Px3KOsy9('\x30' + chr(0b1010 + 0o145) + chr(0b101011 + 0o7) + '\x31' + '\062', ord("\x08")), ehT0Px3KOsy9(chr(2097 - 2049) + '\157' + chr(50) + chr(685 - 630) + chr(1890 - 1836), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b100110 + 0o15), 0o10), ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(0b1101010 + 0o5) + chr(0b110001) + chr(0b110000) + '\x33', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + chr(0b100011 + 0o16) + '\063', 24558 - 24550), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + chr(53) + '\x30', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(4655 - 4544) + '\062' + chr(0b110110) + chr(1014 - 961), ord("\x08")), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\x6f' + '\x35' + chr(0b11101 + 0o26), 21388 - 21380), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(2008 - 1897) + chr(0b110001) + chr(0b110001), 15679 - 15671), ehT0Px3KOsy9(chr(0b110000) + chr(3571 - 3460) + chr(51) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b11001 + 0o30) + '\x31' + chr(1889 - 1835), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\062' + '\x34' + '\060', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(1413 - 1302) + chr(0b101000 + 0o13) + '\064' + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(811 - 700) + '\063' + chr(0b100000 + 0o24) + chr(0b10011 + 0o37), 6109 - 6101), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b1101111) + chr(0b1100 + 0o46) + chr(1887 - 1839), 22786 - 22778), ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(0b1101111) + '\062' + chr(0b110011) + '\x33', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\x32' + '\x35' + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + '\064' + '\x37', 8), ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + '\x33' + chr(0b100011 + 0o21), 0o10), ehT0Px3KOsy9(chr(0b10111 + 0o31) + '\x6f' + chr(50) + chr(1317 - 1263) + '\066', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(53) + chr(0b111 + 0o53), 27818 - 27810), ehT0Px3KOsy9(chr(1446 - 1398) + chr(0b1100110 + 0o11) + chr(1661 - 1611), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(319 - 268) + chr(115 - 60), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b10000 + 0o42) + chr(0b110000) + '\x33', 18759 - 18751), ehT0Px3KOsy9(chr(0b110000) + chr(9380 - 9269) + '\x36' + '\061', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(657 - 607) + chr(1183 - 1132) + chr(1497 - 1449), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(2197 - 2147) + '\x35' + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\x6f' + '\062' + '\x37' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\x6f' + chr(2579 - 2528) + chr(1676 - 1628), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(53) + chr(0b11111 + 0o21), 48106 - 48098)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xbd'), chr(0b1100100) + chr(0b111110 + 0o47) + chr(4166 - 4067) + chr(0b1101111) + chr(0b1100100) + '\145')(chr(0b1110101) + '\x74' + chr(4043 - 3941) + chr(0b101101) + chr(734 - 678)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def YtoUaMvlhpdT(oVre8I6UXc3b, Sz7tXxaCGqJ1, Vemi1XCgm0ph, UxVryR3RtBjw) -> zBnV56fc6HrA[M8_cKLkHVB2V, qRxF7OQ0y39T[eXdenZbwHi0I]]: raise _zJ24Vce7wp0
allenai/allennlp
allennlp/data/token_indexers/token_indexer.py
TokenIndexer.pad_token_sequence
def pad_token_sequence(self, tokens: Dict[str, List[TokenType]], desired_num_tokens: Dict[str, int], padding_lengths: Dict[str, int]) -> Dict[str, List[TokenType]]: """ This method pads a list of tokens to ``desired_num_tokens`` and returns a padded copy of the input tokens. If the input token list is longer than ``desired_num_tokens`` then it will be truncated. ``padding_lengths`` is used to provide supplemental padding parameters which are needed in some cases. For example, it contains the widths to pad characters to when doing character-level padding. """ raise NotImplementedError
python
def pad_token_sequence(self, tokens: Dict[str, List[TokenType]], desired_num_tokens: Dict[str, int], padding_lengths: Dict[str, int]) -> Dict[str, List[TokenType]]: """ This method pads a list of tokens to ``desired_num_tokens`` and returns a padded copy of the input tokens. If the input token list is longer than ``desired_num_tokens`` then it will be truncated. ``padding_lengths`` is used to provide supplemental padding parameters which are needed in some cases. For example, it contains the widths to pad characters to when doing character-level padding. """ raise NotImplementedError
[ "def", "pad_token_sequence", "(", "self", ",", "tokens", ":", "Dict", "[", "str", ",", "List", "[", "TokenType", "]", "]", ",", "desired_num_tokens", ":", "Dict", "[", "str", ",", "int", "]", ",", "padding_lengths", ":", "Dict", "[", "str", ",", "int", "]", ")", "->", "Dict", "[", "str", ",", "List", "[", "TokenType", "]", "]", ":", "raise", "NotImplementedError" ]
This method pads a list of tokens to ``desired_num_tokens`` and returns a padded copy of the input tokens. If the input token list is longer than ``desired_num_tokens`` then it will be truncated. ``padding_lengths`` is used to provide supplemental padding parameters which are needed in some cases. For example, it contains the widths to pad characters to when doing character-level padding.
[ "This", "method", "pads", "a", "list", "of", "tokens", "to", "desired_num_tokens", "and", "returns", "a", "padded", "copy", "of", "the", "input", "tokens", ".", "If", "the", "input", "token", "list", "is", "longer", "than", "desired_num_tokens", "then", "it", "will", "be", "truncated", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/token_indexers/token_indexer.py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LRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(284 - 236) + chr(0b1101111) + chr(49) + chr(50) + chr(2007 - 1959), 0o10), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(8392 - 8281) + chr(50) + '\x35' + chr(0b100111 + 0o15), 0o10), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(0b1001010 + 0o45) + chr(50) + chr(52) + chr(880 - 825), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b100001 + 0o116) + '\062' + chr(55) + chr(52), 0b1000), ehT0Px3KOsy9(chr(48) + chr(4339 - 4228) + '\x31' + '\x37' + chr(0b110110), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(0b110101) + '\x35', 56621 - 56613), ehT0Px3KOsy9('\060' + chr(8443 - 8332) + chr(0b110011) + chr(0b110111) + chr(3022 - 2967), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(2285 - 2235) + chr(0b110111) + '\x35', 59878 - 59870), ehT0Px3KOsy9('\060' + '\157' + '\061' + chr(0b110011), 0o10), ehT0Px3KOsy9('\060' + chr(7795 - 7684) + '\x32' + chr(0b110001) + chr(268 - 219), 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\157' + chr(0b110010) + chr(0b10110 + 0o34) + chr(0b1011 + 0o45), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\x33' + chr(54) + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b1101111) + '\x32' + '\x36' + '\x36', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b10000 + 0o137) + chr(0b100101 + 0o15) + '\x31' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + chr(0b110100) + chr(0b110110), 38106 - 38098), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + chr(908 - 858) + chr(0b11111 + 0o27), ord("\x08")), ehT0Px3KOsy9(chr(2057 - 2009) + chr(111) + chr(0b101010 + 0o13) + chr(351 - 301), ord("\x08")), ehT0Px3KOsy9(chr(1988 - 1940) + '\157' + chr(0b110010) + '\065', ord("\x08")), ehT0Px3KOsy9('\060' + chr(8938 - 8827) + '\061' + chr(0b110011) + '\060', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1001111 + 0o40) + chr(0b100101 + 0o16) + chr(1165 - 1112) + '\x30', 0o10), ehT0Px3KOsy9(chr(1304 - 1256) + chr(0b1100100 + 0o13) + chr(2247 - 2195) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(1927 - 1879) + '\157' + chr(0b110010) + chr(0b110111) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(114 - 66) + chr(111) + '\063' + chr(250 - 201) + chr(2033 - 1982), 20046 - 20038), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1110 - 1060) + '\x36' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(917 - 869) + chr(0b1011100 + 0o23) + chr(0b10101 + 0o36) + chr(0b11110 + 0o23) + chr(591 - 543), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b111011 + 0o64) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\157' + chr(0b110010) + '\060', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011111 + 0o20) + '\x33' + chr(0b101 + 0o54) + chr(1902 - 1850), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b100010 + 0o20) + '\x34' + chr(0b1111 + 0o43), 263 - 255), ehT0Px3KOsy9(chr(1704 - 1656) + chr(3789 - 3678) + chr(0b110001) + chr(0b100011 + 0o16) + chr(0b110001), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(799 - 749) + chr(738 - 688) + '\x31', 0o10), ehT0Px3KOsy9(chr(1905 - 1857) + '\x6f' + '\x31' + '\x36' + '\x31', 23240 - 23232), ehT0Px3KOsy9(chr(48) + chr(111) + chr(728 - 678) + chr(0b10110 + 0o41) + '\x34', 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x35' + '\065', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(53) + '\x35', 8), ehT0Px3KOsy9(chr(1710 - 1662) + chr(0b1101111) + chr(0b101010 + 0o7) + chr(2410 - 2357) + chr(2554 - 2499), 7562 - 7554), ehT0Px3KOsy9(chr(1234 - 1186) + chr(0b1011100 + 0o23) + chr(50) + chr(973 - 918) + chr(700 - 649), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001 + 0o1) + chr(1598 - 1548) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110101) + chr(0b110000), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(6206 - 6095) + '\x35' + '\x30', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'~'), chr(100) + chr(0b1100101) + chr(6940 - 6841) + '\x6f' + chr(1348 - 1248) + chr(101))(chr(117) + chr(116) + '\x66' + chr(1633 - 1588) + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def XgUf36J5LAso(oVre8I6UXc3b, Sz7tXxaCGqJ1, jq3V5XEmIeFh, QJBZYYPtla9t) -> zBnV56fc6HrA[M8_cKLkHVB2V, qRxF7OQ0y39T[eXdenZbwHi0I]]: raise _zJ24Vce7wp0
allenai/allennlp
allennlp/data/dataset_readers/coreference_resolution/conll.py
canonicalize_clusters
def canonicalize_clusters(clusters: DefaultDict[int, List[Tuple[int, int]]]) -> List[List[Tuple[int, int]]]: """ The CONLL 2012 data includes 2 annotated spans which are identical, but have different ids. This checks all clusters for spans which are identical, and if it finds any, merges the clusters containing the identical spans. """ merged_clusters: List[Set[Tuple[int, int]]] = [] for cluster in clusters.values(): cluster_with_overlapping_mention = None for mention in cluster: # Look at clusters we have already processed to # see if they contain a mention in the current # cluster for comparison. for cluster2 in merged_clusters: if mention in cluster2: # first cluster in merged clusters # which contains this mention. cluster_with_overlapping_mention = cluster2 break # Already encountered overlap - no need to keep looking. if cluster_with_overlapping_mention is not None: break if cluster_with_overlapping_mention is not None: # Merge cluster we are currently processing into # the cluster in the processed list. cluster_with_overlapping_mention.update(cluster) else: merged_clusters.append(set(cluster)) return [list(c) for c in merged_clusters]
python
def canonicalize_clusters(clusters: DefaultDict[int, List[Tuple[int, int]]]) -> List[List[Tuple[int, int]]]: """ The CONLL 2012 data includes 2 annotated spans which are identical, but have different ids. This checks all clusters for spans which are identical, and if it finds any, merges the clusters containing the identical spans. """ merged_clusters: List[Set[Tuple[int, int]]] = [] for cluster in clusters.values(): cluster_with_overlapping_mention = None for mention in cluster: # Look at clusters we have already processed to # see if they contain a mention in the current # cluster for comparison. for cluster2 in merged_clusters: if mention in cluster2: # first cluster in merged clusters # which contains this mention. cluster_with_overlapping_mention = cluster2 break # Already encountered overlap - no need to keep looking. if cluster_with_overlapping_mention is not None: break if cluster_with_overlapping_mention is not None: # Merge cluster we are currently processing into # the cluster in the processed list. cluster_with_overlapping_mention.update(cluster) else: merged_clusters.append(set(cluster)) return [list(c) for c in merged_clusters]
[ "def", "canonicalize_clusters", "(", "clusters", ":", "DefaultDict", "[", "int", ",", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", "]", ")", "->", "List", "[", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", "]", ":", "merged_clusters", ":", "List", "[", "Set", "[", "Tuple", "[", "int", ",", "int", "]", "]", "]", "=", "[", "]", "for", "cluster", "in", "clusters", ".", "values", "(", ")", ":", "cluster_with_overlapping_mention", "=", "None", "for", "mention", "in", "cluster", ":", "# Look at clusters we have already processed to", "# see if they contain a mention in the current", "# cluster for comparison.", "for", "cluster2", "in", "merged_clusters", ":", "if", "mention", "in", "cluster2", ":", "# first cluster in merged clusters", "# which contains this mention.", "cluster_with_overlapping_mention", "=", "cluster2", "break", "# Already encountered overlap - no need to keep looking.", "if", "cluster_with_overlapping_mention", "is", "not", "None", ":", "break", "if", "cluster_with_overlapping_mention", "is", "not", "None", ":", "# Merge cluster we are currently processing into", "# the cluster in the processed list.", "cluster_with_overlapping_mention", ".", "update", "(", "cluster", ")", "else", ":", "merged_clusters", ".", "append", "(", "set", "(", "cluster", ")", ")", "return", "[", "list", "(", "c", ")", "for", "c", "in", "merged_clusters", "]" ]
The CONLL 2012 data includes 2 annotated spans which are identical, but have different ids. This checks all clusters for spans which are identical, and if it finds any, merges the clusters containing the identical spans.
[ "The", "CONLL", "2012", "data", "includes", "2", "annotated", "spans", "which", "are", "identical", "but", "have", "different", "ids", ".", "This", "checks", "all", "clusters", "for", "spans", "which", "are", "identical", "and", "if", "it", "finds", "any", "merges", "the", "clusters", "containing", "the", "identical", "spans", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/coreference_resolution/conll.py#L18-L47
train
Canonicalizes the clusters in CONLL 2012 data.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoAL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72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(111) + '\x31' + '\065' + '\064', 56146 - 56138), ehT0Px3KOsy9(chr(175 - 127) + '\157' + chr(0b101001 + 0o10) + '\067' + '\063', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b100000 + 0o117) + chr(2221 - 2170) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(826 - 778) + '\x6f' + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x31' + '\063' + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(74 - 24) + '\060' + chr(0b101010 + 0o6), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b11101 + 0o122) + '\x31' + chr(731 - 676) + chr(0b110101), 55824 - 55816), ehT0Px3KOsy9(chr(1555 - 1507) + '\157' + chr(0b110011) + chr(0b110110) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\063' + chr(2631 - 2578) + chr(49), 0b1000), ehT0Px3KOsy9(chr(689 - 641) + '\x6f' + '\062' + chr(0b100101 + 0o15) + '\064', 25715 - 25707), ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\x6f' + chr(0b100010 + 0o17) + chr(0b110001) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x31' + chr(0b110001) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1004 - 955) + chr(0b110010 + 0o4) + chr(54), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1846 - 1795) + '\x30' + chr(2612 - 2558), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b111001 + 0o66) + '\063' + '\x31', 58544 - 58536), ehT0Px3KOsy9('\x30' + chr(7720 - 7609) + chr(1779 - 1728) + '\062', 0o10), ehT0Px3KOsy9(chr(874 - 826) + chr(0b1101111) + '\061' + chr(355 - 302) + chr(49), 43159 - 43151), ehT0Px3KOsy9(chr(2059 - 2011) + chr(0b1101111) + chr(51) + '\060' + chr(0b101101 + 0o12), 1004 - 996), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(51) + '\066' + chr(0b110110), 8), ehT0Px3KOsy9(chr(48) + chr(6184 - 6073) + chr(363 - 312) + chr(52) + chr(51), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(50) + chr(0b110101), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100111 + 0o12) + chr(2086 - 2033), 0o10), ehT0Px3KOsy9('\060' + chr(1372 - 1261) + '\x32' + chr(50) + '\x30', 3890 - 3882), ehT0Px3KOsy9(chr(1416 - 1368) + '\157' + '\x37' + chr(0b110000), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1095 - 1045) + chr(51) + '\065', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(9180 - 9069) + '\066' + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b1111 + 0o45) + '\x33', 0b1000), ehT0Px3KOsy9(chr(48) + chr(10527 - 10416) + chr(0b100110 + 0o15) + chr(48) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + chr(516 - 466) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(6129 - 6018) + '\x31' + '\064' + chr(55), 44007 - 43999), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(0b1111 + 0o41) + '\x31', 11802 - 11794), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\157' + '\x34' + '\067', 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(0b110000) + chr(0b1111 + 0o46), 8), ehT0Px3KOsy9('\060' + chr(0b10110 + 0o131) + '\x32' + chr(49) + chr(0b110100), 34539 - 34531), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110011) + '\x30' + '\065', 8), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(0b11010 + 0o125) + chr(190 - 140) + chr(0b101111 + 0o7) + chr(0b11110 + 0o30), ord("\x08")), ehT0Px3KOsy9(chr(2089 - 2041) + '\x6f' + chr(593 - 544) + chr(48) + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(2338 - 2289) + '\x33' + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(676 - 628) + '\157' + '\063' + chr(1623 - 1573) + chr(55), 35018 - 35010)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(111) + '\x35' + chr(48), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'B'), '\144' + chr(101) + '\143' + chr(0b1011011 + 0o24) + '\x64' + '\x65')(chr(117) + chr(116) + chr(0b1100110) + chr(1027 - 982) + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def _mG6W47knY9G(sAHNhSKkzJx7) -> qRxF7OQ0y39T[qRxF7OQ0y39T[MRK8Uzg2En3D[ehT0Px3KOsy9, ehT0Px3KOsy9]]]: tguJGtGWHX5L = [] for MM44MZHrD3Bf in xafqLlk3kkUe(sAHNhSKkzJx7, xafqLlk3kkUe(SXOLrMavuUCe(b'?+pC\x16\xf5H\xc2Y\xd8\xf0/'), '\x64' + chr(101) + chr(99) + chr(8436 - 8325) + '\144' + '\145')(chr(117) + '\x74' + chr(102) + '\055' + chr(0b111000)))(): XZ3Nzf4_9nyT = None for KzVVEFpkOMc8 in MM44MZHrD3Bf: for vYkFAbdHLKiJ in tguJGtGWHX5L: if KzVVEFpkOMc8 in vYkFAbdHLKiJ: XZ3Nzf4_9nyT = vYkFAbdHLKiJ break if XZ3Nzf4_9nyT is not None: break if XZ3Nzf4_9nyT is not None: xafqLlk3kkUe(XZ3Nzf4_9nyT, xafqLlk3kkUe(SXOLrMavuUCe(b'6\x0f_E1\xce7\x98h\xdd\xf1}'), chr(0b1100010 + 0o2) + chr(5238 - 5137) + chr(99) + chr(0b1000010 + 0o55) + '\144' + '\x65')(chr(3360 - 3243) + '\x74' + chr(0b1100000 + 0o6) + '\x2d' + chr(56)))(MM44MZHrD3Bf) else: xafqLlk3kkUe(tguJGtGWHX5L, xafqLlk3kkUe(SXOLrMavuUCe(b'\r\x0bne6\xe4'), chr(0b1011111 + 0o5) + chr(0b1100101) + chr(99) + '\x6f' + chr(100) + chr(0b1100101))(chr(117) + '\164' + '\146' + '\055' + chr(1951 - 1895)))(MVEN8G6CxlvR(MM44MZHrD3Bf)) return [YyaZ4tpXu4lf(qzn1Ctg9WgNh) for qzn1Ctg9WgNh in tguJGtGWHX5L]
allenai/allennlp
allennlp/predictors/open_information_extraction.py
join_mwp
def join_mwp(tags: List[str]) -> List[str]: """ Join multi-word predicates to a single predicate ('V') token. """ ret = [] verb_flag = False for tag in tags: if "V" in tag: # Create a continuous 'V' BIO span prefix, _ = tag.split("-") if verb_flag: # Continue a verb label across the different predicate parts prefix = 'I' ret.append(f"{prefix}-V") verb_flag = True else: ret.append(tag) verb_flag = False return ret
python
def join_mwp(tags: List[str]) -> List[str]: """ Join multi-word predicates to a single predicate ('V') token. """ ret = [] verb_flag = False for tag in tags: if "V" in tag: # Create a continuous 'V' BIO span prefix, _ = tag.split("-") if verb_flag: # Continue a verb label across the different predicate parts prefix = 'I' ret.append(f"{prefix}-V") verb_flag = True else: ret.append(tag) verb_flag = False return ret
[ "def", "join_mwp", "(", "tags", ":", "List", "[", "str", "]", ")", "->", "List", "[", "str", "]", ":", "ret", "=", "[", "]", "verb_flag", "=", "False", "for", "tag", "in", "tags", ":", "if", "\"V\"", "in", "tag", ":", "# Create a continuous 'V' BIO span", "prefix", ",", "_", "=", "tag", ".", "split", "(", "\"-\"", ")", "if", "verb_flag", ":", "# Continue a verb label across the different predicate parts", "prefix", "=", "'I'", "ret", ".", "append", "(", "f\"{prefix}-V\"", ")", "verb_flag", "=", "True", "else", ":", "ret", ".", "append", "(", "tag", ")", "verb_flag", "=", "False", "return", "ret" ]
Join multi-word predicates to a single predicate ('V') token.
[ "Join", "multi", "-", "word", "predicates", "to", "a", "single", "predicate", "(", "V", ")", "token", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/predictors/open_information_extraction.py#L13-L33
train
Joins multi - word predicates to a single - word predicate ('V') token.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1Ht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e,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(2154 - 2103) + chr(0b110111) + '\x34', 46003 - 45995), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100101 + 0o16) + '\x35' + '\x36', 48298 - 48290), ehT0Px3KOsy9(chr(1411 - 1363) + chr(0b1000111 + 0o50) + chr(2191 - 2142) + chr(53) + chr(997 - 948), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\x31' + chr(2601 - 2546) + chr(0b110001), 43613 - 43605), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1101 + 0o44) + chr(0b110000) + chr(1814 - 1763), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b11 + 0o57) + '\x34' + chr(48), 0b1000), ehT0Px3KOsy9('\060' + chr(8998 - 8887) + '\061' + chr(49) + chr(0b0 + 0o64), 46684 - 46676), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1101111) + '\x31' + '\x33', 0o10), ehT0Px3KOsy9('\060' + chr(0b1001101 + 0o42) + chr(51) + '\067', 9779 - 9771), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\x6f' + chr(0b110010) + chr(0b1 + 0o61), 58537 - 58529), ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\157' + chr(0b10101 + 0o36) + chr(0b110111) + '\061', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(7916 - 7805) + '\061' + chr(0b101001 + 0o7) + chr(0b100001 + 0o25), ord("\x08")), ehT0Px3KOsy9(chr(1112 - 1064) + chr(11644 - 11533) + chr(0b110000 + 0o1) + chr(55), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1244 - 1194) + '\065', 23981 - 23973), ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(0b1101111) + '\x32' + '\064' + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b10 + 0o56) + '\157' + chr(2965 - 2910), ord("\x08")), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(7502 - 7391) + chr(0b100110 + 0o15) + '\060' + '\x37', 22543 - 22535), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001 + 0o2) + chr(0b100100 + 0o23), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(54) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(2158 - 2110) + chr(1237 - 1126) + chr(51), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(6361 - 6250) + chr(0b110011) + chr(1524 - 1475), 0b1000), ehT0Px3KOsy9(chr(1670 - 1622) + '\x6f' + chr(0b101 + 0o55) + chr(2226 - 2178) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(6602 - 6491) + chr(188 - 137) + '\x30', 48320 - 48312), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b111010 + 0o65) + '\063' + '\x34', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\063' + '\x36' + '\x33', 48842 - 48834), ehT0Px3KOsy9(chr(424 - 376) + '\x6f' + chr(49) + chr(51) + chr(55), 27163 - 27155), ehT0Px3KOsy9(chr(0b1110 + 0o42) + '\x6f' + chr(0b110001) + chr(0b110001 + 0o1) + '\065', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + chr(49) + '\060', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + chr(54) + chr(738 - 683), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(8829 - 8718) + '\062' + chr(2928 - 2873) + '\x36', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(5140 - 5029) + chr(0b11100 + 0o27) + '\x35' + chr(1139 - 1091), ord("\x08")), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(111) + chr(2298 - 2247) + chr(0b110101) + chr(0b100101 + 0o20), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(1303 - 1254) + chr(0b10000 + 0o44) + '\x35', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100000 + 0o21) + '\060', 0o10), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(1101 - 990) + chr(0b1001 + 0o51) + chr(55) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(768 - 720) + '\157' + '\x33' + chr(1484 - 1432) + '\x37', 0o10), ehT0Px3KOsy9(chr(2110 - 2062) + '\x6f' + '\x33' + chr(1974 - 1919) + chr(0b110010), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + '\x36', 0o10), ehT0Px3KOsy9(chr(1526 - 1478) + chr(0b1101111) + chr(0b110110), 32103 - 32095), ehT0Px3KOsy9('\060' + chr(0b110101 + 0o72) + chr(457 - 405) + chr(0b10001 + 0o40), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1026 - 973) + chr(48), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd2'), '\144' + chr(0b1001 + 0o134) + '\143' + chr(11727 - 11616) + chr(0b1100100) + chr(0b1100101))(chr(0b1110101) + '\164' + chr(0b1100110) + chr(0b100010 + 0o13) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def sXlBzcYRrl2U(MRGa81KE7QCh) -> qRxF7OQ0y39T[M8_cKLkHVB2V]: VHn4CV4Ymrei = [] X8X97R2Y3D63 = ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1101111) + '\060', ord("\x08")) for CPdEsc5O1sf7 in MRGa81KE7QCh: if xafqLlk3kkUe(SXOLrMavuUCe(b'\xaa'), chr(4428 - 4328) + '\145' + '\x63' + '\157' + '\x64' + chr(101))('\165' + chr(116) + '\146' + chr(45) + chr(56)) in CPdEsc5O1sf7: (K1Ha0XjJTAE7, VNGQdHSFPrso) = CPdEsc5O1sf7.split(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd1'), chr(100) + chr(0b101000 + 0o75) + chr(0b1100011) + chr(0b110010 + 0o75) + '\x64' + '\145')(chr(117) + chr(13038 - 12922) + chr(0b1100110) + chr(0b101101) + chr(0b11111 + 0o31))) if X8X97R2Y3D63: K1Ha0XjJTAE7 = xafqLlk3kkUe(SXOLrMavuUCe(b'\xb5'), chr(100) + '\145' + '\143' + chr(7593 - 7482) + chr(4262 - 4162) + chr(0b1100101 + 0o0))(chr(0b1110101) + chr(3988 - 3872) + '\146' + chr(423 - 378) + '\x38') xafqLlk3kkUe(VHn4CV4Ymrei, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\x9e\x19\x1c-\xc4'), '\144' + '\145' + '\x63' + chr(7835 - 7724) + '\144' + chr(101))(chr(0b10101 + 0o140) + chr(4629 - 4513) + '\146' + '\055' + chr(0b111000)))(f'{K1Ha0XjJTAE7}-V') X8X97R2Y3D63 = ehT0Px3KOsy9('\060' + '\x6f' + chr(329 - 280), 0b1000) else: xafqLlk3kkUe(VHn4CV4Ymrei, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\x9e\x19\x1c-\xc4'), '\x64' + chr(0b1100101) + chr(0b1100011) + chr(111) + chr(100) + chr(9020 - 8919))(chr(117) + chr(6818 - 6702) + chr(0b110 + 0o140) + '\x2d' + chr(0b101000 + 0o20)))(CPdEsc5O1sf7) X8X97R2Y3D63 = ehT0Px3KOsy9('\x30' + chr(6957 - 6846) + chr(48), 8) return VHn4CV4Ymrei
allenai/allennlp
allennlp/predictors/open_information_extraction.py
make_oie_string
def make_oie_string(tokens: List[Token], tags: List[str]) -> str: """ Converts a list of model outputs (i.e., a list of lists of bio tags, each pertaining to a single word), returns an inline bracket representation of the prediction. """ frame = [] chunk = [] words = [token.text for token in tokens] for (token, tag) in zip(words, tags): if tag.startswith("I-"): chunk.append(token) else: if chunk: frame.append("[" + " ".join(chunk) + "]") chunk = [] if tag.startswith("B-"): chunk.append(tag[2:] + ": " + token) elif tag == "O": frame.append(token) if chunk: frame.append("[" + " ".join(chunk) + "]") return " ".join(frame)
python
def make_oie_string(tokens: List[Token], tags: List[str]) -> str: """ Converts a list of model outputs (i.e., a list of lists of bio tags, each pertaining to a single word), returns an inline bracket representation of the prediction. """ frame = [] chunk = [] words = [token.text for token in tokens] for (token, tag) in zip(words, tags): if tag.startswith("I-"): chunk.append(token) else: if chunk: frame.append("[" + " ".join(chunk) + "]") chunk = [] if tag.startswith("B-"): chunk.append(tag[2:] + ": " + token) elif tag == "O": frame.append(token) if chunk: frame.append("[" + " ".join(chunk) + "]") return " ".join(frame)
[ "def", "make_oie_string", "(", "tokens", ":", "List", "[", "Token", "]", ",", "tags", ":", "List", "[", "str", "]", ")", "->", "str", ":", "frame", "=", "[", "]", "chunk", "=", "[", "]", "words", "=", "[", "token", ".", "text", "for", "token", "in", "tokens", "]", "for", "(", "token", ",", "tag", ")", "in", "zip", "(", "words", ",", "tags", ")", ":", "if", "tag", ".", "startswith", "(", "\"I-\"", ")", ":", "chunk", ".", "append", "(", "token", ")", "else", ":", "if", "chunk", ":", "frame", ".", "append", "(", "\"[\"", "+", "\" \"", ".", "join", "(", "chunk", ")", "+", "\"]\"", ")", "chunk", "=", "[", "]", "if", "tag", ".", "startswith", "(", "\"B-\"", ")", ":", "chunk", ".", "append", "(", "tag", "[", "2", ":", "]", "+", "\": \"", "+", "token", ")", "elif", "tag", "==", "\"O\"", ":", "frame", ".", "append", "(", "token", ")", "if", "chunk", ":", "frame", ".", "append", "(", "\"[\"", "+", "\" \"", ".", "join", "(", "chunk", ")", "+", "\"]\"", ")", "return", "\" \"", ".", "join", "(", "frame", ")" ]
Converts a list of model outputs (i.e., a list of lists of bio tags, each pertaining to a single word), returns an inline bracket representation of the prediction.
[ "Converts", "a", "list", "of", "model", "outputs", "(", "i", ".", "e", ".", "a", "list", "of", "lists", "of", "bio", "tags", "each", "pertaining", "to", "a", "single", "word", ")", "returns", "an", "inline", "bracket", "representation", "of", "the", "prediction", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/predictors/open_information_extraction.py#L35-L61
train
Converts a list of model outputs into an inline bracket representation of the prediction.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7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,iDQ_gSK8V7h0,Rurm1zTRfSmY,reqGiMiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(111) + chr(1154 - 1104) + chr(52) + '\061', 45472 - 45464), ehT0Px3KOsy9('\x30' + chr(3608 - 3497) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101001 + 0o6) + chr(0b110011) + '\x33' + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(0b1010010 + 0o35) + chr(0b10101 + 0o34) + '\062' + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + chr(1140 - 1029) + chr(2248 - 2199) + chr(0b110100), 15802 - 15794), ehT0Px3KOsy9(chr(0b110000) + chr(0b111100 + 0o63) + '\x33' + chr(0b110000) + chr(54), 6398 - 6390), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(0b110100) + '\062', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001101 + 0o42) + '\062' + chr(0b10010 + 0o44) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(11026 - 10915) + chr(1116 - 1065) + '\x33' + '\066', 8), ehT0Px3KOsy9('\x30' + '\157' + '\066' + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(48) + chr(9989 - 9878) + chr(0b110100) + chr(0b11100 + 0o24), ord("\x08")), ehT0Px3KOsy9(chr(639 - 591) + '\x6f' + chr(0b110010) + '\067', 0o10), ehT0Px3KOsy9('\060' + chr(10979 - 10868) + chr(2315 - 2264) + chr(1737 - 1683) + chr(284 - 233), 17626 - 17618), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(0b1101111) + '\061' + '\x34' + chr(0b1101 + 0o47), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110000 + 0o1) + chr(0b100111 + 0o14) + '\x35', 58238 - 58230), ehT0Px3KOsy9(chr(0b110000) + chr(1427 - 1316) + chr(0b110001) + '\064' + '\x33', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b10 + 0o60) + '\066' + '\064', 0o10), ehT0Px3KOsy9('\060' + chr(4501 - 4390) + '\x33' + chr(0b0 + 0o61) + '\x35', 8679 - 8671), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1101111) + chr(51) + '\x32' + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110111) + chr(54), 0b1000), ehT0Px3KOsy9(chr(1726 - 1678) + '\x6f' + chr(0b110010) + '\064' + chr(0b101011 + 0o11), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + chr(0b110000) + '\061', 0o10), ehT0Px3KOsy9('\060' + chr(9803 - 9692) + chr(0b10010 + 0o37) + '\061' + '\x32', 5331 - 5323), ehT0Px3KOsy9('\060' + chr(0b110100 + 0o73) + chr(0b100101 + 0o20) + chr(0b1011 + 0o52), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1000000 + 0o57) + chr(0b110011 + 0o0) + chr(55) + chr(0b110000), 39125 - 39117), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\x6f' + chr(1711 - 1661) + '\060' + chr(0b110100), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1398 - 1348) + chr(1284 - 1231), 7194 - 7186), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b1101111) + chr(0b110011) + '\064' + chr(0b100111 + 0o20), 0b1000), ehT0Px3KOsy9(chr(0b110 + 0o52) + '\157' + '\061' + chr(0b100110 + 0o12) + '\064', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101001 + 0o6) + '\062' + chr(0b100100 + 0o17) + chr(2825 - 2771), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(5315 - 5204) + '\x34' + chr(55), 0o10), ehT0Px3KOsy9(chr(0b10010 + 0o36) + '\157' + '\062' + chr(996 - 941), 8), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(0b1101111) + '\063' + '\064' + chr(2463 - 2410), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\066' + '\062', 0b1000), ehT0Px3KOsy9(chr(1504 - 1456) + '\157' + chr(0b110011) + '\x33' + '\062', ord("\x08")), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1000101 + 0o52) + '\x35' + chr(395 - 342), 8), ehT0Px3KOsy9(chr(48) + chr(0b1011001 + 0o26) + chr(0b1100 + 0o46) + chr(0b100010 + 0o20) + chr(2103 - 2049), 55812 - 55804), ehT0Px3KOsy9('\x30' + '\x6f' + '\x37' + '\062', 53684 - 53676), ehT0Px3KOsy9('\060' + '\157' + chr(538 - 488) + chr(822 - 767) + chr(1102 - 1049), 45178 - 45170)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(111) + chr(0b1 + 0o64) + '\060', 10766 - 10758)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x8f'), '\x64' + chr(7800 - 7699) + chr(0b1011010 + 0o11) + chr(111) + chr(0b1100100) + chr(7359 - 7258))(chr(117) + chr(116) + chr(0b1100110) + chr(731 - 686) + chr(0b110101 + 0o3)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def KBSMnX64v2mC(Sz7tXxaCGqJ1, MRGa81KE7QCh) -> M8_cKLkHVB2V: C4IqNNmLfHXB = [] qrKMvKviNzHg = [] o34DiSJcu6N2 = [mTy3fac_AqJ5.Ah1rInvg48Hb for mTy3fac_AqJ5 in Sz7tXxaCGqJ1] for (mTy3fac_AqJ5, CPdEsc5O1sf7) in pZ0NK2y6HRbn(o34DiSJcu6N2, MRGa81KE7QCh): if xafqLlk3kkUe(CPdEsc5O1sf7, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd2u\xbf%x\xb5\x15\xd9\xaa]'), chr(100) + chr(101) + chr(0b111001 + 0o52) + chr(0b110110 + 0o71) + chr(100) + '\x65')('\x75' + '\x74' + '\146' + '\x2d' + chr(0b111000)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8,'), '\144' + chr(0b100 + 0o141) + '\x63' + chr(0b1101111) + chr(4086 - 3986) + chr(101))(chr(0b1110101) + '\164' + chr(0b101 + 0o141) + chr(45) + chr(56))): xafqLlk3kkUe(qrKMvKviNzHg, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0q\xae2b\xa2'), chr(100) + chr(2742 - 2641) + '\x63' + chr(111) + '\144' + chr(0b100010 + 0o103))(chr(117) + chr(1237 - 1121) + '\146' + chr(1646 - 1601) + '\x38'))(mTy3fac_AqJ5) else: if qrKMvKviNzHg: xafqLlk3kkUe(C4IqNNmLfHXB, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0q\xae2b\xa2'), chr(0b1100100) + chr(9956 - 9855) + '\x63' + chr(111) + '\144' + '\x65')(chr(0b1110101) + chr(6622 - 6506) + chr(0b1100110) + '\x2d' + chr(0b100100 + 0o24)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xfa'), chr(0b101100 + 0o70) + chr(2037 - 1936) + chr(99) + chr(111) + chr(100) + chr(101))('\x75' + chr(116) + chr(0b1100110) + chr(45) + '\x38') + xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\x81'), '\144' + chr(0b1100101) + chr(8983 - 8884) + '\157' + chr(0b1100100) + '\x65')(chr(9829 - 9712) + '\x74' + chr(102) + chr(0b110 + 0o47) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xfen\x89\x0fv\xb24\xfe\xb0DhQ'), '\144' + chr(0b1100101) + '\143' + chr(0b110011 + 0o74) + chr(100) + chr(0b1100101))('\165' + chr(5882 - 5766) + '\x66' + chr(45) + '\x38'))(qrKMvKviNzHg) + xafqLlk3kkUe(SXOLrMavuUCe(b'\xfc'), '\x64' + chr(0b100111 + 0o76) + chr(0b1000001 + 0o42) + chr(3935 - 3824) + chr(0b101100 + 0o70) + chr(101))(chr(0b1110101) + chr(116) + '\146' + '\055' + '\070')) qrKMvKviNzHg = [] if xafqLlk3kkUe(CPdEsc5O1sf7, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd2u\xbf%x\xb5\x15\xd9\xaa]'), chr(0b110000 + 0o64) + '\145' + chr(0b101000 + 0o73) + '\x6f' + chr(100) + chr(7366 - 7265))('\x75' + '\x74' + chr(0b1100110) + chr(554 - 509) + '\x38'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3,'), chr(0b1100100) + chr(0b1100101) + '\x63' + chr(1156 - 1045) + chr(0b1011110 + 0o6) + '\x65')('\x75' + chr(0b100100 + 0o120) + chr(0b1001001 + 0o35) + chr(0b101101) + chr(0b110110 + 0o2))): xafqLlk3kkUe(qrKMvKviNzHg, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0q\xae2b\xa2'), chr(0b10011 + 0o121) + chr(6372 - 6271) + '\143' + '\x6f' + '\x64' + chr(101))('\165' + '\x74' + chr(0b1100110) + chr(0b101101) + chr(56)))(CPdEsc5O1sf7[ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b11111 + 0o23), 0o10):] + xafqLlk3kkUe(SXOLrMavuUCe(b'\x9b!'), chr(0b1100001 + 0o3) + chr(0b1100101) + chr(99) + chr(0b1011111 + 0o20) + chr(100) + chr(0b1111 + 0o126))('\x75' + '\x74' + '\x66' + chr(45) + chr(56)) + mTy3fac_AqJ5) elif CPdEsc5O1sf7 == xafqLlk3kkUe(SXOLrMavuUCe(b'\xee'), chr(0b1010101 + 0o17) + chr(5619 - 5518) + '\143' + chr(111) + '\x64' + chr(101))('\x75' + chr(8938 - 8822) + chr(0b1100110) + chr(45) + chr(0b101001 + 0o17)): xafqLlk3kkUe(C4IqNNmLfHXB, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0q\xae2b\xa2'), '\x64' + '\145' + chr(0b1001100 + 0o27) + '\157' + chr(0b1100100) + '\145')(chr(10063 - 9946) + '\x74' + chr(102) + chr(0b100 + 0o51) + chr(56)))(mTy3fac_AqJ5) if qrKMvKviNzHg: xafqLlk3kkUe(C4IqNNmLfHXB, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0q\xae2b\xa2'), chr(100) + chr(101) + chr(0b1111 + 0o124) + '\157' + chr(0b10101 + 0o117) + chr(0b1011010 + 0o13))(chr(8670 - 8553) + chr(116) + chr(102) + '\055' + chr(0b111000)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xfa'), chr(0b110101 + 0o57) + chr(0b1011101 + 0o10) + chr(99) + '\157' + chr(100) + chr(0b1100101))(chr(0b1110101) + '\164' + '\x66' + chr(0b101101) + chr(56)) + xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\x81'), '\x64' + '\145' + chr(0b1100011) + chr(111) + '\x64' + chr(101))(chr(117) + '\x74' + chr(3020 - 2918) + '\x2d' + chr(2547 - 2491)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xfen\x89\x0fv\xb24\xfe\xb0DhQ'), '\144' + chr(3314 - 3213) + chr(0b1000 + 0o133) + chr(4427 - 4316) + chr(905 - 805) + '\x65')('\165' + chr(1280 - 1164) + chr(0b1100110) + chr(0b101001 + 0o4) + chr(0b111000)))(qrKMvKviNzHg) + xafqLlk3kkUe(SXOLrMavuUCe(b'\xfc'), '\x64' + chr(0b10000 + 0o125) + chr(99) + chr(111) + chr(100) + chr(0b1100101))('\x75' + chr(0b1110100) + chr(2830 - 2728) + chr(45) + chr(56))) return xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\x81'), chr(0b1100 + 0o130) + '\x65' + chr(99) + chr(0b1010010 + 0o35) + chr(100) + chr(0b110001 + 0o64))(chr(0b1110101) + chr(0b100110 + 0o116) + chr(0b1100110) + chr(1902 - 1857) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xfen\x89\x0fv\xb24\xfe\xb0DhQ'), '\144' + chr(9935 - 9834) + chr(0b110010 + 0o61) + chr(0b1101111) + '\x64' + chr(5804 - 5703))('\165' + chr(0b10101 + 0o137) + '\146' + chr(617 - 572) + chr(0b110100 + 0o4)))(C4IqNNmLfHXB)
allenai/allennlp
allennlp/predictors/open_information_extraction.py
get_predicate_indices
def get_predicate_indices(tags: List[str]) -> List[int]: """ Return the word indices of a predicate in BIO tags. """ return [ind for ind, tag in enumerate(tags) if 'V' in tag]
python
def get_predicate_indices(tags: List[str]) -> List[int]: """ Return the word indices of a predicate in BIO tags. """ return [ind for ind, tag in enumerate(tags) if 'V' in tag]
[ "def", "get_predicate_indices", "(", "tags", ":", "List", "[", "str", "]", ")", "->", "List", "[", "int", "]", ":", "return", "[", "ind", "for", "ind", ",", "tag", "in", "enumerate", "(", "tags", ")", "if", "'V'", "in", "tag", "]" ]
Return the word indices of a predicate in BIO tags.
[ "Return", "the", "word", "indices", "of", "a", "predicate", "in", "BIO", "tags", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/predictors/open_information_extraction.py#L63-L67
train
Return the word indices of a predicate in BIO tags.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,e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wwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(129 - 81) + chr(0b1101111) + chr(0b11011 + 0o26) + chr(488 - 438) + chr(51), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1100 + 0o143) + chr(0b10001 + 0o40) + chr(0b10001 + 0o37) + chr(0b110001 + 0o6), 9004 - 8996), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(111) + '\x33' + chr(0b100101 + 0o14) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(2261 - 2210) + chr(49) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b101101 + 0o3) + '\x6f' + chr(687 - 638) + chr(52) + '\x32', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b1000 + 0o52) + chr(0b110000) + chr(86 - 36), 28791 - 28783), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(111) + chr(50) + '\x36' + '\x37', 0o10), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(0b1101111) + chr(0b101110 + 0o4) + '\x34' + chr(51), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1100101 + 0o12) + chr(0b10110 + 0o34) + chr(49) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(325 - 277) + chr(0b100010 + 0o115) + '\x33' + chr(0b11100 + 0o26) + chr(0b101000 + 0o15), 0o10), ehT0Px3KOsy9(chr(1445 - 1397) + chr(0b1101111) + chr(0b110001) + chr(1994 - 1945) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(5858 - 5747) + chr(0b110011) + '\060' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(111) + chr(2354 - 2303) + '\x34' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b101111 + 0o100) + chr(1223 - 1173) + chr(0b110001) + chr(2338 - 2288), 8), ehT0Px3KOsy9(chr(48) + chr(0b100000 + 0o117) + chr(54) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(10552 - 10441) + chr(1935 - 1885) + '\x30' + '\066', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + '\x34' + '\064', 0b1000), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(0b1101111) + chr(1222 - 1173) + chr(0b110011) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + chr(2678 - 2625) + '\x32', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + '\065' + chr(0b110011), 27926 - 27918), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\157' + chr(51) + chr(849 - 796) + '\067', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b110011) + chr(1081 - 1033) + chr(1432 - 1382), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(53), 0o10), ehT0Px3KOsy9('\060' + '\157' + '\061' + chr(53) + '\x32', 21003 - 20995), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101111 + 0o4) + chr(1224 - 1174), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\061' + chr(702 - 653), 0o10), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101111) + chr(53) + chr(0b101010 + 0o14), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b100111 + 0o14) + '\x33' + '\065', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011000 + 0o27) + chr(0b1001 + 0o51) + chr(51) + chr(0b11100 + 0o27), 8067 - 8059), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(869 - 819) + chr(55) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\x6f' + '\x32' + '\062' + '\x36', 57416 - 57408), ehT0Px3KOsy9(chr(48) + chr(111) + chr(51) + chr(0b110001) + chr(1999 - 1951), 0b1000), ehT0Px3KOsy9(chr(1790 - 1742) + chr(111) + chr(51) + '\x32' + '\x35', 8), ehT0Px3KOsy9(chr(48) + chr(0b110001 + 0o76) + chr(50) + chr(1510 - 1458) + chr(0b10001 + 0o45), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + '\x37' + chr(0b100001 + 0o24), 0b1000), ehT0Px3KOsy9(chr(979 - 931) + chr(0b110110 + 0o71) + chr(0b110011) + chr(0b10001 + 0o43) + '\x35', 8), ehT0Px3KOsy9(chr(1056 - 1008) + chr(0b1010011 + 0o34) + chr(0b100001 + 0o20) + '\062' + chr(0b100000 + 0o20), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110011) + chr(0b0 + 0o66) + chr(1773 - 1724), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b11011 + 0o27) + chr(0b101111 + 0o10), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(50) + chr(0b1110 + 0o50) + '\x31', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(684 - 631) + chr(0b11 + 0o55), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'}'), chr(0b1100100) + chr(0b1110 + 0o127) + chr(99) + '\x6f' + chr(100) + '\145')(chr(0b1011010 + 0o33) + chr(4318 - 4202) + chr(0b1011100 + 0o12) + chr(453 - 408) + chr(804 - 748)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def rBG1PL7nWkEi(MRGa81KE7QCh) -> qRxF7OQ0y39T[ehT0Px3KOsy9]: return [r3s_x88rHjuC for (r3s_x88rHjuC, CPdEsc5O1sf7) in YlkZvXL8qwsX(MRGa81KE7QCh) if xafqLlk3kkUe(SXOLrMavuUCe(b'\x05'), '\144' + '\x65' + '\143' + chr(111) + chr(0b110101 + 0o57) + chr(0b1100101))(chr(0b110101 + 0o100) + chr(0b1001100 + 0o50) + chr(102) + chr(360 - 315) + '\x38') in CPdEsc5O1sf7]
allenai/allennlp
allennlp/predictors/open_information_extraction.py
get_predicate_text
def get_predicate_text(sent_tokens: List[Token], tags: List[str]) -> str: """ Get the predicate in this prediction. """ return " ".join([sent_tokens[pred_id].text for pred_id in get_predicate_indices(tags)])
python
def get_predicate_text(sent_tokens: List[Token], tags: List[str]) -> str: """ Get the predicate in this prediction. """ return " ".join([sent_tokens[pred_id].text for pred_id in get_predicate_indices(tags)])
[ "def", "get_predicate_text", "(", "sent_tokens", ":", "List", "[", "Token", "]", ",", "tags", ":", "List", "[", "str", "]", ")", "->", "str", ":", "return", "\" \"", ".", "join", "(", "[", "sent_tokens", "[", "pred_id", "]", ".", "text", "for", "pred_id", "in", "get_predicate_indices", "(", "tags", ")", "]", ")" ]
Get the predicate in this prediction.
[ "Get", "the", "predicate", "in", "this", "prediction", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/predictors/open_information_extraction.py#L69-L74
train
Get the predicate in this prediction.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59w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AbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + '\060' + '\x36', 0o10), ehT0Px3KOsy9('\060' + '\157' + '\062' + chr(48) + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(0b101001 + 0o106) + '\x37' + '\067', 61508 - 61500), ehT0Px3KOsy9('\060' + chr(0b1000011 + 0o54) + '\062' + chr(0b101011 + 0o5) + chr(0b0 + 0o65), 15936 - 15928), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110110) + chr(972 - 919), 40564 - 40556), ehT0Px3KOsy9(chr(1966 - 1918) + chr(0b101110 + 0o101) + chr(51) + chr(53) + '\067', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b11111 + 0o24) + '\061' + '\x34', 27763 - 27755), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(51) + '\x30', 22512 - 22504), ehT0Px3KOsy9(chr(48) + chr(0b1010000 + 0o37) + '\x31' + '\x35' + chr(0b1000 + 0o55), 0b1000), ehT0Px3KOsy9(chr(1322 - 1274) + chr(279 - 168) + chr(0b110001) + chr(0b110100) + chr(0b110000 + 0o4), 58665 - 58657), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110110) + '\067', 6574 - 6566), ehT0Px3KOsy9('\060' + '\157' + '\067' + '\x31', 48047 - 48039), ehT0Px3KOsy9('\060' + chr(2859 - 2748) + chr(1572 - 1518) + '\062', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(51), 0b1000), ehT0Px3KOsy9(chr(969 - 921) + '\x6f' + chr(0b100011 + 0o17) + chr(0b110101) + chr(48), 0o10), ehT0Px3KOsy9(chr(1979 - 1931) + '\x6f' + chr(0b110010) + '\064' + chr(877 - 828), ord("\x08")), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b1101111) + '\x32' + chr(2240 - 2188) + chr(0b11100 + 0o30), 0o10), ehT0Px3KOsy9('\060' + chr(0b101000 + 0o107) + chr(1223 - 1172) + chr(55) + '\x35', 0o10), ehT0Px3KOsy9(chr(1885 - 1837) + chr(0b11110 + 0o121) + chr(1075 - 1026) + chr(51) + '\x35', 6396 - 6388), ehT0Px3KOsy9('\060' + chr(0b0 + 0o157) + chr(51) + '\066' + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(8592 - 8481) + '\061' + chr(0b110010) + '\066', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1000000 + 0o57) + chr(49) + chr(52) + chr(862 - 812), 19298 - 19290), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(111) + chr(49) + chr(0b110001) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x31' + chr(1139 - 1090) + chr(55), 0b1000), ehT0Px3KOsy9('\x30' + chr(5437 - 5326) + chr(54) + chr(1905 - 1853), 0o10), ehT0Px3KOsy9('\060' + '\157' + '\x33' + chr(53) + '\x35', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + chr(0b110100) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(0b1011 + 0o45) + '\157' + chr(0b110001) + '\066' + '\062', 10880 - 10872), ehT0Px3KOsy9(chr(0b11100 + 0o24) + '\x6f' + '\062' + '\x35' + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b100 + 0o153) + '\061' + chr(0b110011) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(0b10000 + 0o41) + '\x32', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(0b100001 + 0o17) + chr(0b110110), 8), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + chr(0b10100 + 0o37) + '\064', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b1 + 0o61) + chr(0b11011 + 0o34) + '\060', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(48) + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b1010 + 0o54) + chr(55), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b101110 + 0o5) + '\x32' + '\060', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(2352 - 2241) + chr(0b110110) + chr(54), 0o10), ehT0Px3KOsy9('\x30' + chr(11927 - 11816) + chr(0b110010) + chr(0b110010) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + '\x31' + chr(51), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(2040 - 1992) + chr(5388 - 5277) + chr(1523 - 1470) + chr(0b110000), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa8'), chr(299 - 199) + chr(0b1100101) + '\x63' + chr(0b1101111) + chr(0b1011011 + 0o11) + chr(0b1100101))(chr(117) + '\164' + chr(7421 - 7319) + '\055' + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def dgaiaNLTAxcK(FuBSioIoPNEt, MRGa81KE7QCh) -> M8_cKLkHVB2V: return xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\xa6'), chr(0b1100100) + '\x65' + chr(0b1100011) + '\157' + '\144' + chr(0b1100101))(chr(117) + chr(116) + chr(6561 - 6459) + chr(45) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd9\xefh\xddO\x9b\x9aV\x03\x15\x7f\x7f'), chr(100) + '\x65' + '\143' + '\157' + chr(5229 - 5129) + '\145')('\165' + chr(7619 - 7503) + '\146' + chr(0b1000 + 0o45) + chr(0b111000)))([xafqLlk3kkUe(FuBSioIoPNEt[AlKVseSWX2_u], xafqLlk3kkUe(SXOLrMavuUCe(b'\xc7\xe8\x0e\xf7|\x81\xba\x7fY\\\x7f['), chr(0b1110 + 0o126) + chr(0b1100101) + chr(3510 - 3411) + chr(111) + chr(8667 - 8567) + '\145')('\165' + chr(0b1110100 + 0o0) + chr(102) + chr(0b101101) + '\x38')) for AlKVseSWX2_u in rBG1PL7nWkEi(MRGa81KE7QCh)])
allenai/allennlp
allennlp/predictors/open_information_extraction.py
predicates_overlap
def predicates_overlap(tags1: List[str], tags2: List[str]) -> bool: """ Tests whether the predicate in BIO tags1 overlap with those of tags2. """ # Get predicate word indices from both predictions pred_ind1 = get_predicate_indices(tags1) pred_ind2 = get_predicate_indices(tags2) # Return if pred_ind1 pred_ind2 overlap return any(set.intersection(set(pred_ind1), set(pred_ind2)))
python
def predicates_overlap(tags1: List[str], tags2: List[str]) -> bool: """ Tests whether the predicate in BIO tags1 overlap with those of tags2. """ # Get predicate word indices from both predictions pred_ind1 = get_predicate_indices(tags1) pred_ind2 = get_predicate_indices(tags2) # Return if pred_ind1 pred_ind2 overlap return any(set.intersection(set(pred_ind1), set(pred_ind2)))
[ "def", "predicates_overlap", "(", "tags1", ":", "List", "[", "str", "]", ",", "tags2", ":", "List", "[", "str", "]", ")", "->", "bool", ":", "# Get predicate word indices from both predictions", "pred_ind1", "=", "get_predicate_indices", "(", "tags1", ")", "pred_ind2", "=", "get_predicate_indices", "(", "tags2", ")", "# Return if pred_ind1 pred_ind2 overlap", "return", "any", "(", "set", ".", "intersection", "(", "set", "(", "pred_ind1", ")", ",", "set", "(", "pred_ind2", ")", ")", ")" ]
Tests whether the predicate in BIO tags1 overlap with those of tags2.
[ "Tests", "whether", "the", "predicate", "in", "BIO", "tags1", "overlap", "with", "those", "of", "tags2", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/predictors/open_information_extraction.py#L76-L86
train
Tests whether the predicate in BIO tags1 overlap with those of tags2.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzM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,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b100001 + 0o20) + chr(49), 0o10), ehT0Px3KOsy9('\060' + chr(12321 - 12210) + chr(55) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\x6f' + chr(281 - 232) + '\064' + '\062', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b0 + 0o62) + chr(52), 20146 - 20138), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\157' + '\x31' + '\x35' + chr(50), 0b1000), ehT0Px3KOsy9('\x30' + chr(10213 - 10102) + '\x31' + chr(53) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(2083 - 1972) + '\061' + '\x35' + '\064', ord("\x08")), ehT0Px3KOsy9(chr(1503 - 1455) + chr(111) + chr(0b10010 + 0o41) + chr(0b11011 + 0o26) + chr(0b110010), 4842 - 4834), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110010) + '\x32' + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b1110 + 0o141) + chr(49) + '\061' + chr(0b10011 + 0o40), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\065' + chr(0b11001 + 0o32), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(48), 0o10), ehT0Px3KOsy9(chr(0b100001 + 0o17) + '\157' + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + '\063' + chr(580 - 532), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(778 - 728) + chr(0b110101 + 0o0) + '\x35', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2120 - 2071) + chr(2684 - 2631), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b111001 + 0o66) + '\062' + chr(0b110001) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b101 + 0o53) + '\x6f' + chr(0b110010) + chr(1701 - 1651) + chr(0b110011), 8), ehT0Px3KOsy9(chr(83 - 35) + '\157' + '\x33' + chr(50) + chr(52), 17307 - 17299), ehT0Px3KOsy9('\060' + chr(0b1010110 + 0o31) + chr(0b101001 + 0o10) + '\067' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + chr(0b11001 + 0o31) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(1777 - 1729) + '\157' + chr(53) + chr(0b101111 + 0o5), 0o10), ehT0Px3KOsy9('\x30' + chr(3771 - 3660) + '\x31' + chr(51) + chr(0b100 + 0o61), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b111 + 0o52) + chr(1016 - 961), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x32' + '\065' + chr(0b1001 + 0o55), 0b1000), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(111) + chr(49) + '\060' + chr(0b110010), 44386 - 44378), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(54) + '\x35', 22307 - 22299), ehT0Px3KOsy9(chr(0b110000) + chr(0b100101 + 0o112) + chr(52) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(53), 63210 - 63202), ehT0Px3KOsy9(chr(1492 - 1444) + chr(8829 - 8718) + chr(0b11001 + 0o33) + chr(53), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + '\x33' + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + chr(0b110100), 11748 - 11740), ehT0Px3KOsy9(chr(48) + chr(5534 - 5423) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + chr(51) + '\x34' + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(911 - 863) + chr(0b100 + 0o153) + chr(52) + chr(52), 0o10), ehT0Px3KOsy9(chr(48) + chr(8221 - 8110) + chr(0b110001) + chr(0b101101 + 0o6) + chr(740 - 687), 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(219 - 168) + '\x31' + chr(0b11101 + 0o24), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b111 + 0o54) + chr(0b110 + 0o61) + chr(0b1110 + 0o50), 47398 - 47390), ehT0Px3KOsy9('\x30' + chr(111) + '\x36' + '\x36', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110101) + '\060', 3420 - 3412)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b"'"), '\x64' + '\145' + chr(0b1100011) + chr(9178 - 9067) + chr(2221 - 2121) + chr(0b1100101))(chr(0b101110 + 0o107) + '\x74' + '\146' + '\x2d' + chr(0b100010 + 0o26)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def CdfgOW0go97X(V7dB20ZqsvLz, bcPA4dqLTCpp) -> WbBjf8Y7v9VN: CCar1JcYLRpG = rBG1PL7nWkEi(V7dB20ZqsvLz) usIxmMcvW0S1 = rBG1PL7nWkEi(bcPA4dqLTCpp) return UVSi4XW7eBIM(xafqLlk3kkUe(MVEN8G6CxlvR, xafqLlk3kkUe(SXOLrMavuUCe(b'`Q\x16q\x18\x1a\t\xa9\xe7"Dn'), '\144' + chr(1125 - 1024) + chr(99) + '\x6f' + chr(1601 - 1501) + '\x65')('\165' + chr(0b0 + 0o164) + chr(102) + chr(47 - 2) + chr(0b111000)))(MVEN8G6CxlvR(CCar1JcYLRpG), MVEN8G6CxlvR(usIxmMcvW0S1)))
allenai/allennlp
allennlp/predictors/open_information_extraction.py
get_coherent_next_tag
def get_coherent_next_tag(prev_label: str, cur_label: str) -> str: """ Generate a coherent tag, given previous tag and current label. """ if cur_label == "O": # Don't need to add prefix to an "O" label return "O" if prev_label == cur_label: return f"I-{cur_label}" else: return f"B-{cur_label}"
python
def get_coherent_next_tag(prev_label: str, cur_label: str) -> str: """ Generate a coherent tag, given previous tag and current label. """ if cur_label == "O": # Don't need to add prefix to an "O" label return "O" if prev_label == cur_label: return f"I-{cur_label}" else: return f"B-{cur_label}"
[ "def", "get_coherent_next_tag", "(", "prev_label", ":", "str", ",", "cur_label", ":", "str", ")", "->", "str", ":", "if", "cur_label", "==", "\"O\"", ":", "# Don't need to add prefix to an \"O\" label", "return", "\"O\"", "if", "prev_label", "==", "cur_label", ":", "return", "f\"I-{cur_label}\"", "else", ":", "return", "f\"B-{cur_label}\"" ]
Generate a coherent tag, given previous tag and current label.
[ "Generate", "a", "coherent", "tag", "given", "previous", "tag", "and", "current", "label", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/predictors/open_information_extraction.py#L88-L99
train
Generate a coherent next tag given previous and current label.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,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N8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001) + '\x36' + chr(0b110010), 11067 - 11059), ehT0Px3KOsy9(chr(1061 - 1013) + chr(111) + chr(1294 - 1245) + chr(1694 - 1643) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1001 + 0o146) + '\x31' + chr(0b10 + 0o56) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b1000 + 0o52) + chr(48) + chr(0b101000 + 0o16), 6622 - 6614), ehT0Px3KOsy9(chr(1485 - 1437) + chr(10714 - 10603) + chr(0b110110) + '\x34', 1750 - 1742), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(50) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(111) + chr(51) + chr(0b100000 + 0o26), ord("\x08")), ehT0Px3KOsy9(chr(0b11111 + 0o21) + '\157' + chr(55) + chr(1388 - 1337), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1515 - 1465) + '\x31' + chr(48), 0o10), ehT0Px3KOsy9(chr(2141 - 2093) + chr(3375 - 3264) + chr(0b110011) + chr(224 - 174), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b111 + 0o53) + chr(55) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100110 + 0o11) + chr(51) + chr(0b110010) + chr(0b100100 + 0o14), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + '\061' + chr(0b1111 + 0o41), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(11717 - 11606) + chr(0b101101 + 0o5) + '\x32' + '\x36', 0o10), ehT0Px3KOsy9(chr(106 - 58) + '\157' + '\061' + chr(0b110000) + chr(54), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1010001 + 0o36) + chr(50) + chr(0b1100 + 0o53) + chr(0b11000 + 0o30), 0b1000), ehT0Px3KOsy9(chr(1839 - 1791) + '\157' + chr(175 - 120) + '\063', 8), ehT0Px3KOsy9(chr(2139 - 2091) + chr(111) + chr(0b110010) + chr(49), 49292 - 49284), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\065' + chr(0b110101), 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\064' + chr(89 - 38), 56039 - 56031), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110111) + chr(0b101011 + 0o6), 57287 - 57279), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(2382 - 2333) + '\066' + '\x30', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b10010 + 0o41) + '\067' + '\x37', 21513 - 21505), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(49) + '\060' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(8684 - 8573) + chr(0b110011) + chr(0b100010 + 0o25) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b110 + 0o151) + '\063' + chr(1087 - 1035) + chr(51), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(983 - 935) + chr(1496 - 1442), 8), ehT0Px3KOsy9(chr(1247 - 1199) + chr(0b1101111) + '\062' + chr(0b11100 + 0o31) + chr(0b110101), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + chr(1392 - 1342) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(0b10100 + 0o34) + '\157' + '\x31' + chr(0b100100 + 0o23) + '\x30', 0o10), ehT0Px3KOsy9('\060' + chr(4353 - 4242) + '\061' + chr(0b110001 + 0o1) + '\x37', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\062' + chr(0b1001 + 0o52) + chr(51), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(0b100001 + 0o24), 0b1000), ehT0Px3KOsy9(chr(620 - 572) + chr(5946 - 5835) + chr(0b1 + 0o65) + '\x35', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + chr(53) + '\x35', 0o10), ehT0Px3KOsy9(chr(1376 - 1328) + '\x6f' + chr(0b10100 + 0o35) + chr(0b10 + 0o63) + chr(0b110 + 0o61), 14019 - 14011), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + chr(0b100111 + 0o20) + chr(2284 - 2230), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\062' + chr(0b11000 + 0o33) + chr(2300 - 2247), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(52), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\157' + chr(53) + chr(378 - 330), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\\'), chr(0b1100100) + chr(101) + chr(99) + chr(111) + '\x64' + chr(0b1100101))(chr(117) + chr(0b111000 + 0o74) + chr(0b1100110) + chr(0b101101) + chr(0b1101 + 0o53)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def p98kFRG099nw(h6RmauJEiVZy, l3f81AwY8LPR) -> M8_cKLkHVB2V: if l3f81AwY8LPR == xafqLlk3kkUe(SXOLrMavuUCe(b'='), chr(0b1100100) + chr(0b1100101) + chr(99) + chr(0b1010 + 0o145) + chr(100) + '\x65')(chr(0b1010010 + 0o43) + chr(11301 - 11185) + '\146' + chr(0b10001 + 0o34) + chr(0b0 + 0o70)): return xafqLlk3kkUe(SXOLrMavuUCe(b'='), '\x64' + chr(0b1001001 + 0o34) + chr(0b1100011) + chr(0b1011 + 0o144) + chr(7569 - 7469) + chr(8380 - 8279))(chr(0b1110101) + chr(0b100110 + 0o116) + '\x66' + '\x2d' + chr(56)) if h6RmauJEiVZy == l3f81AwY8LPR: return f'I-{l3f81AwY8LPR}' else: return f'B-{l3f81AwY8LPR}'
allenai/allennlp
allennlp/predictors/open_information_extraction.py
merge_overlapping_predictions
def merge_overlapping_predictions(tags1: List[str], tags2: List[str]) -> List[str]: """ Merge two predictions into one. Assumes the predicate in tags1 overlap with the predicate of tags2. """ ret_sequence = [] prev_label = "O" # Build a coherent sequence out of two # spans which predicates' overlap for tag1, tag2 in zip(tags1, tags2): label1 = tag1.split("-")[-1] label2 = tag2.split("-")[-1] if (label1 == "V") or (label2 == "V"): # Construct maximal predicate length - # add predicate tag if any of the sequence predict it cur_label = "V" # Else - prefer an argument over 'O' label elif label1 != "O": cur_label = label1 else: cur_label = label2 # Append cur tag to the returned sequence cur_tag = get_coherent_next_tag(prev_label, cur_label) prev_label = cur_label ret_sequence.append(cur_tag) return ret_sequence
python
def merge_overlapping_predictions(tags1: List[str], tags2: List[str]) -> List[str]: """ Merge two predictions into one. Assumes the predicate in tags1 overlap with the predicate of tags2. """ ret_sequence = [] prev_label = "O" # Build a coherent sequence out of two # spans which predicates' overlap for tag1, tag2 in zip(tags1, tags2): label1 = tag1.split("-")[-1] label2 = tag2.split("-")[-1] if (label1 == "V") or (label2 == "V"): # Construct maximal predicate length - # add predicate tag if any of the sequence predict it cur_label = "V" # Else - prefer an argument over 'O' label elif label1 != "O": cur_label = label1 else: cur_label = label2 # Append cur tag to the returned sequence cur_tag = get_coherent_next_tag(prev_label, cur_label) prev_label = cur_label ret_sequence.append(cur_tag) return ret_sequence
[ "def", "merge_overlapping_predictions", "(", "tags1", ":", "List", "[", "str", "]", ",", "tags2", ":", "List", "[", "str", "]", ")", "->", "List", "[", "str", "]", ":", "ret_sequence", "=", "[", "]", "prev_label", "=", "\"O\"", "# Build a coherent sequence out of two", "# spans which predicates' overlap", "for", "tag1", ",", "tag2", "in", "zip", "(", "tags1", ",", "tags2", ")", ":", "label1", "=", "tag1", ".", "split", "(", "\"-\"", ")", "[", "-", "1", "]", "label2", "=", "tag2", ".", "split", "(", "\"-\"", ")", "[", "-", "1", "]", "if", "(", "label1", "==", "\"V\"", ")", "or", "(", "label2", "==", "\"V\"", ")", ":", "# Construct maximal predicate length -", "# add predicate tag if any of the sequence predict it", "cur_label", "=", "\"V\"", "# Else - prefer an argument over 'O' label", "elif", "label1", "!=", "\"O\"", ":", "cur_label", "=", "label1", "else", ":", "cur_label", "=", "label2", "# Append cur tag to the returned sequence", "cur_tag", "=", "get_coherent_next_tag", "(", "prev_label", ",", "cur_label", ")", "prev_label", "=", "cur_label", "ret_sequence", ".", "append", "(", "cur_tag", ")", "return", "ret_sequence" ]
Merge two predictions into one. Assumes the predicate in tags1 overlap with the predicate of tags2.
[ "Merge", "two", "predictions", "into", "one", ".", "Assumes", "the", "predicate", "in", "tags1", "overlap", "with", "the", "predicate", "of", "tags2", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/predictors/open_information_extraction.py#L101-L130
train
Merge two predictions into one. Assumes the predicate in tags1 overlap with tags2.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8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V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1888 - 1840) + '\157' + chr(989 - 940) + chr(224 - 172), 0b1000), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(381 - 270) + chr(50) + '\x33', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x31' + '\065' + chr(478 - 424), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + '\065' + chr(1101 - 1052), 0b1000), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(6595 - 6484) + chr(0b110001) + chr(0b10111 + 0o37) + '\061', 0o10), ehT0Px3KOsy9('\060' + chr(0b1010001 + 0o36) + chr(49) + chr(0b1010 + 0o50) + chr(825 - 776), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b101 + 0o152) + '\x32' + chr(50) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b100111 + 0o13) + '\x37' + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(242 - 188) + chr(0b11000 + 0o33), 0o10), ehT0Px3KOsy9('\060' + '\157' + '\x31' + chr(0b1001 + 0o50) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(1816 - 1768) + '\157' + chr(0b10110 + 0o33) + chr(0b110001), 3114 - 3106), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b111001 + 0o66) + '\062' + chr(55) + chr(1463 - 1412), 4935 - 4927), ehT0Px3KOsy9('\060' + chr(378 - 267) + chr(51) + '\x34' + chr(54), 26002 - 25994), ehT0Px3KOsy9(chr(1950 - 1902) + chr(0b1101111) + chr(50) + chr(0b100 + 0o55) + chr(49), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111 + 0o0) + chr(53) + chr(0b11011 + 0o25), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\x33' + chr(0b1100 + 0o51) + chr(0b10010 + 0o41), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b100011 + 0o17) + chr(0b110000) + chr(130 - 79), 29549 - 29541), ehT0Px3KOsy9('\x30' + '\157' + chr(0b10010 + 0o37) + chr(527 - 478) + chr(0b10101 + 0o41), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x31', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\061' + chr(0b110110) + chr(0b110101 + 0o0), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\062' + chr(0b110110) + '\x32', 30093 - 30085), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(111) + chr(0b10011 + 0o40) + chr(51) + chr(228 - 173), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(0b1100 + 0o44) + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(407 - 357) + chr(0b110111) + chr(0b110110), 8), ehT0Px3KOsy9('\060' + '\157' + chr(55) + '\x37', 0b1000), ehT0Px3KOsy9(chr(882 - 834) + chr(0b1101111) + chr(1867 - 1816) + chr(1511 - 1459) + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1633 - 1583) + chr(55) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b1 + 0o57) + '\157' + chr(0b110001) + chr(0b110010) + '\x35', 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(111) + chr(0b100000 + 0o22) + '\x36' + chr(327 - 275), ord("\x08")), ehT0Px3KOsy9(chr(0b1001 + 0o47) + '\x6f' + chr(1621 - 1571) + '\x31' + '\063', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b100001 + 0o116) + '\063' + chr(0b110000) + '\x33', 17697 - 17689), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1181 - 1131) + '\x30' + chr(730 - 675), 0o10), ehT0Px3KOsy9(chr(48) + chr(1089 - 978) + chr(0b110010) + chr(1001 - 951) + chr(2798 - 2745), 8), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + '\067' + '\x32', 51961 - 51953), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + chr(1008 - 956) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + chr(0b10 + 0o63) + chr(474 - 423), 8), ehT0Px3KOsy9(chr(752 - 704) + chr(111) + chr(0b110010) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(2112 - 2064) + chr(690 - 579) + '\x31' + '\x35' + '\x34', 0o10), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b1101111) + '\062' + chr(0b100001 + 0o21) + '\062', 0o10), ehT0Px3KOsy9(chr(210 - 162) + '\157' + '\061' + '\067' + chr(0b100 + 0o57), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(908 - 860) + chr(0b1101111) + '\x35' + '\060', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'"'), '\x64' + chr(101) + chr(0b1000011 + 0o40) + chr(10293 - 10182) + chr(3247 - 3147) + '\145')('\165' + chr(0b11000 + 0o134) + chr(102) + chr(0b101101) + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def HLsuNVh05I21(V7dB20ZqsvLz, bcPA4dqLTCpp) -> qRxF7OQ0y39T[M8_cKLkHVB2V]: ZuCqM0HVnVS_ = [] h6RmauJEiVZy = xafqLlk3kkUe(SXOLrMavuUCe(b'C'), chr(100) + chr(0b110010 + 0o63) + '\143' + chr(1077 - 966) + '\x64' + chr(0b111 + 0o136))(chr(0b100001 + 0o124) + chr(116) + '\x66' + chr(0b1111 + 0o36) + chr(56)) for (vN2bzMVhFyAH, wZOaDpHVrpCq) in pZ0NK2y6HRbn(V7dB20ZqsvLz, bcPA4dqLTCpp): uuZ9wskB1e44 = vN2bzMVhFyAH.split(xafqLlk3kkUe(SXOLrMavuUCe(b'!'), chr(0b1001111 + 0o25) + '\x65' + '\143' + chr(10157 - 10046) + '\144' + chr(0b100101 + 0o100))(chr(0b100 + 0o161) + chr(0b1000010 + 0o62) + chr(0b111 + 0o137) + '\055' + '\070'))[-ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b1010 + 0o47), 8)] YhwOdeKRvXtZ = wZOaDpHVrpCq.split(xafqLlk3kkUe(SXOLrMavuUCe(b'!'), '\144' + '\x65' + chr(99) + '\157' + '\x64' + chr(0b111100 + 0o51))(chr(0b1110101) + chr(0b1110100) + chr(5047 - 4945) + '\055' + chr(56)))[-ehT0Px3KOsy9('\x30' + '\x6f' + '\x31', 8)] if uuZ9wskB1e44 == xafqLlk3kkUe(SXOLrMavuUCe(b'Z'), chr(0b1 + 0o143) + '\145' + chr(4990 - 4891) + '\x6f' + chr(100) + '\145')('\165' + '\x74' + '\146' + chr(0b101101) + '\x38') or YhwOdeKRvXtZ == xafqLlk3kkUe(SXOLrMavuUCe(b'Z'), chr(100) + chr(0b1100101) + chr(0b1010100 + 0o17) + '\x6f' + '\144' + chr(101))(chr(0b1110101) + '\164' + chr(443 - 341) + '\055' + chr(2306 - 2250)): l3f81AwY8LPR = xafqLlk3kkUe(SXOLrMavuUCe(b'Z'), chr(100) + chr(0b1100101) + chr(0b1100011) + chr(0b1101111) + chr(6894 - 6794) + '\145')('\x75' + chr(10728 - 10612) + chr(0b1100001 + 0o5) + '\055' + chr(56)) elif uuZ9wskB1e44 != xafqLlk3kkUe(SXOLrMavuUCe(b'C'), '\144' + chr(101) + '\x63' + '\x6f' + '\144' + '\x65')(chr(117) + chr(0b1011110 + 0o26) + '\x66' + '\055' + chr(56)): l3f81AwY8LPR = uuZ9wskB1e44 else: l3f81AwY8LPR = YhwOdeKRvXtZ hANvTXdfFLBO = p98kFRG099nw(h6RmauJEiVZy, l3f81AwY8LPR) h6RmauJEiVZy = l3f81AwY8LPR xafqLlk3kkUe(ZuCqM0HVnVS_, xafqLlk3kkUe(SXOLrMavuUCe(b'mc\x1e\xcc\x1f5'), chr(8633 - 8533) + chr(7643 - 7542) + chr(3183 - 3084) + chr(0b101111 + 0o100) + chr(6898 - 6798) + chr(0b1100101))('\165' + chr(0b1110100) + chr(102) + chr(0b101101) + chr(0b111000)))(hANvTXdfFLBO) return ZuCqM0HVnVS_
allenai/allennlp
allennlp/predictors/open_information_extraction.py
consolidate_predictions
def consolidate_predictions(outputs: List[List[str]], sent_tokens: List[Token]) -> Dict[str, List[str]]: """ Identify that certain predicates are part of a multiword predicate (e.g., "decided to run") in which case, we don't need to return the embedded predicate ("run"). """ pred_dict: Dict[str, List[str]] = {} merged_outputs = [join_mwp(output) for output in outputs] predicate_texts = [get_predicate_text(sent_tokens, tags) for tags in merged_outputs] for pred1_text, tags1 in zip(predicate_texts, merged_outputs): # A flag indicating whether to add tags1 to predictions add_to_prediction = True # Check if this predicate overlaps another predicate for pred2_text, tags2 in pred_dict.items(): if predicates_overlap(tags1, tags2): # tags1 overlaps tags2 pred_dict[pred2_text] = merge_overlapping_predictions(tags1, tags2) add_to_prediction = False # This predicate doesn't overlap - add as a new predicate if add_to_prediction: pred_dict[pred1_text] = tags1 return pred_dict
python
def consolidate_predictions(outputs: List[List[str]], sent_tokens: List[Token]) -> Dict[str, List[str]]: """ Identify that certain predicates are part of a multiword predicate (e.g., "decided to run") in which case, we don't need to return the embedded predicate ("run"). """ pred_dict: Dict[str, List[str]] = {} merged_outputs = [join_mwp(output) for output in outputs] predicate_texts = [get_predicate_text(sent_tokens, tags) for tags in merged_outputs] for pred1_text, tags1 in zip(predicate_texts, merged_outputs): # A flag indicating whether to add tags1 to predictions add_to_prediction = True # Check if this predicate overlaps another predicate for pred2_text, tags2 in pred_dict.items(): if predicates_overlap(tags1, tags2): # tags1 overlaps tags2 pred_dict[pred2_text] = merge_overlapping_predictions(tags1, tags2) add_to_prediction = False # This predicate doesn't overlap - add as a new predicate if add_to_prediction: pred_dict[pred1_text] = tags1 return pred_dict
[ "def", "consolidate_predictions", "(", "outputs", ":", "List", "[", "List", "[", "str", "]", "]", ",", "sent_tokens", ":", "List", "[", "Token", "]", ")", "->", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", ":", "pred_dict", ":", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", "=", "{", "}", "merged_outputs", "=", "[", "join_mwp", "(", "output", ")", "for", "output", "in", "outputs", "]", "predicate_texts", "=", "[", "get_predicate_text", "(", "sent_tokens", ",", "tags", ")", "for", "tags", "in", "merged_outputs", "]", "for", "pred1_text", ",", "tags1", "in", "zip", "(", "predicate_texts", ",", "merged_outputs", ")", ":", "# A flag indicating whether to add tags1 to predictions", "add_to_prediction", "=", "True", "# Check if this predicate overlaps another predicate", "for", "pred2_text", ",", "tags2", "in", "pred_dict", ".", "items", "(", ")", ":", "if", "predicates_overlap", "(", "tags1", ",", "tags2", ")", ":", "# tags1 overlaps tags2", "pred_dict", "[", "pred2_text", "]", "=", "merge_overlapping_predictions", "(", "tags1", ",", "tags2", ")", "add_to_prediction", "=", "False", "# This predicate doesn't overlap - add as a new predicate", "if", "add_to_prediction", ":", "pred_dict", "[", "pred1_text", "]", "=", "tags1", "return", "pred_dict" ]
Identify that certain predicates are part of a multiword predicate (e.g., "decided to run") in which case, we don't need to return the embedded predicate ("run").
[ "Identify", "that", "certain", "predicates", "are", "part", "of", "a", "multiword", "predicate", "(", "e", ".", "g", ".", "decided", "to", "run", ")", "in", "which", "case", "we", "don", "t", "need", "to", "return", "the", "embedded", "predicate", "(", "run", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/predictors/open_information_extraction.py#L132-L158
train
Combine the prediction and predictions into one single - word predicate.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n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eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(111) + chr(0b110010 + 0o1) + chr(1990 - 1939) + chr(54), 59798 - 59790), ehT0Px3KOsy9('\060' + chr(11646 - 11535) + '\x33' + '\x31' + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(51) + chr(0b110011) + '\x32', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b111 + 0o150) + chr(0b10000 + 0o43) + chr(809 - 754), 8914 - 8906), ehT0Px3KOsy9('\060' + chr(680 - 569) + chr(0b100010 + 0o24) + chr(0b110110), 53437 - 53429), ehT0Px3KOsy9('\060' + chr(0b1011101 + 0o22) + '\x32' + chr(1916 - 1868), ord("\x08")), ehT0Px3KOsy9(chr(2028 - 1980) + chr(0b1101111) + chr(0b1 + 0o62) + '\x34' + chr(592 - 541), 0b1000), ehT0Px3KOsy9(chr(1639 - 1591) + chr(5537 - 5426) + chr(0b111 + 0o53) + chr(2081 - 2029) + '\x31', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(50) + chr(50) + '\x36', 29788 - 29780), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\157' + '\061' + chr(0b110001) + chr(0b100010 + 0o20), 16165 - 16157), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b100 + 0o56) + chr(0b110000 + 0o6) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(1830 - 1782) + chr(0b1101110 + 0o1) + chr(0b100111 + 0o13) + chr(0b10011 + 0o37) + chr(0b1010 + 0o46), 48437 - 48429), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(0b1101111) + chr(0b110011 + 0o0) + chr(0b110111) + chr(0b101111 + 0o10), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b110101 + 0o72) + '\x33' + chr(0b110001) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(375 - 325) + chr(49) + chr(0b100001 + 0o24), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b10 + 0o61) + chr(0b110011) + chr(0b11110 + 0o26), 28672 - 28664), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(0b10111 + 0o35) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b111011 + 0o64) + chr(292 - 241) + chr(0b11001 + 0o32) + chr(0b110101 + 0o0), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1010 + 0o47) + '\062' + chr(2775 - 2721), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b110001 + 0o76) + chr(49) + '\x37', 0o10), ehT0Px3KOsy9('\060' + chr(0b1001010 + 0o45) + chr(49) + '\x34' + chr(1111 - 1060), 57219 - 57211), ehT0Px3KOsy9(chr(48) + chr(0b11 + 0o154) + chr(0b101100 + 0o10) + chr(372 - 322), 0o10), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(111) + '\x32' + chr(0b101010 + 0o14) + chr(54), 0b1000), ehT0Px3KOsy9('\060' + chr(9949 - 9838) + chr(1643 - 1593) + chr(0b110001) + '\060', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(414 - 363) + '\067' + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001) + chr(2581 - 2529) + chr(170 - 117), ord("\x08")), ehT0Px3KOsy9(chr(1020 - 972) + chr(111) + chr(1913 - 1864) + chr(0b100111 + 0o16) + chr(0b11110 + 0o31), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(11005 - 10894) + '\x32' + '\065' + chr(2525 - 2473), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1100000 + 0o17) + chr(0b110001) + chr(53) + '\067', 8), ehT0Px3KOsy9('\060' + chr(111) + chr(1947 - 1897) + '\x30' + '\067', 0o10), ehT0Px3KOsy9(chr(1995 - 1947) + '\x6f' + chr(0b110001 + 0o1) + '\x30' + chr(544 - 492), 6442 - 6434), ehT0Px3KOsy9(chr(1886 - 1838) + '\x6f' + chr(0b11011 + 0o27) + chr(0b100000 + 0o20), 8), ehT0Px3KOsy9('\060' + chr(0b1000101 + 0o52) + '\061' + '\x33' + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110010) + chr(0b110010) + '\x31', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2421 - 2370) + chr(1169 - 1114) + chr(2173 - 2121), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(1115 - 1065) + chr(53) + chr(512 - 460), 8), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + chr(49) + chr(0b110100), 2858 - 2850), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b100 + 0o153) + '\063' + '\064' + '\060', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + '\x6f' + chr(53) + '\x30', 60303 - 60295)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf0'), chr(8431 - 8331) + '\145' + '\143' + chr(6219 - 6108) + chr(0b1100100) + chr(0b1100101))(chr(0b1101 + 0o150) + chr(0b1110100) + chr(3375 - 3273) + chr(2005 - 1960) + chr(1866 - 1810)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def AsQFbKYQ5pWt(Dx_DllZ8uCko, FuBSioIoPNEt) -> zBnV56fc6HrA[M8_cKLkHVB2V, qRxF7OQ0y39T[M8_cKLkHVB2V]]: mWnOtAkZJlXi = {} v5jllrzAna55 = [sXlBzcYRrl2U(e1jVqMSBZ01Y) for e1jVqMSBZ01Y in Dx_DllZ8uCko] _MFWiq956hE1 = [dgaiaNLTAxcK(FuBSioIoPNEt, MRGa81KE7QCh) for MRGa81KE7QCh in v5jllrzAna55] for (_1cIhPx0kSaq, V7dB20ZqsvLz) in pZ0NK2y6HRbn(_MFWiq956hE1, v5jllrzAna55): AmYip_l1478N = ehT0Px3KOsy9('\x30' + chr(111) + '\x31', 0o10) for (GiJxNcaqTUpT, bcPA4dqLTCpp) in xafqLlk3kkUe(mWnOtAkZJlXi, xafqLlk3kkUe(SXOLrMavuUCe(b'\x90\xb6\xacz\x7fJ\xd0\xe8\xfa\x19@\x8a'), chr(4741 - 4641) + chr(101) + '\x63' + '\x6f' + '\x64' + '\x65')('\x75' + chr(8819 - 8703) + chr(102) + '\x2d' + '\070'))(): if CdfgOW0go97X(V7dB20ZqsvLz, bcPA4dqLTCpp): mWnOtAkZJlXi[GiJxNcaqTUpT] = HLsuNVh05I21(V7dB20ZqsvLz, bcPA4dqLTCpp) AmYip_l1478N = ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b10010 + 0o36), 0o10) if AmYip_l1478N: mWnOtAkZJlXi[_1cIhPx0kSaq] = V7dB20ZqsvLz return mWnOtAkZJlXi
allenai/allennlp
allennlp/predictors/open_information_extraction.py
sanitize_label
def sanitize_label(label: str) -> str: """ Sanitize a BIO label - this deals with OIE labels sometimes having some noise, as parentheses. """ if "-" in label: prefix, suffix = label.split("-") suffix = suffix.split("(")[-1] return f"{prefix}-{suffix}" else: return label
python
def sanitize_label(label: str) -> str: """ Sanitize a BIO label - this deals with OIE labels sometimes having some noise, as parentheses. """ if "-" in label: prefix, suffix = label.split("-") suffix = suffix.split("(")[-1] return f"{prefix}-{suffix}" else: return label
[ "def", "sanitize_label", "(", "label", ":", "str", ")", "->", "str", ":", "if", "\"-\"", "in", "label", ":", "prefix", ",", "suffix", "=", "label", ".", "split", "(", "\"-\"", ")", "suffix", "=", "suffix", ".", "split", "(", "\"(\"", ")", "[", "-", "1", "]", "return", "f\"{prefix}-{suffix}\"", "else", ":", "return", "label" ]
Sanitize a BIO label - this deals with OIE labels sometimes having some noise, as parentheses.
[ "Sanitize", "a", "BIO", "label", "-", "this", "deals", "with", "OIE", "labels", "sometimes", "having", "some", "noise", "as", "parentheses", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/predictors/open_information_extraction.py#L161-L171
train
Sanitize a BIO label - this deals with OIE labels sometimes having some noise as parentheses.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZ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oAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b10111 + 0o33) + chr(1712 - 1660) + '\x32', 60311 - 60303), ehT0Px3KOsy9(chr(60 - 12) + '\x6f' + '\x32' + chr(0b110011) + chr(55), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\063' + chr(0b11111 + 0o26) + '\x35', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + '\063' + chr(1046 - 995), 0o10), ehT0Px3KOsy9('\060' + chr(0b1011110 + 0o21) + chr(0b110010) + chr(2094 - 2040) + '\x34', 51192 - 51184), ehT0Px3KOsy9(chr(0b10111 + 0o31) + '\x6f' + '\063' + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(676 - 625) + '\x36' + '\060', 0o10), ehT0Px3KOsy9('\x30' + chr(6809 - 6698) + '\063' + '\063' + '\065', 0o10), ehT0Px3KOsy9('\060' + '\157' + '\x31' + '\x30' + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(48) + chr(3183 - 3072) + '\x32' + chr(0b11111 + 0o21) + chr(1630 - 1578), 0o10), ehT0Px3KOsy9('\060' + chr(0b11011 + 0o124) + chr(1448 - 1398) + chr(1400 - 1349) + chr(0b100010 + 0o23), ord("\x08")), ehT0Px3KOsy9(chr(0b10110 + 0o32) + '\x6f' + chr(49) + chr(0b110100) + chr(49), 56604 - 56596), ehT0Px3KOsy9('\x30' + '\157' + '\067' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + '\x32', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + '\x32' + '\067', 0b1000), ehT0Px3KOsy9('\x30' + chr(11021 - 10910) + chr(55) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1011000 + 0o27) + chr(1636 - 1585) + chr(2974 - 2919) + chr(1493 - 1444), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + '\x35' + chr(1575 - 1524), 0b1000), ehT0Px3KOsy9(chr(1629 - 1581) + '\x6f' + chr(352 - 302) + chr(0b11100 + 0o26) + chr(0b10011 + 0o36), 2471 - 2463), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1485 - 1436) + chr(0b100110 + 0o16) + chr(284 - 231), 41574 - 41566), ehT0Px3KOsy9(chr(0b101010 + 0o6) + '\x6f' + chr(50) + '\064' + chr(0b110010), 8), ehT0Px3KOsy9(chr(1713 - 1665) + chr(11544 - 11433) + chr(51) + chr(0b110000) + chr(0b110011), 57903 - 57895), ehT0Px3KOsy9(chr(48) + chr(0b11 + 0o154) + chr(1766 - 1716) + chr(48) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(9350 - 9239) + chr(1144 - 1094) + chr(0b110010) + chr(0b110101), 25106 - 25098), ehT0Px3KOsy9('\x30' + '\157' + chr(0b11000 + 0o31) + chr(52) + '\x31', 8), ehT0Px3KOsy9('\x30' + chr(0b101011 + 0o104) + chr(0b11000 + 0o31) + chr(0b110011) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(973 - 862) + chr(1602 - 1551) + chr(0b110101), 0o10), ehT0Px3KOsy9('\060' + chr(0b101011 + 0o104) + chr(0b110101) + chr(1389 - 1334), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b11100 + 0o27) + '\x33' + chr(0b1100 + 0o52), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + chr(49) + chr(0b10110 + 0o34), 0o10), ehT0Px3KOsy9(chr(851 - 803) + chr(0b110111 + 0o70) + chr(51) + chr(0b110010) + chr(0b110101), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(53) + '\065', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b10001 + 0o40) + chr(49) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(1327 - 1279) + '\157' + chr(133 - 84) + chr(0b110010) + chr(560 - 509), 43990 - 43982), ehT0Px3KOsy9(chr(48) + chr(0b10001 + 0o136) + chr(50) + '\062' + '\x37', 8), ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\157' + '\062' + '\x30' + chr(1235 - 1187), ord("\x08")), ehT0Px3KOsy9(chr(230 - 182) + chr(0b101010 + 0o105) + chr(2230 - 2179) + chr(0b110011) + chr(0b100010 + 0o17), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + '\060' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110011) + chr(50) + chr(0b110000), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(11382 - 11271) + chr(53) + '\x30', 59124 - 59116)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x8c'), chr(0b100001 + 0o103) + chr(0b1100101) + '\143' + chr(111) + '\144' + chr(2056 - 1955))('\165' + chr(8825 - 8709) + '\146' + chr(45) + chr(0b11100 + 0o34)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def SK82YJ03ZZ0_(TRUOLFLuD08x) -> M8_cKLkHVB2V: if xafqLlk3kkUe(SXOLrMavuUCe(b'\x8f'), '\x64' + chr(101) + '\x63' + chr(0b1101111) + '\x64' + chr(0b1100101))(chr(8025 - 7908) + chr(0b1011111 + 0o25) + chr(0b1100000 + 0o6) + chr(0b101101) + '\x38') in TRUOLFLuD08x: (K1Ha0XjJTAE7, YhhkyMvxPIjH) = TRUOLFLuD08x.split(xafqLlk3kkUe(SXOLrMavuUCe(b'\x8f'), chr(100) + chr(0b111001 + 0o54) + '\x63' + '\x6f' + '\144' + '\145')(chr(117) + chr(116) + chr(9179 - 9077) + chr(45) + '\070')) YhhkyMvxPIjH = YhhkyMvxPIjH.split(xafqLlk3kkUe(SXOLrMavuUCe(b'\x8a'), chr(100) + chr(0b110110 + 0o57) + chr(0b1100011) + '\x6f' + chr(0b11000 + 0o114) + '\x65')('\165' + '\x74' + chr(0b11100 + 0o112) + chr(0b100001 + 0o14) + '\070'))[-ehT0Px3KOsy9(chr(924 - 876) + '\x6f' + chr(1693 - 1644), 0o10)] return f'{K1Ha0XjJTAE7}-{YhhkyMvxPIjH}' else: return TRUOLFLuD08x
allenai/allennlp
allennlp/modules/elmo.py
batch_to_ids
def batch_to_ids(batch: List[List[str]]) -> torch.Tensor: """ Converts a batch of tokenized sentences to a tensor representing the sentences with encoded characters (len(batch), max sentence length, max word length). Parameters ---------- batch : ``List[List[str]]``, required A list of tokenized sentences. Returns ------- A tensor of padded character ids. """ instances = [] indexer = ELMoTokenCharactersIndexer() for sentence in batch: tokens = [Token(token) for token in sentence] field = TextField(tokens, {'character_ids': indexer}) instance = Instance({"elmo": field}) instances.append(instance) dataset = Batch(instances) vocab = Vocabulary() dataset.index_instances(vocab) return dataset.as_tensor_dict()['elmo']['character_ids']
python
def batch_to_ids(batch: List[List[str]]) -> torch.Tensor: """ Converts a batch of tokenized sentences to a tensor representing the sentences with encoded characters (len(batch), max sentence length, max word length). Parameters ---------- batch : ``List[List[str]]``, required A list of tokenized sentences. Returns ------- A tensor of padded character ids. """ instances = [] indexer = ELMoTokenCharactersIndexer() for sentence in batch: tokens = [Token(token) for token in sentence] field = TextField(tokens, {'character_ids': indexer}) instance = Instance({"elmo": field}) instances.append(instance) dataset = Batch(instances) vocab = Vocabulary() dataset.index_instances(vocab) return dataset.as_tensor_dict()['elmo']['character_ids']
[ "def", "batch_to_ids", "(", "batch", ":", "List", "[", "List", "[", "str", "]", "]", ")", "->", "torch", ".", "Tensor", ":", "instances", "=", "[", "]", "indexer", "=", "ELMoTokenCharactersIndexer", "(", ")", "for", "sentence", "in", "batch", ":", "tokens", "=", "[", "Token", "(", "token", ")", "for", "token", "in", "sentence", "]", "field", "=", "TextField", "(", "tokens", ",", "{", "'character_ids'", ":", "indexer", "}", ")", "instance", "=", "Instance", "(", "{", "\"elmo\"", ":", "field", "}", ")", "instances", ".", "append", "(", "instance", ")", "dataset", "=", "Batch", "(", "instances", ")", "vocab", "=", "Vocabulary", "(", ")", "dataset", ".", "index_instances", "(", "vocab", ")", "return", "dataset", ".", "as_tensor_dict", "(", ")", "[", "'elmo'", "]", "[", "'character_ids'", "]" ]
Converts a batch of tokenized sentences to a tensor representing the sentences with encoded characters (len(batch), max sentence length, max word length). Parameters ---------- batch : ``List[List[str]]``, required A list of tokenized sentences. Returns ------- A tensor of padded character ids.
[ "Converts", "a", "batch", "of", "tokenized", "sentences", "to", "a", "tensor", "representing", "the", "sentences", "with", "encoded", "characters", "(", "len", "(", "batch", ")", "max", "sentence", "length", "max", "word", "length", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/elmo.py#L230-L256
train
Converts a batch of tokenized sentences to a tensor representing the sentences with encoded characters.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTxpD_zsEOh2,LgE_IO_tHXvM,Kk1hd194VKEC,OZYzwAe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HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b100111 + 0o20), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + chr(0b11 + 0o57), 32524 - 32516), ehT0Px3KOsy9('\060' + '\157' + chr(1252 - 1201) + chr(51), 10127 - 10119), ehT0Px3KOsy9('\x30' + chr(111) + '\062', 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + '\x31', 61697 - 61689), ehT0Px3KOsy9(chr(718 - 670) + chr(111) + '\062' + chr(1529 - 1481) + '\067', 8779 - 8771), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(148 - 97) + '\061' + chr(48), 47822 - 47814), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\065', 45284 - 45276), ehT0Px3KOsy9('\060' + chr(11484 - 11373) + '\x31' + chr(0b110111) + '\060', 62930 - 62922), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(111) + chr(0b101001 + 0o11) + chr(52) + chr(654 - 602), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(1703 - 1653) + chr(1657 - 1608), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + '\x35' + chr(53), 59382 - 59374), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11110 + 0o24) + chr(0b110110) + chr(1456 - 1407), 0b1000), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b1101111) + chr(0b110001) + chr(1357 - 1303) + chr(0b100001 + 0o26), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(8948 - 8837) + chr(0b100000 + 0o22) + '\x31' + chr(1556 - 1507), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(262 - 212) + chr(52) + '\x34', 8), ehT0Px3KOsy9('\060' + chr(0b11000 + 0o127) + '\063' + chr(1561 - 1513) + '\064', 34559 - 34551), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + chr(0b110001) + chr(0b101000 + 0o16), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100011 + 0o14) + chr(50) + chr(208 - 157) + chr(0b100011 + 0o16), 24982 - 24974), ehT0Px3KOsy9(chr(288 - 240) + chr(111) + chr(1018 - 968) + chr(0b1011 + 0o47) + chr(425 - 373), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(9751 - 9640) + chr(0b110010) + '\x35' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + chr(0b10010 + 0o37) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1110 + 0o141) + chr(979 - 929), 8), ehT0Px3KOsy9('\060' + chr(0b1000000 + 0o57) + '\x31' + chr(0b110001 + 0o3) + '\061', 0o10), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\x6f' + chr(1834 - 1779) + '\061', 0o10), ehT0Px3KOsy9(chr(0b1 + 0o57) + '\157' + chr(2216 - 2166) + chr(2022 - 1969) + chr(2648 - 2595), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110101) + '\060', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + chr(2239 - 2186) + '\066', 44511 - 44503), ehT0Px3KOsy9(chr(1181 - 1133) + chr(10601 - 10490) + chr(1681 - 1632) + '\063' + '\060', 0o10), ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(0b1101111) + chr(2395 - 2346) + chr(0b110110) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1795 - 1744) + chr(55) + chr(54), 50767 - 50759), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b10011 + 0o37) + chr(339 - 287) + chr(0b100110 + 0o21), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(824 - 773) + '\062' + chr(0b11 + 0o55), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b0 + 0o157) + chr(2163 - 2112) + chr(0b110110) + '\x30', 41706 - 41698), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + chr(0b110101) + chr(50), 0b1000), ehT0Px3KOsy9('\x30' + chr(8838 - 8727) + '\x33' + chr(0b110101) + '\x32', 37126 - 37118), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + chr(0b110011) + '\060', 23961 - 23953), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\x6f' + '\x31' + '\064' + chr(1404 - 1352), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(2653 - 2542) + chr(2011 - 1960) + '\x37', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b100010 + 0o21) + chr(49) + chr(0b110011), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(416 - 368) + '\x6f' + '\x35' + chr(48), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b')'), chr(3452 - 3352) + chr(101) + chr(99) + chr(0b1101111) + '\144' + '\145')('\165' + '\164' + chr(1317 - 1215) + chr(0b101000 + 0o5) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def KBB0yWyM0_TU(dNwAahu8tvoY) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'Swuq~\xf5'), chr(7210 - 7110) + chr(0b1100011 + 0o2) + chr(0b111000 + 0o53) + chr(0b1101111) + chr(0b1011000 + 0o14) + '\145')('\165' + chr(116) + '\146' + '\x2d' + chr(0b111000))): RGI3k8bAy4QR = [] BvJfssszZMhp = jKJwqw39g_f8() for pamQPTGoym5v in dNwAahu8tvoY: Sz7tXxaCGqJ1 = [umJ2jcr5NLY0(mTy3fac_AqJ5) for mTy3fac_AqJ5 in pamQPTGoym5v] fEcfxx4smAdS = OnNQjiI53xqc(Sz7tXxaCGqJ1, {xafqLlk3kkUe(SXOLrMavuUCe(b'dzzpp\xe4\xbc`\n\xfb\xb8\x89\xc2'), chr(3129 - 3029) + chr(10105 - 10004) + chr(99) + '\157' + chr(100) + chr(0b1100101))(chr(4020 - 3903) + '\x74' + '\146' + chr(0b101101) + chr(0b10 + 0o66)): BvJfssszZMhp}) SsX6bRqJdu1L = _jFYXBmhzM0H({xafqLlk3kkUe(SXOLrMavuUCe(b'b~vm'), '\x64' + chr(6117 - 6016) + '\143' + '\157' + chr(0b1100100) + chr(0b1100101))(chr(5460 - 5343) + '\x74' + chr(102) + chr(0b101101) + chr(56)): fEcfxx4smAdS}) xafqLlk3kkUe(RGI3k8bAy4QR, xafqLlk3kkUe(SXOLrMavuUCe(b'fbkg\x7f\xe3'), chr(107 - 7) + chr(101) + chr(0b11111 + 0o104) + chr(111) + '\x64' + chr(101))(chr(0b1110101) + '\164' + chr(7813 - 7711) + chr(1215 - 1170) + chr(0b101 + 0o63)))(SsX6bRqJdu1L) xQt6gV9VfTO3 = w98b4t9mEy7g(RGI3k8bAy4QR) mSU6gEqYPk2T = IAZQXc71OGTl() xafqLlk3kkUe(xQt6gV9VfTO3, xafqLlk3kkUe(SXOLrMavuUCe(b'n|\x7fgi\xd8\xa1k\x0b\xd0\xb0\x83\xd2\x12\xfa'), chr(100) + chr(0b1111 + 0o126) + chr(0b1100011) + chr(0b1000001 + 0o56) + chr(0b111011 + 0o51) + chr(101))('\165' + chr(0b1110100) + '\146' + chr(0b1110 + 0o37) + chr(276 - 220)))(mSU6gEqYPk2T) return xafqLlk3kkUe(xQt6gV9VfTO3, xafqLlk3kkUe(SXOLrMavuUCe(b'faDvt\xe9\xbbj\n\xfb\xb5\x84\xd2\x03'), chr(100) + '\145' + chr(0b101111 + 0o64) + chr(8518 - 8407) + chr(100) + chr(101))('\x75' + '\164' + chr(0b1100110) + '\x2d' + '\x38'))()[xafqLlk3kkUe(SXOLrMavuUCe(b'b~vm'), chr(0b110100 + 0o60) + chr(0b101000 + 0o75) + chr(0b1100011) + '\x6f' + chr(1390 - 1290) + chr(3823 - 3722))(chr(117) + '\x74' + chr(0b1011011 + 0o13) + chr(0b101101) + '\070')][xafqLlk3kkUe(SXOLrMavuUCe(b'dzzpp\xe4\xbc`\n\xfb\xb8\x89\xc2'), chr(0b101001 + 0o73) + chr(6683 - 6582) + '\143' + '\157' + chr(0b100011 + 0o101) + chr(101))('\165' + chr(116) + chr(102) + '\x2d' + chr(56))]
allenai/allennlp
allennlp/modules/elmo.py
Elmo.forward
def forward(self, # pylint: disable=arguments-differ inputs: torch.Tensor, word_inputs: torch.Tensor = None) -> Dict[str, Union[torch.Tensor, List[torch.Tensor]]]: """ Parameters ---------- inputs: ``torch.Tensor``, required. Shape ``(batch_size, timesteps, 50)`` of character ids representing the current batch. word_inputs : ``torch.Tensor``, required. If you passed a cached vocab, you can in addition pass a tensor of shape ``(batch_size, timesteps)``, which represent word ids which have been pre-cached. Returns ------- Dict with keys: ``'elmo_representations'``: ``List[torch.Tensor]`` A ``num_output_representations`` list of ELMo representations for the input sequence. Each representation is shape ``(batch_size, timesteps, embedding_dim)`` ``'mask'``: ``torch.Tensor`` Shape ``(batch_size, timesteps)`` long tensor with sequence mask. """ # reshape the input if needed original_shape = inputs.size() if len(original_shape) > 3: timesteps, num_characters = original_shape[-2:] reshaped_inputs = inputs.view(-1, timesteps, num_characters) else: reshaped_inputs = inputs if word_inputs is not None: original_word_size = word_inputs.size() if self._has_cached_vocab and len(original_word_size) > 2: reshaped_word_inputs = word_inputs.view(-1, original_word_size[-1]) elif not self._has_cached_vocab: logger.warning("Word inputs were passed to ELMo but it does not have a cached vocab.") reshaped_word_inputs = None else: reshaped_word_inputs = word_inputs else: reshaped_word_inputs = word_inputs # run the biLM bilm_output = self._elmo_lstm(reshaped_inputs, reshaped_word_inputs) layer_activations = bilm_output['activations'] mask_with_bos_eos = bilm_output['mask'] # compute the elmo representations representations = [] for i in range(len(self._scalar_mixes)): scalar_mix = getattr(self, 'scalar_mix_{}'.format(i)) representation_with_bos_eos = scalar_mix(layer_activations, mask_with_bos_eos) if self._keep_sentence_boundaries: processed_representation = representation_with_bos_eos processed_mask = mask_with_bos_eos else: representation_without_bos_eos, mask_without_bos_eos = remove_sentence_boundaries( representation_with_bos_eos, mask_with_bos_eos) processed_representation = representation_without_bos_eos processed_mask = mask_without_bos_eos representations.append(self._dropout(processed_representation)) # reshape if necessary if word_inputs is not None and len(original_word_size) > 2: mask = processed_mask.view(original_word_size) elmo_representations = [representation.view(original_word_size + (-1, )) for representation in representations] elif len(original_shape) > 3: mask = processed_mask.view(original_shape[:-1]) elmo_representations = [representation.view(original_shape[:-1] + (-1, )) for representation in representations] else: mask = processed_mask elmo_representations = representations return {'elmo_representations': elmo_representations, 'mask': mask}
python
def forward(self, # pylint: disable=arguments-differ inputs: torch.Tensor, word_inputs: torch.Tensor = None) -> Dict[str, Union[torch.Tensor, List[torch.Tensor]]]: """ Parameters ---------- inputs: ``torch.Tensor``, required. Shape ``(batch_size, timesteps, 50)`` of character ids representing the current batch. word_inputs : ``torch.Tensor``, required. If you passed a cached vocab, you can in addition pass a tensor of shape ``(batch_size, timesteps)``, which represent word ids which have been pre-cached. Returns ------- Dict with keys: ``'elmo_representations'``: ``List[torch.Tensor]`` A ``num_output_representations`` list of ELMo representations for the input sequence. Each representation is shape ``(batch_size, timesteps, embedding_dim)`` ``'mask'``: ``torch.Tensor`` Shape ``(batch_size, timesteps)`` long tensor with sequence mask. """ # reshape the input if needed original_shape = inputs.size() if len(original_shape) > 3: timesteps, num_characters = original_shape[-2:] reshaped_inputs = inputs.view(-1, timesteps, num_characters) else: reshaped_inputs = inputs if word_inputs is not None: original_word_size = word_inputs.size() if self._has_cached_vocab and len(original_word_size) > 2: reshaped_word_inputs = word_inputs.view(-1, original_word_size[-1]) elif not self._has_cached_vocab: logger.warning("Word inputs were passed to ELMo but it does not have a cached vocab.") reshaped_word_inputs = None else: reshaped_word_inputs = word_inputs else: reshaped_word_inputs = word_inputs # run the biLM bilm_output = self._elmo_lstm(reshaped_inputs, reshaped_word_inputs) layer_activations = bilm_output['activations'] mask_with_bos_eos = bilm_output['mask'] # compute the elmo representations representations = [] for i in range(len(self._scalar_mixes)): scalar_mix = getattr(self, 'scalar_mix_{}'.format(i)) representation_with_bos_eos = scalar_mix(layer_activations, mask_with_bos_eos) if self._keep_sentence_boundaries: processed_representation = representation_with_bos_eos processed_mask = mask_with_bos_eos else: representation_without_bos_eos, mask_without_bos_eos = remove_sentence_boundaries( representation_with_bos_eos, mask_with_bos_eos) processed_representation = representation_without_bos_eos processed_mask = mask_without_bos_eos representations.append(self._dropout(processed_representation)) # reshape if necessary if word_inputs is not None and len(original_word_size) > 2: mask = processed_mask.view(original_word_size) elmo_representations = [representation.view(original_word_size + (-1, )) for representation in representations] elif len(original_shape) > 3: mask = processed_mask.view(original_shape[:-1]) elmo_representations = [representation.view(original_shape[:-1] + (-1, )) for representation in representations] else: mask = processed_mask elmo_representations = representations return {'elmo_representations': elmo_representations, 'mask': mask}
[ "def", "forward", "(", "self", ",", "# pylint: disable=arguments-differ", "inputs", ":", "torch", ".", "Tensor", ",", "word_inputs", ":", "torch", ".", "Tensor", "=", "None", ")", "->", "Dict", "[", "str", ",", "Union", "[", "torch", ".", "Tensor", ",", "List", "[", "torch", ".", "Tensor", "]", "]", "]", ":", "# reshape the input if needed", "original_shape", "=", "inputs", ".", "size", "(", ")", "if", "len", "(", "original_shape", ")", ">", "3", ":", "timesteps", ",", "num_characters", "=", "original_shape", "[", "-", "2", ":", "]", "reshaped_inputs", "=", "inputs", ".", "view", "(", "-", "1", ",", "timesteps", ",", "num_characters", ")", "else", ":", "reshaped_inputs", "=", "inputs", "if", "word_inputs", "is", "not", "None", ":", "original_word_size", "=", "word_inputs", ".", "size", "(", ")", "if", "self", ".", "_has_cached_vocab", "and", "len", "(", "original_word_size", ")", ">", "2", ":", "reshaped_word_inputs", "=", "word_inputs", ".", "view", "(", "-", "1", ",", "original_word_size", "[", "-", "1", "]", ")", "elif", "not", "self", ".", "_has_cached_vocab", ":", "logger", ".", "warning", "(", "\"Word inputs were passed to ELMo but it does not have a cached vocab.\"", ")", "reshaped_word_inputs", "=", "None", "else", ":", "reshaped_word_inputs", "=", "word_inputs", "else", ":", "reshaped_word_inputs", "=", "word_inputs", "# run the biLM", "bilm_output", "=", "self", ".", "_elmo_lstm", "(", "reshaped_inputs", ",", "reshaped_word_inputs", ")", "layer_activations", "=", "bilm_output", "[", "'activations'", "]", "mask_with_bos_eos", "=", "bilm_output", "[", "'mask'", "]", "# compute the elmo representations", "representations", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_scalar_mixes", ")", ")", ":", "scalar_mix", "=", "getattr", "(", "self", ",", "'scalar_mix_{}'", ".", "format", "(", "i", ")", ")", "representation_with_bos_eos", "=", "scalar_mix", "(", "layer_activations", ",", "mask_with_bos_eos", ")", "if", "self", ".", "_keep_sentence_boundaries", ":", "processed_representation", "=", "representation_with_bos_eos", "processed_mask", "=", "mask_with_bos_eos", "else", ":", "representation_without_bos_eos", ",", "mask_without_bos_eos", "=", "remove_sentence_boundaries", "(", "representation_with_bos_eos", ",", "mask_with_bos_eos", ")", "processed_representation", "=", "representation_without_bos_eos", "processed_mask", "=", "mask_without_bos_eos", "representations", ".", "append", "(", "self", ".", "_dropout", "(", "processed_representation", ")", ")", "# reshape if necessary", "if", "word_inputs", "is", "not", "None", "and", "len", "(", "original_word_size", ")", ">", "2", ":", "mask", "=", "processed_mask", ".", "view", "(", "original_word_size", ")", "elmo_representations", "=", "[", "representation", ".", "view", "(", "original_word_size", "+", "(", "-", "1", ",", ")", ")", "for", "representation", "in", "representations", "]", "elif", "len", "(", "original_shape", ")", ">", "3", ":", "mask", "=", "processed_mask", ".", "view", "(", "original_shape", "[", ":", "-", "1", "]", ")", "elmo_representations", "=", "[", "representation", ".", "view", "(", "original_shape", "[", ":", "-", "1", "]", "+", "(", "-", "1", ",", ")", ")", "for", "representation", "in", "representations", "]", "else", ":", "mask", "=", "processed_mask", "elmo_representations", "=", "representations", "return", "{", "'elmo_representations'", ":", "elmo_representations", ",", "'mask'", ":", "mask", "}" ]
Parameters ---------- inputs: ``torch.Tensor``, required. Shape ``(batch_size, timesteps, 50)`` of character ids representing the current batch. word_inputs : ``torch.Tensor``, required. If you passed a cached vocab, you can in addition pass a tensor of shape ``(batch_size, timesteps)``, which represent word ids which have been pre-cached. Returns ------- Dict with keys: ``'elmo_representations'``: ``List[torch.Tensor]`` A ``num_output_representations`` list of ELMo representations for the input sequence. Each representation is shape ``(batch_size, timesteps, embedding_dim)`` ``'mask'``: ``torch.Tensor`` Shape ``(batch_size, timesteps)`` long tensor with sequence mask.
[ "Parameters", "----------", "inputs", ":", "torch", ".", "Tensor", "required", ".", "Shape", "(", "batch_size", "timesteps", "50", ")", "of", "character", "ids", "representing", "the", "current", "batch", ".", "word_inputs", ":", "torch", ".", "Tensor", "required", ".", "If", "you", "passed", "a", "cached", "vocab", "you", "can", "in", "addition", "pass", "a", "tensor", "of", "shape", "(", "batch_size", "timesteps", ")", "which", "represent", "word", "ids", "which", "have", "been", "pre", "-", "cached", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/elmo.py#L127-L201
train
Forward computation of the current batch of characters.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU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8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\x6f' + chr(1682 - 1632) + chr(48) + chr(0b10 + 0o57), 38991 - 38983), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1110 + 0o45) + '\x37' + '\063', 58599 - 58591), ehT0Px3KOsy9(chr(1352 - 1304) + chr(0b1101111) + chr(50) + '\x34' + chr(1669 - 1617), 24243 - 24235), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(54) + '\066', 33209 - 33201), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110011) + '\x33' + '\066', 0o10), ehT0Px3KOsy9(chr(792 - 744) + '\x6f' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(975 - 927) + chr(0b1101111) + chr(0b100001 + 0o22) + '\064' + '\060', ord("\x08")), ehT0Px3KOsy9(chr(1278 - 1230) + chr(0b1101111) + chr(0b11001 + 0o32) + chr(0b111 + 0o55) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(55) + '\x33', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(1364 - 1314) + chr(0b110001) + '\x32', ord("\x08")), ehT0Px3KOsy9('\060' + chr(1484 - 1373) + '\x32' + chr(0b10011 + 0o42) + '\061', 13639 - 13631), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(412 - 362) + chr(1312 - 1259), 2242 - 2234), ehT0Px3KOsy9(chr(48) + chr(0b1011001 + 0o26) + '\x31' + chr(0b10011 + 0o43) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b10011 + 0o36) + chr(1692 - 1643) + chr(1051 - 998), 0b1000), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b1010011 + 0o34) + chr(0b110011) + chr(1364 - 1315) + '\065', 17751 - 17743), ehT0Px3KOsy9('\060' + chr(10877 - 10766) + '\x32' + chr(793 - 744) + chr(2787 - 2732), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b101101 + 0o4) + chr(456 - 404) + '\063', 0o10), ehT0Px3KOsy9('\060' + chr(10106 - 9995) + chr(0b110001) + chr(0b11000 + 0o32) + '\066', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b10 + 0o155) + '\x31' + chr(899 - 851) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(0b11011 + 0o27), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x31' + chr(477 - 427) + chr(55), 0o10), ehT0Px3KOsy9('\060' + chr(3471 - 3360) + '\x32' + chr(0b110111) + chr(0b1000 + 0o57), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + chr(53) + chr(1522 - 1471), 50864 - 50856), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b11111 + 0o23) + chr(0b110001 + 0o1), 8), ehT0Px3KOsy9('\x30' + chr(0b11100 + 0o123) + '\061' + chr(0b110010) + chr(1726 - 1673), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b1110 + 0o43) + '\x30' + '\060', 0b1000), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b100111 + 0o110) + chr(0b110100) + '\x37', 35217 - 35209), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b11111 + 0o24) + chr(0b101100 + 0o10) + '\065', 19299 - 19291), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101111) + chr(0b11111 + 0o23) + chr(0b110100) + chr(1390 - 1335), 61565 - 61557), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + '\062' + '\061', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(1461 - 1410) + '\064' + chr(0b110001), 3330 - 3322), ehT0Px3KOsy9('\060' + '\157' + '\x31' + chr(0b1101 + 0o50) + chr(0b10001 + 0o37), 0b1000), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1011100 + 0o23) + '\x34' + chr(0b100100 + 0o23), 8), ehT0Px3KOsy9(chr(48) + chr(111) + chr(158 - 109) + chr(0b110100) + chr(54), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(51) + chr(52) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b101101 + 0o3) + '\157' + '\x31' + chr(0b110101) + chr(52), 6211 - 6203), ehT0Px3KOsy9('\x30' + chr(8130 - 8019) + chr(0b110001) + chr(138 - 87) + chr(54), 0o10), ehT0Px3KOsy9(chr(1106 - 1058) + chr(0b100010 + 0o115) + '\x33' + chr(0b101011 + 0o11) + chr(50), 8), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + chr(51) + chr(0b1101 + 0o52), 27191 - 27183), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b101011 + 0o7) + chr(0b110010) + '\062', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(7943 - 7832) + '\x35' + chr(0b10110 + 0o32), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xaf'), chr(0b1100100) + chr(0b1100101) + '\x63' + chr(0b1101111) + '\144' + '\x65')(chr(0b101111 + 0o106) + '\x74' + '\x66' + '\x2d' + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def GbbcCHUNFMj5(oVre8I6UXc3b, vXoupepMtCXU, Kk2hh9HVMmzs=None) -> zBnV56fc6HrA[M8_cKLkHVB2V, xS28O63k1eqo[xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd5\x9e\xca\x85\xb1r'), chr(4445 - 4345) + chr(0b100011 + 0o102) + '\x63' + chr(111) + chr(0b10011 + 0o121) + chr(101))(chr(3156 - 3039) + '\x74' + '\x66' + chr(0b101101) + chr(56))), qRxF7OQ0y39T[xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd5\x9e\xca\x85\xb1r'), chr(0b1100100) + chr(101) + chr(0b1010001 + 0o22) + chr(2959 - 2848) + chr(0b1001100 + 0o30) + chr(101))(chr(0b1110101) + '\x74' + chr(6852 - 6750) + '\055' + chr(0b111000)))]]]: uoX0EqIBJxTx = vXoupepMtCXU.NLcc3BCJnQka() if c2A0yzQpDQB3(uoX0EqIBJxTx) > ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + '\063', 0b1000): (QNvXCjnvcnON, v7MJqxUGrcMS) = uoX0EqIBJxTx[-ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32', ord("\x08")):] DcWigYJgx1QE = vXoupepMtCXU.view(-ehT0Px3KOsy9('\x30' + chr(0b10010 + 0o135) + chr(0b110001), 1664 - 1656), QNvXCjnvcnON, v7MJqxUGrcMS) else: DcWigYJgx1QE = vXoupepMtCXU if Kk2hh9HVMmzs is not None: QB8hq62bSlJn = Kk2hh9HVMmzs.NLcc3BCJnQka() if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xde\x93\xc5\x85\x81c\x81\x85\x13\xef\xcd\xca\x01"\xae\xee\x01'), chr(100) + '\x65' + chr(0b1100011) + '\x6f' + chr(0b1100100) + chr(3723 - 3622))(chr(0b1001110 + 0o47) + '\164' + '\146' + '\055' + '\x38')) and c2A0yzQpDQB3(QB8hq62bSlJn) > ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062', 8): tXjqSHCYFCPW = Kk2hh9HVMmzs.view(-ehT0Px3KOsy9('\060' + chr(0b10101 + 0o132) + chr(1696 - 1647), 8), QB8hq62bSlJn[-ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110001), 8)]) elif not xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xde\x93\xc5\x85\x81c\x81\x85\x13\xef\xcd\xca\x01"\xae\xee\x01'), chr(100) + '\x65' + chr(99) + '\x6f' + '\x64' + chr(0b1100101))('\x75' + '\x74' + chr(0b1100110) + '\x2d' + chr(0b111000))): xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf6\x9a\xd6\x98\xb7n\x87'), '\144' + '\145' + chr(99) + '\157' + chr(0b1010011 + 0o21) + chr(101))('\165' + '\164' + '\x66' + '\055' + chr(0b110000 + 0o10)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd6\x94\xd6\x92\xfei\x8e\x96\x0e\xfe\xda\xb5\x00(\xbf\xeaC&"a$\xda\xcf2!/\x07\xa0\xeb\xdc\x8eHE\x13\x96L7\x96\xbf\xf6\xee\x9e\xd7\xd6\xb0o\x94\xc6\x13\xeb\xdf\xf0W,\xed\xec\x025+w3\x9f\xdd}6!E\xcb'), '\144' + '\x65' + '\x63' + chr(8678 - 8567) + chr(381 - 281) + chr(101))(chr(117) + chr(116) + '\x66' + '\x2d' + '\070')) tXjqSHCYFCPW = None else: tXjqSHCYFCPW = Kk2hh9HVMmzs else: tXjqSHCYFCPW = Kk2hh9HVMmzs nxnHFrega4Jh = oVre8I6UXc3b._elmo_lstm(DcWigYJgx1QE, tXjqSHCYFCPW) pFsv81douvkT = nxnHFrega4Jh[xafqLlk3kkUe(SXOLrMavuUCe(b'\xe0\x98\xd0\x9f\xa8a\x94\x8f\x14\xe4\xda'), chr(8672 - 8572) + '\145' + chr(0b1100011) + chr(0b101100 + 0o103) + chr(100) + chr(0b1100101))(chr(117) + chr(6393 - 6277) + chr(0b1100110) + chr(0b10010 + 0o33) + chr(1299 - 1243))] dZLQ7q1PiDHZ = nxnHFrega4Jh[xafqLlk3kkUe(SXOLrMavuUCe(b'\xec\x9a\xd7\x9d'), chr(0b1100100) + '\145' + chr(476 - 377) + chr(111) + chr(0b11011 + 0o111) + '\145')(chr(117) + chr(116) + chr(102) + '\055' + '\070')] gokBpl471app = [] for WVxHKyX45z_L in vQr8gNKaIaWE(c2A0yzQpDQB3(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xde\x88\xc7\x97\xb2a\x92\xb9\x16\xe3\xd1\xf0\x04'), '\144' + chr(8170 - 8069) + '\x63' + chr(0b1101111) + chr(100) + chr(8018 - 7917))(chr(0b110101 + 0o100) + chr(0b1110100) + '\x66' + chr(0b101100 + 0o1) + '\070')))): caV4LhtXnEvw = xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf2\x98\xc5\x9a\xbfr\xbf\x8b\x12\xf2\xf6\xee\n'), chr(0b1001101 + 0o27) + '\x65' + '\x63' + chr(5663 - 5552) + '\x64' + chr(9561 - 9460))('\165' + '\164' + '\x66' + '\x2d' + chr(0b1101 + 0o53)).V4roHaS3Ppej(WVxHKyX45z_L)) vUGy_HQZkqkJ = caV4LhtXnEvw(pFsv81douvkT, dZLQ7q1PiDHZ) if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xde\x90\xc1\x93\xae_\x93\x83\x15\xfe\xcc\xfb\x14(\x92\xed\x0c#-v6\xcd\xc2w&'), chr(9584 - 9484) + chr(0b1100101) + '\x63' + '\x6f' + '\x64' + chr(0b1010100 + 0o21))(chr(0b1001010 + 0o53) + chr(116) + chr(7963 - 7861) + chr(0b101101) + chr(0b111000 + 0o0))): Z78caFvJhPsF = vUGy_HQZkqkJ w4HUjRpFKoEh = dZLQ7q1PiDHZ else: (jSH_VZHDO5Gp, g50z162N80_N) = ooqEa__WcZPK(vUGy_HQZkqkJ, dZLQ7q1PiDHZ) Z78caFvJhPsF = jSH_VZHDO5Gp w4HUjRpFKoEh = g50z162N80_N xafqLlk3kkUe(gokBpl471app, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe0\x8b\xd4\x93\xb0d'), chr(0b1100100) + chr(0b1001100 + 0o31) + chr(0b1010111 + 0o14) + chr(0b1101111) + chr(0b101010 + 0o72) + chr(0b1100101))(chr(0b1110101) + chr(0b10 + 0o162) + chr(0b1100110) + '\x2d' + '\x38'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xde\x9f\xd6\x99\xaeo\x95\x92'), '\144' + '\145' + chr(0b1100011) + '\157' + '\144' + chr(0b11110 + 0o107))(chr(117) + chr(0b1001101 + 0o47) + chr(0b1100110) + '\055' + chr(56)))(Z78caFvJhPsF)) if Kk2hh9HVMmzs is not None and c2A0yzQpDQB3(QB8hq62bSlJn) > ehT0Px3KOsy9(chr(190 - 142) + chr(111) + chr(1431 - 1381), 8): Iz1jSgUKZDvt = w4HUjRpFKoEh.view(QB8hq62bSlJn) brDMukkXhAPl = [aAjhQr3arCd2.view(QB8hq62bSlJn + (-ehT0Px3KOsy9('\060' + chr(0b1011 + 0o144) + '\x31', 8),)) for aAjhQr3arCd2 in gokBpl471app] elif c2A0yzQpDQB3(uoX0EqIBJxTx) > ehT0Px3KOsy9('\x30' + '\157' + '\x33', 8): Iz1jSgUKZDvt = w4HUjRpFKoEh.view(uoX0EqIBJxTx[:-ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b11011 + 0o26), 8)]) brDMukkXhAPl = [aAjhQr3arCd2.view(uoX0EqIBJxTx[:-ehT0Px3KOsy9(chr(1034 - 986) + chr(0b1101111) + chr(1168 - 1119), 8)] + (-ehT0Px3KOsy9(chr(48) + '\157' + '\061', 8),)) for aAjhQr3arCd2 in gokBpl471app] else: Iz1jSgUKZDvt = w4HUjRpFKoEh brDMukkXhAPl = gokBpl471app return {xafqLlk3kkUe(SXOLrMavuUCe(b'\xe4\x97\xc9\x99\x81r\x85\x96\t\xef\xda\xf0\x199\xac\xfb\n9-a'), chr(8952 - 8852) + chr(0b1100101) + chr(0b101001 + 0o72) + chr(1250 - 1139) + '\144' + chr(1282 - 1181))(chr(0b1110101) + chr(0b1100101 + 0o17) + chr(9702 - 9600) + chr(542 - 497) + chr(2892 - 2836)): brDMukkXhAPl, xafqLlk3kkUe(SXOLrMavuUCe(b'\xec\x9a\xd7\x9d'), chr(959 - 859) + chr(101) + '\143' + '\157' + '\x64' + chr(1862 - 1761))('\165' + chr(0b1110100) + chr(0b1100110) + chr(0b100100 + 0o11) + '\x38'): Iz1jSgUKZDvt}
allenai/allennlp
allennlp/modules/elmo.py
_ElmoCharacterEncoder.forward
def forward(self, inputs: torch.Tensor) -> Dict[str, torch.Tensor]: # pylint: disable=arguments-differ """ Compute context insensitive token embeddings for ELMo representations. Parameters ---------- inputs: ``torch.Tensor`` Shape ``(batch_size, sequence_length, 50)`` of character ids representing the current batch. Returns ------- Dict with keys: ``'token_embedding'``: ``torch.Tensor`` Shape ``(batch_size, sequence_length + 2, embedding_dim)`` tensor with context insensitive token representations. ``'mask'``: ``torch.Tensor`` Shape ``(batch_size, sequence_length + 2)`` long tensor with sequence mask. """ # Add BOS/EOS mask = ((inputs > 0).long().sum(dim=-1) > 0).long() character_ids_with_bos_eos, mask_with_bos_eos = add_sentence_boundary_token_ids( inputs, mask, self._beginning_of_sentence_characters, self._end_of_sentence_characters ) # the character id embedding max_chars_per_token = self._options['char_cnn']['max_characters_per_token'] # (batch_size * sequence_length, max_chars_per_token, embed_dim) character_embedding = torch.nn.functional.embedding( character_ids_with_bos_eos.view(-1, max_chars_per_token), self._char_embedding_weights ) # run convolutions cnn_options = self._options['char_cnn'] if cnn_options['activation'] == 'tanh': activation = torch.tanh elif cnn_options['activation'] == 'relu': activation = torch.nn.functional.relu else: raise ConfigurationError("Unknown activation") # (batch_size * sequence_length, embed_dim, max_chars_per_token) character_embedding = torch.transpose(character_embedding, 1, 2) convs = [] for i in range(len(self._convolutions)): conv = getattr(self, 'char_conv_{}'.format(i)) convolved = conv(character_embedding) # (batch_size * sequence_length, n_filters for this width) convolved, _ = torch.max(convolved, dim=-1) convolved = activation(convolved) convs.append(convolved) # (batch_size * sequence_length, n_filters) token_embedding = torch.cat(convs, dim=-1) # apply the highway layers (batch_size * sequence_length, n_filters) token_embedding = self._highways(token_embedding) # final projection (batch_size * sequence_length, embedding_dim) token_embedding = self._projection(token_embedding) # reshape to (batch_size, sequence_length, embedding_dim) batch_size, sequence_length, _ = character_ids_with_bos_eos.size() return { 'mask': mask_with_bos_eos, 'token_embedding': token_embedding.view(batch_size, sequence_length, -1) }
python
def forward(self, inputs: torch.Tensor) -> Dict[str, torch.Tensor]: # pylint: disable=arguments-differ """ Compute context insensitive token embeddings for ELMo representations. Parameters ---------- inputs: ``torch.Tensor`` Shape ``(batch_size, sequence_length, 50)`` of character ids representing the current batch. Returns ------- Dict with keys: ``'token_embedding'``: ``torch.Tensor`` Shape ``(batch_size, sequence_length + 2, embedding_dim)`` tensor with context insensitive token representations. ``'mask'``: ``torch.Tensor`` Shape ``(batch_size, sequence_length + 2)`` long tensor with sequence mask. """ # Add BOS/EOS mask = ((inputs > 0).long().sum(dim=-1) > 0).long() character_ids_with_bos_eos, mask_with_bos_eos = add_sentence_boundary_token_ids( inputs, mask, self._beginning_of_sentence_characters, self._end_of_sentence_characters ) # the character id embedding max_chars_per_token = self._options['char_cnn']['max_characters_per_token'] # (batch_size * sequence_length, max_chars_per_token, embed_dim) character_embedding = torch.nn.functional.embedding( character_ids_with_bos_eos.view(-1, max_chars_per_token), self._char_embedding_weights ) # run convolutions cnn_options = self._options['char_cnn'] if cnn_options['activation'] == 'tanh': activation = torch.tanh elif cnn_options['activation'] == 'relu': activation = torch.nn.functional.relu else: raise ConfigurationError("Unknown activation") # (batch_size * sequence_length, embed_dim, max_chars_per_token) character_embedding = torch.transpose(character_embedding, 1, 2) convs = [] for i in range(len(self._convolutions)): conv = getattr(self, 'char_conv_{}'.format(i)) convolved = conv(character_embedding) # (batch_size * sequence_length, n_filters for this width) convolved, _ = torch.max(convolved, dim=-1) convolved = activation(convolved) convs.append(convolved) # (batch_size * sequence_length, n_filters) token_embedding = torch.cat(convs, dim=-1) # apply the highway layers (batch_size * sequence_length, n_filters) token_embedding = self._highways(token_embedding) # final projection (batch_size * sequence_length, embedding_dim) token_embedding = self._projection(token_embedding) # reshape to (batch_size, sequence_length, embedding_dim) batch_size, sequence_length, _ = character_ids_with_bos_eos.size() return { 'mask': mask_with_bos_eos, 'token_embedding': token_embedding.view(batch_size, sequence_length, -1) }
[ "def", "forward", "(", "self", ",", "inputs", ":", "torch", ".", "Tensor", ")", "->", "Dict", "[", "str", ",", "torch", ".", "Tensor", "]", ":", "# pylint: disable=arguments-differ", "# Add BOS/EOS", "mask", "=", "(", "(", "inputs", ">", "0", ")", ".", "long", "(", ")", ".", "sum", "(", "dim", "=", "-", "1", ")", ">", "0", ")", ".", "long", "(", ")", "character_ids_with_bos_eos", ",", "mask_with_bos_eos", "=", "add_sentence_boundary_token_ids", "(", "inputs", ",", "mask", ",", "self", ".", "_beginning_of_sentence_characters", ",", "self", ".", "_end_of_sentence_characters", ")", "# the character id embedding", "max_chars_per_token", "=", "self", ".", "_options", "[", "'char_cnn'", "]", "[", "'max_characters_per_token'", "]", "# (batch_size * sequence_length, max_chars_per_token, embed_dim)", "character_embedding", "=", "torch", ".", "nn", ".", "functional", ".", "embedding", "(", "character_ids_with_bos_eos", ".", "view", "(", "-", "1", ",", "max_chars_per_token", ")", ",", "self", ".", "_char_embedding_weights", ")", "# run convolutions", "cnn_options", "=", "self", ".", "_options", "[", "'char_cnn'", "]", "if", "cnn_options", "[", "'activation'", "]", "==", "'tanh'", ":", "activation", "=", "torch", ".", "tanh", "elif", "cnn_options", "[", "'activation'", "]", "==", "'relu'", ":", "activation", "=", "torch", ".", "nn", ".", "functional", ".", "relu", "else", ":", "raise", "ConfigurationError", "(", "\"Unknown activation\"", ")", "# (batch_size * sequence_length, embed_dim, max_chars_per_token)", "character_embedding", "=", "torch", ".", "transpose", "(", "character_embedding", ",", "1", ",", "2", ")", "convs", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_convolutions", ")", ")", ":", "conv", "=", "getattr", "(", "self", ",", "'char_conv_{}'", ".", "format", "(", "i", ")", ")", "convolved", "=", "conv", "(", "character_embedding", ")", "# (batch_size * sequence_length, n_filters for this width)", "convolved", ",", "_", "=", "torch", ".", "max", "(", "convolved", ",", "dim", "=", "-", "1", ")", "convolved", "=", "activation", "(", "convolved", ")", "convs", ".", "append", "(", "convolved", ")", "# (batch_size * sequence_length, n_filters)", "token_embedding", "=", "torch", ".", "cat", "(", "convs", ",", "dim", "=", "-", "1", ")", "# apply the highway layers (batch_size * sequence_length, n_filters)", "token_embedding", "=", "self", ".", "_highways", "(", "token_embedding", ")", "# final projection (batch_size * sequence_length, embedding_dim)", "token_embedding", "=", "self", ".", "_projection", "(", "token_embedding", ")", "# reshape to (batch_size, sequence_length, embedding_dim)", "batch_size", ",", "sequence_length", ",", "_", "=", "character_ids_with_bos_eos", ".", "size", "(", ")", "return", "{", "'mask'", ":", "mask_with_bos_eos", ",", "'token_embedding'", ":", "token_embedding", ".", "view", "(", "batch_size", ",", "sequence_length", ",", "-", "1", ")", "}" ]
Compute context insensitive token embeddings for ELMo representations. Parameters ---------- inputs: ``torch.Tensor`` Shape ``(batch_size, sequence_length, 50)`` of character ids representing the current batch. Returns ------- Dict with keys: ``'token_embedding'``: ``torch.Tensor`` Shape ``(batch_size, sequence_length + 2, embedding_dim)`` tensor with context insensitive token representations. ``'mask'``: ``torch.Tensor`` Shape ``(batch_size, sequence_length + 2)`` long tensor with sequence mask.
[ "Compute", "context", "insensitive", "token", "embeddings", "for", "ELMo", "representations", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/elmo.py#L324-L395
train
Computes the forward pass of the context insensitive token embedding for the current batch of characters.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKo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aLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(111) + '\x33' + chr(53) + chr(0b100100 + 0o15), ord("\x08")), ehT0Px3KOsy9(chr(663 - 615) + '\x6f' + chr(2030 - 1977) + chr(0b110001), 42248 - 42240), ehT0Px3KOsy9(chr(1837 - 1789) + '\157' + chr(0b1000 + 0o52) + '\065' + chr(0b111 + 0o56), 44398 - 44390), ehT0Px3KOsy9(chr(1519 - 1471) + chr(111) + '\062' + chr(49) + chr(2456 - 2406), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(51) + chr(0b10 + 0o62) + '\x35', 0b1000), ehT0Px3KOsy9('\060' + chr(0b101 + 0o152) + chr(0b110110) + chr(0b100100 + 0o16), 0o10), ehT0Px3KOsy9(chr(936 - 888) + chr(0b1101111) + chr(1789 - 1740) + '\x34' + chr(2571 - 2517), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1126 - 1076) + chr(0b100 + 0o60) + chr(0b1111 + 0o47), 0o10), ehT0Px3KOsy9(chr(0b111 + 0o51) + '\x6f' + chr(0b10 + 0o60) + '\062' + chr(971 - 923), 37685 - 37677), ehT0Px3KOsy9(chr(0b110000) + chr(0b11101 + 0o122) + '\x37' + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x33' + chr(2401 - 2346), 0o10), ehT0Px3KOsy9(chr(48) + chr(6293 - 6182) + chr(50) + '\062' + chr(0b110000), 8), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\157' + '\x31' + chr(0b110110 + 0o1) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110001) + chr(50), 0b1000), ehT0Px3KOsy9(chr(296 - 248) + chr(111) + '\x33' + chr(0b110100) + '\066', 37352 - 37344), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b11100 + 0o27) + '\x33' + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(773 - 725) + chr(111) + chr(0b110010) + chr(0b101110 + 0o5) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(1950 - 1902) + chr(3347 - 3236) + chr(0b110110) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(2483 - 2372) + chr(0b10111 + 0o37) + chr(2172 - 2121), 36144 - 36136), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(8979 - 8868) + chr(0b10000 + 0o43) + chr(0b0 + 0o61) + chr(0b1011 + 0o51), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(595 - 545), 43635 - 43627), ehT0Px3KOsy9(chr(48) + chr(111) + chr(50) + chr(0b110010 + 0o0) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(417 - 367) + '\x35' + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(731 - 683) + chr(4949 - 4838) + chr(0b10100 + 0o35) + chr(1949 - 1901) + chr(55), 0b1000), ehT0Px3KOsy9('\060' + chr(11654 - 11543) + '\066' + chr(0b100100 + 0o15), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + '\062' + '\066', 0b1000), ehT0Px3KOsy9(chr(48) + chr(5954 - 5843) + '\x33' + chr(52) + '\063', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1001100 + 0o43) + chr(0b11100 + 0o25) + chr(0b10111 + 0o36) + '\064', 38399 - 38391), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + chr(48) + chr(0b100001 + 0o23), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + '\x35' + '\x36', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(52) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x36' + chr(0b100111 + 0o16), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + chr(2107 - 2052) + '\061', 1618 - 1610), ehT0Px3KOsy9(chr(1712 - 1664) + chr(111) + chr(0b10100 + 0o36) + chr(49) + chr(0b101010 + 0o6), ord("\x08")), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(0b1100110 + 0o11) + '\x31' + chr(0b110001) + chr(49), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\062' + '\x36' + chr(0b100100 + 0o20), 0b1000), ehT0Px3KOsy9(chr(48) + chr(10111 - 10000) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(2095 - 2047) + chr(0b1101111) + chr(0b110010) + chr(0b10110 + 0o37) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b1101111) + '\062' + '\x31' + chr(0b110010), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1792 - 1742) + chr(0b110011) + '\x30', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(675 - 627) + chr(111) + '\x35' + chr(0b11010 + 0o26), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc7'), '\x64' + '\x65' + chr(0b11111 + 0o104) + '\157' + chr(100) + '\x65')('\165' + '\x74' + chr(0b1100110) + chr(0b101101) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def GbbcCHUNFMj5(oVre8I6UXc3b, vXoupepMtCXU) -> zBnV56fc6HrA[M8_cKLkHVB2V, xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbdL\xc3\xf9\x8a@'), '\x64' + chr(2047 - 1946) + chr(2082 - 1983) + '\157' + '\x64' + '\145')(chr(0b1010000 + 0o45) + chr(0b1110100) + '\x66' + chr(654 - 609) + chr(56)))]: Iz1jSgUKZDvt = ((vXoupepMtCXU > ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101 + 0o53), 0o10)).long().sum(dim=-ehT0Px3KOsy9(chr(1296 - 1248) + chr(10937 - 10826) + chr(49), 8353 - 8345)) > ehT0Px3KOsy9('\x30' + chr(111) + '\x30', 8)).long() (nxz13KdxmJ5X, dZLQ7q1PiDHZ) = lgDVfzWIwOn1(vXoupepMtCXU, Iz1jSgUKZDvt, oVre8I6UXc3b._beginning_of_sentence_characters, oVre8I6UXc3b._end_of_sentence_characters) DwiUH_bmMer1 = oVre8I6UXc3b.snfyDsaD3Jzk[xafqLlk3kkUe(SXOLrMavuUCe(b'\x8aA\xcc\xf8\xbaQ\x08\xc8'), chr(5586 - 5486) + chr(0b1100101) + '\143' + chr(0b100010 + 0o115) + '\144' + chr(4495 - 4394))(chr(0b1110101) + chr(353 - 237) + chr(0b1001010 + 0o34) + chr(0b11010 + 0o23) + chr(2264 - 2208))][xafqLlk3kkUe(SXOLrMavuUCe(b'\x84H\xd5\xd5\x86Z\x07\xd4\xf1Xk\xf5\x0fy\xb9\xae\xfcEl\xb8m\xfc\xcb)'), '\144' + chr(101) + chr(99) + '\157' + chr(0b111001 + 0o53) + chr(101))(chr(0b1010010 + 0o43) + '\164' + '\x66' + chr(0b10011 + 0o32) + '\070')] acf3U3erPXbI = cEkFpYktkSeK.nn.functional.embedding(nxz13KdxmJ5X.view(-ehT0Px3KOsy9(chr(1051 - 1003) + chr(0b1101111) + '\x31', 8), DwiUH_bmMer1), oVre8I6UXc3b._char_embedding_weights) g0brDWZB58q5 = oVre8I6UXc3b.snfyDsaD3Jzk[xafqLlk3kkUe(SXOLrMavuUCe(b'\x8aA\xcc\xf8\xbaQ\x08\xc8'), chr(0b1101 + 0o127) + chr(0b1010010 + 0o23) + '\x63' + chr(11232 - 11121) + chr(100) + chr(4027 - 3926))('\165' + chr(0b1110100) + '\x66' + '\x2d' + chr(0b111000))] if g0brDWZB58q5[xafqLlk3kkUe(SXOLrMavuUCe(b'\x88J\xd9\xe3\x93S\x12\xcf\xffU'), chr(8014 - 7914) + '\145' + '\143' + chr(111) + '\x64' + chr(0b1100101))('\165' + '\164' + chr(0b1100110) + chr(0b100001 + 0o14) + '\070')] == xafqLlk3kkUe(SXOLrMavuUCe(b'\x9dH\xc3\xe2'), chr(7340 - 7240) + '\x65' + chr(0b1100011) + chr(0b1101111) + chr(0b110110 + 0o56) + chr(0b1000011 + 0o42))(chr(0b101001 + 0o114) + chr(0b1101110 + 0o6) + '\x66' + chr(931 - 886) + '\x38'): _GyOifGFZyk1 = cEkFpYktkSeK.tanh elif g0brDWZB58q5[xafqLlk3kkUe(SXOLrMavuUCe(b'\x88J\xd9\xe3\x93S\x12\xcf\xffU'), chr(0b1000101 + 0o37) + chr(0b110 + 0o137) + chr(0b11110 + 0o105) + chr(0b11 + 0o154) + '\144' + chr(5332 - 5231))(chr(117) + chr(116) + chr(102) + '\x2d' + chr(56))] == xafqLlk3kkUe(SXOLrMavuUCe(b'\x9bL\xc1\xff'), '\144' + '\145' + chr(0b100 + 0o137) + '\157' + chr(0b1011101 + 0o7) + '\x65')('\165' + '\164' + '\x66' + chr(0b101101) + chr(56)): _GyOifGFZyk1 = cEkFpYktkSeK.nn.functional.relu else: raise h0iXqtiKVeKg(xafqLlk3kkUe(SXOLrMavuUCe(b'\xbcG\xc6\xe4\x8aE\x08\x86\xf1Xk\xf9\x0bk\x92\xb7\xf6Y'), chr(0b1001001 + 0o33) + '\x65' + chr(0b1100011) + '\157' + '\144' + '\x65')(chr(0b101 + 0o160) + chr(3161 - 3045) + chr(0b1010001 + 0o25) + chr(0b101101) + chr(0b110 + 0o62))) acf3U3erPXbI = cEkFpYktkSeK.transpose(acf3U3erPXbI, ehT0Px3KOsy9(chr(655 - 607) + chr(0b1010100 + 0o33) + chr(0b110001), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062', 8)) Hq_IFE6OTSwu = [] for WVxHKyX45z_L in vQr8gNKaIaWE(c2A0yzQpDQB3(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb6J\xc2\xe4\x93]\n\xd3\xe4Rp\xfe\x0e'), '\x64' + chr(10133 - 10032) + chr(1680 - 1581) + '\157' + chr(100) + chr(0b1100101))(chr(5690 - 5573) + chr(0b1110100) + chr(0b1100110) + chr(45) + '\070')))): m1sWr00SVpVY = xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8aA\xcc\xf8\xbaQ\t\xc8\xe6dd\xed'), chr(0b1100100) + '\145' + '\x63' + chr(0b1100010 + 0o15) + chr(100) + '\145')(chr(0b11100 + 0o131) + chr(0b1111 + 0o145) + chr(0b1010101 + 0o21) + '\x2d' + chr(0b10101 + 0o43)).V4roHaS3Ppej(WVxHKyX45z_L)) tulGoizc7a_y = m1sWr00SVpVY(acf3U3erPXbI) (tulGoizc7a_y, VNGQdHSFPrso) = cEkFpYktkSeK.tsdjvlgh9gDP(tulGoizc7a_y, dim=-ehT0Px3KOsy9('\060' + chr(5482 - 5371) + chr(872 - 823), 8)) tulGoizc7a_y = _GyOifGFZyk1(tulGoizc7a_y) xafqLlk3kkUe(Hq_IFE6OTSwu, xafqLlk3kkUe(SXOLrMavuUCe(b'\x88Y\xdd\xef\x8bV'), chr(7821 - 7721) + '\x65' + chr(3326 - 3227) + chr(111) + chr(100) + chr(0b1100101))('\x75' + chr(0b1000010 + 0o62) + '\146' + '\055' + chr(395 - 339)))(tulGoizc7a_y) ej2OsISSPeax = cEkFpYktkSeK.cat(Hq_IFE6OTSwu, dim=-ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\x6f' + '\061', 8)) ej2OsISSPeax = oVre8I6UXc3b._highways(ej2OsISSPeax) ej2OsISSPeax = oVre8I6UXc3b._projection(ej2OsISSPeax) (ix9dZyeAmUxY, KpLkLOIdDwiZ, VNGQdHSFPrso) = nxz13KdxmJ5X.NLcc3BCJnQka() return {xafqLlk3kkUe(SXOLrMavuUCe(b'\x84H\xde\xe1'), chr(100) + chr(0b1100101) + chr(1856 - 1757) + '\x6f' + chr(0b1010 + 0o132) + chr(0b1000111 + 0o36))(chr(10082 - 9965) + chr(0b1100000 + 0o24) + chr(0b1100110) + chr(0b101101) + chr(56)): dZLQ7q1PiDHZ, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9dF\xc6\xef\x8bm\x03\xcb\xf2^{\xf4\x14d\x81'), chr(5557 - 5457) + '\x65' + chr(0b101 + 0o136) + '\157' + chr(5048 - 4948) + '\x65')('\165' + '\164' + chr(0b100001 + 0o105) + chr(0b101101) + chr(56)): xafqLlk3kkUe(ej2OsISSPeax, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9f@\xc8\xfd'), chr(2497 - 2397) + chr(4545 - 4444) + chr(0b1100011) + chr(0b110010 + 0o75) + chr(5706 - 5606) + chr(8250 - 8149))(chr(13277 - 13160) + '\164' + chr(102) + chr(0b101101) + '\070'))(ix9dZyeAmUxY, KpLkLOIdDwiZ, -ehT0Px3KOsy9(chr(729 - 681) + chr(111) + '\061', 8))}
allenai/allennlp
allennlp/modules/elmo.py
_ElmoBiLm.forward
def forward(self, # pylint: disable=arguments-differ inputs: torch.Tensor, word_inputs: torch.Tensor = None) -> Dict[str, Union[torch.Tensor, List[torch.Tensor]]]: """ Parameters ---------- inputs: ``torch.Tensor``, required. Shape ``(batch_size, timesteps, 50)`` of character ids representing the current batch. word_inputs : ``torch.Tensor``, required. If you passed a cached vocab, you can in addition pass a tensor of shape ``(batch_size, timesteps)``, which represent word ids which have been pre-cached. Returns ------- Dict with keys: ``'activations'``: ``List[torch.Tensor]`` A list of activations at each layer of the network, each of shape ``(batch_size, timesteps + 2, embedding_dim)`` ``'mask'``: ``torch.Tensor`` Shape ``(batch_size, timesteps + 2)`` long tensor with sequence mask. Note that the output tensors all include additional special begin and end of sequence markers. """ if self._word_embedding is not None and word_inputs is not None: try: mask_without_bos_eos = (word_inputs > 0).long() # The character cnn part is cached - just look it up. embedded_inputs = self._word_embedding(word_inputs) # type: ignore # shape (batch_size, timesteps + 2, embedding_dim) type_representation, mask = add_sentence_boundary_token_ids( embedded_inputs, mask_without_bos_eos, self._bos_embedding, self._eos_embedding ) except RuntimeError: # Back off to running the character convolutions, # as we might not have the words in the cache. token_embedding = self._token_embedder(inputs) mask = token_embedding['mask'] type_representation = token_embedding['token_embedding'] else: token_embedding = self._token_embedder(inputs) mask = token_embedding['mask'] type_representation = token_embedding['token_embedding'] lstm_outputs = self._elmo_lstm(type_representation, mask) # Prepare the output. The first layer is duplicated. # Because of minor differences in how masking is applied depending # on whether the char cnn layers are cached, we'll be defensive and # multiply by the mask here. It's not strictly necessary, as the # mask passed on is correct, but the values in the padded areas # of the char cnn representations can change. output_tensors = [ torch.cat([type_representation, type_representation], dim=-1) * mask.float().unsqueeze(-1) ] for layer_activations in torch.chunk(lstm_outputs, lstm_outputs.size(0), dim=0): output_tensors.append(layer_activations.squeeze(0)) return { 'activations': output_tensors, 'mask': mask, }
python
def forward(self, # pylint: disable=arguments-differ inputs: torch.Tensor, word_inputs: torch.Tensor = None) -> Dict[str, Union[torch.Tensor, List[torch.Tensor]]]: """ Parameters ---------- inputs: ``torch.Tensor``, required. Shape ``(batch_size, timesteps, 50)`` of character ids representing the current batch. word_inputs : ``torch.Tensor``, required. If you passed a cached vocab, you can in addition pass a tensor of shape ``(batch_size, timesteps)``, which represent word ids which have been pre-cached. Returns ------- Dict with keys: ``'activations'``: ``List[torch.Tensor]`` A list of activations at each layer of the network, each of shape ``(batch_size, timesteps + 2, embedding_dim)`` ``'mask'``: ``torch.Tensor`` Shape ``(batch_size, timesteps + 2)`` long tensor with sequence mask. Note that the output tensors all include additional special begin and end of sequence markers. """ if self._word_embedding is not None and word_inputs is not None: try: mask_without_bos_eos = (word_inputs > 0).long() # The character cnn part is cached - just look it up. embedded_inputs = self._word_embedding(word_inputs) # type: ignore # shape (batch_size, timesteps + 2, embedding_dim) type_representation, mask = add_sentence_boundary_token_ids( embedded_inputs, mask_without_bos_eos, self._bos_embedding, self._eos_embedding ) except RuntimeError: # Back off to running the character convolutions, # as we might not have the words in the cache. token_embedding = self._token_embedder(inputs) mask = token_embedding['mask'] type_representation = token_embedding['token_embedding'] else: token_embedding = self._token_embedder(inputs) mask = token_embedding['mask'] type_representation = token_embedding['token_embedding'] lstm_outputs = self._elmo_lstm(type_representation, mask) # Prepare the output. The first layer is duplicated. # Because of minor differences in how masking is applied depending # on whether the char cnn layers are cached, we'll be defensive and # multiply by the mask here. It's not strictly necessary, as the # mask passed on is correct, but the values in the padded areas # of the char cnn representations can change. output_tensors = [ torch.cat([type_representation, type_representation], dim=-1) * mask.float().unsqueeze(-1) ] for layer_activations in torch.chunk(lstm_outputs, lstm_outputs.size(0), dim=0): output_tensors.append(layer_activations.squeeze(0)) return { 'activations': output_tensors, 'mask': mask, }
[ "def", "forward", "(", "self", ",", "# pylint: disable=arguments-differ", "inputs", ":", "torch", ".", "Tensor", ",", "word_inputs", ":", "torch", ".", "Tensor", "=", "None", ")", "->", "Dict", "[", "str", ",", "Union", "[", "torch", ".", "Tensor", ",", "List", "[", "torch", ".", "Tensor", "]", "]", "]", ":", "if", "self", ".", "_word_embedding", "is", "not", "None", "and", "word_inputs", "is", "not", "None", ":", "try", ":", "mask_without_bos_eos", "=", "(", "word_inputs", ">", "0", ")", ".", "long", "(", ")", "# The character cnn part is cached - just look it up.", "embedded_inputs", "=", "self", ".", "_word_embedding", "(", "word_inputs", ")", "# type: ignore", "# shape (batch_size, timesteps + 2, embedding_dim)", "type_representation", ",", "mask", "=", "add_sentence_boundary_token_ids", "(", "embedded_inputs", ",", "mask_without_bos_eos", ",", "self", ".", "_bos_embedding", ",", "self", ".", "_eos_embedding", ")", "except", "RuntimeError", ":", "# Back off to running the character convolutions,", "# as we might not have the words in the cache.", "token_embedding", "=", "self", ".", "_token_embedder", "(", "inputs", ")", "mask", "=", "token_embedding", "[", "'mask'", "]", "type_representation", "=", "token_embedding", "[", "'token_embedding'", "]", "else", ":", "token_embedding", "=", "self", ".", "_token_embedder", "(", "inputs", ")", "mask", "=", "token_embedding", "[", "'mask'", "]", "type_representation", "=", "token_embedding", "[", "'token_embedding'", "]", "lstm_outputs", "=", "self", ".", "_elmo_lstm", "(", "type_representation", ",", "mask", ")", "# Prepare the output. The first layer is duplicated.", "# Because of minor differences in how masking is applied depending", "# on whether the char cnn layers are cached, we'll be defensive and", "# multiply by the mask here. It's not strictly necessary, as the", "# mask passed on is correct, but the values in the padded areas", "# of the char cnn representations can change.", "output_tensors", "=", "[", "torch", ".", "cat", "(", "[", "type_representation", ",", "type_representation", "]", ",", "dim", "=", "-", "1", ")", "*", "mask", ".", "float", "(", ")", ".", "unsqueeze", "(", "-", "1", ")", "]", "for", "layer_activations", "in", "torch", ".", "chunk", "(", "lstm_outputs", ",", "lstm_outputs", ".", "size", "(", "0", ")", ",", "dim", "=", "0", ")", ":", "output_tensors", ".", "append", "(", "layer_activations", ".", "squeeze", "(", "0", ")", ")", "return", "{", "'activations'", ":", "output_tensors", ",", "'mask'", ":", "mask", ",", "}" ]
Parameters ---------- inputs: ``torch.Tensor``, required. Shape ``(batch_size, timesteps, 50)`` of character ids representing the current batch. word_inputs : ``torch.Tensor``, required. If you passed a cached vocab, you can in addition pass a tensor of shape ``(batch_size, timesteps)``, which represent word ids which have been pre-cached. Returns ------- Dict with keys: ``'activations'``: ``List[torch.Tensor]`` A list of activations at each layer of the network, each of shape ``(batch_size, timesteps + 2, embedding_dim)`` ``'mask'``: ``torch.Tensor`` Shape ``(batch_size, timesteps + 2)`` long tensor with sequence mask. Note that the output tensors all include additional special begin and end of sequence markers.
[ "Parameters", "----------", "inputs", ":", "torch", ".", "Tensor", "required", ".", "Shape", "(", "batch_size", "timesteps", "50", ")", "of", "character", "ids", "representing", "the", "current", "batch", ".", "word_inputs", ":", "torch", ".", "Tensor", "required", ".", "If", "you", "passed", "a", "cached", "vocab", "you", "can", "in", "addition", "pass", "a", "tensor", "of", "shape", "(", "batch_size", "timesteps", ")", "which", "represent", "word", "ids", "which", "have", "been", "pre", "-", "cached", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/elmo.py#L561-L625
train
Forward computation of the current character set.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9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OQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + chr(0b110010) + chr(0b100111 + 0o16), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b10 + 0o155) + chr(0b0 + 0o65) + chr(0b110011), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b11111 + 0o27) + '\x35', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(55) + chr(53), 48576 - 48568), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + '\065' + '\062', 0b1000), ehT0Px3KOsy9(chr(48) + chr(11583 - 11472) + chr(49) + chr(0b11001 + 0o27) + chr(0b1010 + 0o47), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(53) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(6443 - 6332) + chr(0b110001) + chr(1865 - 1817) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100010 + 0o17) + chr(0b110001) + chr(1714 - 1660), ord("\x08")), ehT0Px3KOsy9('\060' + chr(3580 - 3469) + chr(51) + chr(48) + chr(48), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + chr(1037 - 984) + chr(51), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\062' + '\x33', 39417 - 39409), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + chr(49) + '\065', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b111000 + 0o67) + chr(1789 - 1740) + chr(0b110000) + chr(1092 - 1042), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(0b110010 + 0o2) + chr(0b1011 + 0o54), 26979 - 26971), ehT0Px3KOsy9(chr(900 - 852) + '\157' + '\x32' + chr(0b110010 + 0o1) + chr(0b100001 + 0o26), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000110 + 0o51) + chr(0b110101 + 0o2) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + chr(1042 - 994) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + chr(51) + '\066', 0o10), ehT0Px3KOsy9(chr(1750 - 1702) + chr(11767 - 11656) + chr(0b101100 + 0o5) + '\x32' + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(368 - 320) + '\157' + '\x31' + '\060' + chr(2475 - 2422), 0o10), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b1101111) + '\062' + chr(0b101011 + 0o6) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(2130 - 2082) + '\157' + '\061' + chr(0b1001 + 0o54) + chr(0b11011 + 0o34), 0o10), ehT0Px3KOsy9('\x30' + chr(10683 - 10572) + chr(257 - 202) + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1764 - 1713) + chr(0b110001), 34394 - 34386), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(55) + chr(390 - 335), 8), ehT0Px3KOsy9('\x30' + chr(0b100111 + 0o110) + chr(1304 - 1254) + chr(53) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(0b110010) + chr(2377 - 2323), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(3013 - 2902) + chr(0b1110 + 0o43) + '\065' + chr(463 - 414), 0b1000), ehT0Px3KOsy9(chr(0b10000 + 0o40) + '\157' + chr(0b110011) + chr(0b101001 + 0o15) + chr(1935 - 1885), 47756 - 47748), ehT0Px3KOsy9(chr(970 - 922) + chr(9163 - 9052) + '\x33' + chr(48) + chr(55), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + chr(53) + chr(2177 - 2122), ord("\x08")), ehT0Px3KOsy9(chr(1695 - 1647) + chr(0b1000101 + 0o52) + '\x33' + '\065' + chr(52), 0o10), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(0b1101111) + chr(55) + '\067', 8), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(0b100001 + 0o116) + chr(1656 - 1606) + '\x30' + chr(552 - 499), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(51) + chr(55) + chr(894 - 842), 0b1000), ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(0b111100 + 0o63) + '\062' + chr(327 - 277) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110 + 0o52) + '\157' + '\x32' + chr(0b110010) + chr(48), 0b1000), ehT0Px3KOsy9(chr(1584 - 1536) + '\x6f' + '\061' + chr(0b11111 + 0o26) + '\060', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\064' + '\x32', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101100 + 0o3) + '\x35' + chr(0b110000), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'{'), '\144' + chr(0b1011001 + 0o14) + '\x63' + chr(0b1101111) + chr(2123 - 2023) + chr(101))(chr(117) + '\x74' + chr(4696 - 4594) + chr(0b101101) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def GbbcCHUNFMj5(oVre8I6UXc3b, vXoupepMtCXU, Kk2hh9HVMmzs=None) -> zBnV56fc6HrA[M8_cKLkHVB2V, xS28O63k1eqo[xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x01N[N\x053'), chr(1614 - 1514) + chr(101) + '\x63' + '\157' + chr(3048 - 2948) + chr(101))(chr(3913 - 3796) + '\x74' + chr(0b1001110 + 0o30) + chr(1631 - 1586) + '\070')), qRxF7OQ0y39T[xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x01N[N\x053'), chr(0b1100100) + chr(2424 - 2323) + chr(99) + chr(0b1101111) + chr(0b1100100) + chr(0b1100101))(chr(0b1110101) + chr(0b1110100) + chr(3934 - 3832) + chr(45) + chr(56)))]]]: if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\n\\ZO\x0e\x1eJ-,\xa5\x8fw\xa4,\x80'), chr(100) + chr(0b1100101) + chr(0b1100011) + chr(111) + '\x64' + chr(0b1100101))(chr(117) + chr(0b1110100) + chr(0b1100110) + '\055' + chr(0b11101 + 0o33))) is not None and Kk2hh9HVMmzs is not None: try: g50z162N80_N = (Kk2hh9HVMmzs > ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(2252 - 2204), 58340 - 58332)).long() KZYHHUXmghyU = oVre8I6UXc3b._word_embedding(Kk2hh9HVMmzs) (_0fUkO1ng4L_, Iz1jSgUKZDvt) = lgDVfzWIwOn1(KZYHHUXmghyU, g50z162N80_N, oVre8I6UXc3b._bos_embedding, oVre8I6UXc3b._eos_embedding) except n0ZkatoveZpF: ej2OsISSPeax = oVre8I6UXc3b._token_embedder(vXoupepMtCXU) Iz1jSgUKZDvt = ej2OsISSPeax[xafqLlk3kkUe(SXOLrMavuUCe(b'8JFV'), chr(100) + chr(0b1100101) + chr(0b1010001 + 0o22) + chr(10355 - 10244) + chr(100) + chr(10066 - 9965))(chr(0b1001110 + 0o47) + chr(0b1110100) + '\x66' + '\x2d' + chr(0b1100 + 0o54))] _0fUkO1ng4L_ = ej2OsISSPeax[xafqLlk3kkUe(SXOLrMavuUCe(b'!D^X\x04\x1eJ-,\xa5\x8fw\xa4,\x80'), chr(100) + chr(0b1100101) + chr(6148 - 6049) + '\157' + '\x64' + chr(101))(chr(0b1110101) + chr(2535 - 2419) + chr(0b1100110) + '\x2d' + chr(2545 - 2489))] else: ej2OsISSPeax = oVre8I6UXc3b._token_embedder(vXoupepMtCXU) Iz1jSgUKZDvt = ej2OsISSPeax[xafqLlk3kkUe(SXOLrMavuUCe(b'8JFV'), chr(0b1100100) + chr(0b101011 + 0o72) + '\143' + chr(111) + chr(100) + '\145')(chr(117) + chr(116) + chr(0b1100110) + chr(0b100011 + 0o12) + '\x38')] _0fUkO1ng4L_ = ej2OsISSPeax[xafqLlk3kkUe(SXOLrMavuUCe(b'!D^X\x04\x1eJ-,\xa5\x8fw\xa4,\x80'), '\x64' + chr(0b1011111 + 0o6) + '\x63' + '\x6f' + chr(100) + '\145')(chr(117) + '\x74' + chr(102) + '\055' + '\x38')] dAg4p4XZ70V9 = oVre8I6UXc3b._elmo_lstm(_0fUkO1ng4L_, Iz1jSgUKZDvt) I9TkQtaS5kw5 = [cEkFpYktkSeK.cat([_0fUkO1ng4L_, _0fUkO1ng4L_], dim=-ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x31', ord("\x08"))) * Iz1jSgUKZDvt.float().unsqueeze(-ehT0Px3KOsy9(chr(48) + chr(111) + '\x31', 8))] for pFsv81douvkT in xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'6C@S\x01'), '\144' + chr(0b1100101) + chr(0b101000 + 0o73) + '\157' + chr(0b1100100) + chr(101))(chr(117) + '\x74' + chr(0b1100110) + chr(45) + '\x38'))(dAg4p4XZ70V9, xafqLlk3kkUe(dAg4p4XZ70V9, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1bgV^Y\x03l\n \x91\x80r'), '\144' + '\x65' + chr(99) + chr(0b1101111) + chr(0b1100100) + chr(0b1100101))(chr(7306 - 7189) + chr(0b1000110 + 0o56) + '\146' + '\055' + '\070'))(ehT0Px3KOsy9(chr(2303 - 2255) + chr(0b1101111) + '\x30', 8)), dim=ehT0Px3KOsy9(chr(48) + chr(111) + '\060', 8)): xafqLlk3kkUe(I9TkQtaS5kw5, xafqLlk3kkUe(SXOLrMavuUCe(b'4[EX\x04%'), chr(0b1100100) + chr(0b1100101) + chr(99) + '\157' + chr(7460 - 7360) + '\145')('\x75' + chr(0b1110100) + chr(0b1001001 + 0o35) + chr(1669 - 1624) + '\070'))(xafqLlk3kkUe(pFsv81douvkT, xafqLlk3kkUe(SXOLrMavuUCe(b'&Z@X\x0f;J'), '\144' + '\145' + '\x63' + chr(0b10 + 0o155) + chr(0b1100100) + chr(0b1 + 0o144))('\x75' + '\164' + chr(8337 - 8235) + chr(45) + '\x38'))(ehT0Px3KOsy9(chr(48) + '\157' + '\x30', 8))) return {xafqLlk3kkUe(SXOLrMavuUCe(b'4HAT\x1c [)!\xae\x98'), '\144' + chr(0b1100101) + chr(0b1100011) + chr(111) + chr(0b1100100) + chr(101))(chr(0b101101 + 0o110) + chr(1029 - 913) + chr(0b110000 + 0o66) + chr(45) + chr(0b111000)): I9TkQtaS5kw5, xafqLlk3kkUe(SXOLrMavuUCe(b'8JFV'), chr(100) + chr(0b1011110 + 0o7) + chr(8836 - 8737) + '\x6f' + chr(0b10111 + 0o115) + chr(1379 - 1278))(chr(0b1110101) + '\x74' + chr(6674 - 6572) + chr(0b1001 + 0o44) + chr(0b100100 + 0o24)): Iz1jSgUKZDvt}
allenai/allennlp
allennlp/modules/elmo.py
_ElmoBiLm.create_cached_cnn_embeddings
def create_cached_cnn_embeddings(self, tokens: List[str]) -> None: """ Given a list of tokens, this method precomputes word representations by running just the character convolutions and highway layers of elmo, essentially creating uncontextual word vectors. On subsequent forward passes, the word ids are looked up from an embedding, rather than being computed on the fly via the CNN encoder. This function sets 3 attributes: _word_embedding : ``torch.Tensor`` The word embedding for each word in the tokens passed to this method. _bos_embedding : ``torch.Tensor`` The embedding for the BOS token. _eos_embedding : ``torch.Tensor`` The embedding for the EOS token. Parameters ---------- tokens : ``List[str]``, required. A list of tokens to precompute character convolutions for. """ tokens = [ELMoCharacterMapper.bos_token, ELMoCharacterMapper.eos_token] + tokens timesteps = 32 batch_size = 32 chunked_tokens = lazy_groups_of(iter(tokens), timesteps) all_embeddings = [] device = get_device_of(next(self.parameters())) for batch in lazy_groups_of(chunked_tokens, batch_size): # Shape (batch_size, timesteps, 50) batched_tensor = batch_to_ids(batch) # NOTE: This device check is for when a user calls this method having # already placed the model on a device. If this is called in the # constructor, it will probably happen on the CPU. This isn't too bad, # because it's only a few convolutions and will likely be very fast. if device >= 0: batched_tensor = batched_tensor.cuda(device) output = self._token_embedder(batched_tensor) token_embedding = output["token_embedding"] mask = output["mask"] token_embedding, _ = remove_sentence_boundaries(token_embedding, mask) all_embeddings.append(token_embedding.view(-1, token_embedding.size(-1))) full_embedding = torch.cat(all_embeddings, 0) # We might have some trailing embeddings from padding in the batch, so # we clip the embedding and lookup to the right size. full_embedding = full_embedding[:len(tokens), :] embedding = full_embedding[2:len(tokens), :] vocab_size, embedding_dim = list(embedding.size()) from allennlp.modules.token_embedders import Embedding # type: ignore self._bos_embedding = full_embedding[0, :] self._eos_embedding = full_embedding[1, :] self._word_embedding = Embedding(vocab_size, # type: ignore embedding_dim, weight=embedding.data, trainable=self._requires_grad, padding_index=0)
python
def create_cached_cnn_embeddings(self, tokens: List[str]) -> None: """ Given a list of tokens, this method precomputes word representations by running just the character convolutions and highway layers of elmo, essentially creating uncontextual word vectors. On subsequent forward passes, the word ids are looked up from an embedding, rather than being computed on the fly via the CNN encoder. This function sets 3 attributes: _word_embedding : ``torch.Tensor`` The word embedding for each word in the tokens passed to this method. _bos_embedding : ``torch.Tensor`` The embedding for the BOS token. _eos_embedding : ``torch.Tensor`` The embedding for the EOS token. Parameters ---------- tokens : ``List[str]``, required. A list of tokens to precompute character convolutions for. """ tokens = [ELMoCharacterMapper.bos_token, ELMoCharacterMapper.eos_token] + tokens timesteps = 32 batch_size = 32 chunked_tokens = lazy_groups_of(iter(tokens), timesteps) all_embeddings = [] device = get_device_of(next(self.parameters())) for batch in lazy_groups_of(chunked_tokens, batch_size): # Shape (batch_size, timesteps, 50) batched_tensor = batch_to_ids(batch) # NOTE: This device check is for when a user calls this method having # already placed the model on a device. If this is called in the # constructor, it will probably happen on the CPU. This isn't too bad, # because it's only a few convolutions and will likely be very fast. if device >= 0: batched_tensor = batched_tensor.cuda(device) output = self._token_embedder(batched_tensor) token_embedding = output["token_embedding"] mask = output["mask"] token_embedding, _ = remove_sentence_boundaries(token_embedding, mask) all_embeddings.append(token_embedding.view(-1, token_embedding.size(-1))) full_embedding = torch.cat(all_embeddings, 0) # We might have some trailing embeddings from padding in the batch, so # we clip the embedding and lookup to the right size. full_embedding = full_embedding[:len(tokens), :] embedding = full_embedding[2:len(tokens), :] vocab_size, embedding_dim = list(embedding.size()) from allennlp.modules.token_embedders import Embedding # type: ignore self._bos_embedding = full_embedding[0, :] self._eos_embedding = full_embedding[1, :] self._word_embedding = Embedding(vocab_size, # type: ignore embedding_dim, weight=embedding.data, trainable=self._requires_grad, padding_index=0)
[ "def", "create_cached_cnn_embeddings", "(", "self", ",", "tokens", ":", "List", "[", "str", "]", ")", "->", "None", ":", "tokens", "=", "[", "ELMoCharacterMapper", ".", "bos_token", ",", "ELMoCharacterMapper", ".", "eos_token", "]", "+", "tokens", "timesteps", "=", "32", "batch_size", "=", "32", "chunked_tokens", "=", "lazy_groups_of", "(", "iter", "(", "tokens", ")", ",", "timesteps", ")", "all_embeddings", "=", "[", "]", "device", "=", "get_device_of", "(", "next", "(", "self", ".", "parameters", "(", ")", ")", ")", "for", "batch", "in", "lazy_groups_of", "(", "chunked_tokens", ",", "batch_size", ")", ":", "# Shape (batch_size, timesteps, 50)", "batched_tensor", "=", "batch_to_ids", "(", "batch", ")", "# NOTE: This device check is for when a user calls this method having", "# already placed the model on a device. If this is called in the", "# constructor, it will probably happen on the CPU. This isn't too bad,", "# because it's only a few convolutions and will likely be very fast.", "if", "device", ">=", "0", ":", "batched_tensor", "=", "batched_tensor", ".", "cuda", "(", "device", ")", "output", "=", "self", ".", "_token_embedder", "(", "batched_tensor", ")", "token_embedding", "=", "output", "[", "\"token_embedding\"", "]", "mask", "=", "output", "[", "\"mask\"", "]", "token_embedding", ",", "_", "=", "remove_sentence_boundaries", "(", "token_embedding", ",", "mask", ")", "all_embeddings", ".", "append", "(", "token_embedding", ".", "view", "(", "-", "1", ",", "token_embedding", ".", "size", "(", "-", "1", ")", ")", ")", "full_embedding", "=", "torch", ".", "cat", "(", "all_embeddings", ",", "0", ")", "# We might have some trailing embeddings from padding in the batch, so", "# we clip the embedding and lookup to the right size.", "full_embedding", "=", "full_embedding", "[", ":", "len", "(", "tokens", ")", ",", ":", "]", "embedding", "=", "full_embedding", "[", "2", ":", "len", "(", "tokens", ")", ",", ":", "]", "vocab_size", ",", "embedding_dim", "=", "list", "(", "embedding", ".", "size", "(", ")", ")", "from", "allennlp", ".", "modules", ".", "token_embedders", "import", "Embedding", "# type: ignore", "self", ".", "_bos_embedding", "=", "full_embedding", "[", "0", ",", ":", "]", "self", ".", "_eos_embedding", "=", "full_embedding", "[", "1", ",", ":", "]", "self", ".", "_word_embedding", "=", "Embedding", "(", "vocab_size", ",", "# type: ignore", "embedding_dim", ",", "weight", "=", "embedding", ".", "data", ",", "trainable", "=", "self", ".", "_requires_grad", ",", "padding_index", "=", "0", ")" ]
Given a list of tokens, this method precomputes word representations by running just the character convolutions and highway layers of elmo, essentially creating uncontextual word vectors. On subsequent forward passes, the word ids are looked up from an embedding, rather than being computed on the fly via the CNN encoder. This function sets 3 attributes: _word_embedding : ``torch.Tensor`` The word embedding for each word in the tokens passed to this method. _bos_embedding : ``torch.Tensor`` The embedding for the BOS token. _eos_embedding : ``torch.Tensor`` The embedding for the EOS token. Parameters ---------- tokens : ``List[str]``, required. A list of tokens to precompute character convolutions for.
[ "Given", "a", "list", "of", "tokens", "this", "method", "precomputes", "word", "representations", "by", "running", "just", "the", "character", "convolutions", "and", "highway", "layers", "of", "elmo", "essentially", "creating", "uncontextual", "word", "vectors", ".", "On", "subsequent", "forward", "passes", "the", "word", "ids", "are", "looked", "up", "from", "an", "embedding", "rather", "than", "being", "computed", "on", "the", "fly", "via", "the", "CNN", "encoder", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/elmo.py#L627-L685
train
Creates the word embedding tensors for each token in the list of tokens.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthd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Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\x6f' + chr(49) + chr(761 - 711) + '\066', 49837 - 49829), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(111) + chr(1893 - 1843) + chr(769 - 719) + chr(49), 15589 - 15581), ehT0Px3KOsy9(chr(1029 - 981) + '\x6f' + '\x31' + chr(0b110011) + chr(49), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b11001 + 0o32) + chr(0b110100) + chr(0b100101 + 0o20), 0b1000), ehT0Px3KOsy9(chr(1316 - 1268) + '\x6f' + chr(0b10000 + 0o43) + '\061' + chr(2420 - 2365), 0o10), ehT0Px3KOsy9(chr(314 - 266) + chr(0b1101111) + chr(755 - 705) + '\067' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\062' + chr(0b11101 + 0o23) + chr(1858 - 1804), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1001000 + 0o47) + '\x32' + chr(50) + chr(50), 0o10), ehT0Px3KOsy9(chr(1760 - 1712) + chr(0b10000 + 0o137) + chr(0b101110 + 0o3) + '\x35' + '\064', 0o10), ehT0Px3KOsy9(chr(1234 - 1186) + '\157' + chr(53) + chr(0b11 + 0o64), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + chr(0b110001) + chr(2487 - 2432), 8), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b1101111) + '\061' + chr(0b10010 + 0o45) + '\066', 0o10), ehT0Px3KOsy9('\x30' + chr(4356 - 4245) + chr(0b11011 + 0o33) + '\062', 0b1000), ehT0Px3KOsy9(chr(881 - 833) + chr(111) + chr(0b1001 + 0o50) + chr(1087 - 1038) + '\067', 1960 - 1952), ehT0Px3KOsy9(chr(280 - 232) + chr(0b1100 + 0o143) + chr(1963 - 1912) + '\066' + chr(2158 - 2108), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b11010 + 0o30) + chr(0b110011) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\157' + chr(0b110000 + 0o4) + chr(0b1 + 0o63), 0o10), ehT0Px3KOsy9(chr(0b110 + 0o52) + '\157' + '\062' + chr(0b110010) + chr(0b110000), 57575 - 57567), ehT0Px3KOsy9(chr(2281 - 2233) + chr(111) + chr(0b10011 + 0o36) + chr(407 - 358) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + chr(2247 - 2196) + chr(1168 - 1116), 59836 - 59828), ehT0Px3KOsy9('\060' + '\x6f' + chr(565 - 516) + '\x31' + chr(0b110111), 8), ehT0Px3KOsy9(chr(0b110000) + chr(3153 - 3042) + chr(49) + chr(0b100011 + 0o20) + chr(53), 4506 - 4498), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(0b1100011 + 0o14) + chr(777 - 728) + '\061' + '\065', 26936 - 26928), ehT0Px3KOsy9('\x30' + '\x6f' + chr(55) + '\x36', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b11 + 0o56) + chr(54) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + chr(0b110010) + chr(0b11110 + 0o27), 11035 - 11027), ehT0Px3KOsy9('\060' + chr(3130 - 3019) + '\x32' + chr(52) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(0b101010 + 0o6) + '\157' + chr(1642 - 1591) + '\061' + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b101001 + 0o12) + '\x36' + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(0b1010001 + 0o36) + '\x31' + chr(1195 - 1145) + chr(1650 - 1602), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001 + 0o146) + chr(0b100 + 0o56) + '\x35' + chr(0b10000 + 0o45), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b100110 + 0o13) + '\061', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110111), 60500 - 60492), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b100101 + 0o21) + chr(1999 - 1950), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + chr(55) + chr(1313 - 1261), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110111) + chr(1904 - 1854), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b101000 + 0o11) + chr(0b110110) + chr(0b110000), 25721 - 25713), ehT0Px3KOsy9('\x30' + '\157' + chr(0b11 + 0o60) + chr(0b110001), 32475 - 32467), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + chr(0b11111 + 0o24) + chr(48) + chr(0b110100), 15231 - 15223), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(784 - 734) + chr(943 - 891) + '\x30', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(637 - 589) + chr(0b1101111) + chr(0b110101) + chr(48), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'x'), chr(100) + chr(1893 - 1792) + chr(99) + chr(11184 - 11073) + chr(0b10010 + 0o122) + chr(0b111101 + 0o50))('\165' + chr(0b1100001 + 0o23) + chr(102) + '\x2d' + chr(2670 - 2614)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def cvapHGXsCcos(oVre8I6UXc3b, Sz7tXxaCGqJ1) -> None: Sz7tXxaCGqJ1 = [kQmRK2XvgC45.bos_token, kQmRK2XvgC45.eos_token] + Sz7tXxaCGqJ1 QNvXCjnvcnON = ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110 + 0o56) + '\x30', ord("\x08")) ix9dZyeAmUxY = ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110100 + 0o0) + chr(48), 8) J4h5ajleisPn = A7kxV2FuX2_9(ZdP978XkGspL(Sz7tXxaCGqJ1), QNvXCjnvcnON) G1nJChNMxtrI = [] v9dZPx26KxBP = yRvvZkDFNAV9(nSwwHEeM4cxI(oVre8I6UXc3b.parameters())) for dNwAahu8tvoY in A7kxV2FuX2_9(J4h5ajleisPn, ix9dZyeAmUxY): Ar9KRSv3M9Er = KBB0yWyM0_TU(dNwAahu8tvoY) if v9dZPx26KxBP >= ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\x6f' + chr(0b101100 + 0o4), ord("\x08")): Ar9KRSv3M9Er = Ar9KRSv3M9Er.cuda(v9dZPx26KxBP) e1jVqMSBZ01Y = oVre8I6UXc3b._token_embedder(Ar9KRSv3M9Er) ej2OsISSPeax = e1jVqMSBZ01Y[xafqLlk3kkUe(SXOLrMavuUCe(b'"\xfe2\x80\xa1\xe0\xe3\xff\x0eJ\xab\x1a[!\x95'), chr(100) + chr(0b1100101) + chr(99) + '\x6f' + chr(3459 - 3359) + '\145')('\x75' + chr(116) + chr(0b110111 + 0o57) + chr(45) + chr(1360 - 1304))] Iz1jSgUKZDvt = e1jVqMSBZ01Y[xafqLlk3kkUe(SXOLrMavuUCe(b';\xf0*\x8e'), chr(0b101011 + 0o71) + '\x65' + chr(0b1100011) + chr(3603 - 3492) + '\144' + chr(101))(chr(0b100 + 0o161) + chr(0b1110100) + '\146' + chr(683 - 638) + chr(56))] (ej2OsISSPeax, VNGQdHSFPrso) = ooqEa__WcZPK(ej2OsISSPeax, Iz1jSgUKZDvt) xafqLlk3kkUe(G1nJChNMxtrI, xafqLlk3kkUe(SXOLrMavuUCe(b'7\xe1)\x80\xa1\xdb'), chr(1609 - 1509) + chr(101) + chr(4913 - 4814) + '\157' + chr(100) + '\145')(chr(0b1110101) + chr(0b1110100) + '\x66' + '\x2d' + '\x38'))(xafqLlk3kkUe(ej2OsISSPeax, xafqLlk3kkUe(SXOLrMavuUCe(b' \xf8<\x92'), '\144' + chr(0b1100101) + chr(9713 - 9614) + chr(111) + chr(100) + chr(101))('\x75' + chr(0b1110100) + chr(0b1100110) + '\055' + '\x38'))(-ehT0Px3KOsy9(chr(48) + chr(0b1011 + 0o144) + chr(49), 0b1000), xafqLlk3kkUe(ej2OsISSPeax, xafqLlk3kkUe(SXOLrMavuUCe(b'\x18\xdd:\x86\xfc\xfd\xc5\xd8\x02~\xa4\x1f'), '\x64' + chr(0b1100101) + '\x63' + '\x6f' + '\x64' + '\145')(chr(0b1110101) + '\x74' + chr(0b1010001 + 0o25) + '\055' + '\x38'))(-ehT0Px3KOsy9(chr(48) + '\157' + '\x31', 8)))) SG25WmkW9SRC = cEkFpYktkSeK.cat(G1nJChNMxtrI, ehT0Px3KOsy9('\x30' + chr(2932 - 2821) + '\x30', 8)) SG25WmkW9SRC = SG25WmkW9SRC[:c2A0yzQpDQB3(Sz7tXxaCGqJ1), :] lwIir85sFEJp = SG25WmkW9SRC[ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062', 0b1000):c2A0yzQpDQB3(Sz7tXxaCGqJ1), :] (CeyMIoSyrpkQ, ys3GY1_gtGOx) = YyaZ4tpXu4lf(lwIir85sFEJp.NLcc3BCJnQka()) (UvUNwTdSPUfp,) = (xafqLlk3kkUe(xafqLlk3kkUe(xafqLlk3kkUe(NPPHb59961Bv(xafqLlk3kkUe(SXOLrMavuUCe(b'7\xfd5\x80\xa1\xd1\xea\xe2BB\xa0\x1aG#\x97\xef\n\xe4#\xb7*3\x12[\x19\xf7\xc7\xad\x905\xdfz'), chr(7670 - 7570) + chr(0b111000 + 0o55) + chr(2547 - 2448) + chr(3630 - 3519) + '\x64' + chr(101))(chr(117) + chr(116) + chr(0b1100110) + '\x2d' + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x13\xfc;\x80\xab\xdb\xef\xfc\x0b'), chr(0b1000101 + 0o37) + '\145' + chr(0b1100011) + chr(0b1101111) + chr(1666 - 1566) + '\145')(chr(0b1101101 + 0o10) + '\164' + '\146' + '\x2d' + chr(0b100 + 0o64))), xafqLlk3kkUe(SXOLrMavuUCe(b';\xfe=\x90\xa3\xda\xf5'), '\144' + '\145' + '\x63' + chr(0b1101111) + chr(100) + chr(0b1100101))(chr(216 - 99) + '\164' + chr(0b1100110) + '\055' + chr(0b100001 + 0o27))), xafqLlk3kkUe(SXOLrMavuUCe(b'"\xfe2\x80\xa1\xe0\xe3\xff\x0eJ\xab\x1aW=\x81'), chr(100) + chr(6830 - 6729) + '\x63' + chr(0b1101111) + chr(100) + '\145')('\165' + '\x74' + chr(0b1100110) + chr(0b101101) + chr(1326 - 1270))), xafqLlk3kkUe(SXOLrMavuUCe(b'\x13\xfc;\x80\xab\xdb\xef\xfc\x0b'), '\144' + '\145' + chr(3884 - 3785) + '\157' + chr(0b1100100) + chr(0b1010010 + 0o23))('\x75' + chr(116) + chr(102) + '\x2d' + chr(56))),) oVre8I6UXc3b.zA_WG9exkAEW = SG25WmkW9SRC[ehT0Px3KOsy9(chr(0b110000) + chr(6270 - 6159) + chr(0b1011 + 0o45), 8), :] oVre8I6UXc3b.YUwg3mcNoTcb = SG25WmkW9SRC[ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001), 8), :] oVre8I6UXc3b.xibo5f2e1rWl = UvUNwTdSPUfp(CeyMIoSyrpkQ, ys3GY1_gtGOx, weight=lwIir85sFEJp.ULnjp6D6efFH, trainable=oVre8I6UXc3b._requires_grad, padding_index=ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + chr(48), 8))
allenai/allennlp
allennlp/data/dataset_readers/reading_comprehension/util.py
normalize_text
def normalize_text(text: str) -> str: """ Performs a normalization that is very similar to that done by the normalization functions in SQuAD and TriviaQA. This involves splitting and rejoining the text, and could be a somewhat expensive operation. """ return ' '.join([token for token in text.lower().strip(STRIPPED_CHARACTERS).split() if token not in IGNORED_TOKENS])
python
def normalize_text(text: str) -> str: """ Performs a normalization that is very similar to that done by the normalization functions in SQuAD and TriviaQA. This involves splitting and rejoining the text, and could be a somewhat expensive operation. """ return ' '.join([token for token in text.lower().strip(STRIPPED_CHARACTERS).split() if token not in IGNORED_TOKENS])
[ "def", "normalize_text", "(", "text", ":", "str", ")", "->", "str", ":", "return", "' '", ".", "join", "(", "[", "token", "for", "token", "in", "text", ".", "lower", "(", ")", ".", "strip", "(", "STRIPPED_CHARACTERS", ")", ".", "split", "(", ")", "if", "token", "not", "in", "IGNORED_TOKENS", "]", ")" ]
Performs a normalization that is very similar to that done by the normalization functions in SQuAD and TriviaQA. This involves splitting and rejoining the text, and could be a somewhat expensive operation.
[ "Performs", "a", "normalization", "that", "is", "very", "similar", "to", "that", "done", "by", "the", "normalization", "functions", "in", "SQuAD", "and", "TriviaQA", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/reading_comprehension/util.py#L24-L33
train
Normalizes the given text to be a more efficient form.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMd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eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b11110 + 0o22) + '\157' + '\x32' + chr(48) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110011) + '\062' + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b10101 + 0o132) + chr(1238 - 1189) + '\063' + chr(0b100111 + 0o16), 0b1000), ehT0Px3KOsy9(chr(1164 - 1116) + chr(5786 - 5675) + chr(0b1000 + 0o52) + chr(55) + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(11846 - 11735) + chr(0b110111) + chr(0b110101), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(55) + chr(53), 8), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + chr(49) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(2362 - 2251) + chr(646 - 596) + chr(0b100001 + 0o21), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b111100 + 0o63) + '\x32' + '\066', 53200 - 53192), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\157' + chr(0b110001) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + chr(1775 - 1723) + '\067', 30890 - 30882), ehT0Px3KOsy9(chr(890 - 842) + chr(1243 - 1132) + '\063' + chr(1253 - 1204) + chr(0b100100 + 0o23), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1000000 + 0o57) + chr(0b1111 + 0o42) + chr(0b100110 + 0o13) + chr(1600 - 1550), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x31' + '\062' + '\x32', 0o10), ehT0Px3KOsy9(chr(1685 - 1637) + chr(0b1101111) + '\x31' + chr(0b110010) + '\x32', 8), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101111) + chr(53) + chr(0b10110 + 0o37), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(1373 - 1320) + chr(2295 - 2242), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101101 + 0o4) + chr(0b111 + 0o53) + '\x37', 28548 - 28540), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(111) + chr(705 - 656) + chr(54) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\x6f' + chr(49) + chr(53) + '\062', 0o10), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(0b1011010 + 0o25) + chr(1069 - 1020) + '\062' + chr(0b110101), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\062' + '\x33' + chr(0b110011 + 0o1), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + chr(0b110011) + chr(0b110110), 54844 - 54836), ehT0Px3KOsy9(chr(554 - 506) + chr(111) + '\063' + chr(2247 - 2199) + chr(1392 - 1337), 0b1000), ehT0Px3KOsy9('\060' + chr(583 - 472) + chr(796 - 747) + chr(0b110000) + chr(1164 - 1111), 0b1000), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101111) + chr(0b110010) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\x6f' + '\063' + chr(0b101110 + 0o7), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b101111 + 0o4) + chr(0b110011) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(1982 - 1934) + chr(111) + '\x37' + chr(48), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\x35' + chr(2597 - 2545), 0o10), ehT0Px3KOsy9(chr(1672 - 1624) + chr(10611 - 10500) + chr(1083 - 1034) + '\x30' + '\x33', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + '\x36' + '\x33', 43296 - 43288), ehT0Px3KOsy9(chr(462 - 414) + chr(6006 - 5895) + '\x32' + chr(50) + chr(48), 0b1000), ehT0Px3KOsy9(chr(984 - 936) + chr(0b110000 + 0o77) + chr(0b1010 + 0o51) + '\066' + chr(971 - 923), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\062' + '\x33' + chr(0b10010 + 0o45), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1001111 + 0o40) + '\x33' + chr(52) + '\x34', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + '\060' + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(669 - 621) + '\157' + chr(2541 - 2490) + chr(0b110101), 8), ehT0Px3KOsy9(chr(48) + chr(0b1100001 + 0o16) + chr(1418 - 1369) + chr(2466 - 2412) + chr(55), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1455 - 1405) + chr(472 - 421) + '\060', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(557 - 509) + '\157' + '\x35' + chr(48), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xae'), '\x64' + '\145' + '\x63' + '\157' + '\x64' + '\x65')(chr(12735 - 12618) + '\164' + '\146' + chr(0b100001 + 0o14) + chr(823 - 767)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def LWdkb4QBA6Qk(Ah1rInvg48Hb) -> M8_cKLkHVB2V: return xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\xa0'), chr(0b1100100) + chr(101) + chr(4490 - 4391) + '\x6f' + chr(100) + chr(8441 - 8340))('\x75' + '\164' + chr(3296 - 3194) + chr(0b1100 + 0o41) + chr(1416 - 1360)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xdf\xbd\n\xe2GI\x9d\\x\x7f/\x89'), chr(0b1100100) + '\145' + chr(0b110100 + 0o57) + chr(0b1101111) + chr(100) + chr(2321 - 2220))('\x75' + chr(0b1110100) + chr(102) + '\055' + '\070'))([mTy3fac_AqJ5 for mTy3fac_AqJ5 in xafqLlk3kkUe(Ah1rInvg48Hb.lower().strip(r8tsfoTkseiV), xafqLlk3kkUe(SXOLrMavuUCe(b'\xf3\xa21\xd3I'), chr(100) + '\145' + '\x63' + chr(111) + chr(4243 - 4143) + '\145')(chr(9416 - 9299) + chr(9161 - 9045) + '\x66' + '\x2d' + chr(2499 - 2443)))() if mTy3fac_AqJ5 not in n7anaSAgIlFL])
allenai/allennlp
allennlp/data/dataset_readers/reading_comprehension/util.py
char_span_to_token_span
def char_span_to_token_span(token_offsets: List[Tuple[int, int]], character_span: Tuple[int, int]) -> Tuple[Tuple[int, int], bool]: """ Converts a character span from a passage into the corresponding token span in the tokenized version of the passage. If you pass in a character span that does not correspond to complete tokens in the tokenized version, we'll do our best, but the behavior is officially undefined. We return an error flag in this case, and have some debug logging so you can figure out the cause of this issue (in SQuAD, these are mostly either tokenization problems or annotation problems; there's a fair amount of both). The basic outline of this method is to find the token span that has the same offsets as the input character span. If the tokenizer tokenized the passage correctly and has matching offsets, this is easy. We try to be a little smart about cases where they don't match exactly, but mostly just find the closest thing we can. The returned ``(begin, end)`` indices are `inclusive` for both ``begin`` and ``end``. So, for example, ``(2, 2)`` is the one word span beginning at token index 2, ``(3, 4)`` is the two-word span beginning at token index 3, and so on. Returns ------- token_span : ``Tuple[int, int]`` `Inclusive` span start and end token indices that match as closely as possible to the input character spans. error : ``bool`` Whether the token spans match the input character spans exactly. If this is ``False``, it means there was an error in either the tokenization or the annotated character span. """ # We have token offsets into the passage from the tokenizer; we _should_ be able to just find # the tokens that have the same offsets as our span. error = False start_index = 0 while start_index < len(token_offsets) and token_offsets[start_index][0] < character_span[0]: start_index += 1 # start_index should now be pointing at the span start index. if token_offsets[start_index][0] > character_span[0]: # In this case, a tokenization or labeling issue made us go too far - the character span # we're looking for actually starts in the previous token. We'll back up one. logger.debug("Bad labelling or tokenization - start offset doesn't match") start_index -= 1 if token_offsets[start_index][0] != character_span[0]: error = True end_index = start_index while end_index < len(token_offsets) and token_offsets[end_index][1] < character_span[1]: end_index += 1 if end_index == start_index and token_offsets[end_index][1] > character_span[1]: # Looks like there was a token that should have been split, like "1854-1855", where the # answer is "1854". We can't do much in this case, except keep the answer as the whole # token. logger.debug("Bad tokenization - end offset doesn't match") elif token_offsets[end_index][1] > character_span[1]: # This is a case where the given answer span is more than one token, and the last token is # cut off for some reason, like "split with Luckett and Rober", when the original passage # said "split with Luckett and Roberson". In this case, we'll just keep the end index # where it is, and assume the intent was to mark the whole token. logger.debug("Bad labelling or tokenization - end offset doesn't match") if token_offsets[end_index][1] != character_span[1]: error = True return (start_index, end_index), error
python
def char_span_to_token_span(token_offsets: List[Tuple[int, int]], character_span: Tuple[int, int]) -> Tuple[Tuple[int, int], bool]: """ Converts a character span from a passage into the corresponding token span in the tokenized version of the passage. If you pass in a character span that does not correspond to complete tokens in the tokenized version, we'll do our best, but the behavior is officially undefined. We return an error flag in this case, and have some debug logging so you can figure out the cause of this issue (in SQuAD, these are mostly either tokenization problems or annotation problems; there's a fair amount of both). The basic outline of this method is to find the token span that has the same offsets as the input character span. If the tokenizer tokenized the passage correctly and has matching offsets, this is easy. We try to be a little smart about cases where they don't match exactly, but mostly just find the closest thing we can. The returned ``(begin, end)`` indices are `inclusive` for both ``begin`` and ``end``. So, for example, ``(2, 2)`` is the one word span beginning at token index 2, ``(3, 4)`` is the two-word span beginning at token index 3, and so on. Returns ------- token_span : ``Tuple[int, int]`` `Inclusive` span start and end token indices that match as closely as possible to the input character spans. error : ``bool`` Whether the token spans match the input character spans exactly. If this is ``False``, it means there was an error in either the tokenization or the annotated character span. """ # We have token offsets into the passage from the tokenizer; we _should_ be able to just find # the tokens that have the same offsets as our span. error = False start_index = 0 while start_index < len(token_offsets) and token_offsets[start_index][0] < character_span[0]: start_index += 1 # start_index should now be pointing at the span start index. if token_offsets[start_index][0] > character_span[0]: # In this case, a tokenization or labeling issue made us go too far - the character span # we're looking for actually starts in the previous token. We'll back up one. logger.debug("Bad labelling or tokenization - start offset doesn't match") start_index -= 1 if token_offsets[start_index][0] != character_span[0]: error = True end_index = start_index while end_index < len(token_offsets) and token_offsets[end_index][1] < character_span[1]: end_index += 1 if end_index == start_index and token_offsets[end_index][1] > character_span[1]: # Looks like there was a token that should have been split, like "1854-1855", where the # answer is "1854". We can't do much in this case, except keep the answer as the whole # token. logger.debug("Bad tokenization - end offset doesn't match") elif token_offsets[end_index][1] > character_span[1]: # This is a case where the given answer span is more than one token, and the last token is # cut off for some reason, like "split with Luckett and Rober", when the original passage # said "split with Luckett and Roberson". In this case, we'll just keep the end index # where it is, and assume the intent was to mark the whole token. logger.debug("Bad labelling or tokenization - end offset doesn't match") if token_offsets[end_index][1] != character_span[1]: error = True return (start_index, end_index), error
[ "def", "char_span_to_token_span", "(", "token_offsets", ":", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", ",", "character_span", ":", "Tuple", "[", "int", ",", "int", "]", ")", "->", "Tuple", "[", "Tuple", "[", "int", ",", "int", "]", ",", "bool", "]", ":", "# We have token offsets into the passage from the tokenizer; we _should_ be able to just find", "# the tokens that have the same offsets as our span.", "error", "=", "False", "start_index", "=", "0", "while", "start_index", "<", "len", "(", "token_offsets", ")", "and", "token_offsets", "[", "start_index", "]", "[", "0", "]", "<", "character_span", "[", "0", "]", ":", "start_index", "+=", "1", "# start_index should now be pointing at the span start index.", "if", "token_offsets", "[", "start_index", "]", "[", "0", "]", ">", "character_span", "[", "0", "]", ":", "# In this case, a tokenization or labeling issue made us go too far - the character span", "# we're looking for actually starts in the previous token. We'll back up one.", "logger", ".", "debug", "(", "\"Bad labelling or tokenization - start offset doesn't match\"", ")", "start_index", "-=", "1", "if", "token_offsets", "[", "start_index", "]", "[", "0", "]", "!=", "character_span", "[", "0", "]", ":", "error", "=", "True", "end_index", "=", "start_index", "while", "end_index", "<", "len", "(", "token_offsets", ")", "and", "token_offsets", "[", "end_index", "]", "[", "1", "]", "<", "character_span", "[", "1", "]", ":", "end_index", "+=", "1", "if", "end_index", "==", "start_index", "and", "token_offsets", "[", "end_index", "]", "[", "1", "]", ">", "character_span", "[", "1", "]", ":", "# Looks like there was a token that should have been split, like \"1854-1855\", where the", "# answer is \"1854\". We can't do much in this case, except keep the answer as the whole", "# token.", "logger", ".", "debug", "(", "\"Bad tokenization - end offset doesn't match\"", ")", "elif", "token_offsets", "[", "end_index", "]", "[", "1", "]", ">", "character_span", "[", "1", "]", ":", "# This is a case where the given answer span is more than one token, and the last token is", "# cut off for some reason, like \"split with Luckett and Rober\", when the original passage", "# said \"split with Luckett and Roberson\". In this case, we'll just keep the end index", "# where it is, and assume the intent was to mark the whole token.", "logger", ".", "debug", "(", "\"Bad labelling or tokenization - end offset doesn't match\"", ")", "if", "token_offsets", "[", "end_index", "]", "[", "1", "]", "!=", "character_span", "[", "1", "]", ":", "error", "=", "True", "return", "(", "start_index", ",", "end_index", ")", ",", "error" ]
Converts a character span from a passage into the corresponding token span in the tokenized version of the passage. If you pass in a character span that does not correspond to complete tokens in the tokenized version, we'll do our best, but the behavior is officially undefined. We return an error flag in this case, and have some debug logging so you can figure out the cause of this issue (in SQuAD, these are mostly either tokenization problems or annotation problems; there's a fair amount of both). The basic outline of this method is to find the token span that has the same offsets as the input character span. If the tokenizer tokenized the passage correctly and has matching offsets, this is easy. We try to be a little smart about cases where they don't match exactly, but mostly just find the closest thing we can. The returned ``(begin, end)`` indices are `inclusive` for both ``begin`` and ``end``. So, for example, ``(2, 2)`` is the one word span beginning at token index 2, ``(3, 4)`` is the two-word span beginning at token index 3, and so on. Returns ------- token_span : ``Tuple[int, int]`` `Inclusive` span start and end token indices that match as closely as possible to the input character spans. error : ``bool`` Whether the token spans match the input character spans exactly. If this is ``False``, it means there was an error in either the tokenization or the annotated character span.
[ "Converts", "a", "character", "span", "from", "a", "passage", "into", "the", "corresponding", "token", "span", "in", "the", "tokenized", "version", "of", "the", "passage", ".", "If", "you", "pass", "in", "a", "character", "span", "that", "does", "not", "correspond", "to", "complete", "tokens", "in", "the", "tokenized", "version", "we", "ll", "do", "our", "best", "but", "the", "behavior", "is", "officially", "undefined", ".", "We", "return", "an", "error", "flag", "in", "this", "case", "and", "have", "some", "debug", "logging", "so", "you", "can", "figure", "out", "the", "cause", "of", "this", "issue", "(", "in", "SQuAD", "these", "are", "mostly", "either", "tokenization", "problems", "or", "annotation", "problems", ";", "there", "s", "a", "fair", "amount", "of", "both", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/reading_comprehension/util.py#L36-L94
train
Converts a character span into a token span in the tokenized version.
Pu7Z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bej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\x6f' + chr(1147 - 1098) + '\x34' + chr(1306 - 1257), 31653 - 31645), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(54) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b11010 + 0o31) + chr(1036 - 988), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1000101 + 0o52) + chr(0b110011) + chr(2244 - 2190) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1011010 + 0o25) + '\063' + chr(0b1000 + 0o56) + chr(50), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(1048 - 999) + '\x34' + chr(0b1101 + 0o43), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + chr(51) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(674 - 626) + chr(0b1101111) + '\061' + chr(0b101101 + 0o7) + '\x36', 0b1000), ehT0Px3KOsy9(chr(1437 - 1389) + chr(0b1101111) + '\062' + chr(0b101 + 0o54) + chr(0b10101 + 0o41), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110011) + '\x33' + chr(0b110100), 41289 - 41281), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(0b110111 + 0o70) + chr(50) + chr(2161 - 2111) + chr(0b1000 + 0o52), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(49) + chr(0b110000 + 0o2) + '\x36', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(482 - 430) + chr(0b110001), 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(0b110010) + chr(2385 - 2336), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(0b1111 + 0o46) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(619 - 571) + chr(2450 - 2339) + chr(0b110010) + '\x36' + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1010 + 0o50) + chr(48) + chr(1829 - 1777), 0b1000), ehT0Px3KOsy9(chr(48) + chr(10720 - 10609) + '\x36' + '\x37', 8), ehT0Px3KOsy9(chr(364 - 316) + chr(111) + '\063' + chr(0b110111) + chr(0b110001), 36086 - 36078), ehT0Px3KOsy9(chr(1769 - 1721) + '\157' + chr(745 - 695) + chr(0b10 + 0o61) + '\062', 0o10), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b1101111) + chr(49) + '\067' + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\x6f' + chr(51) + chr(54) + '\x32', 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(55) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(111) + '\063' + chr(2023 - 1971) + '\x36', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(923 - 872) + chr(54), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(1916 - 1867) + chr(2058 - 2006) + '\067', 5821 - 5813), ehT0Px3KOsy9(chr(0b110000) + chr(4656 - 4545) + chr(0b110001) + chr(55) + '\x36', 0o10), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(0b1101111) + chr(0b100 + 0o57) + chr(184 - 135) + chr(52), 0o10), ehT0Px3KOsy9(chr(1831 - 1783) + '\x6f' + chr(0b101101 + 0o6) + chr(492 - 444) + chr(1246 - 1194), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\067' + chr(777 - 727), ord("\x08")), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101111) + chr(50) + chr(51) + chr(0b11101 + 0o30), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(0b110000 + 0o2) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(4432 - 4321) + chr(2446 - 2395) + '\065' + chr(55), 3408 - 3400), ehT0Px3KOsy9('\060' + chr(0b101000 + 0o107) + chr(443 - 394) + chr(1109 - 1054) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(952 - 904) + chr(0b1011110 + 0o21) + chr(2015 - 1966) + chr(0b10100 + 0o41) + chr(0b110001 + 0o6), 0b1000), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(0b1001 + 0o146) + '\062' + chr(60 - 9) + chr(0b100000 + 0o20), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b10101 + 0o132) + chr(0b100010 + 0o17) + chr(1098 - 1043) + '\064', 8), ehT0Px3KOsy9(chr(48) + chr(9637 - 9526) + '\063' + '\067', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(165 - 116) + chr(0b110101) + chr(649 - 600), 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(10387 - 10276) + chr(0b110011) + chr(0b110010) + chr(0b110100), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b110111 + 0o70) + chr(53) + chr(0b110000), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'O'), '\144' + chr(4792 - 4691) + chr(4175 - 4076) + '\157' + '\144' + chr(3823 - 3722))('\x75' + '\x74' + chr(6616 - 6514) + '\055' + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def x9IXzyxrjocS(W4ulLqe9Mit5, eaKgObNjm7N1) -> MRK8Uzg2En3D[MRK8Uzg2En3D[ehT0Px3KOsy9, ehT0Px3KOsy9], WbBjf8Y7v9VN]: EUdPatOS1wx0 = ehT0Px3KOsy9(chr(0b110000) + '\157' + '\060', 19145 - 19137) jrpEXfDZwQEA = ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(111) + '\x30', 8) while jrpEXfDZwQEA < c2A0yzQpDQB3(W4ulLqe9Mit5) and W4ulLqe9Mit5[jrpEXfDZwQEA][ehT0Px3KOsy9('\x30' + chr(0b101000 + 0o107) + chr(0b110000), 8)] < eaKgObNjm7N1[ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b100110 + 0o111) + '\060', 8)]: jrpEXfDZwQEA += ehT0Px3KOsy9('\060' + '\157' + chr(49), ord("\x08")) if W4ulLqe9Mit5[jrpEXfDZwQEA][ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\060', 8)] > eaKgObNjm7N1[ehT0Px3KOsy9('\060' + chr(9874 - 9763) + chr(0b1 + 0o57), 8)]: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x05Rz\x82\x95'), chr(0b1100100) + chr(101) + '\x63' + '\x6f' + '\x64' + chr(0b10 + 0o143))('\165' + '\164' + chr(102) + '\055' + chr(0b0 + 0o70)))(xafqLlk3kkUe(SXOLrMavuUCe(b'#V|\xd7\x9e\x01<\x03\xe2\xb0\xfb8\x06\xf1\x81\xc2\xa4C\x96\xf1\x1e\x9cU\x9c\x7f\x13\x17\xa3\xaa\x1a\xb0\xf2\x9c\x08\x0e\xea\x08?\x06\xb2\x07D}\x83\xd2\x041\x03\xfd\xb2\xb5"A\xbc\x8f\xc4\xe7_'), '\x64' + chr(101) + chr(99) + chr(5825 - 5714) + chr(0b110110 + 0o56) + '\145')('\165' + '\164' + chr(5738 - 5636) + '\x2d' + chr(1629 - 1573))) jrpEXfDZwQEA -= ehT0Px3KOsy9(chr(1402 - 1354) + chr(111) + '\061', 8) if W4ulLqe9Mit5[jrpEXfDZwQEA][ehT0Px3KOsy9('\x30' + '\x6f' + '\060', 8)] != eaKgObNjm7N1[ehT0Px3KOsy9('\x30' + chr(111) + '\x30', 8)]: EUdPatOS1wx0 = ehT0Px3KOsy9(chr(48) + '\157' + chr(1679 - 1630), 8) WjkykCmrXkZ6 = jrpEXfDZwQEA while WjkykCmrXkZ6 < c2A0yzQpDQB3(W4ulLqe9Mit5) and W4ulLqe9Mit5[WjkykCmrXkZ6][ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001), 8)] < eaKgObNjm7N1[ehT0Px3KOsy9('\060' + chr(0b111001 + 0o66) + chr(707 - 658), 8)]: WjkykCmrXkZ6 += ehT0Px3KOsy9(chr(1994 - 1946) + '\x6f' + '\x31', 8) if WjkykCmrXkZ6 == jrpEXfDZwQEA and W4ulLqe9Mit5[WjkykCmrXkZ6][ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(3379 - 3268) + chr(49), 8)] > eaKgObNjm7N1[ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(2009 - 1960), 8)]: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x05Rz\x82\x95'), chr(1143 - 1043) + chr(0b1100 + 0o131) + chr(6738 - 6639) + '\x6f' + chr(0b1100011 + 0o1) + '\145')('\x75' + '\164' + chr(0b1100110) + chr(690 - 645) + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'#V|\xd7\x86\x0f5\x03\xe0\xb5\xe87\x15\xb8\x81\xde\xa4\x1a\xd9\xff\x15\x96\x1c\x89x\x01\r\xa9\xb0\x1a\xf9\xbd\x8a\x0f\x01\xbf\x08?\x04\xb5\x15Tp'), '\x64' + '\145' + '\143' + '\157' + chr(0b1100100) + '\145')(chr(0b10101 + 0o140) + chr(116) + chr(5210 - 5108) + chr(370 - 325) + '\070')) elif W4ulLqe9Mit5[WjkykCmrXkZ6][ehT0Px3KOsy9('\060' + chr(0b1001011 + 0o44) + '\x31', 8)] > eaKgObNjm7N1[ehT0Px3KOsy9('\060' + '\x6f' + '\061', 8)]: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x05Rz\x82\x95'), '\144' + '\145' + chr(99) + '\157' + chr(0b1100100) + chr(0b1100101))(chr(0b1110101) + '\164' + chr(0b10011 + 0o123) + chr(45) + chr(0b110110 + 0o2)))(xafqLlk3kkUe(SXOLrMavuUCe(b'#V|\xd7\x9e\x01<\x03\xe2\xb0\xfb8\x06\xf1\x81\xc2\xa4C\x96\xf1\x1e\x9cU\x9c\x7f\x13\x17\xa3\xaa\x1a\xb0\xf2\x8a\x12\x0b\xb8\x13y\x0f\xa7\x04C8\x93\x9d\x05-\x08\xa9\xa8\xb2;\x00\xa5\x8d\xd8'), chr(0b1010110 + 0o16) + chr(0b1100100 + 0o1) + chr(99) + chr(0b11001 + 0o126) + chr(100) + chr(101))(chr(117) + chr(0b1110100) + chr(0b1001010 + 0o34) + chr(0b101101) + '\x38')) if W4ulLqe9Mit5[WjkykCmrXkZ6][ehT0Px3KOsy9('\060' + chr(111) + chr(49), 8)] != eaKgObNjm7N1[ehT0Px3KOsy9(chr(48) + '\x6f' + '\061', 8)]: EUdPatOS1wx0 = ehT0Px3KOsy9(chr(2288 - 2240) + '\x6f' + chr(0b110001), 8) return ((jrpEXfDZwQEA, WjkykCmrXkZ6), EUdPatOS1wx0)
allenai/allennlp
allennlp/data/dataset_readers/reading_comprehension/util.py
find_valid_answer_spans
def find_valid_answer_spans(passage_tokens: List[Token], answer_texts: List[str]) -> List[Tuple[int, int]]: """ Finds a list of token spans in ``passage_tokens`` that match the given ``answer_texts``. This tries to find all spans that would evaluate to correct given the SQuAD and TriviaQA official evaluation scripts, which do some normalization of the input text. Note that this could return duplicate spans! The caller is expected to be able to handle possible duplicates (as already happens in the SQuAD dev set, for instance). """ normalized_tokens = [token.text.lower().strip(STRIPPED_CHARACTERS) for token in passage_tokens] # Because there could be many `answer_texts`, we'll do the most expensive pre-processing # step once. This gives us a map from tokens to the position in the passage they appear. word_positions: Dict[str, List[int]] = defaultdict(list) for i, token in enumerate(normalized_tokens): word_positions[token].append(i) spans = [] for answer_text in answer_texts: # For each answer, we'll first find all valid start positions in the passage. Then # we'll grow each span to the same length as the number of answer tokens, and see if we # have a match. We're a little tricky as we grow the span, skipping words that are # already pruned from the normalized answer text, and stopping early if we don't match. answer_tokens = answer_text.lower().strip(STRIPPED_CHARACTERS).split() num_answer_tokens = len(answer_tokens) for span_start in word_positions[answer_tokens[0]]: span_end = span_start # span_end is _inclusive_ answer_index = 1 while answer_index < num_answer_tokens and span_end + 1 < len(normalized_tokens): token = normalized_tokens[span_end + 1] if answer_tokens[answer_index] == token: answer_index += 1 span_end += 1 elif token in IGNORED_TOKENS: span_end += 1 else: break if num_answer_tokens == answer_index: spans.append((span_start, span_end)) return spans
python
def find_valid_answer_spans(passage_tokens: List[Token], answer_texts: List[str]) -> List[Tuple[int, int]]: """ Finds a list of token spans in ``passage_tokens`` that match the given ``answer_texts``. This tries to find all spans that would evaluate to correct given the SQuAD and TriviaQA official evaluation scripts, which do some normalization of the input text. Note that this could return duplicate spans! The caller is expected to be able to handle possible duplicates (as already happens in the SQuAD dev set, for instance). """ normalized_tokens = [token.text.lower().strip(STRIPPED_CHARACTERS) for token in passage_tokens] # Because there could be many `answer_texts`, we'll do the most expensive pre-processing # step once. This gives us a map from tokens to the position in the passage they appear. word_positions: Dict[str, List[int]] = defaultdict(list) for i, token in enumerate(normalized_tokens): word_positions[token].append(i) spans = [] for answer_text in answer_texts: # For each answer, we'll first find all valid start positions in the passage. Then # we'll grow each span to the same length as the number of answer tokens, and see if we # have a match. We're a little tricky as we grow the span, skipping words that are # already pruned from the normalized answer text, and stopping early if we don't match. answer_tokens = answer_text.lower().strip(STRIPPED_CHARACTERS).split() num_answer_tokens = len(answer_tokens) for span_start in word_positions[answer_tokens[0]]: span_end = span_start # span_end is _inclusive_ answer_index = 1 while answer_index < num_answer_tokens and span_end + 1 < len(normalized_tokens): token = normalized_tokens[span_end + 1] if answer_tokens[answer_index] == token: answer_index += 1 span_end += 1 elif token in IGNORED_TOKENS: span_end += 1 else: break if num_answer_tokens == answer_index: spans.append((span_start, span_end)) return spans
[ "def", "find_valid_answer_spans", "(", "passage_tokens", ":", "List", "[", "Token", "]", ",", "answer_texts", ":", "List", "[", "str", "]", ")", "->", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", ":", "normalized_tokens", "=", "[", "token", ".", "text", ".", "lower", "(", ")", ".", "strip", "(", "STRIPPED_CHARACTERS", ")", "for", "token", "in", "passage_tokens", "]", "# Because there could be many `answer_texts`, we'll do the most expensive pre-processing", "# step once. This gives us a map from tokens to the position in the passage they appear.", "word_positions", ":", "Dict", "[", "str", ",", "List", "[", "int", "]", "]", "=", "defaultdict", "(", "list", ")", "for", "i", ",", "token", "in", "enumerate", "(", "normalized_tokens", ")", ":", "word_positions", "[", "token", "]", ".", "append", "(", "i", ")", "spans", "=", "[", "]", "for", "answer_text", "in", "answer_texts", ":", "# For each answer, we'll first find all valid start positions in the passage. Then", "# we'll grow each span to the same length as the number of answer tokens, and see if we", "# have a match. We're a little tricky as we grow the span, skipping words that are", "# already pruned from the normalized answer text, and stopping early if we don't match.", "answer_tokens", "=", "answer_text", ".", "lower", "(", ")", ".", "strip", "(", "STRIPPED_CHARACTERS", ")", ".", "split", "(", ")", "num_answer_tokens", "=", "len", "(", "answer_tokens", ")", "for", "span_start", "in", "word_positions", "[", "answer_tokens", "[", "0", "]", "]", ":", "span_end", "=", "span_start", "# span_end is _inclusive_", "answer_index", "=", "1", "while", "answer_index", "<", "num_answer_tokens", "and", "span_end", "+", "1", "<", "len", "(", "normalized_tokens", ")", ":", "token", "=", "normalized_tokens", "[", "span_end", "+", "1", "]", "if", "answer_tokens", "[", "answer_index", "]", "==", "token", ":", "answer_index", "+=", "1", "span_end", "+=", "1", "elif", "token", "in", "IGNORED_TOKENS", ":", "span_end", "+=", "1", "else", ":", "break", "if", "num_answer_tokens", "==", "answer_index", ":", "spans", ".", "append", "(", "(", "span_start", ",", "span_end", ")", ")", "return", "spans" ]
Finds a list of token spans in ``passage_tokens`` that match the given ``answer_texts``. This tries to find all spans that would evaluate to correct given the SQuAD and TriviaQA official evaluation scripts, which do some normalization of the input text. Note that this could return duplicate spans! The caller is expected to be able to handle possible duplicates (as already happens in the SQuAD dev set, for instance).
[ "Finds", "a", "list", "of", "token", "spans", "in", "passage_tokens", "that", "match", "the", "given", "answer_texts", ".", "This", "tries", "to", "find", "all", "spans", "that", "would", "evaluate", "to", "correct", "given", "the", "SQuAD", "and", "TriviaQA", "official", "evaluation", "scripts", "which", "do", "some", "normalization", "of", "the", "input", "text", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/reading_comprehension/util.py#L97-L135
train
Finds a list of token spans in passage_tokens that match the given answer_texts.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1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C7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + '\x33' + chr(1845 - 1794), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + '\x35' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\157' + '\x33' + '\064' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11001 + 0o32) + '\060' + '\064', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\x36' + chr(0b10010 + 0o37), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + '\x30' + chr(1552 - 1498), 32928 - 32920), ehT0Px3KOsy9(chr(739 - 691) + '\x6f' + chr(2258 - 2209) + chr(51) + chr(2695 - 2643), 0o10), ehT0Px3KOsy9('\x30' + chr(6595 - 6484) + '\x31' + chr(0b110100) + chr(0b11110 + 0o25), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b100 + 0o56) + chr(0b110100) + chr(48), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + chr(0b10000 + 0o46) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(111) + '\065' + chr(0b1000 + 0o57), 36129 - 36121), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10000 + 0o42) + chr(0b110001) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(3777 - 3666) + chr(51) + chr(0b101011 + 0o13), ord("\x08")), ehT0Px3KOsy9(chr(0b1 + 0o57) + '\x6f' + '\x31' + chr(53) + '\067', 0b1000), ehT0Px3KOsy9(chr(1278 - 1230) + chr(111) + '\063' + chr(0b110110) + chr(0b110 + 0o55), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(749 - 700) + '\065' + chr(53), 8), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\157' + chr(0b110001) + chr(2412 - 2360) + '\066', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110011) + chr(0b100111 + 0o14) + chr(0b110000), 8709 - 8701), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(4716 - 4605) + '\x32' + chr(0b10010 + 0o45) + '\066', 0o10), ehT0Px3KOsy9(chr(1715 - 1667) + chr(4334 - 4223) + chr(66 - 15) + chr(0b110111) + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + '\066' + chr(1884 - 1833), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(49) + chr(0b110111) + chr(0b101010 + 0o7), 50396 - 50388), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(2491 - 2440) + '\x35' + chr(0b11000 + 0o35), 637 - 629), ehT0Px3KOsy9(chr(845 - 797) + '\157' + chr(51) + chr(604 - 556) + '\062', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\x34' + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(51) + chr(0b11110 + 0o31) + chr(0b110101), 44760 - 44752), ehT0Px3KOsy9(chr(2248 - 2200) + chr(111) + chr(51) + chr(1765 - 1713) + '\x36', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(0b100101 + 0o14) + chr(0b110010), 29899 - 29891), ehT0Px3KOsy9(chr(394 - 346) + chr(0b1001100 + 0o43) + '\061' + chr(0b101110 + 0o6) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(1153 - 1105) + chr(0b1101111) + '\x33' + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(7890 - 7779) + chr(0b100010 + 0o21) + chr(52) + '\x32', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1011 + 0o144) + chr(1853 - 1800) + '\x37', 8), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + '\x33' + '\x33', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1000110 + 0o51) + chr(0b110011) + chr(1609 - 1558) + chr(48), 8), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(0b1010010 + 0o35) + '\061' + chr(0b110111) + '\064', 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + '\067', 53263 - 53255), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(0b10001 + 0o46), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b10001 + 0o40) + chr(2275 - 2226) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + chr(1001 - 890) + chr(50) + chr(0b110111) + chr(0b110010 + 0o2), 12930 - 12922), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b100110 + 0o13) + '\x34' + chr(0b110001), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1308 - 1260) + chr(111) + chr(0b110010 + 0o3) + '\060', 64480 - 64472)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'5'), '\x64' + chr(0b1001100 + 0o31) + chr(0b1100011) + '\157' + chr(0b1100100) + chr(0b1100101))(chr(7727 - 7610) + '\x74' + chr(0b101100 + 0o72) + '\x2d' + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def W8On4Qsa8jWx(G5DiCHakuupP, zMl0ipK0tYea) -> qRxF7OQ0y39T[MRK8Uzg2En3D[ehT0Px3KOsy9, ehT0Px3KOsy9]]: qoeLlP0eHdWg = [mTy3fac_AqJ5.text.lower().strip(r8tsfoTkseiV) for mTy3fac_AqJ5 in G5DiCHakuupP] dWhlPDZ9ZemT = rLgqW9imlCdX(YyaZ4tpXu4lf) for (WVxHKyX45z_L, mTy3fac_AqJ5) in YlkZvXL8qwsX(qoeLlP0eHdWg): xafqLlk3kkUe(dWhlPDZ9ZemT[mTy3fac_AqJ5], xafqLlk3kkUe(SXOLrMavuUCe(b'z\x1d\x97\xa1_"'), chr(0b111 + 0o135) + '\x65' + chr(0b1100011) + chr(0b1101111) + chr(100) + '\x65')(chr(0b1110101) + chr(0b1110100) + chr(0b1010101 + 0o21) + chr(0b11001 + 0o24) + chr(0b1100 + 0o54)))(WVxHKyX45z_L) aPSH2X7oF0wS = [] for BPGA4eIvPpcn in zMl0ipK0tYea: T8ynjhL4YNnY = BPGA4eIvPpcn.lower().strip(r8tsfoTkseiV).split() q3XZMw2zLu3S = c2A0yzQpDQB3(T8ynjhL4YNnY) for CGzUSvlyKBQD in dWhlPDZ9ZemT[T8ynjhL4YNnY[ehT0Px3KOsy9(chr(1938 - 1890) + chr(0b1101111) + chr(0b101001 + 0o7), 0b1000)]]: b5O2oQPg9Xzq = CGzUSvlyKBQD OU8xOysdp8GD = ehT0Px3KOsy9(chr(48) + '\x6f' + chr(49), 5022 - 5014) while OU8xOysdp8GD < q3XZMw2zLu3S and b5O2oQPg9Xzq + ehT0Px3KOsy9('\060' + chr(0b111010 + 0o65) + chr(1967 - 1918), 8) < c2A0yzQpDQB3(qoeLlP0eHdWg): mTy3fac_AqJ5 = qoeLlP0eHdWg[b5O2oQPg9Xzq + ehT0Px3KOsy9(chr(2060 - 2012) + chr(0b1101 + 0o142) + chr(0b100100 + 0o15), 8)] if T8ynjhL4YNnY[OU8xOysdp8GD] == mTy3fac_AqJ5: OU8xOysdp8GD += ehT0Px3KOsy9(chr(48) + chr(9533 - 9422) + '\061', 8) b5O2oQPg9Xzq += ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110001), 8) elif mTy3fac_AqJ5 in n7anaSAgIlFL: b5O2oQPg9Xzq += ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110001), 8) else: break if q3XZMw2zLu3S == OU8xOysdp8GD: xafqLlk3kkUe(aPSH2X7oF0wS, xafqLlk3kkUe(SXOLrMavuUCe(b'z\x1d\x97\xa1_"'), '\x64' + chr(0b1100101) + chr(0b1010 + 0o131) + chr(0b1101111) + '\x64' + chr(7170 - 7069))(chr(117) + chr(0b1110100) + '\x66' + chr(0b101101) + chr(0b111000)))((CGzUSvlyKBQD, b5O2oQPg9Xzq)) return aPSH2X7oF0wS
allenai/allennlp
allennlp/data/dataset_readers/reading_comprehension/util.py
make_reading_comprehension_instance
def make_reading_comprehension_instance(question_tokens: List[Token], passage_tokens: List[Token], token_indexers: Dict[str, TokenIndexer], passage_text: str, token_spans: List[Tuple[int, int]] = None, answer_texts: List[str] = None, additional_metadata: Dict[str, Any] = None) -> Instance: """ Converts a question, a passage, and an optional answer (or answers) to an ``Instance`` for use in a reading comprehension model. Creates an ``Instance`` with at least these fields: ``question`` and ``passage``, both ``TextFields``; and ``metadata``, a ``MetadataField``. Additionally, if both ``answer_texts`` and ``char_span_starts`` are given, the ``Instance`` has ``span_start`` and ``span_end`` fields, which are both ``IndexFields``. Parameters ---------- question_tokens : ``List[Token]`` An already-tokenized question. passage_tokens : ``List[Token]`` An already-tokenized passage that contains the answer to the given question. token_indexers : ``Dict[str, TokenIndexer]`` Determines how the question and passage ``TextFields`` will be converted into tensors that get input to a model. See :class:`TokenIndexer`. passage_text : ``str`` The original passage text. We need this so that we can recover the actual span from the original passage that the model predicts as the answer to the question. This is used in official evaluation scripts. token_spans : ``List[Tuple[int, int]]``, optional Indices into ``passage_tokens`` to use as the answer to the question for training. This is a list because there might be several possible correct answer spans in the passage. Currently, we just select the most frequent span in this list (i.e., SQuAD has multiple annotations on the dev set; this will select the span that the most annotators gave as correct). answer_texts : ``List[str]``, optional All valid answer strings for the given question. In SQuAD, e.g., the training set has exactly one answer per question, but the dev and test sets have several. TriviaQA has many possible answers, which are the aliases for the known correct entity. This is put into the metadata for use with official evaluation scripts, but not used anywhere else. additional_metadata : ``Dict[str, Any]``, optional The constructed ``metadata`` field will by default contain ``original_passage``, ``token_offsets``, ``question_tokens``, ``passage_tokens``, and ``answer_texts`` keys. If you want any other metadata to be associated with each instance, you can pass that in here. This dictionary will get added to the ``metadata`` dictionary we already construct. """ additional_metadata = additional_metadata or {} fields: Dict[str, Field] = {} passage_offsets = [(token.idx, token.idx + len(token.text)) for token in passage_tokens] # This is separate so we can reference it later with a known type. passage_field = TextField(passage_tokens, token_indexers) fields['passage'] = passage_field fields['question'] = TextField(question_tokens, token_indexers) metadata = {'original_passage': passage_text, 'token_offsets': passage_offsets, 'question_tokens': [token.text for token in question_tokens], 'passage_tokens': [token.text for token in passage_tokens], } if answer_texts: metadata['answer_texts'] = answer_texts if token_spans: # There may be multiple answer annotations, so we pick the one that occurs the most. This # only matters on the SQuAD dev set, and it means our computed metrics ("start_acc", # "end_acc", and "span_acc") aren't quite the same as the official metrics, which look at # all of the annotations. This is why we have a separate official SQuAD metric calculation # (the "em" and "f1" metrics use the official script). candidate_answers: Counter = Counter() for span_start, span_end in token_spans: candidate_answers[(span_start, span_end)] += 1 span_start, span_end = candidate_answers.most_common(1)[0][0] fields['span_start'] = IndexField(span_start, passage_field) fields['span_end'] = IndexField(span_end, passage_field) metadata.update(additional_metadata) fields['metadata'] = MetadataField(metadata) return Instance(fields)
python
def make_reading_comprehension_instance(question_tokens: List[Token], passage_tokens: List[Token], token_indexers: Dict[str, TokenIndexer], passage_text: str, token_spans: List[Tuple[int, int]] = None, answer_texts: List[str] = None, additional_metadata: Dict[str, Any] = None) -> Instance: """ Converts a question, a passage, and an optional answer (or answers) to an ``Instance`` for use in a reading comprehension model. Creates an ``Instance`` with at least these fields: ``question`` and ``passage``, both ``TextFields``; and ``metadata``, a ``MetadataField``. Additionally, if both ``answer_texts`` and ``char_span_starts`` are given, the ``Instance`` has ``span_start`` and ``span_end`` fields, which are both ``IndexFields``. Parameters ---------- question_tokens : ``List[Token]`` An already-tokenized question. passage_tokens : ``List[Token]`` An already-tokenized passage that contains the answer to the given question. token_indexers : ``Dict[str, TokenIndexer]`` Determines how the question and passage ``TextFields`` will be converted into tensors that get input to a model. See :class:`TokenIndexer`. passage_text : ``str`` The original passage text. We need this so that we can recover the actual span from the original passage that the model predicts as the answer to the question. This is used in official evaluation scripts. token_spans : ``List[Tuple[int, int]]``, optional Indices into ``passage_tokens`` to use as the answer to the question for training. This is a list because there might be several possible correct answer spans in the passage. Currently, we just select the most frequent span in this list (i.e., SQuAD has multiple annotations on the dev set; this will select the span that the most annotators gave as correct). answer_texts : ``List[str]``, optional All valid answer strings for the given question. In SQuAD, e.g., the training set has exactly one answer per question, but the dev and test sets have several. TriviaQA has many possible answers, which are the aliases for the known correct entity. This is put into the metadata for use with official evaluation scripts, but not used anywhere else. additional_metadata : ``Dict[str, Any]``, optional The constructed ``metadata`` field will by default contain ``original_passage``, ``token_offsets``, ``question_tokens``, ``passage_tokens``, and ``answer_texts`` keys. If you want any other metadata to be associated with each instance, you can pass that in here. This dictionary will get added to the ``metadata`` dictionary we already construct. """ additional_metadata = additional_metadata or {} fields: Dict[str, Field] = {} passage_offsets = [(token.idx, token.idx + len(token.text)) for token in passage_tokens] # This is separate so we can reference it later with a known type. passage_field = TextField(passage_tokens, token_indexers) fields['passage'] = passage_field fields['question'] = TextField(question_tokens, token_indexers) metadata = {'original_passage': passage_text, 'token_offsets': passage_offsets, 'question_tokens': [token.text for token in question_tokens], 'passage_tokens': [token.text for token in passage_tokens], } if answer_texts: metadata['answer_texts'] = answer_texts if token_spans: # There may be multiple answer annotations, so we pick the one that occurs the most. This # only matters on the SQuAD dev set, and it means our computed metrics ("start_acc", # "end_acc", and "span_acc") aren't quite the same as the official metrics, which look at # all of the annotations. This is why we have a separate official SQuAD metric calculation # (the "em" and "f1" metrics use the official script). candidate_answers: Counter = Counter() for span_start, span_end in token_spans: candidate_answers[(span_start, span_end)] += 1 span_start, span_end = candidate_answers.most_common(1)[0][0] fields['span_start'] = IndexField(span_start, passage_field) fields['span_end'] = IndexField(span_end, passage_field) metadata.update(additional_metadata) fields['metadata'] = MetadataField(metadata) return Instance(fields)
[ "def", "make_reading_comprehension_instance", "(", "question_tokens", ":", "List", "[", "Token", "]", ",", "passage_tokens", ":", "List", "[", "Token", "]", ",", "token_indexers", ":", "Dict", "[", "str", ",", "TokenIndexer", "]", ",", "passage_text", ":", "str", ",", "token_spans", ":", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", "=", "None", ",", "answer_texts", ":", "List", "[", "str", "]", "=", "None", ",", "additional_metadata", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ")", "->", "Instance", ":", "additional_metadata", "=", "additional_metadata", "or", "{", "}", "fields", ":", "Dict", "[", "str", ",", "Field", "]", "=", "{", "}", "passage_offsets", "=", "[", "(", "token", ".", "idx", ",", "token", ".", "idx", "+", "len", "(", "token", ".", "text", ")", ")", "for", "token", "in", "passage_tokens", "]", "# This is separate so we can reference it later with a known type.", "passage_field", "=", "TextField", "(", "passage_tokens", ",", "token_indexers", ")", "fields", "[", "'passage'", "]", "=", "passage_field", "fields", "[", "'question'", "]", "=", "TextField", "(", "question_tokens", ",", "token_indexers", ")", "metadata", "=", "{", "'original_passage'", ":", "passage_text", ",", "'token_offsets'", ":", "passage_offsets", ",", "'question_tokens'", ":", "[", "token", ".", "text", "for", "token", "in", "question_tokens", "]", ",", "'passage_tokens'", ":", "[", "token", ".", "text", "for", "token", "in", "passage_tokens", "]", ",", "}", "if", "answer_texts", ":", "metadata", "[", "'answer_texts'", "]", "=", "answer_texts", "if", "token_spans", ":", "# There may be multiple answer annotations, so we pick the one that occurs the most. This", "# only matters on the SQuAD dev set, and it means our computed metrics (\"start_acc\",", "# \"end_acc\", and \"span_acc\") aren't quite the same as the official metrics, which look at", "# all of the annotations. This is why we have a separate official SQuAD metric calculation", "# (the \"em\" and \"f1\" metrics use the official script).", "candidate_answers", ":", "Counter", "=", "Counter", "(", ")", "for", "span_start", ",", "span_end", "in", "token_spans", ":", "candidate_answers", "[", "(", "span_start", ",", "span_end", ")", "]", "+=", "1", "span_start", ",", "span_end", "=", "candidate_answers", ".", "most_common", "(", "1", ")", "[", "0", "]", "[", "0", "]", "fields", "[", "'span_start'", "]", "=", "IndexField", "(", "span_start", ",", "passage_field", ")", "fields", "[", "'span_end'", "]", "=", "IndexField", "(", "span_end", ",", "passage_field", ")", "metadata", ".", "update", "(", "additional_metadata", ")", "fields", "[", "'metadata'", "]", "=", "MetadataField", "(", "metadata", ")", "return", "Instance", "(", "fields", ")" ]
Converts a question, a passage, and an optional answer (or answers) to an ``Instance`` for use in a reading comprehension model. Creates an ``Instance`` with at least these fields: ``question`` and ``passage``, both ``TextFields``; and ``metadata``, a ``MetadataField``. Additionally, if both ``answer_texts`` and ``char_span_starts`` are given, the ``Instance`` has ``span_start`` and ``span_end`` fields, which are both ``IndexFields``. Parameters ---------- question_tokens : ``List[Token]`` An already-tokenized question. passage_tokens : ``List[Token]`` An already-tokenized passage that contains the answer to the given question. token_indexers : ``Dict[str, TokenIndexer]`` Determines how the question and passage ``TextFields`` will be converted into tensors that get input to a model. See :class:`TokenIndexer`. passage_text : ``str`` The original passage text. We need this so that we can recover the actual span from the original passage that the model predicts as the answer to the question. This is used in official evaluation scripts. token_spans : ``List[Tuple[int, int]]``, optional Indices into ``passage_tokens`` to use as the answer to the question for training. This is a list because there might be several possible correct answer spans in the passage. Currently, we just select the most frequent span in this list (i.e., SQuAD has multiple annotations on the dev set; this will select the span that the most annotators gave as correct). answer_texts : ``List[str]``, optional All valid answer strings for the given question. In SQuAD, e.g., the training set has exactly one answer per question, but the dev and test sets have several. TriviaQA has many possible answers, which are the aliases for the known correct entity. This is put into the metadata for use with official evaluation scripts, but not used anywhere else. additional_metadata : ``Dict[str, Any]``, optional The constructed ``metadata`` field will by default contain ``original_passage``, ``token_offsets``, ``question_tokens``, ``passage_tokens``, and ``answer_texts`` keys. If you want any other metadata to be associated with each instance, you can pass that in here. This dictionary will get added to the ``metadata`` dictionary we already construct.
[ "Converts", "a", "question", "a", "passage", "and", "an", "optional", "answer", "(", "or", "answers", ")", "to", "an", "Instance", "for", "use", "in", "a", "reading", "comprehension", "model", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/reading_comprehension/util.py#L138-L214
train
Converts a list of tokens into a reading comprehension instance.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ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84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(0b1010000 + 0o37) + chr(0b110001) + '\063' + chr(2094 - 2039), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110111) + chr(223 - 172), 0o10), ehT0Px3KOsy9(chr(664 - 616) + chr(0b1010 + 0o145) + chr(50) + chr(0b110100) + '\060', 52401 - 52393), ehT0Px3KOsy9(chr(0b110000) + chr(3697 - 3586) + chr(0b1111 + 0o46) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(54) + chr(0b110010 + 0o5), 41871 - 41863), ehT0Px3KOsy9('\x30' + '\157' + chr(0b1000 + 0o53) + chr(48) + chr(0b110101), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1001 + 0o146) + chr(51) + chr(0b10100 + 0o40) + '\x36', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110011) + chr(55) + chr(0b11010 + 0o27), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + '\x32' + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(1206 - 1095) + '\062' + chr(48) + '\x37', 0b1000), ehT0Px3KOsy9(chr(691 - 643) + chr(0b101011 + 0o104) + chr(52) + chr(55), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + '\063' + chr(302 - 250), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1001110 + 0o41) + '\062' + chr(0b110011), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(2256 - 2206) + '\x30' + chr(0b101001 + 0o16), 8), ehT0Px3KOsy9(chr(469 - 421) + chr(2162 - 2051) + chr(0b110001) + chr(0b100001 + 0o20) + chr(0b1011 + 0o47), 65447 - 65439), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b1101111) + chr(2379 - 2327) + '\064', 0o10), ehT0Px3KOsy9(chr(1972 - 1924) + chr(0b1101111) + chr(49) + chr(363 - 312) + chr(2258 - 2205), 40717 - 40709), ehT0Px3KOsy9(chr(51 - 3) + chr(0b1101111) + chr(49) + '\067' + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(471 - 423) + '\157' + chr(0b1101 + 0o46) + chr(0b1 + 0o57) + chr(2120 - 2072), 16514 - 16506), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(0b110001 + 0o0) + '\x36', 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\063' + '\064', 0o10), ehT0Px3KOsy9(chr(474 - 426) + chr(0b1101000 + 0o7) + chr(0b110010) + chr(0b110100) + '\x30', 8), ehT0Px3KOsy9('\x30' + chr(0b1101 + 0o142) + '\062' + chr(0b100100 + 0o14) + '\067', 8), ehT0Px3KOsy9('\060' + chr(0b1011111 + 0o20) + chr(49) + chr(53) + chr(428 - 374), 1500 - 1492), ehT0Px3KOsy9('\x30' + chr(0b1100110 + 0o11) + '\x37' + chr(0b110110), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + chr(49) + chr(53), 12221 - 12213), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000111 + 0o50) + chr(0b110001) + chr(2364 - 2312) + '\x32', 4338 - 4330), ehT0Px3KOsy9(chr(226 - 178) + chr(0b1101111) + '\062' + chr(52) + chr(1408 - 1356), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b100010 + 0o25) + '\062', 47777 - 47769), ehT0Px3KOsy9(chr(574 - 526) + chr(0b1101111) + '\062' + chr(0b1110 + 0o42) + chr(54), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + '\x31' + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(9438 - 9327) + chr(0b101 + 0o55) + chr(349 - 300) + '\x35', 8), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + chr(136 - 82) + chr(49), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + chr(54) + chr(54), 0b1000), ehT0Px3KOsy9(chr(715 - 667) + '\157' + chr(2461 - 2411) + chr(0b101101 + 0o12), 40354 - 40346), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(49) + '\064' + chr(429 - 375), 0o10), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(111) + '\x32' + chr(49), 87 - 79), ehT0Px3KOsy9(chr(48) + '\157' + chr(54) + '\x33', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110001) + chr(55) + chr(1615 - 1562), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(910 - 860) + '\x34' + chr(49), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\157' + chr(233 - 180) + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'q'), chr(0b1100100) + chr(0b1001101 + 0o30) + '\143' + chr(111) + chr(0b100101 + 0o77) + chr(5477 - 5376))(chr(0b101 + 0o160) + chr(8478 - 8362) + chr(102) + chr(81 - 36) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def ZaV3lPYDvaZX(yHVya2HrNXZM, G5DiCHakuupP, HhKJnSagy0bW, o23UUTrQniSz, CFtm_LgpLjy0=None, zMl0ipK0tYea=None, aVcqhET1qeNF=None) -> _jFYXBmhzM0H: aVcqhET1qeNF = aVcqhET1qeNF or {} _yavFU6VJ0wY = {} QVc0DMim8Z90 = [(mTy3fac_AqJ5.YlqusYB6InkM, mTy3fac_AqJ5.YlqusYB6InkM + c2A0yzQpDQB3(mTy3fac_AqJ5.Ah1rInvg48Hb)) for mTy3fac_AqJ5 in G5DiCHakuupP] dUeGDvbfM9fr = OnNQjiI53xqc(G5DiCHakuupP, HhKJnSagy0bW) _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'/Z\xd3YV\xa2\x83'), chr(100) + '\145' + '\x63' + chr(0b1101111) + chr(100) + chr(0b1100101))(chr(1150 - 1033) + '\x74' + chr(9073 - 8971) + chr(45) + chr(0b110010 + 0o6))] = dUeGDvbfM9fr _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'.N\xc5YC\xac\x89\x97'), chr(0b1000111 + 0o35) + '\x65' + chr(99) + '\x6f' + chr(0b0 + 0o144) + chr(9778 - 9677))(chr(0b10000 + 0o145) + '\x74' + chr(0b1001010 + 0o34) + chr(543 - 498) + chr(56))] = OnNQjiI53xqc(yHVya2HrNXZM, HhKJnSagy0bW) mU7wOAGoTnlM = {xafqLlk3kkUe(SXOLrMavuUCe(b'0I\xc9M^\xab\x87\x95\xc9\xf7F/`\xe6-A'), '\x64' + chr(0b1100101) + chr(99) + chr(111) + chr(0b110001 + 0o63) + chr(0b111111 + 0o46))(chr(0b1110 + 0o147) + '\x74' + '\x66' + chr(45) + chr(0b100100 + 0o24)): o23UUTrQniSz, xafqLlk3kkUe(SXOLrMavuUCe(b'+T\xcbOY\x9a\x89\x9f\xf0\xf4B(`'), chr(0b1000000 + 0o44) + chr(0b1100101) + chr(99) + chr(0b11100 + 0o123) + chr(0b1100100) + chr(0b1100101))(chr(117) + '\164' + chr(0b1100110) + '\x2d' + chr(0b11 + 0o65)): QVc0DMim8Z90, xafqLlk3kkUe(SXOLrMavuUCe(b'.N\xc5YC\xac\x89\x97\xc9\xf3H7v\xe99'), chr(100) + chr(0b110010 + 0o63) + chr(0b1100011) + chr(0b1101111) + chr(0b1100100) + chr(0b1100101))(chr(0b1010101 + 0o40) + chr(0b1011001 + 0o33) + chr(102) + '\x2d' + chr(0b1010 + 0o56)): [mTy3fac_AqJ5.Ah1rInvg48Hb for mTy3fac_AqJ5 in yHVya2HrNXZM], xafqLlk3kkUe(SXOLrMavuUCe(b'/Z\xd3YV\xa2\x83\xa6\xe2\xe8L9}\xf4'), chr(0b111111 + 0o45) + '\x65' + chr(0b111110 + 0o45) + chr(0b101101 + 0o102) + chr(0b1000000 + 0o44) + '\145')(chr(13118 - 13001) + '\x74' + '\146' + chr(405 - 360) + chr(0b111000)): [mTy3fac_AqJ5.Ah1rInvg48Hb for mTy3fac_AqJ5 in G5DiCHakuupP]} if zMl0ipK0tYea: mU7wOAGoTnlM[xafqLlk3kkUe(SXOLrMavuUCe(b'>U\xd3]R\xb7\xb9\x8d\xf3\xffS/'), '\x64' + '\145' + chr(99) + '\x6f' + '\x64' + chr(4387 - 4286))(chr(117) + chr(3236 - 3120) + chr(0b1100110) + '\055' + chr(1566 - 1510))] = zMl0ipK0tYea if CFtm_LgpLjy0: Gyu2eoK4DUN0 = T75YCkBBa7BE() for (CGzUSvlyKBQD, b5O2oQPg9Xzq) in CFtm_LgpLjy0: Gyu2eoK4DUN0[CGzUSvlyKBQD, b5O2oQPg9Xzq] += ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x31', 0o10) (CGzUSvlyKBQD, b5O2oQPg9Xzq) = Gyu2eoK4DUN0.most_common(ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1040 - 991), 8))[ehT0Px3KOsy9(chr(48) + '\x6f' + chr(48), 0o10)][ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(111) + chr(0b110000), 8)] _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b',K\xc1Dh\xb6\x92\x98\xe4\xf3'), chr(892 - 792) + chr(1552 - 1451) + '\x63' + chr(0b1101111) + chr(8844 - 8744) + chr(101))(chr(0b1110101) + chr(0b1110100) + '\x66' + chr(936 - 891) + chr(0b101110 + 0o12))] = t7JPS4qvikx6(CGzUSvlyKBQD, dUeGDvbfM9fr) _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b',K\xc1Dh\xa0\x88\x9d'), chr(100) + chr(7615 - 7514) + chr(0b1000011 + 0o40) + chr(0b1101111) + chr(3027 - 2927) + chr(101))(chr(9106 - 8989) + chr(12151 - 12035) + chr(102) + '\x2d' + '\x38')] = t7JPS4qvikx6(b5O2oQPg9Xzq, dUeGDvbfM9fr) xafqLlk3kkUe(mU7wOAGoTnlM, xafqLlk3kkUe(SXOLrMavuUCe(b'\x05O\xe1o^\x8b\xac\x97\xef\xb3Bl'), '\144' + '\145' + chr(0b0 + 0o143) + chr(0b1101111) + chr(0b1001 + 0o133) + chr(0b1100101))('\x75' + chr(0b1110100) + '\x66' + '\x2d' + chr(0b111000)))(aVcqhET1qeNF) _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'2^\xd4KS\xa4\x92\x98'), chr(100) + chr(0b1100101) + chr(99) + chr(4393 - 4282) + '\144' + chr(1590 - 1489))(chr(117) + '\164' + chr(102) + '\x2d' + chr(1530 - 1474))] = t6SYWO6Og436(mU7wOAGoTnlM) return _jFYXBmhzM0H(_yavFU6VJ0wY)
allenai/allennlp
allennlp/data/dataset_readers/reading_comprehension/util.py
make_reading_comprehension_instance_quac
def make_reading_comprehension_instance_quac(question_list_tokens: List[List[Token]], passage_tokens: List[Token], token_indexers: Dict[str, TokenIndexer], passage_text: str, token_span_lists: List[List[Tuple[int, int]]] = None, yesno_list: List[int] = None, followup_list: List[int] = None, additional_metadata: Dict[str, Any] = None, num_context_answers: int = 0) -> Instance: """ Converts a question, a passage, and an optional answer (or answers) to an ``Instance`` for use in a reading comprehension model. Creates an ``Instance`` with at least these fields: ``question`` and ``passage``, both ``TextFields``; and ``metadata``, a ``MetadataField``. Additionally, if both ``answer_texts`` and ``char_span_starts`` are given, the ``Instance`` has ``span_start`` and ``span_end`` fields, which are both ``IndexFields``. Parameters ---------- question_list_tokens : ``List[List[Token]]`` An already-tokenized list of questions. Each dialog have multiple questions. passage_tokens : ``List[Token]`` An already-tokenized passage that contains the answer to the given question. token_indexers : ``Dict[str, TokenIndexer]`` Determines how the question and passage ``TextFields`` will be converted into tensors that get input to a model. See :class:`TokenIndexer`. passage_text : ``str`` The original passage text. We need this so that we can recover the actual span from the original passage that the model predicts as the answer to the question. This is used in official evaluation scripts. token_span_lists : ``List[List[Tuple[int, int]]]``, optional Indices into ``passage_tokens`` to use as the answer to the question for training. This is a list of list, first because there is multiple questions per dialog, and because there might be several possible correct answer spans in the passage. Currently, we just select the last span in this list (i.e., QuAC has multiple annotations on the dev set; this will select the last span, which was given by the original annotator). yesno_list : ``List[int]`` List of the affirmation bit for each question answer pairs. followup_list : ``List[int]`` List of the continuation bit for each question answer pairs. num_context_answers : ``int``, optional How many answers to encode into the passage. additional_metadata : ``Dict[str, Any]``, optional The constructed ``metadata`` field will by default contain ``original_passage``, ``token_offsets``, ``question_tokens``, ``passage_tokens``, and ``answer_texts`` keys. If you want any other metadata to be associated with each instance, you can pass that in here. This dictionary will get added to the ``metadata`` dictionary we already construct. """ additional_metadata = additional_metadata or {} fields: Dict[str, Field] = {} passage_offsets = [(token.idx, token.idx + len(token.text)) for token in passage_tokens] # This is separate so we can reference it later with a known type. passage_field = TextField(passage_tokens, token_indexers) fields['passage'] = passage_field fields['question'] = ListField([TextField(q_tokens, token_indexers) for q_tokens in question_list_tokens]) metadata = {'original_passage': passage_text, 'token_offsets': passage_offsets, 'question_tokens': [[token.text for token in question_tokens] \ for question_tokens in question_list_tokens], 'passage_tokens': [token.text for token in passage_tokens], } p1_answer_marker_list: List[Field] = [] p2_answer_marker_list: List[Field] = [] p3_answer_marker_list: List[Field] = [] def get_tag(i, i_name): # Generate a tag to mark previous answer span in the passage. return "<{0:d}_{1:s}>".format(i, i_name) def mark_tag(span_start, span_end, passage_tags, prev_answer_distance): try: assert span_start >= 0 assert span_end >= 0 except: raise ValueError("Previous {0:d}th answer span should have been updated!".format(prev_answer_distance)) # Modify "tags" to mark previous answer span. if span_start == span_end: passage_tags[prev_answer_distance][span_start] = get_tag(prev_answer_distance, "") else: passage_tags[prev_answer_distance][span_start] = get_tag(prev_answer_distance, "start") passage_tags[prev_answer_distance][span_end] = get_tag(prev_answer_distance, "end") for passage_index in range(span_start + 1, span_end): passage_tags[prev_answer_distance][passage_index] = get_tag(prev_answer_distance, "in") if token_span_lists: span_start_list: List[Field] = [] span_end_list: List[Field] = [] p1_span_start, p1_span_end, p2_span_start = -1, -1, -1 p2_span_end, p3_span_start, p3_span_end = -1, -1, -1 # Looping each <<answers>>. for question_index, answer_span_lists in enumerate(token_span_lists): span_start, span_end = answer_span_lists[-1] # Last one is the original answer span_start_list.append(IndexField(span_start, passage_field)) span_end_list.append(IndexField(span_end, passage_field)) prev_answer_marker_lists = [["O"] * len(passage_tokens), ["O"] * len(passage_tokens), ["O"] * len(passage_tokens), ["O"] * len(passage_tokens)] if question_index > 0 and num_context_answers > 0: mark_tag(p1_span_start, p1_span_end, prev_answer_marker_lists, 1) if question_index > 1 and num_context_answers > 1: mark_tag(p2_span_start, p2_span_end, prev_answer_marker_lists, 2) if question_index > 2 and num_context_answers > 2: mark_tag(p3_span_start, p3_span_end, prev_answer_marker_lists, 3) p3_span_start = p2_span_start p3_span_end = p2_span_end p2_span_start = p1_span_start p2_span_end = p1_span_end p1_span_start = span_start p1_span_end = span_end if num_context_answers > 2: p3_answer_marker_list.append(SequenceLabelField(prev_answer_marker_lists[3], passage_field, label_namespace="answer_tags")) if num_context_answers > 1: p2_answer_marker_list.append(SequenceLabelField(prev_answer_marker_lists[2], passage_field, label_namespace="answer_tags")) if num_context_answers > 0: p1_answer_marker_list.append(SequenceLabelField(prev_answer_marker_lists[1], passage_field, label_namespace="answer_tags")) fields['span_start'] = ListField(span_start_list) fields['span_end'] = ListField(span_end_list) if num_context_answers > 0: fields['p1_answer_marker'] = ListField(p1_answer_marker_list) if num_context_answers > 1: fields['p2_answer_marker'] = ListField(p2_answer_marker_list) if num_context_answers > 2: fields['p3_answer_marker'] = ListField(p3_answer_marker_list) fields['yesno_list'] = ListField( \ [LabelField(yesno, label_namespace="yesno_labels") for yesno in yesno_list]) fields['followup_list'] = ListField([LabelField(followup, label_namespace="followup_labels") \ for followup in followup_list]) metadata.update(additional_metadata) fields['metadata'] = MetadataField(metadata) return Instance(fields)
python
def make_reading_comprehension_instance_quac(question_list_tokens: List[List[Token]], passage_tokens: List[Token], token_indexers: Dict[str, TokenIndexer], passage_text: str, token_span_lists: List[List[Tuple[int, int]]] = None, yesno_list: List[int] = None, followup_list: List[int] = None, additional_metadata: Dict[str, Any] = None, num_context_answers: int = 0) -> Instance: """ Converts a question, a passage, and an optional answer (or answers) to an ``Instance`` for use in a reading comprehension model. Creates an ``Instance`` with at least these fields: ``question`` and ``passage``, both ``TextFields``; and ``metadata``, a ``MetadataField``. Additionally, if both ``answer_texts`` and ``char_span_starts`` are given, the ``Instance`` has ``span_start`` and ``span_end`` fields, which are both ``IndexFields``. Parameters ---------- question_list_tokens : ``List[List[Token]]`` An already-tokenized list of questions. Each dialog have multiple questions. passage_tokens : ``List[Token]`` An already-tokenized passage that contains the answer to the given question. token_indexers : ``Dict[str, TokenIndexer]`` Determines how the question and passage ``TextFields`` will be converted into tensors that get input to a model. See :class:`TokenIndexer`. passage_text : ``str`` The original passage text. We need this so that we can recover the actual span from the original passage that the model predicts as the answer to the question. This is used in official evaluation scripts. token_span_lists : ``List[List[Tuple[int, int]]]``, optional Indices into ``passage_tokens`` to use as the answer to the question for training. This is a list of list, first because there is multiple questions per dialog, and because there might be several possible correct answer spans in the passage. Currently, we just select the last span in this list (i.e., QuAC has multiple annotations on the dev set; this will select the last span, which was given by the original annotator). yesno_list : ``List[int]`` List of the affirmation bit for each question answer pairs. followup_list : ``List[int]`` List of the continuation bit for each question answer pairs. num_context_answers : ``int``, optional How many answers to encode into the passage. additional_metadata : ``Dict[str, Any]``, optional The constructed ``metadata`` field will by default contain ``original_passage``, ``token_offsets``, ``question_tokens``, ``passage_tokens``, and ``answer_texts`` keys. If you want any other metadata to be associated with each instance, you can pass that in here. This dictionary will get added to the ``metadata`` dictionary we already construct. """ additional_metadata = additional_metadata or {} fields: Dict[str, Field] = {} passage_offsets = [(token.idx, token.idx + len(token.text)) for token in passage_tokens] # This is separate so we can reference it later with a known type. passage_field = TextField(passage_tokens, token_indexers) fields['passage'] = passage_field fields['question'] = ListField([TextField(q_tokens, token_indexers) for q_tokens in question_list_tokens]) metadata = {'original_passage': passage_text, 'token_offsets': passage_offsets, 'question_tokens': [[token.text for token in question_tokens] \ for question_tokens in question_list_tokens], 'passage_tokens': [token.text for token in passage_tokens], } p1_answer_marker_list: List[Field] = [] p2_answer_marker_list: List[Field] = [] p3_answer_marker_list: List[Field] = [] def get_tag(i, i_name): # Generate a tag to mark previous answer span in the passage. return "<{0:d}_{1:s}>".format(i, i_name) def mark_tag(span_start, span_end, passage_tags, prev_answer_distance): try: assert span_start >= 0 assert span_end >= 0 except: raise ValueError("Previous {0:d}th answer span should have been updated!".format(prev_answer_distance)) # Modify "tags" to mark previous answer span. if span_start == span_end: passage_tags[prev_answer_distance][span_start] = get_tag(prev_answer_distance, "") else: passage_tags[prev_answer_distance][span_start] = get_tag(prev_answer_distance, "start") passage_tags[prev_answer_distance][span_end] = get_tag(prev_answer_distance, "end") for passage_index in range(span_start + 1, span_end): passage_tags[prev_answer_distance][passage_index] = get_tag(prev_answer_distance, "in") if token_span_lists: span_start_list: List[Field] = [] span_end_list: List[Field] = [] p1_span_start, p1_span_end, p2_span_start = -1, -1, -1 p2_span_end, p3_span_start, p3_span_end = -1, -1, -1 # Looping each <<answers>>. for question_index, answer_span_lists in enumerate(token_span_lists): span_start, span_end = answer_span_lists[-1] # Last one is the original answer span_start_list.append(IndexField(span_start, passage_field)) span_end_list.append(IndexField(span_end, passage_field)) prev_answer_marker_lists = [["O"] * len(passage_tokens), ["O"] * len(passage_tokens), ["O"] * len(passage_tokens), ["O"] * len(passage_tokens)] if question_index > 0 and num_context_answers > 0: mark_tag(p1_span_start, p1_span_end, prev_answer_marker_lists, 1) if question_index > 1 and num_context_answers > 1: mark_tag(p2_span_start, p2_span_end, prev_answer_marker_lists, 2) if question_index > 2 and num_context_answers > 2: mark_tag(p3_span_start, p3_span_end, prev_answer_marker_lists, 3) p3_span_start = p2_span_start p3_span_end = p2_span_end p2_span_start = p1_span_start p2_span_end = p1_span_end p1_span_start = span_start p1_span_end = span_end if num_context_answers > 2: p3_answer_marker_list.append(SequenceLabelField(prev_answer_marker_lists[3], passage_field, label_namespace="answer_tags")) if num_context_answers > 1: p2_answer_marker_list.append(SequenceLabelField(prev_answer_marker_lists[2], passage_field, label_namespace="answer_tags")) if num_context_answers > 0: p1_answer_marker_list.append(SequenceLabelField(prev_answer_marker_lists[1], passage_field, label_namespace="answer_tags")) fields['span_start'] = ListField(span_start_list) fields['span_end'] = ListField(span_end_list) if num_context_answers > 0: fields['p1_answer_marker'] = ListField(p1_answer_marker_list) if num_context_answers > 1: fields['p2_answer_marker'] = ListField(p2_answer_marker_list) if num_context_answers > 2: fields['p3_answer_marker'] = ListField(p3_answer_marker_list) fields['yesno_list'] = ListField( \ [LabelField(yesno, label_namespace="yesno_labels") for yesno in yesno_list]) fields['followup_list'] = ListField([LabelField(followup, label_namespace="followup_labels") \ for followup in followup_list]) metadata.update(additional_metadata) fields['metadata'] = MetadataField(metadata) return Instance(fields)
[ "def", "make_reading_comprehension_instance_quac", "(", "question_list_tokens", ":", "List", "[", "List", "[", "Token", "]", "]", ",", "passage_tokens", ":", "List", "[", "Token", "]", ",", "token_indexers", ":", "Dict", "[", "str", ",", "TokenIndexer", "]", ",", "passage_text", ":", "str", ",", "token_span_lists", ":", "List", "[", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", "]", "=", "None", ",", "yesno_list", ":", "List", "[", "int", "]", "=", "None", ",", "followup_list", ":", "List", "[", "int", "]", "=", "None", ",", "additional_metadata", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "num_context_answers", ":", "int", "=", "0", ")", "->", "Instance", ":", "additional_metadata", "=", "additional_metadata", "or", "{", "}", "fields", ":", "Dict", "[", "str", ",", "Field", "]", "=", "{", "}", "passage_offsets", "=", "[", "(", "token", ".", "idx", ",", "token", ".", "idx", "+", "len", "(", "token", ".", "text", ")", ")", "for", "token", "in", "passage_tokens", "]", "# This is separate so we can reference it later with a known type.", "passage_field", "=", "TextField", "(", "passage_tokens", ",", "token_indexers", ")", "fields", "[", "'passage'", "]", "=", "passage_field", "fields", "[", "'question'", "]", "=", "ListField", "(", "[", "TextField", "(", "q_tokens", ",", "token_indexers", ")", "for", "q_tokens", "in", "question_list_tokens", "]", ")", "metadata", "=", "{", "'original_passage'", ":", "passage_text", ",", "'token_offsets'", ":", "passage_offsets", ",", "'question_tokens'", ":", "[", "[", "token", ".", "text", "for", "token", "in", "question_tokens", "]", "for", "question_tokens", "in", "question_list_tokens", "]", ",", "'passage_tokens'", ":", "[", "token", ".", "text", "for", "token", "in", "passage_tokens", "]", ",", "}", "p1_answer_marker_list", ":", "List", "[", "Field", "]", "=", "[", "]", "p2_answer_marker_list", ":", "List", "[", "Field", "]", "=", "[", "]", "p3_answer_marker_list", ":", "List", "[", "Field", "]", "=", "[", "]", "def", "get_tag", "(", "i", ",", "i_name", ")", ":", "# Generate a tag to mark previous answer span in the passage.", "return", "\"<{0:d}_{1:s}>\"", ".", "format", "(", "i", ",", "i_name", ")", "def", "mark_tag", "(", "span_start", ",", "span_end", ",", "passage_tags", ",", "prev_answer_distance", ")", ":", "try", ":", "assert", "span_start", ">=", "0", "assert", "span_end", ">=", "0", "except", ":", "raise", "ValueError", "(", "\"Previous {0:d}th answer span should have been updated!\"", ".", "format", "(", "prev_answer_distance", ")", ")", "# Modify \"tags\" to mark previous answer span.", "if", "span_start", "==", "span_end", ":", "passage_tags", "[", "prev_answer_distance", "]", "[", "span_start", "]", "=", "get_tag", "(", "prev_answer_distance", ",", "\"\"", ")", "else", ":", "passage_tags", "[", "prev_answer_distance", "]", "[", "span_start", "]", "=", "get_tag", "(", "prev_answer_distance", ",", "\"start\"", ")", "passage_tags", "[", "prev_answer_distance", "]", "[", "span_end", "]", "=", "get_tag", "(", "prev_answer_distance", ",", "\"end\"", ")", "for", "passage_index", "in", "range", "(", "span_start", "+", "1", ",", "span_end", ")", ":", "passage_tags", "[", "prev_answer_distance", "]", "[", "passage_index", "]", "=", "get_tag", "(", "prev_answer_distance", ",", "\"in\"", ")", "if", "token_span_lists", ":", "span_start_list", ":", "List", "[", "Field", "]", "=", "[", "]", "span_end_list", ":", "List", "[", "Field", "]", "=", "[", "]", "p1_span_start", ",", "p1_span_end", ",", "p2_span_start", "=", "-", "1", ",", "-", "1", ",", "-", "1", "p2_span_end", ",", "p3_span_start", ",", "p3_span_end", "=", "-", "1", ",", "-", "1", ",", "-", "1", "# Looping each <<answers>>.", "for", "question_index", ",", "answer_span_lists", "in", "enumerate", "(", "token_span_lists", ")", ":", "span_start", ",", "span_end", "=", "answer_span_lists", "[", "-", "1", "]", "# Last one is the original answer", "span_start_list", ".", "append", "(", "IndexField", "(", "span_start", ",", "passage_field", ")", ")", "span_end_list", ".", "append", "(", "IndexField", "(", "span_end", ",", "passage_field", ")", ")", "prev_answer_marker_lists", "=", "[", "[", "\"O\"", "]", "*", "len", "(", "passage_tokens", ")", ",", "[", "\"O\"", "]", "*", "len", "(", "passage_tokens", ")", ",", "[", "\"O\"", "]", "*", "len", "(", "passage_tokens", ")", ",", "[", "\"O\"", "]", "*", "len", "(", "passage_tokens", ")", "]", "if", "question_index", ">", "0", "and", "num_context_answers", ">", "0", ":", "mark_tag", "(", "p1_span_start", ",", "p1_span_end", ",", "prev_answer_marker_lists", ",", "1", ")", "if", "question_index", ">", "1", "and", "num_context_answers", ">", "1", ":", "mark_tag", "(", "p2_span_start", ",", "p2_span_end", ",", "prev_answer_marker_lists", ",", "2", ")", "if", "question_index", ">", "2", "and", "num_context_answers", ">", "2", ":", "mark_tag", "(", "p3_span_start", ",", "p3_span_end", ",", "prev_answer_marker_lists", ",", "3", ")", "p3_span_start", "=", "p2_span_start", "p3_span_end", "=", "p2_span_end", "p2_span_start", "=", "p1_span_start", "p2_span_end", "=", "p1_span_end", "p1_span_start", "=", "span_start", "p1_span_end", "=", "span_end", "if", "num_context_answers", ">", "2", ":", "p3_answer_marker_list", ".", "append", "(", "SequenceLabelField", "(", "prev_answer_marker_lists", "[", "3", "]", ",", "passage_field", ",", "label_namespace", "=", "\"answer_tags\"", ")", ")", "if", "num_context_answers", ">", "1", ":", "p2_answer_marker_list", ".", "append", "(", "SequenceLabelField", "(", "prev_answer_marker_lists", "[", "2", "]", ",", "passage_field", ",", "label_namespace", "=", "\"answer_tags\"", ")", ")", "if", "num_context_answers", ">", "0", ":", "p1_answer_marker_list", ".", "append", "(", "SequenceLabelField", "(", "prev_answer_marker_lists", "[", "1", "]", ",", "passage_field", ",", "label_namespace", "=", "\"answer_tags\"", ")", ")", "fields", "[", "'span_start'", "]", "=", "ListField", "(", "span_start_list", ")", "fields", "[", "'span_end'", "]", "=", "ListField", "(", "span_end_list", ")", "if", "num_context_answers", ">", "0", ":", "fields", "[", "'p1_answer_marker'", "]", "=", "ListField", "(", "p1_answer_marker_list", ")", "if", "num_context_answers", ">", "1", ":", "fields", "[", "'p2_answer_marker'", "]", "=", "ListField", "(", "p2_answer_marker_list", ")", "if", "num_context_answers", ">", "2", ":", "fields", "[", "'p3_answer_marker'", "]", "=", "ListField", "(", "p3_answer_marker_list", ")", "fields", "[", "'yesno_list'", "]", "=", "ListField", "(", "[", "LabelField", "(", "yesno", ",", "label_namespace", "=", "\"yesno_labels\"", ")", "for", "yesno", "in", "yesno_list", "]", ")", "fields", "[", "'followup_list'", "]", "=", "ListField", "(", "[", "LabelField", "(", "followup", ",", "label_namespace", "=", "\"followup_labels\"", ")", "for", "followup", "in", "followup_list", "]", ")", "metadata", ".", "update", "(", "additional_metadata", ")", "fields", "[", "'metadata'", "]", "=", "MetadataField", "(", "metadata", ")", "return", "Instance", "(", "fields", ")" ]
Converts a question, a passage, and an optional answer (or answers) to an ``Instance`` for use in a reading comprehension model. Creates an ``Instance`` with at least these fields: ``question`` and ``passage``, both ``TextFields``; and ``metadata``, a ``MetadataField``. Additionally, if both ``answer_texts`` and ``char_span_starts`` are given, the ``Instance`` has ``span_start`` and ``span_end`` fields, which are both ``IndexFields``. Parameters ---------- question_list_tokens : ``List[List[Token]]`` An already-tokenized list of questions. Each dialog have multiple questions. passage_tokens : ``List[Token]`` An already-tokenized passage that contains the answer to the given question. token_indexers : ``Dict[str, TokenIndexer]`` Determines how the question and passage ``TextFields`` will be converted into tensors that get input to a model. See :class:`TokenIndexer`. passage_text : ``str`` The original passage text. We need this so that we can recover the actual span from the original passage that the model predicts as the answer to the question. This is used in official evaluation scripts. token_span_lists : ``List[List[Tuple[int, int]]]``, optional Indices into ``passage_tokens`` to use as the answer to the question for training. This is a list of list, first because there is multiple questions per dialog, and because there might be several possible correct answer spans in the passage. Currently, we just select the last span in this list (i.e., QuAC has multiple annotations on the dev set; this will select the last span, which was given by the original annotator). yesno_list : ``List[int]`` List of the affirmation bit for each question answer pairs. followup_list : ``List[int]`` List of the continuation bit for each question answer pairs. num_context_answers : ``int``, optional How many answers to encode into the passage. additional_metadata : ``Dict[str, Any]``, optional The constructed ``metadata`` field will by default contain ``original_passage``, ``token_offsets``, ``question_tokens``, ``passage_tokens``, and ``answer_texts`` keys. If you want any other metadata to be associated with each instance, you can pass that in here. This dictionary will get added to the ``metadata`` dictionary we already construct.
[ "Converts", "a", "question", "a", "passage", "and", "an", "optional", "answer", "(", "or", "answers", ")", "to", "an", "Instance", "for", "use", "in", "a", "reading", "comprehension", "model", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/reading_comprehension/util.py#L217-L351
train
Creates a reading comprehension instance from a list of questions passages and answers.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKK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ildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(8934 - 8823) + '\061' + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1000 + 0o57) + chr(0b101111 + 0o10), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(51) + '\064' + '\x30', 33814 - 33806), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + '\063' + '\063', 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + '\x35' + chr(52), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(51) + '\x37' + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100000 + 0o17) + '\x34' + chr(753 - 704), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2034 - 1984) + '\x33', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(997 - 944) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(1433 - 1385) + '\157' + '\x33' + chr(0b110011) + chr(0b110111), 17922 - 17914), ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\x6f' + chr(1552 - 1502) + chr(482 - 433) + '\x35', 21036 - 21028), ehT0Px3KOsy9(chr(48) + '\157' + chr(879 - 830) + chr(1015 - 966) + '\064', 0o10), ehT0Px3KOsy9('\060' + chr(8938 - 8827) + '\x32' + chr(54), 40964 - 40956), ehT0Px3KOsy9('\060' + chr(111) + chr(2539 - 2484) + chr(0b1011 + 0o50), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1310 - 1260) + chr(0b101101 + 0o10) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(1046 - 998) + chr(0b1101111) + '\066' + chr(0b111 + 0o52), 0o10), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(0b1101111) + chr(0b101001 + 0o12) + '\x31' + chr(53), 7616 - 7608), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10110 + 0o35) + '\x31' + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + '\062' + chr(571 - 518), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100110 + 0o11) + chr(51) + chr(766 - 714) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + '\x36' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(2028 - 1980) + '\x6f' + chr(0b110001) + chr(0b10111 + 0o32) + '\x37', 0b1000), ehT0Px3KOsy9(chr(2110 - 2062) + chr(0b1101111) + chr(0b110001) + chr(0b11 + 0o61) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(1431 - 1381) + chr(175 - 126) + chr(0b10010 + 0o40), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110011) + chr(1013 - 962) + chr(0b101111 + 0o7), 21470 - 21462), ehT0Px3KOsy9('\060' + '\157' + chr(0b110011) + '\066' + chr(52), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b101100 + 0o103) + chr(51) + chr(49) + chr(54), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110100) + chr(0b11 + 0o57), 23809 - 23801), ehT0Px3KOsy9('\060' + chr(0b1100011 + 0o14) + chr(49) + '\064' + chr(0b110011), 23026 - 23018), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(442 - 391) + chr(51) + chr(0b0 + 0o66), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + '\064' + chr(603 - 554), 8), ehT0Px3KOsy9(chr(0b110000) + chr(3590 - 3479) + chr(50) + '\064' + chr(1494 - 1445), 64505 - 64497), ehT0Px3KOsy9(chr(258 - 210) + '\157' + '\x33' + '\067', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b11010 + 0o31) + chr(767 - 718) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(1138 - 1090) + '\157' + chr(54), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(176 - 126) + chr(0b100100 + 0o17) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + chr(0b10111 + 0o31) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b11111 + 0o120) + chr(1377 - 1327) + '\x32' + '\065', 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b111 + 0o52) + chr(0b110111) + chr(50), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + chr(2072 - 2019) + chr(0b11 + 0o63), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(0b1011 + 0o144) + '\065' + chr(0b110000), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'"'), chr(0b1100100) + '\x65' + chr(0b1100011) + '\x6f' + chr(0b1100100) + '\145')('\165' + chr(10347 - 10231) + chr(0b11100 + 0o112) + '\055' + chr(0b110000 + 0o10)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def RtEFx6rITArM(GGNQMMlJqJll, G5DiCHakuupP, HhKJnSagy0bW, o23UUTrQniSz, Cas28Ox91AKE=None, G1trZ9S2NCus=None, NOK2o3lcwPEk=None, aVcqhET1qeNF=None, qjxZ3R0OIqxB=ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x30', 14045 - 14037)) -> _jFYXBmhzM0H: aVcqhET1qeNF = aVcqhET1qeNF or {} _yavFU6VJ0wY = {} QVc0DMim8Z90 = [(mTy3fac_AqJ5.YlqusYB6InkM, mTy3fac_AqJ5.YlqusYB6InkM + c2A0yzQpDQB3(mTy3fac_AqJ5.Ah1rInvg48Hb)) for mTy3fac_AqJ5 in G5DiCHakuupP] dUeGDvbfM9fr = OnNQjiI53xqc(G5DiCHakuupP, HhKJnSagy0bW) _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'|^\x93(\xcd\x9cD'), chr(0b1010010 + 0o22) + '\145' + '\143' + '\x6f' + '\144' + chr(101))('\x75' + '\x74' + '\146' + chr(0b101100 + 0o1) + chr(0b111000))] = dUeGDvbfM9fr _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'}J\x85(\xd8\x92N}'), chr(1927 - 1827) + chr(3222 - 3121) + '\143' + chr(10408 - 10297) + chr(0b1100100) + chr(101))(chr(117) + '\164' + '\x66' + chr(45) + '\x38')] = MUBCQ_ZKUvaB([OnNQjiI53xqc(IVEjoLxtoa6e, HhKJnSagy0bW) for IVEjoLxtoa6e in GGNQMMlJqJll]) mU7wOAGoTnlM = {xafqLlk3kkUe(SXOLrMavuUCe(b'cM\x89<\xc5\x95@\x7fw\xaf\xec?eZ\xceT'), chr(100) + chr(0b100011 + 0o102) + '\x63' + chr(1020 - 909) + '\x64' + '\145')(chr(0b1110101) + chr(9455 - 9339) + chr(102) + '\055' + chr(56)): o23UUTrQniSz, xafqLlk3kkUe(SXOLrMavuUCe(b'xP\x8b>\xc2\xa4NuN\xac\xe88e'), '\x64' + '\x65' + chr(0b1100011) + chr(0b1101100 + 0o3) + chr(0b11110 + 0o106) + chr(101))('\165' + '\164' + '\146' + '\055' + chr(660 - 604)): QVc0DMim8Z90, xafqLlk3kkUe(SXOLrMavuUCe(b"}J\x85(\xd8\x92N}w\xab\xe2'sU\xda"), chr(8686 - 8586) + chr(101) + '\143' + chr(0b1101111) + chr(0b1100100) + chr(4922 - 4821))('\x75' + chr(0b1000011 + 0o61) + '\146' + '\055' + '\070'): [[mTy3fac_AqJ5.Ah1rInvg48Hb for mTy3fac_AqJ5 in yHVya2HrNXZM] for yHVya2HrNXZM in GGNQMMlJqJll], xafqLlk3kkUe(SXOLrMavuUCe(b'|^\x93(\xcd\x9cDL\\\xb0\xe6)xH'), chr(4493 - 4393) + '\x65' + chr(0b110101 + 0o56) + chr(0b1011 + 0o144) + chr(0b1100100) + chr(0b1100101))(chr(0b1110101) + chr(0b1101 + 0o147) + chr(0b1100110) + '\x2d' + '\x38'): [mTy3fac_AqJ5.Ah1rInvg48Hb for mTy3fac_AqJ5 in G5DiCHakuupP]} SjyRXMyrbf_a = [] FxNXH5P7F5fu = [] Q0T3V8yT1jyB = [] def Vb9455gopMjS(WVxHKyX45z_L, z_1liBysFy5b): return xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'0D\xd0a\xc8\x86~h\x19\xe5\xfe1('), chr(100) + '\x65' + chr(8597 - 8498) + chr(0b1101111) + '\x64' + chr(0b1100101))('\x75' + chr(7777 - 7661) + chr(0b1100110) + '\055' + chr(0b11101 + 0o33)), xafqLlk3kkUe(SXOLrMavuUCe(b'Z\x0b\x924\xe4\x9ar x\xaf\xe8&'), chr(100) + '\145' + '\143' + '\x6f' + '\x64' + chr(8295 - 8194))('\165' + '\x74' + chr(0b1100110) + chr(1788 - 1743) + chr(0b111000)))(WVxHKyX45z_L, z_1liBysFy5b) def Bvhy_jb79f3L(CGzUSvlyKBQD, b5O2oQPg9Xzq, IBZQBRD2fKTx, WBjCrWXsALUH): try: assert CGzUSvlyKBQD >= ehT0Px3KOsy9(chr(1620 - 1572) + '\x6f' + chr(2038 - 1990), 8) assert b5O2oQPg9Xzq >= ehT0Px3KOsy9('\x30' + chr(111) + chr(0b10101 + 0o33), 8) except ZVWAAMjVVHHl: raise q1QCh3W88sgk(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\\M\x85-\xc5\x94T`\x08\xa4\xbdvrF\xddY\xed\xad\xfb\x94\xc5*\x16\xaa\xad\x84\xafLC\xadI\xcej\xa7b\xb9\xeb\xf4\x0c\xcb,]\x85>\xc2\xdbTcL\xbe\xf9)r\x1a'), chr(0b100010 + 0o102) + chr(0b1100101) + chr(0b1100011) + chr(0b1101111) + '\x64' + '\x65')('\165' + chr(0b11 + 0o161) + chr(2001 - 1899) + chr(706 - 661) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'Z\x0b\x924\xe4\x9ar x\xaf\xe8&'), '\144' + '\145' + chr(2443 - 2344) + '\x6f' + chr(100) + '\145')('\165' + '\164' + chr(4789 - 4687) + chr(0b1011 + 0o42) + '\x38'))(WBjCrWXsALUH)) if CGzUSvlyKBQD == b5O2oQPg9Xzq: IBZQBRD2fKTx[WBjCrWXsALUH][CGzUSvlyKBQD] = Vb9455gopMjS(WBjCrWXsALUH, xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(7276 - 7176) + chr(0b100111 + 0o76) + '\143' + '\x6f' + '\x64' + chr(0b1100101))(chr(13555 - 13438) + '\164' + chr(8936 - 8834) + '\055' + chr(0b111000))) else: IBZQBRD2fKTx[WBjCrWXsALUH][CGzUSvlyKBQD] = Vb9455gopMjS(WBjCrWXsALUH, xafqLlk3kkUe(SXOLrMavuUCe(b'\x7fK\x81)\xd8'), '\x64' + chr(0b1100101) + chr(0b1100011) + chr(0b1101111) + '\144' + chr(0b1100101))(chr(0b100010 + 0o123) + chr(6372 - 6256) + chr(0b1001111 + 0o27) + chr(0b100001 + 0o14) + chr(0b111000))) IBZQBRD2fKTx[WBjCrWXsALUH][b5O2oQPg9Xzq] = Vb9455gopMjS(WBjCrWXsALUH, xafqLlk3kkUe(SXOLrMavuUCe(b'iQ\x84'), chr(0b1100100) + '\x65' + chr(0b1100000 + 0o3) + '\157' + '\144' + '\145')(chr(0b1110101) + chr(0b1100 + 0o150) + '\146' + '\055' + chr(0b111000))) for J_z0b5NUYjsi in vQr8gNKaIaWE(CGzUSvlyKBQD + ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(2282 - 2233), 50911 - 50903), b5O2oQPg9Xzq): IBZQBRD2fKTx[WBjCrWXsALUH][J_z0b5NUYjsi] = Vb9455gopMjS(WBjCrWXsALUH, xafqLlk3kkUe(SXOLrMavuUCe(b'eQ'), chr(100) + chr(0b100011 + 0o102) + chr(0b1100011) + chr(0b11111 + 0o120) + chr(4724 - 4624) + '\145')(chr(117) + '\x74' + '\146' + chr(0b101101) + chr(0b111000 + 0o0))) if Cas28Ox91AKE: MDXnrkBefPSd = [] mSyFWBTybMRW = [] (P9NHUZXvn76g, ku4ohKqlqgsd, IEWd6Ysj27Sj) = (-ehT0Px3KOsy9('\x30' + '\157' + chr(0b11 + 0o56), 8), -ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001), 8), -ehT0Px3KOsy9('\x30' + chr(11630 - 11519) + chr(0b110001), 8)) (u4MrT0HDBwLn, raC8vw3r98zS, MaBqdIxeiQx6) = (-ehT0Px3KOsy9(chr(1328 - 1280) + '\157' + chr(77 - 28), 8), -ehT0Px3KOsy9('\x30' + chr(0b10011 + 0o134) + chr(0b1110 + 0o43), 8), -ehT0Px3KOsy9(chr(48) + '\157' + chr(1711 - 1662), 8)) for (yixuTX4lpEBK, BAsfqql0k6L8) in YlkZvXL8qwsX(Cas28Ox91AKE): (CGzUSvlyKBQD, b5O2oQPg9Xzq) = BAsfqql0k6L8[-ehT0Px3KOsy9(chr(48) + '\x6f' + '\x31', 8)] xafqLlk3kkUe(MDXnrkBefPSd, xafqLlk3kkUe(SXOLrMavuUCe(b'mO\x90>\xc2\x9f'), chr(9534 - 9434) + chr(1768 - 1667) + chr(2499 - 2400) + '\157' + '\144' + '\145')(chr(0b101111 + 0o106) + chr(0b1110100) + chr(0b1100110) + chr(0b10 + 0o53) + chr(0b111000)))(t7JPS4qvikx6(CGzUSvlyKBQD, dUeGDvbfM9fr)) xafqLlk3kkUe(mSyFWBTybMRW, xafqLlk3kkUe(SXOLrMavuUCe(b'mO\x90>\xc2\x9f'), chr(0b110101 + 0o57) + '\145' + chr(2772 - 2673) + chr(6837 - 6726) + '\x64' + '\145')('\x75' + '\164' + '\x66' + '\x2d' + chr(56)))(t7JPS4qvikx6(b5O2oQPg9Xzq, dUeGDvbfM9fr)) Cv2XkeETuLGY = [[xafqLlk3kkUe(SXOLrMavuUCe(b'C'), chr(0b100110 + 0o76) + chr(0b1100101) + chr(99) + '\x6f' + '\x64' + chr(0b1100101))(chr(0b1110101) + chr(2939 - 2823) + chr(0b1100110) + chr(45) + chr(0b111000))] * c2A0yzQpDQB3(G5DiCHakuupP), [xafqLlk3kkUe(SXOLrMavuUCe(b'C'), chr(0b1100100) + '\x65' + chr(0b101000 + 0o73) + '\157' + '\144' + chr(662 - 561))(chr(0b101001 + 0o114) + chr(0b10 + 0o162) + '\146' + chr(1374 - 1329) + chr(0b10110 + 0o42))] * c2A0yzQpDQB3(G5DiCHakuupP), [xafqLlk3kkUe(SXOLrMavuUCe(b'C'), chr(100) + chr(0b1010010 + 0o23) + chr(0b101011 + 0o70) + chr(8211 - 8100) + '\144' + '\x65')('\x75' + '\164' + chr(0b1100110) + '\055' + chr(0b111000 + 0o0))] * c2A0yzQpDQB3(G5DiCHakuupP), [xafqLlk3kkUe(SXOLrMavuUCe(b'C'), chr(100) + chr(5020 - 4919) + chr(99) + '\157' + chr(0b10010 + 0o122) + chr(101))(chr(117) + chr(116) + chr(5739 - 5637) + chr(0b100011 + 0o12) + chr(1552 - 1496))] * c2A0yzQpDQB3(G5DiCHakuupP)] if yixuTX4lpEBK > ehT0Px3KOsy9(chr(923 - 875) + chr(111) + '\x30', 8) and qjxZ3R0OIqxB > ehT0Px3KOsy9('\060' + chr(7337 - 7226) + chr(0b10011 + 0o35), 8): Bvhy_jb79f3L(P9NHUZXvn76g, ku4ohKqlqgsd, Cv2XkeETuLGY, ehT0Px3KOsy9(chr(48) + '\157' + chr(49), 8)) if yixuTX4lpEBK > ehT0Px3KOsy9('\x30' + chr(538 - 427) + chr(1588 - 1539), 8) and qjxZ3R0OIqxB > ehT0Px3KOsy9(chr(2070 - 2022) + '\157' + chr(0b110001), 8): Bvhy_jb79f3L(IEWd6Ysj27Sj, u4MrT0HDBwLn, Cv2XkeETuLGY, ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010), 19972 - 19964)) if yixuTX4lpEBK > ehT0Px3KOsy9('\060' + chr(8032 - 7921) + chr(1992 - 1942), 8) and qjxZ3R0OIqxB > ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\157' + chr(50), 8): Bvhy_jb79f3L(raC8vw3r98zS, MaBqdIxeiQx6, Cv2XkeETuLGY, ehT0Px3KOsy9(chr(48) + chr(0b11001 + 0o126) + '\x33', ord("\x08"))) raC8vw3r98zS = IEWd6Ysj27Sj MaBqdIxeiQx6 = u4MrT0HDBwLn IEWd6Ysj27Sj = P9NHUZXvn76g u4MrT0HDBwLn = ku4ohKqlqgsd P9NHUZXvn76g = CGzUSvlyKBQD ku4ohKqlqgsd = b5O2oQPg9Xzq if qjxZ3R0OIqxB > ehT0Px3KOsy9('\060' + chr(0b1011011 + 0o24) + '\x32', 8): xafqLlk3kkUe(Q0T3V8yT1jyB, xafqLlk3kkUe(SXOLrMavuUCe(b'mO\x90>\xc2\x9f'), chr(8492 - 8392) + '\145' + chr(99) + '\x6f' + chr(0b0 + 0o144) + '\x65')(chr(0b1110101) + chr(732 - 616) + '\146' + chr(0b101101) + chr(56)))(AwqTyd611fWg(Cv2XkeETuLGY[ehT0Px3KOsy9(chr(48) + chr(0b1010111 + 0o30) + chr(0b110011), 8)], dUeGDvbfM9fr, label_namespace=xafqLlk3kkUe(SXOLrMavuUCe(b'mQ\x93,\xc9\x89~gI\xb8\xfe'), chr(0b1100100) + chr(5524 - 5423) + '\x63' + '\157' + '\144' + chr(0b0 + 0o145))(chr(117) + '\x74' + chr(3145 - 3043) + chr(45) + chr(0b111000)))) if qjxZ3R0OIqxB > ehT0Px3KOsy9('\x30' + chr(111) + '\061', 8): xafqLlk3kkUe(FxNXH5P7F5fu, xafqLlk3kkUe(SXOLrMavuUCe(b'mO\x90>\xc2\x9f'), chr(4937 - 4837) + chr(5357 - 5256) + '\x63' + '\x6f' + '\x64' + '\x65')('\x75' + chr(0b1110100) + chr(5512 - 5410) + chr(0b101101) + chr(0b111000)))(AwqTyd611fWg(Cv2XkeETuLGY[ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010), 8)], dUeGDvbfM9fr, label_namespace=xafqLlk3kkUe(SXOLrMavuUCe(b'mQ\x93,\xc9\x89~gI\xb8\xfe'), chr(0b1100100) + chr(101) + chr(0b110000 + 0o63) + chr(0b11001 + 0o126) + chr(2460 - 2360) + chr(0b10000 + 0o125))('\165' + chr(116) + chr(102) + chr(0b100 + 0o51) + chr(0b111000)))) if qjxZ3R0OIqxB > ehT0Px3KOsy9('\x30' + chr(0b1001110 + 0o41) + chr(0b110000), 8): xafqLlk3kkUe(SjyRXMyrbf_a, xafqLlk3kkUe(SXOLrMavuUCe(b'mO\x90>\xc2\x9f'), '\x64' + chr(0b111011 + 0o52) + chr(2838 - 2739) + chr(6295 - 6184) + chr(0b111100 + 0o50) + '\145')(chr(117) + chr(0b1000 + 0o154) + chr(0b1100110) + chr(45) + chr(0b100100 + 0o24)))(AwqTyd611fWg(Cv2XkeETuLGY[ehT0Px3KOsy9(chr(1030 - 982) + chr(0b1101111) + '\x31', 8)], dUeGDvbfM9fr, label_namespace=xafqLlk3kkUe(SXOLrMavuUCe(b'mQ\x93,\xc9\x89~gI\xb8\xfe'), chr(0b1100100) + chr(0b1100101) + chr(0b1100011) + chr(0b1011101 + 0o22) + chr(0b1100100) + chr(0b1100101))(chr(3732 - 3615) + chr(0b100 + 0o160) + '\x66' + '\x2d' + '\070'))) _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'\x7fO\x815\xf3\x88UrZ\xab'), '\144' + '\145' + '\143' + chr(0b1011 + 0o144) + chr(0b1100100) + chr(4377 - 4276))(chr(0b110110 + 0o77) + chr(11824 - 11708) + '\x66' + chr(0b101 + 0o50) + chr(3051 - 2995))] = MUBCQ_ZKUvaB(MDXnrkBefPSd) _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'\x7fO\x815\xf3\x9eOw'), chr(100) + chr(614 - 513) + '\143' + chr(8743 - 8632) + '\x64' + chr(8225 - 8124))('\165' + chr(10112 - 9996) + '\x66' + '\055' + chr(0b111000))] = MUBCQ_ZKUvaB(mSyFWBTybMRW) if qjxZ3R0OIqxB > ehT0Px3KOsy9('\060' + chr(111) + '\060', 8): _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'|\x0e\xbf:\xc2\x88VvZ\x80\xe0-dP\xccC'), chr(0b1100100) + chr(101) + '\x63' + chr(10643 - 10532) + '\x64' + '\x65')(chr(0b101010 + 0o113) + chr(0b1110100) + chr(102) + '\x2d' + '\x38')] = MUBCQ_ZKUvaB(SjyRXMyrbf_a) if qjxZ3R0OIqxB > ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(0b1101111) + chr(49), 8): _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'|\r\xbf:\xc2\x88VvZ\x80\xe0-dP\xccC'), '\144' + '\145' + chr(0b100110 + 0o75) + chr(4385 - 4274) + '\144' + '\x65')(chr(117) + chr(0b1110100) + chr(4935 - 4833) + chr(640 - 595) + chr(0b111000))] = MUBCQ_ZKUvaB(FxNXH5P7F5fu) if qjxZ3R0OIqxB > ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010), 8): _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'|\x0c\xbf:\xc2\x88VvZ\x80\xe0-dP\xccC'), chr(0b11011 + 0o111) + chr(101) + '\143' + chr(442 - 331) + chr(0b1100100) + chr(0b10110 + 0o117))(chr(0b1110101) + chr(9835 - 9719) + '\x66' + chr(0b101101 + 0o0) + '\x38')] = MUBCQ_ZKUvaB(Q0T3V8yT1jyB) _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'uZ\x935\xc3\xa4Mz[\xab'), chr(100) + chr(101) + '\143' + '\x6f' + chr(100) + chr(0b101011 + 0o72))('\x75' + chr(0b1110100) + '\x66' + chr(0b100010 + 0o13) + chr(2139 - 2083))] = MUBCQ_ZKUvaB([QMss2ke2StGn(c8SBz0wzlaO6, label_namespace=xafqLlk3kkUe(SXOLrMavuUCe(b'uZ\x935\xc3\xa4MrJ\xba\xe1?'), chr(0b1100100) + '\145' + chr(0b1010110 + 0o15) + '\x6f' + chr(8894 - 8794) + chr(0b101011 + 0o72))(chr(0b1110101) + chr(10726 - 10610) + '\146' + '\x2d' + '\070')) for c8SBz0wzlaO6 in G1trZ9S2NCus]) _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'jP\x8c7\xc3\x8cTcw\xb3\xe4?b'), chr(3414 - 3314) + '\x65' + chr(99) + '\157' + chr(0b11010 + 0o112) + chr(101))('\165' + chr(0b1011011 + 0o31) + chr(5357 - 5255) + '\x2d' + '\070')] = MUBCQ_ZKUvaB([QMss2ke2StGn(iA06vs86lHyJ, label_namespace=xafqLlk3kkUe(SXOLrMavuUCe(b'jP\x8c7\xc3\x8cTcw\xb3\xec.sW\xda'), chr(100) + '\145' + chr(0b1100011) + '\x6f' + chr(100) + chr(4706 - 4605))(chr(0b1110101) + '\164' + chr(0b11010 + 0o114) + chr(1164 - 1119) + chr(0b110000 + 0o10))) for iA06vs86lHyJ in NOK2o3lcwPEk]) xafqLlk3kkUe(mU7wOAGoTnlM, xafqLlk3kkUe(SXOLrMavuUCe(b'VK\xa1\x1e\xc5\xb5k}Q\xeb\xe8|'), '\144' + chr(8531 - 8430) + '\x63' + '\x6f' + chr(0b1100100) + '\x65')(chr(0b101100 + 0o111) + chr(116) + '\146' + chr(0b101101) + chr(0b11101 + 0o33)))(aVcqhET1qeNF) _yavFU6VJ0wY[xafqLlk3kkUe(SXOLrMavuUCe(b'aZ\x94:\xc8\x9aUr'), '\144' + '\x65' + chr(0b1011111 + 0o4) + '\x6f' + chr(100) + chr(0b1100101))(chr(117) + chr(116) + '\146' + chr(1696 - 1651) + '\x38')] = t6SYWO6Og436(mU7wOAGoTnlM) return _jFYXBmhzM0H(_yavFU6VJ0wY)
allenai/allennlp
allennlp/data/dataset_readers/reading_comprehension/util.py
handle_cannot
def handle_cannot(reference_answers: List[str]): """ Process a list of reference answers. If equal or more than half of the reference answers are "CANNOTANSWER", take it as gold. Otherwise, return answers that are not "CANNOTANSWER". """ num_cannot = 0 num_spans = 0 for ref in reference_answers: if ref == 'CANNOTANSWER': num_cannot += 1 else: num_spans += 1 if num_cannot >= num_spans: reference_answers = ['CANNOTANSWER'] else: reference_answers = [x for x in reference_answers if x != 'CANNOTANSWER'] return reference_answers
python
def handle_cannot(reference_answers: List[str]): """ Process a list of reference answers. If equal or more than half of the reference answers are "CANNOTANSWER", take it as gold. Otherwise, return answers that are not "CANNOTANSWER". """ num_cannot = 0 num_spans = 0 for ref in reference_answers: if ref == 'CANNOTANSWER': num_cannot += 1 else: num_spans += 1 if num_cannot >= num_spans: reference_answers = ['CANNOTANSWER'] else: reference_answers = [x for x in reference_answers if x != 'CANNOTANSWER'] return reference_answers
[ "def", "handle_cannot", "(", "reference_answers", ":", "List", "[", "str", "]", ")", ":", "num_cannot", "=", "0", "num_spans", "=", "0", "for", "ref", "in", "reference_answers", ":", "if", "ref", "==", "'CANNOTANSWER'", ":", "num_cannot", "+=", "1", "else", ":", "num_spans", "+=", "1", "if", "num_cannot", ">=", "num_spans", ":", "reference_answers", "=", "[", "'CANNOTANSWER'", "]", "else", ":", "reference_answers", "=", "[", "x", "for", "x", "in", "reference_answers", "if", "x", "!=", "'CANNOTANSWER'", "]", "return", "reference_answers" ]
Process a list of reference answers. If equal or more than half of the reference answers are "CANNOTANSWER", take it as gold. Otherwise, return answers that are not "CANNOTANSWER".
[ "Process", "a", "list", "of", "reference", "answers", ".", "If", "equal", "or", "more", "than", "half", "of", "the", "reference", "answers", "are", "CANNOTANSWER", "take", "it", "as", "gold", ".", "Otherwise", "return", "answers", "that", "are", "not", "CANNOTANSWER", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/reading_comprehension/util.py#L354-L371
train
Process a list of reference answers.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQC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,reqGiMiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(71 - 23) + chr(111) + '\x31' + '\063' + chr(0b11100 + 0o30), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(5398 - 5287) + '\x31' + '\063' + chr(0b10011 + 0o41), 8), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110011) + chr(0b110100) + chr(0b11110 + 0o25), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(3113 - 3002) + chr(0b110110) + '\062', 0o10), ehT0Px3KOsy9('\060' + chr(1465 - 1354) + chr(0b110010) + chr(1406 - 1355) + chr(432 - 377), 29714 - 29706), ehT0Px3KOsy9('\060' + '\157' + chr(51) + chr(1761 - 1709) + chr(147 - 99), 0b1000), ehT0Px3KOsy9(chr(0b100 + 0o54) + '\x6f' + chr(50) + '\x36' + chr(0b110101), 54929 - 54921), ehT0Px3KOsy9(chr(48) + chr(8628 - 8517) + chr(0b110011) + chr(54) + '\x32', 4211 - 4203), ehT0Px3KOsy9(chr(1058 - 1010) + chr(111) + chr(50) + chr(352 - 301) + '\x32', 25 - 17), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(667 - 613) + chr(0b10010 + 0o37), 0b1000), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(111) + chr(49) + chr(1599 - 1545) + chr(0b101111 + 0o3), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1001001 + 0o46) + '\x31' + chr(737 - 683) + chr(0b110011), 0o10), ehT0Px3KOsy9('\x30' + chr(0b111100 + 0o63) + chr(1258 - 1207) + chr(0b110110) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(11498 - 11387) + chr(0b110110) + '\062', 8), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(111) + chr(0b110001) + '\061' + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b10000 + 0o45) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\x6f' + chr(0b101011 + 0o7) + chr(0b110 + 0o52) + chr(50), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001) + chr(0b110111) + '\x35', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b110100 + 0o73) + '\x33' + chr(53) + '\x34', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + chr(2265 - 2217), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + chr(0b110011) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\067' + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\061' + chr(0b10100 + 0o41) + chr(0b110101), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\x33' + '\x30' + chr(0b100110 + 0o15), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101010 + 0o10) + chr(0b110001) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(1706 - 1658) + chr(111) + chr(0b110001) + chr(49) + chr(0b110101), 52882 - 52874), ehT0Px3KOsy9(chr(1203 - 1155) + chr(0b1101111) + chr(0b110010) + chr(0b10 + 0o56) + '\x34', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(1529 - 1479) + chr(574 - 525) + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1011100 + 0o23) + '\x33' + chr(0b10101 + 0o35) + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + '\x30', 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\x33' + chr(715 - 664) + '\x37', 0o10), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\x6f' + chr(0b10011 + 0o44) + chr(2454 - 2401), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(9990 - 9879) + chr(955 - 905) + '\065' + chr(2432 - 2382), 1061 - 1053), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101111) + chr(49) + chr(2028 - 1973) + chr(55), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + chr(798 - 750) + '\x32', 0o10), ehT0Px3KOsy9(chr(1848 - 1800) + chr(0b10011 + 0o134) + '\063' + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1101111) + chr(0b110100) + chr(0b100001 + 0o22), 17075 - 17067), ehT0Px3KOsy9('\x30' + chr(1844 - 1733) + chr(52) + chr(0b10101 + 0o42), ord("\x08")), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\x6f' + '\x32' + chr(0b110111) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(5297 - 5186) + chr(0b11010 + 0o30) + '\x37' + '\x35', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(5327 - 5216) + chr(53) + chr(48), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'r'), chr(8545 - 8445) + '\145' + chr(0b1100011) + chr(0b1101111) + chr(100) + chr(8307 - 8206))(chr(0b1110101) + chr(116) + '\x66' + '\x2d' + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def JTJwI3sEOqYX(cPqEpm2JCXdw): sCPokiicMyAR = ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(2268 - 2220), ord("\x08")) OUd0ToLbwEx5 = ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1000 + 0o50), 8) for X4s0pSydcnYR in cPqEpm2JCXdw: if X4s0pSydcnYR == xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f\x1d\xad|\xd0\xb4\xf4\xbc\xc9f7!'), '\x64' + chr(2313 - 2212) + chr(6742 - 6643) + chr(111) + chr(0b11110 + 0o106) + '\x65')('\165' + chr(116) + chr(161 - 59) + chr(278 - 233) + chr(56)): sCPokiicMyAR += ehT0Px3KOsy9('\x30' + chr(0b111010 + 0o65) + '\061', 38682 - 38674) else: OUd0ToLbwEx5 += ehT0Px3KOsy9(chr(0b110000) + chr(7252 - 7141) + chr(0b101000 + 0o11), 8) if sCPokiicMyAR >= OUd0ToLbwEx5: cPqEpm2JCXdw = [xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f\x1d\xad|\xd0\xb4\xf4\xbc\xc9f7!'), '\144' + '\145' + '\143' + '\157' + '\144' + '\145')(chr(117) + '\164' + chr(0b1100110) + chr(45) + chr(56))] else: cPqEpm2JCXdw = [OeWW0F1dBPRQ for OeWW0F1dBPRQ in cPqEpm2JCXdw if OeWW0F1dBPRQ != xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f\x1d\xad|\xd0\xb4\xf4\xbc\xc9f7!'), chr(8172 - 8072) + '\x65' + chr(9329 - 9230) + chr(0b1101111) + '\144' + '\145')(chr(4821 - 4704) + chr(0b1101 + 0o147) + chr(8165 - 8063) + '\x2d' + chr(1635 - 1579))] return cPqEpm2JCXdw
allenai/allennlp
allennlp/models/reading_comprehension/util.py
get_best_span
def get_best_span(span_start_logits: torch.Tensor, span_end_logits: torch.Tensor) -> torch.Tensor: """ This acts the same as the static method ``BidirectionalAttentionFlow.get_best_span()`` in ``allennlp/models/reading_comprehension/bidaf.py``. We keep it here so that users can directly import this function without the class. We call the inputs "logits" - they could either be unnormalized logits or normalized log probabilities. A log_softmax operation is a constant shifting of the entire logit vector, so taking an argmax over either one gives the same result. """ if span_start_logits.dim() != 2 or span_end_logits.dim() != 2: raise ValueError("Input shapes must be (batch_size, passage_length)") batch_size, passage_length = span_start_logits.size() device = span_start_logits.device # (batch_size, passage_length, passage_length) span_log_probs = span_start_logits.unsqueeze(2) + span_end_logits.unsqueeze(1) # Only the upper triangle of the span matrix is valid; the lower triangle has entries where # the span ends before it starts. span_log_mask = torch.triu(torch.ones((passage_length, passage_length), device=device)).log() valid_span_log_probs = span_log_probs + span_log_mask # Here we take the span matrix and flatten it, then find the best span using argmax. We # can recover the start and end indices from this flattened list using simple modular # arithmetic. # (batch_size, passage_length * passage_length) best_spans = valid_span_log_probs.view(batch_size, -1).argmax(-1) span_start_indices = best_spans // passage_length span_end_indices = best_spans % passage_length return torch.stack([span_start_indices, span_end_indices], dim=-1)
python
def get_best_span(span_start_logits: torch.Tensor, span_end_logits: torch.Tensor) -> torch.Tensor: """ This acts the same as the static method ``BidirectionalAttentionFlow.get_best_span()`` in ``allennlp/models/reading_comprehension/bidaf.py``. We keep it here so that users can directly import this function without the class. We call the inputs "logits" - they could either be unnormalized logits or normalized log probabilities. A log_softmax operation is a constant shifting of the entire logit vector, so taking an argmax over either one gives the same result. """ if span_start_logits.dim() != 2 or span_end_logits.dim() != 2: raise ValueError("Input shapes must be (batch_size, passage_length)") batch_size, passage_length = span_start_logits.size() device = span_start_logits.device # (batch_size, passage_length, passage_length) span_log_probs = span_start_logits.unsqueeze(2) + span_end_logits.unsqueeze(1) # Only the upper triangle of the span matrix is valid; the lower triangle has entries where # the span ends before it starts. span_log_mask = torch.triu(torch.ones((passage_length, passage_length), device=device)).log() valid_span_log_probs = span_log_probs + span_log_mask # Here we take the span matrix and flatten it, then find the best span using argmax. We # can recover the start and end indices from this flattened list using simple modular # arithmetic. # (batch_size, passage_length * passage_length) best_spans = valid_span_log_probs.view(batch_size, -1).argmax(-1) span_start_indices = best_spans // passage_length span_end_indices = best_spans % passage_length return torch.stack([span_start_indices, span_end_indices], dim=-1)
[ "def", "get_best_span", "(", "span_start_logits", ":", "torch", ".", "Tensor", ",", "span_end_logits", ":", "torch", ".", "Tensor", ")", "->", "torch", ".", "Tensor", ":", "if", "span_start_logits", ".", "dim", "(", ")", "!=", "2", "or", "span_end_logits", ".", "dim", "(", ")", "!=", "2", ":", "raise", "ValueError", "(", "\"Input shapes must be (batch_size, passage_length)\"", ")", "batch_size", ",", "passage_length", "=", "span_start_logits", ".", "size", "(", ")", "device", "=", "span_start_logits", ".", "device", "# (batch_size, passage_length, passage_length)", "span_log_probs", "=", "span_start_logits", ".", "unsqueeze", "(", "2", ")", "+", "span_end_logits", ".", "unsqueeze", "(", "1", ")", "# Only the upper triangle of the span matrix is valid; the lower triangle has entries where", "# the span ends before it starts.", "span_log_mask", "=", "torch", ".", "triu", "(", "torch", ".", "ones", "(", "(", "passage_length", ",", "passage_length", ")", ",", "device", "=", "device", ")", ")", ".", "log", "(", ")", "valid_span_log_probs", "=", "span_log_probs", "+", "span_log_mask", "# Here we take the span matrix and flatten it, then find the best span using argmax. We", "# can recover the start and end indices from this flattened list using simple modular", "# arithmetic.", "# (batch_size, passage_length * passage_length)", "best_spans", "=", "valid_span_log_probs", ".", "view", "(", "batch_size", ",", "-", "1", ")", ".", "argmax", "(", "-", "1", ")", "span_start_indices", "=", "best_spans", "//", "passage_length", "span_end_indices", "=", "best_spans", "%", "passage_length", "return", "torch", ".", "stack", "(", "[", "span_start_indices", ",", "span_end_indices", "]", ",", "dim", "=", "-", "1", ")" ]
This acts the same as the static method ``BidirectionalAttentionFlow.get_best_span()`` in ``allennlp/models/reading_comprehension/bidaf.py``. We keep it here so that users can directly import this function without the class. We call the inputs "logits" - they could either be unnormalized logits or normalized log probabilities. A log_softmax operation is a constant shifting of the entire logit vector, so taking an argmax over either one gives the same result.
[ "This", "acts", "the", "same", "as", "the", "static", "method", "BidirectionalAttentionFlow", ".", "get_best_span", "()", "in", "allennlp", "/", "models", "/", "reading_comprehension", "/", "bidaf", ".", "py", ".", "We", "keep", "it", "here", "so", "that", "users", "can", "directly", "import", "this", "function", "without", "the", "class", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/reading_comprehension/util.py#L4-L33
train
This method returns the best span for the given set of logits.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP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Exqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\x6f' + chr(204 - 155) + chr(48), 54718 - 54710), ehT0Px3KOsy9(chr(0b10000 + 0o40) + '\x6f' + chr(50) + '\x33' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(10029 - 9918) + chr(51) + chr(54) + chr(2214 - 2161), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101010 + 0o5) + chr(49) + chr(0b100001 + 0o17) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x33' + chr(0b110001 + 0o0) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(2104 - 2056) + chr(11952 - 11841) + chr(1671 - 1621) + '\x34' + chr(49), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1110 + 0o141) + chr(2899 - 2845) + chr(1717 - 1665), 32939 - 32931), ehT0Px3KOsy9(chr(2085 - 2037) + chr(0b1101111) + '\x31' + '\x35' + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(8450 - 8339) + chr(0b110011) + chr(54) + chr(0b110000), 7502 - 7494), ehT0Px3KOsy9(chr(0b1 + 0o57) + '\x6f' + chr(50) + '\065' + '\x31', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + '\063' + '\062', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(710 - 662) + chr(0b1101111) + '\x31' + chr(0b1100 + 0o51) + '\064', 25647 - 25639), ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\157' + chr(49) + '\x33' + chr(162 - 113), 12139 - 12131), ehT0Px3KOsy9(chr(2160 - 2112) + chr(5402 - 5291) + '\x32' + chr(2052 - 2001) + chr(1983 - 1931), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110110) + chr(0b100101 + 0o13), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110010) + '\067' + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + chr(0b110101) + chr(2457 - 2406), 0o10), ehT0Px3KOsy9('\x30' + chr(0b111001 + 0o66) + chr(54) + chr(2871 - 2817), 31686 - 31678), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11010 + 0o30) + '\x32', 0b1000), ehT0Px3KOsy9(chr(1998 - 1950) + chr(8446 - 8335) + '\x33' + '\067', 0o10), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b10100 + 0o133) + chr(2420 - 2369) + '\060', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1110 + 0o141) + chr(0b1 + 0o60) + chr(0b110110) + chr(438 - 385), 0o10), ehT0Px3KOsy9(chr(48) + chr(1756 - 1645) + '\x32' + '\x33' + '\x34', 8), ehT0Px3KOsy9('\x30' + '\157' + chr(2380 - 2331) + chr(0b1111 + 0o42) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(1150 - 1102) + chr(6926 - 6815) + chr(0b1110 + 0o47) + chr(0b1100 + 0o45), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001110 + 0o41) + '\x34' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b0 + 0o157) + chr(1163 - 1113) + chr(536 - 481) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1226 - 1175) + chr(2178 - 2128) + chr(2263 - 2215), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b100100 + 0o16) + '\064' + '\066', ord("\x08")), ehT0Px3KOsy9('\060' + chr(11689 - 11578) + chr(868 - 817) + chr(48) + chr(306 - 255), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b101101 + 0o5) + '\066' + '\063', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\063' + chr(615 - 562) + chr(0b100001 + 0o24), 0o10), ehT0Px3KOsy9('\x30' + chr(0b100010 + 0o115) + '\061' + chr(1332 - 1277), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b1100 + 0o46) + chr(50) + chr(525 - 475), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\x36' + chr(2688 - 2636), 8), ehT0Px3KOsy9(chr(1993 - 1945) + chr(8301 - 8190) + '\x34' + chr(2515 - 2461), 0b1000), ehT0Px3KOsy9(chr(606 - 558) + '\x6f' + chr(49) + chr(53) + chr(0b110010), 64110 - 64102), ehT0Px3KOsy9(chr(48) + chr(10248 - 10137) + chr(54) + chr(53), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + chr(50) + chr(55), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(0b101 + 0o152) + chr(0b110101) + '\060', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'&'), chr(510 - 410) + '\145' + '\143' + chr(0b10000 + 0o137) + '\144' + chr(101))(chr(0b1110101) + chr(0b1110100) + '\x66' + '\x2d' + chr(2411 - 2355)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def D1YRssQVY1ZR(DgLcIQmdq__J, Y3Qqi3OfaWAB) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\\\xff\x9b5\xa7\xd3'), chr(0b1100100) + chr(2842 - 2741) + '\143' + chr(10982 - 10871) + '\x64' + chr(987 - 886))('\x75' + '\164' + chr(1837 - 1735) + chr(45) + '\x38')): if xafqLlk3kkUe(DgLcIQmdq__J, xafqLlk3kkUe(SXOLrMavuUCe(b'l\xf3\x98'), '\144' + chr(3154 - 3053) + chr(965 - 866) + '\157' + chr(100) + chr(101))(chr(9532 - 9415) + chr(0b1011001 + 0o33) + chr(0b1000010 + 0o44) + '\x2d' + '\070'))() != ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\x6f' + chr(1240 - 1190), 33142 - 33134) or xafqLlk3kkUe(Y3Qqi3OfaWAB, xafqLlk3kkUe(SXOLrMavuUCe(b'l\xf3\x98'), '\x64' + chr(0b1100101) + '\143' + chr(0b1011111 + 0o20) + chr(100) + '\145')(chr(0b1110101) + '\164' + chr(2593 - 2491) + '\x2d' + chr(0b111000)))() != ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110010), 8): raise q1QCh3W88sgk(xafqLlk3kkUe(SXOLrMavuUCe(b'A\xf4\x853\xbc\x81G\x00\x91\xd9?bL4\xe9C\xcdKTw?0\x17\xfd8JM\xe7\xa3\xcf\xb9\xd6\xc1/\xe2UU\x19T\xb0m\xc5\x99#\xa6\xc6@\x00\xd9'), '\x64' + chr(1144 - 1043) + '\x63' + '\157' + chr(0b1100100) + '\x65')('\165' + chr(116) + chr(0b1100110) + '\055' + '\x38')) (ix9dZyeAmUxY, oc2YJqTuyXgm) = DgLcIQmdq__J.NLcc3BCJnQka() v9dZPx26KxBP = DgLcIQmdq__J.device uXcjkVhCfO1_ = DgLcIQmdq__J.unsqueeze(ehT0Px3KOsy9('\x30' + chr(3118 - 3007) + chr(50), 8)) + Y3Qqi3OfaWAB.unsqueeze(ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001), 34172 - 34164)) cQpjCfHr3Fsk = cEkFpYktkSeK.triu(cEkFpYktkSeK.ones((oc2YJqTuyXgm, oc2YJqTuyXgm), device=v9dZPx26KxBP)).log() cLiXKfV3Jugb = uXcjkVhCfO1_ + cQpjCfHr3Fsk GbC7SV1fxs7E = cLiXKfV3Jugb.view(ix9dZyeAmUxY, -ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110001), 8)).argmax(-ehT0Px3KOsy9('\x30' + chr(111) + chr(0b100111 + 0o12), 8)) BHvOzqX4HPx7 = GbC7SV1fxs7E // oc2YJqTuyXgm wpJrRX5FfRju = GbC7SV1fxs7E % oc2YJqTuyXgm return xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'{\xee\x94%\xa3'), '\144' + chr(9011 - 8910) + chr(99) + chr(0b1101111) + chr(7029 - 6929) + chr(6196 - 6095))('\165' + chr(0b1110100) + '\x66' + '\055' + chr(1779 - 1723)))([BHvOzqX4HPx7, wpJrRX5FfRju], dim=-ehT0Px3KOsy9(chr(48) + '\x6f' + '\061', 8))
allenai/allennlp
allennlp/data/tokenizers/word_splitter.py
WordSplitter.batch_split_words
def batch_split_words(self, sentences: List[str]) -> List[List[Token]]: """ Spacy needs to do batch processing, or it can be really slow. This method lets you take advantage of that if you want. Default implementation is to just iterate of the sentences and call ``split_words``, but the ``SpacyWordSplitter`` will actually do batched processing. """ return [self.split_words(sentence) for sentence in sentences]
python
def batch_split_words(self, sentences: List[str]) -> List[List[Token]]: """ Spacy needs to do batch processing, or it can be really slow. This method lets you take advantage of that if you want. Default implementation is to just iterate of the sentences and call ``split_words``, but the ``SpacyWordSplitter`` will actually do batched processing. """ return [self.split_words(sentence) for sentence in sentences]
[ "def", "batch_split_words", "(", "self", ",", "sentences", ":", "List", "[", "str", "]", ")", "->", "List", "[", "List", "[", "Token", "]", "]", ":", "return", "[", "self", ".", "split_words", "(", "sentence", ")", "for", "sentence", "in", "sentences", "]" ]
Spacy needs to do batch processing, or it can be really slow. This method lets you take advantage of that if you want. Default implementation is to just iterate of the sentences and call ``split_words``, but the ``SpacyWordSplitter`` will actually do batched processing.
[ "Spacy", "needs", "to", "do", "batch", "processing", "or", "it", "can", "be", "really", "slow", ".", "This", "method", "lets", "you", "take", "advantage", "of", "that", "if", "you", "want", ".", "Default", "implementation", "is", "to", "just", "iterate", "of", "the", "sentences", "and", "call", "split_words", "but", "the", "SpacyWordSplitter", "will", "actually", "do", "batched", "processing", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/tokenizers/word_splitter.py#L25-L32
train
This method will iterate over the sentences and split the words into a list of tokens.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0Cg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w8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1960 - 1912) + '\157' + '\063' + chr(379 - 326) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(0b11111 + 0o22) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(183 - 129) + chr(0b110110), 5007 - 4999), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(6481 - 6370) + chr(0b11101 + 0o30) + chr(0b100011 + 0o24), ord("\x08")), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b11111 + 0o120) + chr(788 - 737) + chr(48) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b110100 + 0o73) + chr(994 - 945) + '\x32' + '\x35', 0b1000), ehT0Px3KOsy9(chr(320 - 272) + '\157' + chr(375 - 324) + chr(0b110110) + chr(0b110011 + 0o2), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(2089 - 2036) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + chr(49) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\x6f' + chr(0b110010) + chr(0b110001) + chr(0b11101 + 0o30), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + chr(0b11000 + 0o31) + chr(0b110001), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b10000 + 0o41) + chr(668 - 617) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(1873 - 1825) + chr(111) + chr(0b110011) + '\067' + '\066', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(462 - 351) + chr(0b101 + 0o62) + chr(2322 - 2273), 30492 - 30484), ehT0Px3KOsy9('\060' + chr(0b1010000 + 0o37) + chr(0b110010) + chr(48) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(2266 - 2218) + '\157' + chr(0b11010 + 0o27) + chr(52) + chr(0b1100 + 0o51), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(0b101010 + 0o14) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(1628 - 1580) + chr(0b1101111) + chr(0b110011) + '\x30' + chr(450 - 399), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + chr(0b100110 + 0o12) + chr(0b10011 + 0o35), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(1544 - 1433) + chr(51) + chr(52) + chr(49), 48456 - 48448), ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + chr(0b110010) + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x32' + chr(48) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + '\x37', 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + chr(54) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(0b100000 + 0o117) + chr(0b110001) + chr(569 - 514) + chr(1899 - 1848), 17834 - 17826), ehT0Px3KOsy9('\060' + chr(8469 - 8358) + '\061' + chr(1451 - 1401) + '\060', 44836 - 44828), ehT0Px3KOsy9('\x30' + '\157' + chr(0b11000 + 0o33) + chr(0b110001) + '\065', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(2902 - 2791) + '\x31' + chr(0b100111 + 0o14) + chr(1732 - 1681), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(51) + chr(0b110011 + 0o0) + chr(0b110001), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(1332 - 1280) + chr(54), 59798 - 59790), ehT0Px3KOsy9('\x30' + chr(12203 - 12092) + chr(0b110010), 0o10), ehT0Px3KOsy9('\x30' + chr(5237 - 5126) + chr(1850 - 1795) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(111) + chr(49) + '\060' + '\064', 0b1000), ehT0Px3KOsy9(chr(0b100001 + 0o17) + '\x6f' + '\x33' + '\066' + chr(0b110110), 12958 - 12950), ehT0Px3KOsy9(chr(1977 - 1929) + chr(0b11001 + 0o126) + '\x33' + chr(53) + chr(48), 0b1000), ehT0Px3KOsy9(chr(1939 - 1891) + '\x6f' + chr(0b11010 + 0o31) + chr(52), 38016 - 38008), ehT0Px3KOsy9(chr(2173 - 2125) + chr(111) + chr(0b110010) + chr(53) + '\066', 63517 - 63509), ehT0Px3KOsy9(chr(48) + chr(6076 - 5965) + '\x33' + '\x30', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\x31' + chr(0b101 + 0o57) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x31' + chr(0b11101 + 0o31) + chr(54), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\065' + chr(48), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc7'), chr(100) + '\145' + '\x63' + '\x6f' + chr(0b1100100) + chr(0b1100101))(chr(0b1110101) + chr(10356 - 10240) + chr(0b111010 + 0o54) + chr(0b101101) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def V6ebiEF_UaaY(oVre8I6UXc3b, tqdrVw7QhW0i) -> qRxF7OQ0y39T[qRxF7OQ0y39T[umJ2jcr5NLY0]]: return [xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9a\xfe\xdaF\xb5\n\x82E>\xe9\xba'), chr(0b1100100) + chr(5695 - 5594) + chr(0b1100011) + chr(0b110 + 0o151) + chr(100) + chr(0b11000 + 0o115))(chr(117) + chr(116) + '\146' + '\x2d' + chr(817 - 761)))(pamQPTGoym5v) for pamQPTGoym5v in tqdrVw7QhW0i]
allenai/allennlp
allennlp/state_machines/beam_search.py
BeamSearch.constrained_to
def constrained_to(self, initial_sequence: torch.Tensor, keep_beam_details: bool = True) -> 'BeamSearch': """ Return a new BeamSearch instance that's like this one but with the specified constraint. """ return BeamSearch(self._beam_size, self._per_node_beam_size, initial_sequence, keep_beam_details)
python
def constrained_to(self, initial_sequence: torch.Tensor, keep_beam_details: bool = True) -> 'BeamSearch': """ Return a new BeamSearch instance that's like this one but with the specified constraint. """ return BeamSearch(self._beam_size, self._per_node_beam_size, initial_sequence, keep_beam_details)
[ "def", "constrained_to", "(", "self", ",", "initial_sequence", ":", "torch", ".", "Tensor", ",", "keep_beam_details", ":", "bool", "=", "True", ")", "->", "'BeamSearch'", ":", "return", "BeamSearch", "(", "self", ".", "_beam_size", ",", "self", ".", "_per_node_beam_size", ",", "initial_sequence", ",", "keep_beam_details", ")" ]
Return a new BeamSearch instance that's like this one but with the specified constraint.
[ "Return", "a", "new", "BeamSearch", "instance", "that", "s", "like", "this", "one", "but", "with", "the", "specified", "constraint", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/state_machines/beam_search.py#L70-L74
train
Returns a new instance that s like this one but with the specified constraint.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ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cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\157' + '\063' + chr(0b110011) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + '\x35' + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\x6f' + chr(2347 - 2298) + chr(747 - 699) + '\x37', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b11000 + 0o127) + '\062' + chr(0b110010) + '\067', 18281 - 18273), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + '\065' + chr(0b11110 + 0o24), 0o10), ehT0Px3KOsy9(chr(1096 - 1048) + '\x6f' + '\061' + chr(0b0 + 0o61) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b10110 + 0o131) + '\061' + chr(2577 - 2524) + chr(0b10 + 0o61), 42071 - 42063), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001 + 0o146) + chr(50) + chr(500 - 448) + '\x31', 2292 - 2284), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\061' + '\064' + '\063', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(6714 - 6603) + '\061' + chr(0b101111 + 0o5), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(1007 - 959) + chr(0b1011111 + 0o20) + chr(0b10000 + 0o43) + chr(1960 - 1912) + chr(991 - 939), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(1847 - 1736) + '\x32' + '\x32' + chr(1141 - 1091), 0o10), ehT0Px3KOsy9('\060' + chr(5693 - 5582) + chr(50) + chr(0b110000) + chr(0b110100 + 0o0), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b10100 + 0o35) + chr(0b110010) + chr(0b101010 + 0o12), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + '\063' + '\066', 56858 - 56850), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1765 - 1716) + chr(2684 - 2631) + chr(1858 - 1805), 0b1000), ehT0Px3KOsy9('\x30' + chr(8833 - 8722) + chr(0b110000 + 0o2) + '\065' + chr(1980 - 1930), 8), ehT0Px3KOsy9(chr(48) + chr(0b1 + 0o156) + '\064' + '\x32', 65053 - 65045), ehT0Px3KOsy9(chr(0b110000) + chr(12090 - 11979) + chr(0b110001) + chr(0b101 + 0o53) + chr(1366 - 1318), 0b1000), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(0b10100 + 0o133) + chr(1113 - 1064) + '\061' + chr(0b10 + 0o56), ord("\x08")), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1001000 + 0o47) + chr(0b1101 + 0o44) + '\x34' + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110101) + chr(0b100101 + 0o21), 0o10), ehT0Px3KOsy9('\060' + chr(0b1010111 + 0o30) + '\x31' + chr(51) + chr(2513 - 2459), 8), ehT0Px3KOsy9('\060' + '\157' + chr(52) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(4349 - 4238) + chr(0b110011) + chr(0b10101 + 0o37) + '\x34', 0b1000), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(945 - 834) + '\x31' + chr(49) + chr(0b110000), 8), ehT0Px3KOsy9(chr(0b110000) + chr(6715 - 6604) + '\x36' + '\x37', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1100011 + 0o14) + chr(49) + chr(50) + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\064' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b10011 + 0o37) + chr(48) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(433 - 385) + '\157' + '\064' + '\x32', 8), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + chr(52) + chr(2657 - 2603), 0o10), ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\x6f' + chr(2112 - 2063) + '\065' + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(177 - 129) + '\x6f' + '\x33' + chr(1141 - 1091), 7667 - 7659), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + '\064' + chr(0b110011), 8), ehT0Px3KOsy9(chr(482 - 434) + chr(0b110001 + 0o76) + chr(0b110011 + 0o0) + chr(50) + chr(2032 - 1984), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(53), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110111) + '\x32', 0o10), ehT0Px3KOsy9('\x30' + chr(7188 - 7077) + chr(0b11 + 0o57) + chr(0b110010), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x35' + chr(0b110000), 26622 - 26614)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf7'), '\x64' + chr(101) + chr(0b1100011) + chr(8249 - 8138) + '\x64' + chr(101))(chr(6555 - 6438) + chr(116) + chr(0b1100110) + '\055' + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def GrQLuQXUyHtt(oVre8I6UXc3b, HqI9Qq8fzAhG, suXx7Y7uAtqm=ehT0Px3KOsy9('\x30' + chr(3133 - 3022) + '\x31', ord("\x08"))) -> xafqLlk3kkUe(SXOLrMavuUCe(b'\x9b\x0c&\xfa\xf9(\n\xd3\x00d'), chr(8115 - 8015) + '\145' + chr(8758 - 8659) + '\157' + chr(0b1000111 + 0o35) + chr(0b1100101))(chr(0b1110101) + '\164' + chr(0b11101 + 0o111) + chr(0b101101) + chr(0b110001 + 0o7)): return aK9do8_R2Dij(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x86\x0b"\xf6\xc7\x12\x18\xc8\x19i'), chr(3569 - 3469) + '\145' + chr(99) + chr(111) + '\x64' + chr(9985 - 9884))('\165' + '\x74' + '\146' + chr(1118 - 1073) + '\x38')), xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x86\x19"\xe5\xf5#\x04\xc5\x06Sq\xa1\xf3\xe9\x0b-\x04\xd0G'), chr(0b1000101 + 0o37) + chr(8289 - 8188) + chr(99) + chr(0b1001101 + 0o42) + chr(0b1100100) + chr(3996 - 3895))(chr(117) + chr(2448 - 2332) + chr(0b1011101 + 0o11) + '\x2d' + '\070')), HqI9Qq8fzAhG, suXx7Y7uAtqm)
allenai/allennlp
allennlp/state_machines/beam_search.py
BeamSearch.search
def search(self, num_steps: int, initial_state: StateType, transition_function: TransitionFunction, keep_final_unfinished_states: bool = True) -> Dict[int, List[StateType]]: """ Parameters ---------- num_steps : ``int`` How many steps should we take in our search? This is an upper bound, as it's possible for the search to run out of valid actions before hitting this number, or for all states on the beam to finish. initial_state : ``StateType`` The starting state of our search. This is assumed to be `batched`, and our beam search is batch-aware - we'll keep ``beam_size`` states around for each instance in the batch. transition_function : ``TransitionFunction`` The ``TransitionFunction`` object that defines and scores transitions from one state to the next. keep_final_unfinished_states : ``bool``, optional (default=True) If we run out of steps before a state is "finished", should we return that state in our search results? Returns ------- best_states : ``Dict[int, List[StateType]]`` This is a mapping from batch index to the top states for that instance. """ finished_states: Dict[int, List[StateType]] = defaultdict(list) states = [initial_state] step_num = 1 # Erase stored beams, if we're tracking them. if self.beam_snapshots is not None: self.beam_snapshots = defaultdict(list) while states and step_num <= num_steps: next_states: Dict[int, List[StateType]] = defaultdict(list) grouped_state = states[0].combine_states(states) if self._allowed_transitions: # We were provided an initial sequence, so we need to check # if the current sequence is still constrained. key = tuple(grouped_state.action_history[0]) if key in self._allowed_transitions: # We're still in the initial_sequence, so our hand is forced. allowed_actions = [self._allowed_transitions[key]] else: # We've gone past the end of the initial sequence, so no constraint. allowed_actions = None else: # No initial sequence was provided, so all actions are allowed. allowed_actions = None for next_state in transition_function.take_step(grouped_state, max_actions=self._per_node_beam_size, allowed_actions=allowed_actions): # NOTE: we're doing state.batch_indices[0] here (and similar things below), # hard-coding a group size of 1. But, our use of `next_state.is_finished()` # already checks for that, as it crashes if the group size is not 1. batch_index = next_state.batch_indices[0] if next_state.is_finished(): finished_states[batch_index].append(next_state) else: if step_num == num_steps and keep_final_unfinished_states: finished_states[batch_index].append(next_state) next_states[batch_index].append(next_state) states = [] for batch_index, batch_states in next_states.items(): # The states from the generator are already sorted, so we can just take the first # ones here, without an additional sort. states.extend(batch_states[:self._beam_size]) if self.beam_snapshots is not None: # Add to beams self.beam_snapshots[batch_index].append( [(state.score[0].item(), state.action_history[0]) for state in batch_states] ) step_num += 1 # Add finished states to the stored beams as well. if self.beam_snapshots is not None: for batch_index, states in finished_states.items(): for state in states: score = state.score[0].item() action_history = state.action_history[0] while len(self.beam_snapshots[batch_index]) < len(action_history): self.beam_snapshots[batch_index].append([]) self.beam_snapshots[batch_index][len(action_history) - 1].append((score, action_history)) best_states: Dict[int, List[StateType]] = {} for batch_index, batch_states in finished_states.items(): # The time this sort takes is pretty negligible, no particular need to optimize this # yet. Maybe with a larger beam size... finished_to_sort = [(-state.score[0].item(), state) for state in batch_states] finished_to_sort.sort(key=lambda x: x[0]) best_states[batch_index] = [state[1] for state in finished_to_sort[:self._beam_size]] return best_states
python
def search(self, num_steps: int, initial_state: StateType, transition_function: TransitionFunction, keep_final_unfinished_states: bool = True) -> Dict[int, List[StateType]]: """ Parameters ---------- num_steps : ``int`` How many steps should we take in our search? This is an upper bound, as it's possible for the search to run out of valid actions before hitting this number, or for all states on the beam to finish. initial_state : ``StateType`` The starting state of our search. This is assumed to be `batched`, and our beam search is batch-aware - we'll keep ``beam_size`` states around for each instance in the batch. transition_function : ``TransitionFunction`` The ``TransitionFunction`` object that defines and scores transitions from one state to the next. keep_final_unfinished_states : ``bool``, optional (default=True) If we run out of steps before a state is "finished", should we return that state in our search results? Returns ------- best_states : ``Dict[int, List[StateType]]`` This is a mapping from batch index to the top states for that instance. """ finished_states: Dict[int, List[StateType]] = defaultdict(list) states = [initial_state] step_num = 1 # Erase stored beams, if we're tracking them. if self.beam_snapshots is not None: self.beam_snapshots = defaultdict(list) while states and step_num <= num_steps: next_states: Dict[int, List[StateType]] = defaultdict(list) grouped_state = states[0].combine_states(states) if self._allowed_transitions: # We were provided an initial sequence, so we need to check # if the current sequence is still constrained. key = tuple(grouped_state.action_history[0]) if key in self._allowed_transitions: # We're still in the initial_sequence, so our hand is forced. allowed_actions = [self._allowed_transitions[key]] else: # We've gone past the end of the initial sequence, so no constraint. allowed_actions = None else: # No initial sequence was provided, so all actions are allowed. allowed_actions = None for next_state in transition_function.take_step(grouped_state, max_actions=self._per_node_beam_size, allowed_actions=allowed_actions): # NOTE: we're doing state.batch_indices[0] here (and similar things below), # hard-coding a group size of 1. But, our use of `next_state.is_finished()` # already checks for that, as it crashes if the group size is not 1. batch_index = next_state.batch_indices[0] if next_state.is_finished(): finished_states[batch_index].append(next_state) else: if step_num == num_steps and keep_final_unfinished_states: finished_states[batch_index].append(next_state) next_states[batch_index].append(next_state) states = [] for batch_index, batch_states in next_states.items(): # The states from the generator are already sorted, so we can just take the first # ones here, without an additional sort. states.extend(batch_states[:self._beam_size]) if self.beam_snapshots is not None: # Add to beams self.beam_snapshots[batch_index].append( [(state.score[0].item(), state.action_history[0]) for state in batch_states] ) step_num += 1 # Add finished states to the stored beams as well. if self.beam_snapshots is not None: for batch_index, states in finished_states.items(): for state in states: score = state.score[0].item() action_history = state.action_history[0] while len(self.beam_snapshots[batch_index]) < len(action_history): self.beam_snapshots[batch_index].append([]) self.beam_snapshots[batch_index][len(action_history) - 1].append((score, action_history)) best_states: Dict[int, List[StateType]] = {} for batch_index, batch_states in finished_states.items(): # The time this sort takes is pretty negligible, no particular need to optimize this # yet. Maybe with a larger beam size... finished_to_sort = [(-state.score[0].item(), state) for state in batch_states] finished_to_sort.sort(key=lambda x: x[0]) best_states[batch_index] = [state[1] for state in finished_to_sort[:self._beam_size]] return best_states
[ "def", "search", "(", "self", ",", "num_steps", ":", "int", ",", "initial_state", ":", "StateType", ",", "transition_function", ":", "TransitionFunction", ",", "keep_final_unfinished_states", ":", "bool", "=", "True", ")", "->", "Dict", "[", "int", ",", "List", "[", "StateType", "]", "]", ":", "finished_states", ":", "Dict", "[", "int", ",", "List", "[", "StateType", "]", "]", "=", "defaultdict", "(", "list", ")", "states", "=", "[", "initial_state", "]", "step_num", "=", "1", "# Erase stored beams, if we're tracking them.", "if", "self", ".", "beam_snapshots", "is", "not", "None", ":", "self", ".", "beam_snapshots", "=", "defaultdict", "(", "list", ")", "while", "states", "and", "step_num", "<=", "num_steps", ":", "next_states", ":", "Dict", "[", "int", ",", "List", "[", "StateType", "]", "]", "=", "defaultdict", "(", "list", ")", "grouped_state", "=", "states", "[", "0", "]", ".", "combine_states", "(", "states", ")", "if", "self", ".", "_allowed_transitions", ":", "# We were provided an initial sequence, so we need to check", "# if the current sequence is still constrained.", "key", "=", "tuple", "(", "grouped_state", ".", "action_history", "[", "0", "]", ")", "if", "key", "in", "self", ".", "_allowed_transitions", ":", "# We're still in the initial_sequence, so our hand is forced.", "allowed_actions", "=", "[", "self", ".", "_allowed_transitions", "[", "key", "]", "]", "else", ":", "# We've gone past the end of the initial sequence, so no constraint.", "allowed_actions", "=", "None", "else", ":", "# No initial sequence was provided, so all actions are allowed.", "allowed_actions", "=", "None", "for", "next_state", "in", "transition_function", ".", "take_step", "(", "grouped_state", ",", "max_actions", "=", "self", ".", "_per_node_beam_size", ",", "allowed_actions", "=", "allowed_actions", ")", ":", "# NOTE: we're doing state.batch_indices[0] here (and similar things below),", "# hard-coding a group size of 1. But, our use of `next_state.is_finished()`", "# already checks for that, as it crashes if the group size is not 1.", "batch_index", "=", "next_state", ".", "batch_indices", "[", "0", "]", "if", "next_state", ".", "is_finished", "(", ")", ":", "finished_states", "[", "batch_index", "]", ".", "append", "(", "next_state", ")", "else", ":", "if", "step_num", "==", "num_steps", "and", "keep_final_unfinished_states", ":", "finished_states", "[", "batch_index", "]", ".", "append", "(", "next_state", ")", "next_states", "[", "batch_index", "]", ".", "append", "(", "next_state", ")", "states", "=", "[", "]", "for", "batch_index", ",", "batch_states", "in", "next_states", ".", "items", "(", ")", ":", "# The states from the generator are already sorted, so we can just take the first", "# ones here, without an additional sort.", "states", ".", "extend", "(", "batch_states", "[", ":", "self", ".", "_beam_size", "]", ")", "if", "self", ".", "beam_snapshots", "is", "not", "None", ":", "# Add to beams", "self", ".", "beam_snapshots", "[", "batch_index", "]", ".", "append", "(", "[", "(", "state", ".", "score", "[", "0", "]", ".", "item", "(", ")", ",", "state", ".", "action_history", "[", "0", "]", ")", "for", "state", "in", "batch_states", "]", ")", "step_num", "+=", "1", "# Add finished states to the stored beams as well.", "if", "self", ".", "beam_snapshots", "is", "not", "None", ":", "for", "batch_index", ",", "states", "in", "finished_states", ".", "items", "(", ")", ":", "for", "state", "in", "states", ":", "score", "=", "state", ".", "score", "[", "0", "]", ".", "item", "(", ")", "action_history", "=", "state", ".", "action_history", "[", "0", "]", "while", "len", "(", "self", ".", "beam_snapshots", "[", "batch_index", "]", ")", "<", "len", "(", "action_history", ")", ":", "self", ".", "beam_snapshots", "[", "batch_index", "]", ".", "append", "(", "[", "]", ")", "self", ".", "beam_snapshots", "[", "batch_index", "]", "[", "len", "(", "action_history", ")", "-", "1", "]", ".", "append", "(", "(", "score", ",", "action_history", ")", ")", "best_states", ":", "Dict", "[", "int", ",", "List", "[", "StateType", "]", "]", "=", "{", "}", "for", "batch_index", ",", "batch_states", "in", "finished_states", ".", "items", "(", ")", ":", "# The time this sort takes is pretty negligible, no particular need to optimize this", "# yet. Maybe with a larger beam size...", "finished_to_sort", "=", "[", "(", "-", "state", ".", "score", "[", "0", "]", ".", "item", "(", ")", ",", "state", ")", "for", "state", "in", "batch_states", "]", "finished_to_sort", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x", "[", "0", "]", ")", "best_states", "[", "batch_index", "]", "=", "[", "state", "[", "1", "]", "for", "state", "in", "finished_to_sort", "[", ":", "self", ".", "_beam_size", "]", "]", "return", "best_states" ]
Parameters ---------- num_steps : ``int`` How many steps should we take in our search? This is an upper bound, as it's possible for the search to run out of valid actions before hitting this number, or for all states on the beam to finish. initial_state : ``StateType`` The starting state of our search. This is assumed to be `batched`, and our beam search is batch-aware - we'll keep ``beam_size`` states around for each instance in the batch. transition_function : ``TransitionFunction`` The ``TransitionFunction`` object that defines and scores transitions from one state to the next. keep_final_unfinished_states : ``bool``, optional (default=True) If we run out of steps before a state is "finished", should we return that state in our search results? Returns ------- best_states : ``Dict[int, List[StateType]]`` This is a mapping from batch index to the top states for that instance.
[ "Parameters", "----------", "num_steps", ":", "int", "How", "many", "steps", "should", "we", "take", "in", "our", "search?", "This", "is", "an", "upper", "bound", "as", "it", "s", "possible", "for", "the", "search", "to", "run", "out", "of", "valid", "actions", "before", "hitting", "this", "number", "or", "for", "all", "states", "on", "the", "beam", "to", "finish", ".", "initial_state", ":", "StateType", "The", "starting", "state", "of", "our", "search", ".", "This", "is", "assumed", "to", "be", "batched", "and", "our", "beam", "search", "is", "batch", "-", "aware", "-", "we", "ll", "keep", "beam_size", "states", "around", "for", "each", "instance", "in", "the", "batch", ".", "transition_function", ":", "TransitionFunction", "The", "TransitionFunction", "object", "that", "defines", "and", "scores", "transitions", "from", "one", "state", "to", "the", "next", ".", "keep_final_unfinished_states", ":", "bool", "optional", "(", "default", "=", "True", ")", "If", "we", "run", "out", "of", "steps", "before", "a", "state", "is", "finished", "should", "we", "return", "that", "state", "in", "our", "search", "results?" ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/state_machines/beam_search.py#L76-L175
train
Search for a specific state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RZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(0b1101111) + chr(575 - 524) + chr(50) + '\x36', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + chr(0b101111 + 0o5), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(312 - 263) + chr(0b110010) + chr(2418 - 2366), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + chr(1161 - 1108) + '\x31', 34499 - 34491), ehT0Px3KOsy9(chr(132 - 84) + '\x6f' + '\x31' + '\063' + chr(1006 - 952), ord("\x08")), ehT0Px3KOsy9(chr(1271 - 1223) + chr(0b1101111) + '\062' + '\065' + chr(0b11100 + 0o30), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + chr(0b110001) + '\x30', 0b1000), ehT0Px3KOsy9(chr(239 - 191) + chr(0b1101111) + chr(51) + '\060' + '\062', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(52) + chr(54), 0o10), ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\157' + chr(51) + '\067' + chr(2110 - 2056), 0b1000), ehT0Px3KOsy9('\x30' + chr(10710 - 10599) + '\062' + chr(2247 - 2196) + chr(0b1000 + 0o51), 0o10), ehT0Px3KOsy9(chr(2058 - 2010) + chr(0b1010010 + 0o35) + chr(51) + chr(1118 - 1068) + chr(55), 0o10), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(0b1101111 + 0o0) + chr(0b10100 + 0o35) + '\063' + chr(0b110010), 11828 - 11820), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\157' + '\062' + chr(2113 - 2064) + '\067', 0b1000), ehT0Px3KOsy9('\060' + chr(3007 - 2896) + chr(0b100 + 0o55) + chr(0b110101) + '\x30', 0o10), ehT0Px3KOsy9(chr(48) + chr(7111 - 7000) + '\061' + '\065' + chr(54), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(2384 - 2334) + chr(0b110011) + chr(1167 - 1118), 8), ehT0Px3KOsy9(chr(1456 - 1408) + chr(0b1110 + 0o141) + chr(49) + chr(2365 - 2316) + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010010 + 0o35) + chr(49) + '\060' + '\066', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(6863 - 6752) + '\063' + chr(0b100000 + 0o20), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\061' + chr(0b11100 + 0o26), ord("\x08")), ehT0Px3KOsy9(chr(1292 - 1244) + chr(11819 - 11708) + chr(1423 - 1374) + chr(0b110011) + '\x36', 8), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(12293 - 12182) + '\x32' + chr(50) + chr(53), 0b1000), ehT0Px3KOsy9(chr(421 - 373) + chr(0b1101111) + '\x31' + chr(0b110011) + chr(2350 - 2296), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001 + 0o0) + chr(0b110110) + chr(53), 43917 - 43909), ehT0Px3KOsy9(chr(230 - 182) + '\x6f' + chr(49) + chr(0b110001) + chr(0b100111 + 0o13), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110010) + chr(48) + '\064', 1985 - 1977), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + chr(1352 - 1301) + chr(0b110111) + '\x31', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b101010 + 0o105) + chr(50) + chr(1523 - 1471) + '\062', 0b1000), ehT0Px3KOsy9(chr(610 - 562) + '\157' + chr(0b110 + 0o53) + chr(1803 - 1752) + chr(0b1100 + 0o51), 42621 - 42613), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(440 - 390) + chr(2274 - 2223), 8288 - 8280), ehT0Px3KOsy9(chr(48) + chr(0b1010111 + 0o30) + '\061' + chr(0b110100) + chr(0b110000 + 0o3), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(51) + chr(0b11 + 0o63) + chr(500 - 446), 0b1000), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(6232 - 6121) + '\061' + chr(0b101111 + 0o5) + chr(0b110010 + 0o1), 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(2050 - 2001) + chr(55) + chr(2482 - 2430), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110 + 0o57), 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1010011 + 0o34) + '\063' + chr(0b110101), 33691 - 33683), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b100110 + 0o14) + chr(290 - 237) + chr(0b110010 + 0o2), 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + chr(0b110000) + chr(50), 8), ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\x6f' + '\x35' + chr(0b1100 + 0o52), 51615 - 51607)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b101 + 0o60) + '\060', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf8'), '\x64' + chr(101) + '\x63' + '\157' + chr(0b1100100) + chr(0b1100101))(chr(117) + '\164' + '\x66' + '\055' + chr(56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def d3sjjjpuU5tq(oVre8I6UXc3b, UQsgPnJC3jY0, jXyGqlVq68Bb, Ew8eGiv6mHjR, wtRuQcTfrAF2=ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061', 30594 - 30586)) -> zBnV56fc6HrA[ehT0Px3KOsy9, qRxF7OQ0y39T[Q8UDZwNlk6Wk]]: HV1dcqfUnFmU = rLgqW9imlCdX(YyaZ4tpXu4lf) jI0E6zso5mLP = [jXyGqlVq68Bb] s4MGxQMbnqrH = ehT0Px3KOsy9(chr(470 - 422) + chr(0b100101 + 0o112) + '\x31', 8) if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb4q5\x84\x01\xdf&\xa3\xd6\x8d\xf1\xb8.\xfc'), '\144' + chr(0b1100101) + '\143' + chr(0b1100001 + 0o16) + '\144' + '\145')(chr(0b1110101) + chr(0b1110100) + '\146' + '\055' + chr(56))) is not None: oVre8I6UXc3b.JYKtIYnx7Kgb = rLgqW9imlCdX(YyaZ4tpXu4lf) while jI0E6zso5mLP and s4MGxQMbnqrH <= UQsgPnJC3jY0: jPZpDZH3GdVX = rLgqW9imlCdX(YyaZ4tpXu4lf) HFKIjhy8OINa = jI0E6zso5mLP[ehT0Px3KOsy9('\060' + '\x6f' + chr(2153 - 2105), 0o10)].combine_states(jI0E6zso5mLP) if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x89u8\x851\xdb-\xa6\xf9\x8a\xeb\xb64\xfc\x01\x1a\xf0 (k'), chr(6316 - 6216) + chr(0b1100101) + chr(99) + chr(0b11100 + 0o123) + '\144' + '\145')(chr(0b1110101) + chr(116) + chr(0b1100110) + chr(45) + chr(56))): K3J4ZwSlE0sT = KNyTy8rYcwji(HFKIjhy8OINa.action_history[ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\060', 8)]) if K3J4ZwSlE0sT in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x89u8\x851\xdb-\xa6\xf9\x8a\xeb\xb64\xfc\x01\x1a\xf0 (k'), chr(0b1100100) + chr(5049 - 4948) + chr(99) + '\157' + chr(100) + chr(101))('\165' + chr(0b1110100) + chr(3514 - 3412) + chr(0b101101) + '\070')): BNz_fSTQLGui = [oVre8I6UXc3b._allowed_transitions[K3J4ZwSlE0sT]] else: BNz_fSTQLGui = None else: BNz_fSTQLGui = None for l7yOP9uqtsC4 in xafqLlk3kkUe(Ew8eGiv6mHjR, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa2u?\x8c\x01\xdf<\xa7\xd6'), chr(100) + chr(101) + chr(4290 - 4191) + chr(111) + '\144' + chr(0b10001 + 0o124))('\x75' + chr(0b1110100) + chr(7250 - 7148) + chr(45) + '\070'))(HFKIjhy8OINa, max_actions=xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b"\x89d1\x9b\x01\xc2'\xa6\xc3\xa1\xfb\xb2;\xe27\x1d\xf05#"), chr(0b1100100) + '\145' + chr(0b100101 + 0o76) + chr(0b1011010 + 0o25) + chr(0b1010001 + 0o23) + chr(0b10101 + 0o120))('\x75' + chr(10363 - 10247) + chr(0b0 + 0o146) + chr(0b101101) + '\070')), allowed_actions=BNz_fSTQLGui): Q3TVZeZzkrZ0 = l7yOP9uqtsC4.batch_indices[ehT0Px3KOsy9('\060' + chr(111) + chr(0b110 + 0o52), 8)] if xafqLlk3kkUe(l7yOP9uqtsC4, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbfg\x0b\x8f7\xc2!\xb1\xce\x9b\xfd'), chr(100) + '\145' + chr(0b1100011) + chr(111) + '\144' + '\x65')('\165' + chr(1473 - 1357) + chr(102) + chr(0b1101 + 0o40) + '\x38'))(): xafqLlk3kkUe(HV1dcqfUnFmU[Q3TVZeZzkrZ0], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb7d$\x8c0\xc8'), '\144' + chr(0b1001 + 0o134) + chr(185 - 86) + chr(5097 - 4986) + '\144' + chr(2710 - 2609))(chr(0b1110101) + '\164' + chr(102) + chr(1055 - 1010) + chr(56)))(l7yOP9uqtsC4) else: if s4MGxQMbnqrH == UQsgPnJC3jY0 and wtRuQcTfrAF2: xafqLlk3kkUe(HV1dcqfUnFmU[Q3TVZeZzkrZ0], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb7d$\x8c0\xc8'), '\x64' + '\x65' + '\x63' + chr(111) + chr(8892 - 8792) + chr(0b1100101))('\165' + chr(0b110001 + 0o103) + '\146' + chr(0b11000 + 0o25) + '\x38'))(l7yOP9uqtsC4) xafqLlk3kkUe(jPZpDZH3GdVX[Q3TVZeZzkrZ0], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb7d$\x8c0\xc8'), '\144' + '\x65' + chr(0b1000111 + 0o34) + chr(111) + chr(0b101010 + 0o72) + '\x65')(chr(0b1110101) + '\164' + chr(0b100001 + 0o105) + chr(1868 - 1823) + '\x38'))(l7yOP9uqtsC4) jI0E6zso5mLP = [] for (Q3TVZeZzkrZ0, t6Sd6XIAAZlg) in xafqLlk3kkUe(jPZpDZH3GdVX, xafqLlk3kkUe(SXOLrMavuUCe(b'\x98n"\x8c\x17\xf6{\x8b\xca\xad\xd1\xee'), chr(0b1001 + 0o133) + chr(0b1100101 + 0o0) + chr(0b100011 + 0o100) + chr(0b100111 + 0o110) + chr(100) + chr(101))(chr(117) + '\x74' + chr(6076 - 5974) + '\055' + '\070'))(): xafqLlk3kkUe(jI0E6zso5mLP, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb3l \x8c0\xc8'), '\144' + chr(101) + chr(0b110100 + 0o57) + chr(6648 - 6537) + chr(0b1100100) + chr(0b1100101))('\165' + '\164' + '\146' + chr(0b101101) + chr(1470 - 1414)))(t6Sd6XIAAZlg[:xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x89v1\x883\xf3;\xab\xdc\x9b'), '\144' + chr(8213 - 8112) + '\143' + chr(0b1010001 + 0o36) + '\x64' + chr(0b1100101))('\165' + chr(0b1110100) + chr(8052 - 7950) + '\x2d' + '\070'))]) if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9cM\x1f\x9d\x17\xf5&\xba\x91\xb5\xfe\xb5'), chr(0b1100100) + chr(101) + chr(0b111000 + 0o53) + chr(0b110101 + 0o72) + '\144' + '\145')(chr(117) + '\164' + chr(0b1100110) + '\055' + chr(0b11001 + 0o37))) is not None: xafqLlk3kkUe(oVre8I6UXc3b.beam_snapshots[Q3TVZeZzkrZ0], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb7d$\x8c0\xc8'), chr(0b1001011 + 0o31) + chr(0b1100101) + chr(0b1100011) + '\157' + chr(100) + '\x65')(chr(0b1110101) + chr(10192 - 10076) + '\x66' + chr(45) + chr(333 - 277)))([(xafqLlk3kkUe(KKFQISrGeiAm.score[ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(10312 - 10201) + chr(1551 - 1503), 8)], xafqLlk3kkUe(SXOLrMavuUCe(b'\x98#>\xde;\xfc\x1c\x9a\xdc\x84\xd0\xe7'), chr(5245 - 5145) + '\145' + chr(99) + '\x6f' + chr(100) + chr(101))('\x75' + '\x74' + chr(9753 - 9651) + chr(914 - 869) + chr(0b110110 + 0o2)))(), xafqLlk3kkUe(KKFQISrGeiAm, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb7w \x801\xc2\x17\xaa\xcf\x8d\xed\xb8(\xf6'), chr(0b1100100) + chr(101) + chr(0b1100011) + '\157' + '\144' + chr(0b10011 + 0o122))('\165' + '\164' + '\x66' + '\x2d' + chr(805 - 749)))[ehT0Px3KOsy9('\060' + chr(0b1011010 + 0o25) + '\060', 8)]) for KKFQISrGeiAm in t6Sd6XIAAZlg]) s4MGxQMbnqrH += ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061', 8) if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9cM\x1f\x9d\x17\xf5&\xba\x91\xb5\xfe\xb5'), chr(7757 - 7657) + chr(0b1100101) + '\x63' + chr(7142 - 7031) + '\x64' + chr(0b1100101))('\x75' + '\164' + chr(102) + chr(0b101101) + chr(605 - 549))) is not None: for (Q3TVZeZzkrZ0, jI0E6zso5mLP) in xafqLlk3kkUe(HV1dcqfUnFmU, xafqLlk3kkUe(SXOLrMavuUCe(b'\x98n"\x8c\x17\xf6{\x8b\xca\xad\xd1\xee'), chr(0b1010000 + 0o24) + chr(0b100001 + 0o104) + '\143' + chr(111) + '\144' + chr(0b1100101))('\x75' + chr(0b1100 + 0o150) + '\146' + chr(0b101101) + chr(0b10001 + 0o47)))(): for KKFQISrGeiAm in jI0E6zso5mLP: n9fd4FsgoqFs = KKFQISrGeiAm.score[ehT0Px3KOsy9(chr(2281 - 2233) + chr(0b10001 + 0o136) + chr(0b110000), 8)].N7j7ePTXzzI0() sdGUbW0q0W8A = KKFQISrGeiAm.action_history[ehT0Px3KOsy9('\x30' + '\x6f' + '\060', 8)] while c2A0yzQpDQB3(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9cM\x1f\x9d\x17\xf5&\xba\x91\xb5\xfe\xb5'), chr(2614 - 2514) + chr(6293 - 6192) + '\x63' + chr(1972 - 1861) + chr(0b1001111 + 0o25) + '\145')(chr(5687 - 5570) + chr(116) + '\x66' + chr(0b101010 + 0o3) + chr(759 - 703)))[Q3TVZeZzkrZ0]) < c2A0yzQpDQB3(sdGUbW0q0W8A): xafqLlk3kkUe(oVre8I6UXc3b.beam_snapshots[Q3TVZeZzkrZ0], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb7d$\x8c0\xc8'), chr(3527 - 3427) + chr(0b101111 + 0o66) + chr(0b1100011) + chr(111) + chr(7270 - 7170) + chr(1154 - 1053))('\x75' + chr(3919 - 3803) + chr(102) + chr(45) + chr(0b111000)))([]) xafqLlk3kkUe(oVre8I6UXc3b.beam_snapshots[Q3TVZeZzkrZ0][c2A0yzQpDQB3(sdGUbW0q0W8A) - ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001), 8)], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb7d$\x8c0\xc8'), '\x64' + chr(0b1101 + 0o130) + chr(2945 - 2846) + chr(111) + chr(100) + chr(7228 - 7127))('\x75' + '\x74' + chr(2014 - 1912) + chr(204 - 159) + chr(0b111000)))((n9fd4FsgoqFs, sdGUbW0q0W8A)) FYmaFou6uVaj = {} for (Q3TVZeZzkrZ0, t6Sd6XIAAZlg) in xafqLlk3kkUe(HV1dcqfUnFmU, xafqLlk3kkUe(SXOLrMavuUCe(b'\x98n"\x8c\x17\xf6{\x8b\xca\xad\xd1\xee'), chr(0b11001 + 0o113) + '\145' + chr(0b1100011) + chr(0b1101111) + '\144' + chr(0b1100101))('\x75' + chr(0b1110100) + chr(439 - 337) + chr(1419 - 1374) + '\070'))(): QYnhBbKeq8Ml = [(-KKFQISrGeiAm.score[ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(747 - 636) + chr(0b100011 + 0o15), 8)].N7j7ePTXzzI0(), KKFQISrGeiAm) for KKFQISrGeiAm in t6Sd6XIAAZlg] xafqLlk3kkUe(QYnhBbKeq8Ml, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa5{&\x9d'), chr(0b1100 + 0o130) + '\145' + chr(0b100001 + 0o102) + '\157' + chr(0b1010001 + 0o23) + chr(0b1100101))('\x75' + chr(9242 - 9126) + chr(0b110011 + 0o63) + chr(0b101101) + chr(0b1100 + 0o54)))(key=lambda OeWW0F1dBPRQ: OeWW0F1dBPRQ[ehT0Px3KOsy9(chr(119 - 71) + chr(837 - 726) + chr(0b110000), 8)]) FYmaFou6uVaj[Q3TVZeZzkrZ0] = [KKFQISrGeiAm[ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001), 8)] for KKFQISrGeiAm in QYnhBbKeq8Ml[:oVre8I6UXc3b._beam_size]] return FYmaFou6uVaj
allenai/allennlp
allennlp/tools/drop_eval.py
_normalize_answer
def _normalize_answer(text: str) -> str: """Lower text and remove punctuation, articles and extra whitespace.""" parts = [_white_space_fix(_remove_articles(_normalize_number(_remove_punc(_lower(token))))) for token in _tokenize(text)] parts = [part for part in parts if part.strip()] normalized = ' '.join(parts).strip() return normalized
python
def _normalize_answer(text: str) -> str: """Lower text and remove punctuation, articles and extra whitespace.""" parts = [_white_space_fix(_remove_articles(_normalize_number(_remove_punc(_lower(token))))) for token in _tokenize(text)] parts = [part for part in parts if part.strip()] normalized = ' '.join(parts).strip() return normalized
[ "def", "_normalize_answer", "(", "text", ":", "str", ")", "->", "str", ":", "parts", "=", "[", "_white_space_fix", "(", "_remove_articles", "(", "_normalize_number", "(", "_remove_punc", "(", "_lower", "(", "token", ")", ")", ")", ")", ")", "for", "token", "in", "_tokenize", "(", "text", ")", "]", "parts", "=", "[", "part", "for", "part", "in", "parts", "if", "part", ".", "strip", "(", ")", "]", "normalized", "=", "' '", ".", "join", "(", "parts", ")", ".", "strip", "(", ")", "return", "normalized" ]
Lower text and remove punctuation, articles and extra whitespace.
[ "Lower", "text", "and", "remove", "punctuation", "articles", "and", "extra", "whitespace", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/tools/drop_eval.py#L36-L43
train
Lower text and remove punctuation articles and extra whitespace.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtr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sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\157' + chr(0b1111 + 0o44) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(191 - 143) + '\157' + '\x34' + chr(825 - 774), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + chr(52) + chr(2066 - 2016), 52357 - 52349), ehT0Px3KOsy9(chr(1499 - 1451) + chr(111) + chr(279 - 230) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(7709 - 7598) + '\x33' + '\063', 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\x36' + '\x33', 0o10), ehT0Px3KOsy9(chr(0b10110 + 0o32) + '\157' + chr(49) + chr(1437 - 1382) + chr(0b101001 + 0o15), 0o10), ehT0Px3KOsy9(chr(856 - 808) + '\x6f' + chr(0b110001) + chr(0b110011) + '\067', 0o10), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + '\063' + chr(55) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + chr(0b110001) + chr(1306 - 1256), 12221 - 12213), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b1000 + 0o53) + '\066' + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b11111 + 0o120) + chr(1268 - 1218) + '\x35' + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(4349 - 4238) + chr(49) + '\x33' + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(1580 - 1532) + chr(111) + '\061' + chr(0b100100 + 0o14), ord("\x08")), ehT0Px3KOsy9(chr(1173 - 1125) + '\157' + chr(0b1101 + 0o45) + '\x35' + chr(2393 - 2341), ord("\x08")), ehT0Px3KOsy9(chr(1121 - 1073) + chr(111) + '\064' + '\x34', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(50) + chr(551 - 499), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110110), 45906 - 45898), ehT0Px3KOsy9(chr(48) + '\157' + '\063' + chr(0b110100) + '\x37', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\062' + '\x36' + chr(0b110001 + 0o1), ord("\x08")), ehT0Px3KOsy9(chr(0b100101 + 0o13) + '\157' + chr(54) + chr(0b110010), 37056 - 37048), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + '\x35' + '\x37', 21004 - 20996), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(50) + chr(2284 - 2236) + chr(0b11011 + 0o33), 24083 - 24075), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100110 + 0o14) + chr(49) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b111000 + 0o67) + chr(51) + chr(48) + chr(0b11111 + 0o22), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11100 + 0o27) + chr(1218 - 1164) + chr(54), 8), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(0b1000001 + 0o56) + '\x34' + '\064', 8), ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\157' + chr(128 - 77) + chr(1407 - 1357) + chr(2002 - 1950), 0o10), ehT0Px3KOsy9(chr(944 - 896) + chr(111) + chr(0b10000 + 0o43) + '\x32' + '\061', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110100 + 0o3), 0o10), ehT0Px3KOsy9(chr(48) + chr(10786 - 10675) + chr(0b0 + 0o62) + chr(55) + chr(0b101010 + 0o11), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b10101 + 0o132) + '\062' + chr(0b100 + 0o63) + '\x31', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110010) + '\061' + '\x34', 0b1000), ehT0Px3KOsy9(chr(1472 - 1424) + '\157' + chr(50) + chr(1668 - 1614) + chr(0b100001 + 0o24), 51804 - 51796), ehT0Px3KOsy9('\060' + chr(0b111111 + 0o60) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(2579 - 2528) + '\x33' + '\065', 0b1000), ehT0Px3KOsy9(chr(877 - 829) + chr(0b1101111) + '\061' + '\x34' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + chr(411 - 363) + '\x30', 58192 - 58184), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + chr(0b100010 + 0o20) + chr(0b11011 + 0o27), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b100111 + 0o110) + '\x37', 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b11111 + 0o120) + chr(0b101111 + 0o6) + chr(0b101000 + 0o10), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'2'), chr(100) + '\145' + chr(0b10 + 0o141) + chr(111) + '\x64' + '\x65')(chr(13613 - 13496) + chr(0b1110100 + 0o0) + chr(102) + chr(0b101101) + chr(0b111000)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def kM9AY1Cki8v0(Ah1rInvg48Hb) -> M8_cKLkHVB2V: gIfWK5W_pmM4 = [Fvprry5JYaLN(BwFlskgVLKrD(uQKS57pAdu_8(UDSWq8UZH4ZK(M51eHlEwub5g(mTy3fac_AqJ5))))) for mTy3fac_AqJ5 in qwzhU8DQ4ZeR(Ah1rInvg48Hb)] gIfWK5W_pmM4 = [kZUV3FyMs20M for kZUV3FyMs20M in gIfWK5W_pmM4 if kZUV3FyMs20M.strip()] FRzF_AGYk44w = xafqLlk3kkUe(SXOLrMavuUCe(b'<'), chr(100) + chr(0b1000000 + 0o45) + chr(0b11000 + 0o113) + chr(0b1011110 + 0o21) + chr(0b10111 + 0o115) + chr(0b1100101))('\x75' + chr(0b1100 + 0o150) + chr(0b101110 + 0o70) + chr(294 - 249) + chr(56)).join(gIfWK5W_pmM4).strip() return FRzF_AGYk44w
allenai/allennlp
allennlp/tools/drop_eval.py
_align_bags
def _align_bags(predicted: List[Set[str]], gold: List[Set[str]]) -> List[float]: """ Takes gold and predicted answer sets and first finds a greedy 1-1 alignment between them and gets maximum metric values over all the answers """ f1_scores = [] for gold_index, gold_item in enumerate(gold): max_f1 = 0.0 max_index = None best_alignment: Tuple[Set[str], Set[str]] = (set(), set()) if predicted: for pred_index, pred_item in enumerate(predicted): current_f1 = _compute_f1(pred_item, gold_item) if current_f1 >= max_f1: best_alignment = (gold_item, pred_item) max_f1 = current_f1 max_index = pred_index match_flag = _match_numbers_if_present(*best_alignment) gold[gold_index] = set() predicted[max_index] = set() else: match_flag = False if match_flag: f1_scores.append(max_f1) else: f1_scores.append(0.0) return f1_scores
python
def _align_bags(predicted: List[Set[str]], gold: List[Set[str]]) -> List[float]: """ Takes gold and predicted answer sets and first finds a greedy 1-1 alignment between them and gets maximum metric values over all the answers """ f1_scores = [] for gold_index, gold_item in enumerate(gold): max_f1 = 0.0 max_index = None best_alignment: Tuple[Set[str], Set[str]] = (set(), set()) if predicted: for pred_index, pred_item in enumerate(predicted): current_f1 = _compute_f1(pred_item, gold_item) if current_f1 >= max_f1: best_alignment = (gold_item, pred_item) max_f1 = current_f1 max_index = pred_index match_flag = _match_numbers_if_present(*best_alignment) gold[gold_index] = set() predicted[max_index] = set() else: match_flag = False if match_flag: f1_scores.append(max_f1) else: f1_scores.append(0.0) return f1_scores
[ "def", "_align_bags", "(", "predicted", ":", "List", "[", "Set", "[", "str", "]", "]", ",", "gold", ":", "List", "[", "Set", "[", "str", "]", "]", ")", "->", "List", "[", "float", "]", ":", "f1_scores", "=", "[", "]", "for", "gold_index", ",", "gold_item", "in", "enumerate", "(", "gold", ")", ":", "max_f1", "=", "0.0", "max_index", "=", "None", "best_alignment", ":", "Tuple", "[", "Set", "[", "str", "]", ",", "Set", "[", "str", "]", "]", "=", "(", "set", "(", ")", ",", "set", "(", ")", ")", "if", "predicted", ":", "for", "pred_index", ",", "pred_item", "in", "enumerate", "(", "predicted", ")", ":", "current_f1", "=", "_compute_f1", "(", "pred_item", ",", "gold_item", ")", "if", "current_f1", ">=", "max_f1", ":", "best_alignment", "=", "(", "gold_item", ",", "pred_item", ")", "max_f1", "=", "current_f1", "max_index", "=", "pred_index", "match_flag", "=", "_match_numbers_if_present", "(", "*", "best_alignment", ")", "gold", "[", "gold_index", "]", "=", "set", "(", ")", "predicted", "[", "max_index", "]", "=", "set", "(", ")", "else", ":", "match_flag", "=", "False", "if", "match_flag", ":", "f1_scores", ".", "append", "(", "max_f1", ")", "else", ":", "f1_scores", ".", "append", "(", "0.0", ")", "return", "f1_scores" ]
Takes gold and predicted answer sets and first finds a greedy 1-1 alignment between them and gets maximum metric values over all the answers
[ "Takes", "gold", "and", "predicted", "answer", "sets", "and", "first", "finds", "a", "greedy", "1", "-", "1", "alignment", "between", "them", "and", "gets", "maximum", "metric", "values", "over", "all", "the", "answers" ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/tools/drop_eval.py#L73-L99
train
Given gold and predicted answer sets returns a list of scores that are the maximum metric values over all the answers
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdb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aseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(1659 - 1548) + chr(49) + chr(0b1 + 0o64) + chr(0b100 + 0o55), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(49) + chr(1733 - 1681) + chr(0b10010 + 0o42), 0b1000), ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\x6f' + chr(1373 - 1323) + chr(0b110000) + chr(1550 - 1498), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10000 + 0o41) + chr(0b110110 + 0o1) + '\065', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + '\x33', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + chr(50) + chr(0b110000), 53445 - 53437), ehT0Px3KOsy9(chr(48) + chr(9420 - 9309) + '\x32' + chr(51) + chr(0b110110), 41981 - 41973), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b1101111) + chr(0b11100 + 0o27) + '\061' + chr(999 - 946), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b101000 + 0o11) + '\x34' + chr(0b100001 + 0o24), 0b1000), ehT0Px3KOsy9(chr(1086 - 1038) + '\x6f' + '\061' + chr(0b110110) + chr(2428 - 2374), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\065' + chr(0b100111 + 0o13), 0o10), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b0 + 0o157) + chr(0b110010) + chr(49) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\066' + chr(48), 61649 - 61641), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31' + '\065', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + '\065' + chr(0b110001), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + chr(0b101110 + 0o10) + chr(2780 - 2727), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1321 - 1267) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11011 + 0o27) + chr(1643 - 1590) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(50) + '\061' + chr(48), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + chr(899 - 846) + '\063', 0o10), ehT0Px3KOsy9('\060' + chr(0b1010 + 0o145) + chr(0b110010) + chr(0b10100 + 0o37) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b110000 + 0o77) + chr(50) + chr(49), 6569 - 6561), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011100 + 0o23) + chr(0b1100 + 0o45) + '\x31' + chr(1892 - 1839), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1307 - 1256) + '\061' + chr(55), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b11100 + 0o27) + chr(0b1110 + 0o42) + chr(0b110110), 37602 - 37594), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110001) + '\x33' + chr(0b110111), 25117 - 25109), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(444 - 393) + chr(49) + chr(2237 - 2187), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + '\063' + '\x34', 20263 - 20255), ehT0Px3KOsy9('\x30' + chr(0b1000011 + 0o54) + chr(0b110010) + chr(0b110101), 11874 - 11866), ehT0Px3KOsy9(chr(1669 - 1621) + '\x6f' + '\061' + chr(1206 - 1154) + chr(0b101000 + 0o17), ord("\x08")), ehT0Px3KOsy9(chr(918 - 870) + chr(0b1101111) + chr(52) + chr(53), 0b1000), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\x6f' + '\061' + chr(50) + '\x30', 4620 - 4612), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + chr(0b110010) + '\060', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(1070 - 1016) + '\061', 0o10), ehT0Px3KOsy9('\x30' + chr(2605 - 2494) + chr(1869 - 1820) + chr(53) + chr(0b10001 + 0o46), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + '\063' + '\x31', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b111 + 0o150) + '\x32' + chr(0b1110 + 0o45) + chr(1808 - 1754), 8), ehT0Px3KOsy9('\x30' + chr(0b1101011 + 0o4) + chr(0b11011 + 0o26) + chr(0b110001) + chr(673 - 625), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + '\060' + '\066', 49928 - 49920), ehT0Px3KOsy9('\060' + chr(0b11110 + 0o121) + '\062' + chr(2551 - 2499) + chr(0b101111 + 0o3), 53138 - 53130)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\065' + chr(115 - 67), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'G'), chr(0b1100100) + '\x65' + chr(0b1100011) + '\157' + '\144' + chr(6333 - 6232))(chr(4467 - 4350) + '\x74' + '\x66' + chr(45) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def S9gs0WA0MFle(zljAUjbBWUdH, engLn_Bmu8eW) -> qRxF7OQ0y39T[kkSX4ccExqw4]: EIzogWlMxCLS = [] for (LRPKfACGCTf4, UzAyDzl3_gce) in YlkZvXL8qwsX(engLn_Bmu8eW): D6DHc8zObc4q = 0.0 WzS6HyMbnYkc = None BJYjIU9umoBN = (MVEN8G6CxlvR(), MVEN8G6CxlvR()) if zljAUjbBWUdH: for (nyvXiOLWSgKJ, u1IWT0A4_l9k) in YlkZvXL8qwsX(zljAUjbBWUdH): wYiUJVneTwNF = rzlAlXQQCaFk(u1IWT0A4_l9k, UzAyDzl3_gce) if wYiUJVneTwNF >= D6DHc8zObc4q: BJYjIU9umoBN = (UzAyDzl3_gce, u1IWT0A4_l9k) D6DHc8zObc4q = wYiUJVneTwNF WzS6HyMbnYkc = nyvXiOLWSgKJ OXKEA_be0gZP = fTtp3xYM7wn7(*BJYjIU9umoBN) engLn_Bmu8eW[LRPKfACGCTf4] = MVEN8G6CxlvR() zljAUjbBWUdH[WzS6HyMbnYkc] = MVEN8G6CxlvR() else: OXKEA_be0gZP = ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110000), 0o10) if OXKEA_be0gZP: xafqLlk3kkUe(EIzogWlMxCLS, xafqLlk3kkUe(SXOLrMavuUCe(b'\x08\x14\xf4\x18e\xb4'), chr(0b1010011 + 0o21) + chr(7819 - 7718) + chr(7507 - 7408) + '\157' + '\144' + '\145')(chr(4821 - 4704) + chr(9172 - 9056) + chr(0b100 + 0o142) + '\x2d' + chr(0b10110 + 0o42)))(D6DHc8zObc4q) else: xafqLlk3kkUe(EIzogWlMxCLS, xafqLlk3kkUe(SXOLrMavuUCe(b'\x08\x14\xf4\x18e\xb4'), chr(100) + '\x65' + '\x63' + '\x6f' + chr(0b110010 + 0o62) + chr(0b101001 + 0o74))(chr(117) + chr(0b1011 + 0o151) + chr(102) + '\x2d' + chr(56)))(0.0) return EIzogWlMxCLS
allenai/allennlp
allennlp/tools/drop_eval.py
get_metrics
def get_metrics(predicted: Union[str, List[str], Tuple[str, ...]], gold: Union[str, List[str], Tuple[str, ...]]) -> Tuple[float, float]: """ Takes a predicted answer and a gold answer (that are both either a string or a list of strings), and returns exact match and the DROP F1 metric for the prediction. If you are writing a script for evaluating objects in memory (say, the output of predictions during validation, or while training), this is the function you want to call, after using :func:`answer_json_to_strings` when reading the gold answer from the released data file. """ predicted_bags = _answer_to_bags(predicted) gold_bags = _answer_to_bags(gold) exact_match = 1.0 if predicted_bags[0] == gold_bags[0] else 0 f1_per_bag = _align_bags(predicted_bags[1], gold_bags[1]) f1 = np.mean(f1_per_bag) f1 = round(f1, 2) return exact_match, f1
python
def get_metrics(predicted: Union[str, List[str], Tuple[str, ...]], gold: Union[str, List[str], Tuple[str, ...]]) -> Tuple[float, float]: """ Takes a predicted answer and a gold answer (that are both either a string or a list of strings), and returns exact match and the DROP F1 metric for the prediction. If you are writing a script for evaluating objects in memory (say, the output of predictions during validation, or while training), this is the function you want to call, after using :func:`answer_json_to_strings` when reading the gold answer from the released data file. """ predicted_bags = _answer_to_bags(predicted) gold_bags = _answer_to_bags(gold) exact_match = 1.0 if predicted_bags[0] == gold_bags[0] else 0 f1_per_bag = _align_bags(predicted_bags[1], gold_bags[1]) f1 = np.mean(f1_per_bag) f1 = round(f1, 2) return exact_match, f1
[ "def", "get_metrics", "(", "predicted", ":", "Union", "[", "str", ",", "List", "[", "str", "]", ",", "Tuple", "[", "str", ",", "...", "]", "]", ",", "gold", ":", "Union", "[", "str", ",", "List", "[", "str", "]", ",", "Tuple", "[", "str", ",", "...", "]", "]", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "predicted_bags", "=", "_answer_to_bags", "(", "predicted", ")", "gold_bags", "=", "_answer_to_bags", "(", "gold", ")", "exact_match", "=", "1.0", "if", "predicted_bags", "[", "0", "]", "==", "gold_bags", "[", "0", "]", "else", "0", "f1_per_bag", "=", "_align_bags", "(", "predicted_bags", "[", "1", "]", ",", "gold_bags", "[", "1", "]", ")", "f1", "=", "np", ".", "mean", "(", "f1_per_bag", ")", "f1", "=", "round", "(", "f1", ",", "2", ")", "return", "exact_match", ",", "f1" ]
Takes a predicted answer and a gold answer (that are both either a string or a list of strings), and returns exact match and the DROP F1 metric for the prediction. If you are writing a script for evaluating objects in memory (say, the output of predictions during validation, or while training), this is the function you want to call, after using :func:`answer_json_to_strings` when reading the gold answer from the released data file.
[ "Takes", "a", "predicted", "answer", "and", "a", "gold", "answer", "(", "that", "are", "both", "either", "a", "string", "or", "a", "list", "of", "strings", ")", "and", "returns", "exact", "match", "and", "the", "DROP", "F1", "metric", "for", "the", "prediction", ".", "If", "you", "are", "writing", "a", "script", "for", "evaluating", "objects", "in", "memory", "(", "say", "the", "output", "of", "predictions", "during", "validation", "or", "while", "training", ")", "this", "is", "the", "function", "you", "want", "to", "call", "after", "using", ":", "func", ":", "answer_json_to_strings", "when", "reading", "the", "gold", "answer", "from", "the", "released", "data", "file", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/tools/drop_eval.py#L130-L147
train
Returns the metrics for the prediction and the DROP F1 metric for the gold answer.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,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Ty8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\x6f' + chr(828 - 778) + '\060', 0o10), ehT0Px3KOsy9('\060' + chr(3613 - 3502) + '\x31' + chr(2827 - 2772) + chr(55), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x31' + chr(0b110010) + chr(0b1011 + 0o52), 52615 - 52607), ehT0Px3KOsy9(chr(399 - 351) + '\x6f' + '\x32' + '\060' + '\x34', 4865 - 4857), ehT0Px3KOsy9(chr(161 - 113) + '\x6f' + chr(0b1 + 0o60) + '\064' + '\067', ord("\x08")), ehT0Px3KOsy9(chr(1586 - 1538) + chr(4748 - 4637) + '\x35' + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001 + 0o146) + '\x32' + '\063' + chr(54), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001010 + 0o45) + chr(0b100110 + 0o13) + chr(0b110010) + chr(0b110111), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110011) + '\067' + chr(51), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b11001 + 0o31) + chr(53) + chr(0b11100 + 0o30), 42940 - 42932), ehT0Px3KOsy9(chr(469 - 421) + chr(0b1101111) + chr(2415 - 2364) + chr(2165 - 2111) + chr(55), 23435 - 23427), ehT0Px3KOsy9(chr(0b110000) + chr(0b1110 + 0o141) + '\061' + '\x34' + '\060', 25963 - 25955), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\157' + '\065' + chr(1383 - 1334), 0o10), ehT0Px3KOsy9(chr(0b101110 + 0o2) + '\157' + '\061' + chr(2359 - 2310) + '\064', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1001001 + 0o46) + chr(0b110011) + '\064' + '\061', ord("\x08")), ehT0Px3KOsy9(chr(1217 - 1169) + chr(2758 - 2647) + chr(50) + chr(53) + chr(0b11101 + 0o31), 0b1000), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b1101111) + chr(0b110111) + chr(796 - 743), 41716 - 41708), ehT0Px3KOsy9(chr(197 - 149) + chr(111) + chr(51) + '\064' + chr(0b0 + 0o66), 0o10), ehT0Px3KOsy9(chr(2169 - 2121) + chr(111) + '\062' + '\063' + chr(0b101001 + 0o10), ord("\x08")), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1101111) + chr(0b110010) + chr(0b11010 + 0o26) + '\067', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1111 + 0o43) + chr(55) + '\062', 0o10), ehT0Px3KOsy9(chr(1227 - 1179) + chr(0b1101111) + '\x32' + '\x35' + '\063', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(280 - 229) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(4640 - 4529) + chr(1250 - 1201) + '\x34' + '\063', 0b1000), ehT0Px3KOsy9(chr(658 - 610) + chr(10239 - 10128) + chr(55) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1566 - 1516) + '\x34' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(111 - 63) + chr(111) + chr(0b110010) + chr(0b110000) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110011) + '\x37' + chr(1571 - 1522), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011011 + 0o24) + chr(646 - 597) + chr(1240 - 1187) + chr(0b110001), 0b1000), ehT0Px3KOsy9('\060' + chr(0b111101 + 0o62) + chr(0b11010 + 0o27) + chr(0b110010) + '\x36', 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\063' + chr(0b110000), 0b1000), ehT0Px3KOsy9('\x30' + chr(6375 - 6264) + '\063' + '\x35' + chr(48), 49643 - 49635), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110010) + chr(1341 - 1290) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001) + chr(0b110100 + 0o1) + chr(55), 2588 - 2580), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + chr(2851 - 2796), 56409 - 56401), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(55) + chr(0b1100 + 0o53), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b1111 + 0o42) + chr(0b110011) + chr(0b110001), 1640 - 1632), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + chr(48) + chr(0b11110 + 0o25), 0o10), ehT0Px3KOsy9(chr(1120 - 1072) + '\157' + '\x32' + '\066' + '\064', 0o10), ehT0Px3KOsy9(chr(0b1110 + 0o42) + '\x6f' + chr(2127 - 2076) + '\x37' + '\062', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110101) + chr(0b110000), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'>'), chr(373 - 273) + '\x65' + '\x63' + chr(111) + '\x64' + '\145')(chr(0b111110 + 0o67) + chr(0b1110100) + chr(102) + '\055' + chr(0b10101 + 0o43)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def OX6sfedkWBvf(zljAUjbBWUdH, engLn_Bmu8eW) -> MRK8Uzg2En3D[kkSX4ccExqw4, kkSX4ccExqw4]: mr9vVbUplnyT = zN4_PsS_cQwX(zljAUjbBWUdH) RLvudEb44evp = zN4_PsS_cQwX(engLn_Bmu8eW) BNBL9WZtZxed = 1.0 if mr9vVbUplnyT[ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b111101 + 0o62) + chr(48), 0o10)] == RLvudEb44evp[ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110000), 8)] else ehT0Px3KOsy9('\060' + '\157' + chr(0b101011 + 0o5), 8) sAgrKalvxF0R = S9gs0WA0MFle(mr9vVbUplnyT[ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x31', ord("\x08"))], RLvudEb44evp[ehT0Px3KOsy9('\x30' + chr(2226 - 2115) + chr(49), 8)]) dHCiiTHxprsx = WqUC3KWvYVup.aJhItC_Vawlw(sAgrKalvxF0R) dHCiiTHxprsx = jB_HdqgHmVpI(dHCiiTHxprsx, ehT0Px3KOsy9(chr(453 - 405) + chr(0b1101111) + chr(0b110010), 0o10)) return (BNBL9WZtZxed, dHCiiTHxprsx)
allenai/allennlp
allennlp/tools/drop_eval.py
answer_json_to_strings
def answer_json_to_strings(answer: Dict[str, Any]) -> Tuple[Tuple[str, ...], str]: """ Takes an answer JSON blob from the DROP data release and converts it into strings used for evaluation. """ if "number" in answer and answer["number"]: return tuple([str(answer["number"])]), "number" elif "spans" in answer and answer["spans"]: return tuple(answer["spans"]), "span" if len(answer["spans"]) == 1 else "spans" elif "date" in answer: return tuple(["{0} {1} {2}".format(answer["date"]["day"], answer["date"]["month"], answer["date"]["year"])]), "date" else: raise ValueError(f"Answer type not found, should be one of number, spans or date at: {json.dumps(answer)}")
python
def answer_json_to_strings(answer: Dict[str, Any]) -> Tuple[Tuple[str, ...], str]: """ Takes an answer JSON blob from the DROP data release and converts it into strings used for evaluation. """ if "number" in answer and answer["number"]: return tuple([str(answer["number"])]), "number" elif "spans" in answer and answer["spans"]: return tuple(answer["spans"]), "span" if len(answer["spans"]) == 1 else "spans" elif "date" in answer: return tuple(["{0} {1} {2}".format(answer["date"]["day"], answer["date"]["month"], answer["date"]["year"])]), "date" else: raise ValueError(f"Answer type not found, should be one of number, spans or date at: {json.dumps(answer)}")
[ "def", "answer_json_to_strings", "(", "answer", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Tuple", "[", "Tuple", "[", "str", ",", "...", "]", ",", "str", "]", ":", "if", "\"number\"", "in", "answer", "and", "answer", "[", "\"number\"", "]", ":", "return", "tuple", "(", "[", "str", "(", "answer", "[", "\"number\"", "]", ")", "]", ")", ",", "\"number\"", "elif", "\"spans\"", "in", "answer", "and", "answer", "[", "\"spans\"", "]", ":", "return", "tuple", "(", "answer", "[", "\"spans\"", "]", ")", ",", "\"span\"", "if", "len", "(", "answer", "[", "\"spans\"", "]", ")", "==", "1", "else", "\"spans\"", "elif", "\"date\"", "in", "answer", ":", "return", "tuple", "(", "[", "\"{0} {1} {2}\"", ".", "format", "(", "answer", "[", "\"date\"", "]", "[", "\"day\"", "]", ",", "answer", "[", "\"date\"", "]", "[", "\"month\"", "]", ",", "answer", "[", "\"date\"", "]", "[", "\"year\"", "]", ")", "]", ")", ",", "\"date\"", "else", ":", "raise", "ValueError", "(", "f\"Answer type not found, should be one of number, spans or date at: {json.dumps(answer)}\"", ")" ]
Takes an answer JSON blob from the DROP data release and converts it into strings used for evaluation.
[ "Takes", "an", "answer", "JSON", "blob", "from", "the", "DROP", "data", "release", "and", "converts", "it", "into", "strings", "used", "for", "evaluation", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/tools/drop_eval.py#L150-L164
train
Takes an answer JSON blob from the DROP data release and converts it into a list of strings used for evaluation.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT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8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(343 - 232) + chr(0b101101 + 0o5) + '\x30' + '\066', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001) + chr(0b1110 + 0o42), ord("\x08")), ehT0Px3KOsy9('\060' + chr(8001 - 7890) + chr(0b110100) + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b10110 + 0o32) + '\x6f' + chr(0b110111) + chr(0b101111 + 0o6), 45078 - 45070), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(0b110011) + chr(0b1101 + 0o47), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b110 + 0o151) + chr(51) + chr(1189 - 1134) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(48) + chr(5180 - 5069) + chr(0b10001 + 0o40) + chr(727 - 675) + chr(52), 0o10), ehT0Px3KOsy9(chr(1722 - 1674) + '\157' + chr(0b1011 + 0o46) + chr(2370 - 2317) + '\x34', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101 + 0o142) + '\062' + chr(50) + '\061', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b1100 + 0o47) + chr(1975 - 1921) + '\x37', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b10 + 0o61) + chr(2244 - 2196) + '\063', 0o10), ehT0Px3KOsy9(chr(977 - 929) + '\x6f' + chr(0b1010 + 0o51) + chr(64 - 16) + '\x32', 0o10), ehT0Px3KOsy9(chr(2198 - 2150) + chr(0b1101111 + 0o0) + chr(0b10110 + 0o35) + chr(2380 - 2329) + chr(0b110001 + 0o1), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(2627 - 2575) + chr(2186 - 2133), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b10101 + 0o34) + chr(49) + chr(0b11111 + 0o26), 19155 - 19147), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b101000 + 0o11) + chr(48), 8), ehT0Px3KOsy9(chr(1122 - 1074) + '\157' + chr(0b10001 + 0o40) + chr(52) + '\x35', 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1201 - 1152) + chr(48) + '\x32', 0o10), ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\157' + chr(0b111 + 0o56), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\065' + '\x30', 53999 - 53991), ehT0Px3KOsy9(chr(1660 - 1612) + '\x6f' + chr(0b110011) + chr(53) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(3796 - 3685) + chr(0b11011 + 0o33) + chr(1436 - 1386), 2609 - 2601), ehT0Px3KOsy9(chr(916 - 868) + chr(0b1101101 + 0o2) + chr(0b10010 + 0o37) + chr(0b100111 + 0o17) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b110111 + 0o70) + chr(0b110011) + '\x30' + '\x36', 0b1000), ehT0Px3KOsy9(chr(1179 - 1131) + chr(10782 - 10671) + chr(1441 - 1392) + chr(0b110101) + '\066', 11087 - 11079), ehT0Px3KOsy9(chr(1161 - 1113) + chr(111) + '\x32' + '\063' + '\x30', 19926 - 19918), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\065' + chr(54), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110010) + '\067' + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(51) + '\x32' + '\x32', 0o10), ehT0Px3KOsy9('\060' + chr(3516 - 3405) + chr(54) + chr(54), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + chr(0b10101 + 0o42) + chr(0b10110 + 0o41), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1000 + 0o52) + chr(50) + chr(1599 - 1549), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + chr(52) + chr(2369 - 2320), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(96 - 45) + chr(51) + chr(0b101010 + 0o15), 0b1000), ehT0Px3KOsy9(chr(897 - 849) + chr(10750 - 10639) + '\063' + chr(0b110 + 0o56) + chr(55), 4941 - 4933), ehT0Px3KOsy9(chr(48) + chr(0b101011 + 0o104) + '\063' + '\x36' + chr(0b101100 + 0o4), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(5670 - 5559) + '\061' + chr(0b110111) + chr(1724 - 1669), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + chr(49) + '\067', 0b1000), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(0b100101 + 0o112) + chr(0b1001 + 0o52) + '\x32' + '\067', 18652 - 18644), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(0b101000 + 0o16) + chr(0b101100 + 0o6), 7786 - 7778)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b10010 + 0o135) + chr(53) + chr(397 - 349), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa8'), '\144' + '\x65' + chr(0b1100011) + '\x6f' + '\144' + chr(101))(chr(117) + chr(116) + '\x66' + chr(45) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def I7eYdMORi8o7(_aygkdacRfLD) -> MRK8Uzg2En3D[MRK8Uzg2En3D[M8_cKLkHVB2V, ...], M8_cKLkHVB2V]: if xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8}K_\xb9\x8d'), chr(0b10100 + 0o120) + '\x65' + chr(0b1100011) + chr(0b110100 + 0o73) + chr(100) + '\x65')(chr(0b1110101) + chr(3483 - 3367) + chr(0b1100110) + chr(45) + '\070') in _aygkdacRfLD and _aygkdacRfLD[xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8}K_\xb9\x8d'), chr(0b1100100) + '\x65' + chr(0b1100011) + '\157' + chr(0b1010010 + 0o22) + chr(0b1100101))('\165' + '\164' + '\x66' + '\055' + chr(0b110 + 0o62))]: return (KNyTy8rYcwji([M8_cKLkHVB2V(_aygkdacRfLD[xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8}K_\xb9\x8d'), chr(1905 - 1805) + '\x65' + chr(0b10011 + 0o120) + chr(111) + chr(9640 - 9540) + chr(0b1100101))('\x75' + chr(5573 - 5457) + chr(102) + '\x2d' + chr(56))])]), xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8}K_\xb9\x8d'), '\144' + '\145' + chr(6305 - 6206) + '\157' + chr(0b110001 + 0o63) + chr(0b101101 + 0o70))(chr(0b111010 + 0o73) + chr(2226 - 2110) + '\146' + chr(0b101101) + chr(56))) elif xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5xGS\xaf'), chr(6931 - 6831) + '\145' + '\143' + chr(0b0 + 0o157) + chr(8029 - 7929) + chr(0b1100101))(chr(0b1110101) + chr(0b1110100) + chr(0b1111 + 0o127) + chr(0b101101) + chr(56)) in _aygkdacRfLD and _aygkdacRfLD[xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5xGS\xaf'), chr(100) + chr(2314 - 2213) + chr(0b1010011 + 0o20) + chr(0b1001010 + 0o45) + '\144' + chr(0b1100101))('\x75' + '\164' + chr(102) + '\x2d' + chr(0b100101 + 0o23))]: return (KNyTy8rYcwji(_aygkdacRfLD[xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5xGS\xaf'), '\144' + chr(0b1100101) + chr(0b101011 + 0o70) + '\157' + chr(0b1100100) + chr(6408 - 6307))(chr(117) + chr(0b10010 + 0o142) + '\146' + '\x2d' + chr(0b110111 + 0o1))]), xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5xGS'), chr(100) + '\x65' + chr(1575 - 1476) + chr(0b101101 + 0o102) + '\x64' + chr(0b111010 + 0o53))('\165' + chr(116) + '\x66' + '\055' + chr(56)) if c2A0yzQpDQB3(_aygkdacRfLD[xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5xGS\xaf'), chr(9865 - 9765) + chr(0b1001001 + 0o34) + chr(8008 - 7909) + '\x6f' + chr(0b1100100) + '\145')('\x75' + '\164' + chr(0b1100101 + 0o1) + chr(45) + chr(503 - 447))]) == ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061', 39000 - 38992) else xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5xGS\xaf'), chr(0b11100 + 0o110) + '\x65' + chr(0b101010 + 0o71) + '\x6f' + chr(4103 - 4003) + '\x65')(chr(117) + '\164' + '\146' + chr(1939 - 1894) + chr(56))) elif xafqLlk3kkUe(SXOLrMavuUCe(b'\xe2iRX'), chr(0b1011001 + 0o13) + chr(8145 - 8044) + chr(306 - 207) + '\x6f' + chr(0b10000 + 0o124) + '\145')(chr(0b1110101) + '\164' + chr(102) + chr(1668 - 1623) + '\x38') in _aygkdacRfLD: return (KNyTy8rYcwji([xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\xfd8[\x1d\xa7\xce\x19L\xea\xc5\xbe'), chr(0b1010101 + 0o17) + '\145' + chr(0b10100 + 0o117) + chr(0b1101111) + chr(100) + '\x65')(chr(5699 - 5582) + chr(0b1110100) + chr(102) + chr(0b100101 + 0o10) + chr(1887 - 1831)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0<TR\x94\x9e7_\xc1\x87\xa6\xa8'), '\x64' + '\145' + '\143' + chr(11805 - 11694) + chr(4216 - 4116) + chr(0b1000011 + 0o42))('\165' + '\x74' + '\x66' + chr(0b101101) + chr(2855 - 2799)))(_aygkdacRfLD[xafqLlk3kkUe(SXOLrMavuUCe(b'\xe2iRX'), chr(0b1011100 + 0o10) + chr(0b1100101) + chr(0b1100011) + chr(111) + '\144' + chr(101))(chr(8160 - 8043) + chr(116) + chr(0b1010011 + 0o23) + chr(45) + chr(2513 - 2457))][xafqLlk3kkUe(SXOLrMavuUCe(b'\xe2i_'), chr(0b1100100) + '\145' + '\x63' + chr(0b1101111) + '\x64' + chr(101))('\x75' + chr(0b110001 + 0o103) + '\146' + '\x2d' + chr(0b111000))], _aygkdacRfLD[xafqLlk3kkUe(SXOLrMavuUCe(b'\xe2iRX'), '\144' + chr(0b1100101) + '\143' + '\157' + '\144' + '\x65')(chr(0b1110101) + chr(0b100100 + 0o120) + '\146' + chr(45) + '\x38')][xafqLlk3kkUe(SXOLrMavuUCe(b'\xebgHI\xb4'), chr(0b111101 + 0o47) + chr(1493 - 1392) + '\x63' + '\157' + '\144' + '\145')(chr(0b1110101) + chr(0b1110100) + chr(0b1100110) + chr(0b100011 + 0o12) + '\x38')], _aygkdacRfLD[xafqLlk3kkUe(SXOLrMavuUCe(b'\xe2iRX'), chr(100) + '\x65' + chr(0b111111 + 0o44) + '\x6f' + '\144' + '\145')('\165' + '\x74' + chr(102) + '\x2d' + '\x38')][xafqLlk3kkUe(SXOLrMavuUCe(b'\xffmGO'), chr(0b111 + 0o135) + '\145' + chr(0b1001110 + 0o25) + chr(0b100001 + 0o116) + '\x64' + '\x65')('\x75' + '\x74' + '\146' + chr(0b1111 + 0o36) + chr(0b1100 + 0o54))])]), xafqLlk3kkUe(SXOLrMavuUCe(b'\xe2iRX'), chr(1982 - 1882) + '\145' + chr(99) + '\157' + chr(7119 - 7019) + chr(101))(chr(0b1110101) + chr(10406 - 10290) + '\x66' + chr(45) + '\x38')) else: raise q1QCh3W88sgk(f"Answer type not found, should be one of number, spans or date at: {xafqLlk3kkUe(fXk443epxtd5, chr(100) + chr(3185 - 3068) + chr(109) + chr(0b1100101 + 0o13) + chr(12456 - 12341))(_aygkdacRfLD)}")
allenai/allennlp
allennlp/tools/drop_eval.py
evaluate_json
def evaluate_json(annotations: Dict[str, Any], predicted_answers: Dict[str, Any]) -> Tuple[float, float]: """ Takes gold annotations and predicted answers and evaluates the predictions for each question in the gold annotations. Both JSON dictionaries must have query_id keys, which are used to match predictions to gold annotations (note that these are somewhat deep in the JSON for the gold annotations, but must be top-level keys in the predicted answers). The ``annotations`` are assumed to have the format of the dev set in the DROP data release. The ``predicted_answers`` JSON must be a dictionary keyed by query id, where the value is a string (or list of strings) that is the answer. """ instance_exact_match = [] instance_f1 = [] # for each type as well type_to_em: Dict[str, List[float]] = defaultdict(list) type_to_f1: Dict[str, List[float]] = defaultdict(list) for _, annotation in annotations.items(): for qa_pair in annotation["qa_pairs"]: query_id = qa_pair["query_id"] max_em_score = 0.0 max_f1_score = 0.0 max_type = None if query_id in predicted_answers: predicted = predicted_answers[query_id] candidate_answers = [qa_pair["answer"]] if "validated_answers" in qa_pair and qa_pair["validated_answers"]: candidate_answers += qa_pair["validated_answers"] for answer in candidate_answers: gold_answer, gold_type = answer_json_to_strings(answer) em_score, f1_score = get_metrics(predicted, gold_answer) if gold_answer[0].strip() != "": max_em_score = max(max_em_score, em_score) max_f1_score = max(max_f1_score, f1_score) if max_em_score == em_score or max_f1_score == f1_score: max_type = gold_type else: print("Missing prediction for question: {}".format(query_id)) if qa_pair and qa_pair["answer"]: max_type = answer_json_to_strings(qa_pair["answer"])[1] else: max_type = "number" max_em_score = 0.0 max_f1_score = 0.0 instance_exact_match.append(max_em_score) instance_f1.append(max_f1_score) type_to_em[max_type].append(max_em_score) type_to_f1[max_type].append(max_f1_score) global_em = np.mean(instance_exact_match) global_f1 = np.mean(instance_f1) print("Exact-match accuracy {0:.2f}".format(global_em * 100)) print("F1 score {0:.2f}".format(global_f1 * 100)) print("{0:.2f} & {1:.2f}".format(global_em * 100, global_f1 * 100)) print("----") total = np.sum([len(v) for v in type_to_em.values()]) for typ in sorted(type_to_em.keys()): print("{0}: {1} ({2:.2f}%)".format(typ, len(type_to_em[typ]), 100. * len(type_to_em[typ])/total)) print(" Exact-match accuracy {0:.3f}".format(100. * np.mean(type_to_em[typ]))) print(" F1 score {0:.3f}".format(100. * np.mean(type_to_f1[typ]))) return global_em, global_f1
python
def evaluate_json(annotations: Dict[str, Any], predicted_answers: Dict[str, Any]) -> Tuple[float, float]: """ Takes gold annotations and predicted answers and evaluates the predictions for each question in the gold annotations. Both JSON dictionaries must have query_id keys, which are used to match predictions to gold annotations (note that these are somewhat deep in the JSON for the gold annotations, but must be top-level keys in the predicted answers). The ``annotations`` are assumed to have the format of the dev set in the DROP data release. The ``predicted_answers`` JSON must be a dictionary keyed by query id, where the value is a string (or list of strings) that is the answer. """ instance_exact_match = [] instance_f1 = [] # for each type as well type_to_em: Dict[str, List[float]] = defaultdict(list) type_to_f1: Dict[str, List[float]] = defaultdict(list) for _, annotation in annotations.items(): for qa_pair in annotation["qa_pairs"]: query_id = qa_pair["query_id"] max_em_score = 0.0 max_f1_score = 0.0 max_type = None if query_id in predicted_answers: predicted = predicted_answers[query_id] candidate_answers = [qa_pair["answer"]] if "validated_answers" in qa_pair and qa_pair["validated_answers"]: candidate_answers += qa_pair["validated_answers"] for answer in candidate_answers: gold_answer, gold_type = answer_json_to_strings(answer) em_score, f1_score = get_metrics(predicted, gold_answer) if gold_answer[0].strip() != "": max_em_score = max(max_em_score, em_score) max_f1_score = max(max_f1_score, f1_score) if max_em_score == em_score or max_f1_score == f1_score: max_type = gold_type else: print("Missing prediction for question: {}".format(query_id)) if qa_pair and qa_pair["answer"]: max_type = answer_json_to_strings(qa_pair["answer"])[1] else: max_type = "number" max_em_score = 0.0 max_f1_score = 0.0 instance_exact_match.append(max_em_score) instance_f1.append(max_f1_score) type_to_em[max_type].append(max_em_score) type_to_f1[max_type].append(max_f1_score) global_em = np.mean(instance_exact_match) global_f1 = np.mean(instance_f1) print("Exact-match accuracy {0:.2f}".format(global_em * 100)) print("F1 score {0:.2f}".format(global_f1 * 100)) print("{0:.2f} & {1:.2f}".format(global_em * 100, global_f1 * 100)) print("----") total = np.sum([len(v) for v in type_to_em.values()]) for typ in sorted(type_to_em.keys()): print("{0}: {1} ({2:.2f}%)".format(typ, len(type_to_em[typ]), 100. * len(type_to_em[typ])/total)) print(" Exact-match accuracy {0:.3f}".format(100. * np.mean(type_to_em[typ]))) print(" F1 score {0:.3f}".format(100. * np.mean(type_to_f1[typ]))) return global_em, global_f1
[ "def", "evaluate_json", "(", "annotations", ":", "Dict", "[", "str", ",", "Any", "]", ",", "predicted_answers", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "instance_exact_match", "=", "[", "]", "instance_f1", "=", "[", "]", "# for each type as well", "type_to_em", ":", "Dict", "[", "str", ",", "List", "[", "float", "]", "]", "=", "defaultdict", "(", "list", ")", "type_to_f1", ":", "Dict", "[", "str", ",", "List", "[", "float", "]", "]", "=", "defaultdict", "(", "list", ")", "for", "_", ",", "annotation", "in", "annotations", ".", "items", "(", ")", ":", "for", "qa_pair", "in", "annotation", "[", "\"qa_pairs\"", "]", ":", "query_id", "=", "qa_pair", "[", "\"query_id\"", "]", "max_em_score", "=", "0.0", "max_f1_score", "=", "0.0", "max_type", "=", "None", "if", "query_id", "in", "predicted_answers", ":", "predicted", "=", "predicted_answers", "[", "query_id", "]", "candidate_answers", "=", "[", "qa_pair", "[", "\"answer\"", "]", "]", "if", "\"validated_answers\"", "in", "qa_pair", "and", "qa_pair", "[", "\"validated_answers\"", "]", ":", "candidate_answers", "+=", "qa_pair", "[", "\"validated_answers\"", "]", "for", "answer", "in", "candidate_answers", ":", "gold_answer", ",", "gold_type", "=", "answer_json_to_strings", "(", "answer", ")", "em_score", ",", "f1_score", "=", "get_metrics", "(", "predicted", ",", "gold_answer", ")", "if", "gold_answer", "[", "0", "]", ".", "strip", "(", ")", "!=", "\"\"", ":", "max_em_score", "=", "max", "(", "max_em_score", ",", "em_score", ")", "max_f1_score", "=", "max", "(", "max_f1_score", ",", "f1_score", ")", "if", "max_em_score", "==", "em_score", "or", "max_f1_score", "==", "f1_score", ":", "max_type", "=", "gold_type", "else", ":", "print", "(", "\"Missing prediction for question: {}\"", ".", "format", "(", "query_id", ")", ")", "if", "qa_pair", "and", "qa_pair", "[", "\"answer\"", "]", ":", "max_type", "=", "answer_json_to_strings", "(", "qa_pair", "[", "\"answer\"", "]", ")", "[", "1", "]", "else", ":", "max_type", "=", "\"number\"", "max_em_score", "=", "0.0", "max_f1_score", "=", "0.0", "instance_exact_match", ".", "append", "(", "max_em_score", ")", "instance_f1", ".", "append", "(", "max_f1_score", ")", "type_to_em", "[", "max_type", "]", ".", "append", "(", "max_em_score", ")", "type_to_f1", "[", "max_type", "]", ".", "append", "(", "max_f1_score", ")", "global_em", "=", "np", ".", "mean", "(", "instance_exact_match", ")", "global_f1", "=", "np", ".", "mean", "(", "instance_f1", ")", "print", "(", "\"Exact-match accuracy {0:.2f}\"", ".", "format", "(", "global_em", "*", "100", ")", ")", "print", "(", "\"F1 score {0:.2f}\"", ".", "format", "(", "global_f1", "*", "100", ")", ")", "print", "(", "\"{0:.2f} & {1:.2f}\"", ".", "format", "(", "global_em", "*", "100", ",", "global_f1", "*", "100", ")", ")", "print", "(", "\"----\"", ")", "total", "=", "np", ".", "sum", "(", "[", "len", "(", "v", ")", "for", "v", "in", "type_to_em", ".", "values", "(", ")", "]", ")", "for", "typ", "in", "sorted", "(", "type_to_em", ".", "keys", "(", ")", ")", ":", "print", "(", "\"{0}: {1} ({2:.2f}%)\"", ".", "format", "(", "typ", ",", "len", "(", "type_to_em", "[", "typ", "]", ")", ",", "100.", "*", "len", "(", "type_to_em", "[", "typ", "]", ")", "/", "total", ")", ")", "print", "(", "\" Exact-match accuracy {0:.3f}\"", ".", "format", "(", "100.", "*", "np", ".", "mean", "(", "type_to_em", "[", "typ", "]", ")", ")", ")", "print", "(", "\" F1 score {0:.3f}\"", ".", "format", "(", "100.", "*", "np", ".", "mean", "(", "type_to_f1", "[", "typ", "]", ")", ")", ")", "return", "global_em", ",", "global_f1" ]
Takes gold annotations and predicted answers and evaluates the predictions for each question in the gold annotations. Both JSON dictionaries must have query_id keys, which are used to match predictions to gold annotations (note that these are somewhat deep in the JSON for the gold annotations, but must be top-level keys in the predicted answers). The ``annotations`` are assumed to have the format of the dev set in the DROP data release. The ``predicted_answers`` JSON must be a dictionary keyed by query id, where the value is a string (or list of strings) that is the answer.
[ "Takes", "gold", "annotations", "and", "predicted", "answers", "and", "evaluates", "the", "predictions", "for", "each", "question", "in", "the", "gold", "annotations", ".", "Both", "JSON", "dictionaries", "must", "have", "query_id", "keys", "which", "are", "used", "to", "match", "predictions", "to", "gold", "annotations", "(", "note", "that", "these", "are", "somewhat", "deep", "in", "the", "JSON", "for", "the", "gold", "annotations", "but", "must", "be", "top", "-", "level", "keys", "in", "the", "predicted", "answers", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/tools/drop_eval.py#L167-L226
train
Evaluate the JSON for each question in the gold annotations and predicted answers and returns the predicted answer and the best answer for each question in the gold annotations.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sH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rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x33' + chr(0b110001) + chr(0b110011), 18060 - 18052), ehT0Px3KOsy9(chr(1099 - 1051) + '\157' + '\064' + chr(2137 - 2088), 28067 - 28059), ehT0Px3KOsy9(chr(1649 - 1601) + chr(0b1101000 + 0o7) + chr(1654 - 1603) + '\x32' + chr(2189 - 2135), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011100 + 0o23) + chr(0b100101 + 0o15) + '\060' + chr(2470 - 2415), ord("\x08")), ehT0Px3KOsy9(chr(1046 - 998) + chr(111) + chr(1118 - 1067) + chr(55) + chr(1327 - 1274), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(9304 - 9193) + chr(158 - 107) + chr(448 - 399) + '\064', 32997 - 32989), ehT0Px3KOsy9(chr(1667 - 1619) + chr(0b1101 + 0o142) + '\062' + '\061' + chr(0b110111), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1452 - 1400) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(51) + '\x33' + chr(0b1000 + 0o52), 52232 - 52224), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001011 + 0o44) + chr(0b110100) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(804 - 756) + '\x6f' + chr(50) + '\060' + '\066', 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(6512 - 6401) + chr(1379 - 1329) + chr(0b110100) + '\066', 64219 - 64211), ehT0Px3KOsy9(chr(0b110000) + chr(4137 - 4026) + '\x31' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + chr(3623 - 3512) + chr(0b110000), 31863 - 31855), ehT0Px3KOsy9(chr(48) + chr(111) + chr(51) + '\x37' + chr(50), 61777 - 61769), ehT0Px3KOsy9(chr(0b110000) + chr(0b111011 + 0o64) + chr(2323 - 2274) + '\060' + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(131 - 20) + chr(51) + chr(50) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(720 - 672) + chr(0b10100 + 0o133) + chr(1880 - 1829) + chr(53) + chr(0b110101), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(50) + chr(50) + chr(1998 - 1948), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\063' + chr(0b110001) + '\067', 46442 - 46434), ehT0Px3KOsy9(chr(968 - 920) + chr(0b110000 + 0o77) + chr(51) + chr(54) + chr(54), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(6466 - 6355) + '\x32' + chr(0b110111 + 0o0) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(192 - 144) + '\157' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(4118 - 4007) + chr(50) + chr(50), 0o10), ehT0Px3KOsy9(chr(1907 - 1859) + chr(111) + chr(55) + chr(0b110000), 51807 - 51799), ehT0Px3KOsy9(chr(0b10000 + 0o40) + '\157' + chr(50) + '\061' + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + chr(0b110101) + chr(0b110010 + 0o5), 0o10), ehT0Px3KOsy9(chr(430 - 382) + '\x6f' + '\063' + chr(0b100101 + 0o22) + chr(55), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b10001 + 0o136) + chr(0b100000 + 0o23) + chr(0b110010) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b100011 + 0o114) + '\061' + '\063' + '\064', 30887 - 30879), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(510 - 460) + chr(48) + chr(0b110010), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x31' + chr(0b100101 + 0o16) + chr(51), 40049 - 40041), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b11010 + 0o30) + chr(1318 - 1267) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(2005 - 1957) + '\x6f' + chr(0b100010 + 0o25) + chr(1327 - 1274), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(2432 - 2382) + chr(0b110011) + chr(49), 19080 - 19072), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(0b1101111) + '\x32' + chr(55) + chr(1589 - 1535), 39481 - 39473), ehT0Px3KOsy9(chr(1395 - 1347) + chr(0b1101111) + chr(1664 - 1614) + chr(0b1000 + 0o52) + chr(1826 - 1772), 2889 - 2881), ehT0Px3KOsy9(chr(1050 - 1002) + chr(915 - 804) + chr(49) + chr(50) + '\067', 37091 - 37083), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100111 + 0o13) + chr(0b100111 + 0o11) + '\062', 8), ehT0Px3KOsy9(chr(1218 - 1170) + chr(9727 - 9616) + chr(1330 - 1281) + '\065' + chr(0b100111 + 0o20), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(7371 - 7260) + chr(53) + '\060', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xe5'), '\x64' + chr(7919 - 7818) + chr(99) + chr(0b1001010 + 0o45) + chr(0b1100010 + 0o2) + chr(101))(chr(8925 - 8808) + chr(11150 - 11034) + chr(7459 - 7357) + chr(0b101101) + '\070') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def xbHkKbdEEqS6(zvbVkvaN64xd, GFZ18Pxw22Q7) -> MRK8Uzg2En3D[kkSX4ccExqw4, kkSX4ccExqw4]: a_fw_rGO0jMX = [] VkyBNdlCWGci = [] BqXETVCTZK2A = rLgqW9imlCdX(YyaZ4tpXu4lf) phohigUYsQkC = rLgqW9imlCdX(YyaZ4tpXu4lf) for (VNGQdHSFPrso, vIc_73L45y1x) in xafqLlk3kkUe(zvbVkvaN64xd, xafqLlk3kkUe(SXOLrMavuUCe(b'\x85[\xa0\xe2\xb4\x96\xbci\xb6t\xce\x9f'), '\x64' + chr(906 - 805) + chr(99) + '\x6f' + chr(1980 - 1880) + '\x65')(chr(117) + '\x74' + '\146' + chr(0b100001 + 0o14) + chr(0b111000)))(): for LNhHqkZOJZkU in vIc_73L45y1x[xafqLlk3kkUe(SXOLrMavuUCe(b'\xba@\x89\xf7\x9c\xa5\xfdS'), '\x64' + '\145' + '\x63' + '\157' + '\x64' + '\145')(chr(0b1110101) + chr(0b100101 + 0o117) + chr(8003 - 7901) + '\055' + '\070')]: xxl5e6WaaQRQ = LNhHqkZOJZkU[xafqLlk3kkUe(SXOLrMavuUCe(b'\xbaT\xb3\xf5\x84\x93\xe6D'), chr(100) + '\145' + '\143' + chr(0b1101111) + '\144' + chr(7202 - 7101))('\x75' + '\164' + chr(0b1011000 + 0o16) + chr(0b101101) + chr(1956 - 1900))] JLvL4HAUw_UX = 0.0 XclBmBWSEMsE = 0.0 UWh0MN3geQYr = None if xxl5e6WaaQRQ in GFZ18Pxw22Q7: zljAUjbBWUdH = GFZ18Pxw22Q7[xxl5e6WaaQRQ] Gyu2eoK4DUN0 = [LNhHqkZOJZkU[xafqLlk3kkUe(SXOLrMavuUCe(b'\xaaO\xa5\xf0\x98\xbe'), chr(100) + chr(0b100110 + 0o77) + chr(682 - 583) + chr(111) + chr(0b1100100) + '\x65')('\165' + '\x74' + chr(102) + chr(0b101010 + 0o3) + chr(764 - 708))]] if xafqLlk3kkUe(SXOLrMavuUCe(b'\xbd@\xba\xee\x99\xad\xfbE\xbex\xe7\xc8~w\x9f3\xa2'), chr(0b111000 + 0o54) + chr(0b10000 + 0o125) + chr(0b101110 + 0o65) + chr(2214 - 2103) + '\x64' + chr(0b10001 + 0o124))(chr(117) + chr(116) + '\146' + chr(0b10111 + 0o26) + '\070') in LNhHqkZOJZkU and LNhHqkZOJZkU[xafqLlk3kkUe(SXOLrMavuUCe(b'\xbd@\xba\xee\x99\xad\xfbE\xbex\xe7\xc8~w\x9f3\xa2'), '\x64' + '\145' + chr(8314 - 8215) + chr(0b1101111) + '\x64' + chr(101))('\165' + chr(116) + chr(2445 - 2343) + chr(0b101101) + chr(56))]: Gyu2eoK4DUN0 += LNhHqkZOJZkU[xafqLlk3kkUe(SXOLrMavuUCe(b'\xbd@\xba\xee\x99\xad\xfbE\xbex\xe7\xc8~w\x9f3\xa2'), chr(0b1100100) + '\x65' + chr(3950 - 3851) + chr(111) + chr(100 - 0) + chr(101))(chr(0b1001110 + 0o47) + '\164' + chr(5863 - 5761) + '\055' + chr(0b111000))] for _aygkdacRfLD in Gyu2eoK4DUN0: (J6oY8_kAF4hY, Nb66yhPMtY5E) = I7eYdMORi8o7(_aygkdacRfLD) (j1ZiRTEYAXLD, RLuUMxwuKIGi) = OX6sfedkWBvf(zljAUjbBWUdH, J6oY8_kAF4hY) if xafqLlk3kkUe(J6oY8_kAF4hY[ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x30', 8)], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb8U\xa4\xee\x8d'), '\144' + chr(0b1100101) + chr(0b101010 + 0o71) + '\x6f' + chr(2796 - 2696) + '\x65')(chr(0b10 + 0o163) + chr(8375 - 8259) + chr(0b1100000 + 0o6) + chr(1658 - 1613) + chr(0b111000)))() != xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(8005 - 7905) + chr(7739 - 7638) + chr(2451 - 2352) + chr(0b1101111) + chr(4709 - 4609) + chr(0b1100101))(chr(0b1110101) + '\x74' + '\x66' + chr(1025 - 980) + '\x38'): JLvL4HAUw_UX = tsdjvlgh9gDP(JLvL4HAUw_UX, j1ZiRTEYAXLD) XclBmBWSEMsE = tsdjvlgh9gDP(XclBmBWSEMsE, RLuUMxwuKIGi) if JLvL4HAUw_UX == j1ZiRTEYAXLD or XclBmBWSEMsE == RLuUMxwuKIGi: UWh0MN3geQYr = Nb66yhPMtY5E else: zLUzGokYBM2Z(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b"\x86H\xa5\xf4\x94\xa2\xe8\x00\xaaU\xe3\xc2dc\x8e(\xbe\x83\xb2\xa9\x99\xce'cM\xee\xdc\x8b\xbb3\xeca\xbdF\xe4"), chr(5791 - 5691) + chr(1690 - 1589) + chr(99) + '\x6f' + chr(0b1000 + 0o134) + chr(9975 - 9874))(chr(117) + chr(2954 - 2838) + '\146' + chr(0b11000 + 0o25) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\x15\xa4\xe8\xb5\xad\xdc\x13\x8aW\xe3\xcc'), '\x64' + chr(0b1100101) + chr(0b1100011) + chr(8389 - 8278) + '\x64' + chr(0b1100101))('\x75' + '\x74' + chr(102) + '\x2d' + chr(56)))(xxl5e6WaaQRQ)) if LNhHqkZOJZkU and LNhHqkZOJZkU[xafqLlk3kkUe(SXOLrMavuUCe(b'\xaaO\xa5\xf0\x98\xbe'), chr(8132 - 8032) + chr(0b1001101 + 0o30) + chr(99) + '\x6f' + chr(0b1100100) + '\x65')(chr(117) + chr(12781 - 12665) + chr(0b1010010 + 0o24) + chr(0b1000 + 0o45) + chr(0b111000))]: UWh0MN3geQYr = I7eYdMORi8o7(LNhHqkZOJZkU[xafqLlk3kkUe(SXOLrMavuUCe(b'\xaaO\xa5\xf0\x98\xbe'), chr(0b100100 + 0o100) + '\145' + chr(99) + chr(0b1101111) + chr(0b101111 + 0o65) + '\x65')('\x75' + chr(0b1110100) + '\x66' + chr(45) + chr(56))])[ehT0Px3KOsy9('\060' + chr(111) + chr(0b1111 + 0o42), ord("\x08"))] else: UWh0MN3geQYr = xafqLlk3kkUe(SXOLrMavuUCe(b'\xa5T\xbb\xe5\x98\xbe'), '\144' + '\x65' + chr(99) + '\157' + '\144' + chr(0b1100101))(chr(0b11 + 0o162) + chr(2107 - 1991) + chr(102) + '\x2d' + chr(0b10101 + 0o43)) JLvL4HAUw_UX = 0.0 XclBmBWSEMsE = 0.0 xafqLlk3kkUe(a_fw_rGO0jMX, xafqLlk3kkUe(SXOLrMavuUCe(b'\xaaQ\xa6\xe2\x93\xa8'), chr(426 - 326) + chr(0b111101 + 0o50) + chr(0b1100011) + chr(0b1101111) + chr(100) + chr(101))(chr(117) + chr(0b1110100) + '\146' + chr(0b100110 + 0o7) + chr(2945 - 2889)))(JLvL4HAUw_UX) xafqLlk3kkUe(VkyBNdlCWGci, xafqLlk3kkUe(SXOLrMavuUCe(b'\xaaQ\xa6\xe2\x93\xa8'), '\x64' + '\x65' + '\143' + chr(111) + chr(0b1100100) + '\x65')(chr(4218 - 4101) + '\x74' + '\x66' + chr(1038 - 993) + '\x38'))(XclBmBWSEMsE) xafqLlk3kkUe(BqXETVCTZK2A[UWh0MN3geQYr], xafqLlk3kkUe(SXOLrMavuUCe(b'\xaaQ\xa6\xe2\x93\xa8'), chr(0b1100100) + chr(0b0 + 0o145) + chr(0b1100011) + chr(111) + chr(5510 - 5410) + '\x65')('\165' + chr(0b1001100 + 0o50) + chr(0b1001110 + 0o30) + chr(1581 - 1536) + chr(0b111000)))(JLvL4HAUw_UX) xafqLlk3kkUe(phohigUYsQkC[UWh0MN3geQYr], xafqLlk3kkUe(SXOLrMavuUCe(b'\xaaQ\xa6\xe2\x93\xa8'), chr(0b1100100) + '\145' + '\x63' + chr(0b1101111) + chr(0b1100100) + chr(8430 - 8329))(chr(0b1001101 + 0o50) + chr(116) + '\146' + chr(1770 - 1725) + chr(0b111000)))(XclBmBWSEMsE) aaRyRIQ5KOar = WqUC3KWvYVup.aJhItC_Vawlw(a_fw_rGO0jMX) iAbNegFZ9BMv = WqUC3KWvYVup.aJhItC_Vawlw(VkyBNdlCWGci) zLUzGokYBM2Z(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\x8eY\xb7\xe4\x89\xe1\xe2A\xaeD\xee\x86lc\x994\xa3\x8c\xf1\xb6\xd6\xc77(\x16\xb9\xc9\x82'), chr(0b1100100) + chr(0b1100101 + 0o0) + chr(0b100001 + 0o102) + '\x6f' + chr(0b1100100) + '\145')(chr(0b100000 + 0o125) + '\164' + '\146' + chr(1863 - 1818) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\x15\xa4\xe8\xb5\xad\xdc\x13\x8aW\xe3\xcc'), chr(7548 - 7448) + '\x65' + chr(0b1100011) + '\157' + chr(0b1100100) + chr(3037 - 2936))(chr(0b1101000 + 0o15) + chr(0b1110100) + chr(0b1100110) + chr(45) + chr(0b111000)))(aaRyRIQ5KOar * ehT0Px3KOsy9('\x30' + chr(0b1001111 + 0o40) + '\061' + '\x34' + '\x34', ord("\x08")))) zLUzGokYBM2Z(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\x8d\x10\xf6\xf4\x9e\xa3\xfdE\xfa\\\xb6\x9c#2\x9c<'), chr(100) + chr(0b1100101) + chr(0b1100011) + chr(111) + '\144' + chr(101))('\165' + '\x74' + '\146' + chr(45) + chr(2979 - 2923)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\x15\xa4\xe8\xb5\xad\xdc\x13\x8aW\xe3\xcc'), chr(1800 - 1700) + chr(0b1100101) + chr(7636 - 7537) + chr(0b1101111) + chr(0b1100100) + chr(0b1100101))(chr(117) + '\164' + chr(0b110 + 0o140) + chr(45) + chr(56)))(iAbNegFZ9BMv * ehT0Px3KOsy9(chr(703 - 655) + chr(111) + chr(0b110001) + chr(1826 - 1774) + chr(0b1101 + 0o47), 8))) zLUzGokYBM2Z(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\xb0\x11\xec\xa9\xcf\xaa\xf2\x00\xfa\x07\xa0\x86- \x81p\xeb\xc3\xa0\xa9\x8b'), chr(0b100001 + 0o103) + chr(7162 - 7061) + chr(0b1100011) + chr(111) + chr(100) + chr(101))('\x75' + chr(116) + '\146' + chr(1450 - 1405) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\x15\xa4\xe8\xb5\xad\xdc\x13\x8aW\xe3\xcc'), chr(0b1000000 + 0o44) + '\x65' + chr(0b1100011) + '\x6f' + '\144' + chr(719 - 618))(chr(3374 - 3257) + chr(0b1001101 + 0o47) + '\146' + '\x2d' + chr(839 - 783)))(aaRyRIQ5KOar * ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + chr(52) + chr(0b110100 + 0o0), 8), iAbNegFZ9BMv * ehT0Px3KOsy9('\060' + chr(0b1100100 + 0o13) + chr(0b110001) + '\064' + chr(0b110100), 8))) zLUzGokYBM2Z(xafqLlk3kkUe(SXOLrMavuUCe(b'\xe6\x0c\xfb\xaa'), chr(0b1100100) + chr(0b1100101) + chr(0b1100011) + chr(0b1011110 + 0o21) + '\144' + chr(7019 - 6918))('\165' + chr(116) + chr(1641 - 1539) + chr(0b101101) + chr(0b111 + 0o61))) K6dkrI1oAm5b = WqUC3KWvYVup.xkxBmo49x2An([c2A0yzQpDQB3(cMbll0QYhULo) for cMbll0QYhULo in BqXETVCTZK2A.SPnCNu54H1db()]) for bpaEEKQUs94d in vUlqIvNSaRMa(xafqLlk3kkUe(BqXETVCTZK2A, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa0D\xaf\xf4'), chr(0b1100100) + chr(101) + chr(0b0 + 0o143) + chr(0b111110 + 0o61) + chr(0b10100 + 0o120) + '\x65')('\165' + '\x74' + chr(102) + '\x2d' + chr(72 - 16)))()): zLUzGokYBM2Z(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b"\xb0\x11\xab\xbd\xdd\xb7\xbe]\xfa\x0f\xfd\x947.\xc8'\xac\xc8\xbb"), chr(1977 - 1877) + chr(101) + chr(0b1100011) + chr(111) + chr(100) + chr(0b1100101))(chr(12579 - 12462) + chr(116) + chr(0b1100110) + '\055' + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\x15\xa4\xe8\xb5\xad\xdc\x13\x8aW\xe3\xcc'), '\x64' + '\145' + chr(99) + '\x6f' + chr(0b1010 + 0o132) + chr(0b111110 + 0o47))(chr(117) + chr(3806 - 3690) + chr(0b1100110) + chr(45) + '\x38'))(bpaEEKQUs94d, c2A0yzQpDQB3(BqXETVCTZK2A[bpaEEKQUs94d]), 100.0 * c2A0yzQpDQB3(BqXETVCTZK2A[bpaEEKQUs94d]) / K6dkrI1oAm5b)) zLUzGokYBM2Z(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\xeb\x01\x93\xff\x9c\xaf\xfb\r\xb7F\xf2\xc5e \x9b"\xb2\x98\xe0\xae\x95\xc5\'i\x08\xb1\x81\xcc\xb4!'), chr(100) + '\x65' + '\143' + chr(111) + chr(6358 - 6258) + chr(8623 - 8522))(chr(0b1110101) + chr(11699 - 11583) + chr(7080 - 6978) + '\x2d' + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\x15\xa4\xe8\xb5\xad\xdc\x13\x8aW\xe3\xcc'), chr(0b1100100) + chr(9128 - 9027) + chr(1189 - 1090) + chr(9993 - 9882) + chr(0b1000010 + 0o42) + chr(0b1100101))('\165' + chr(0b1110100) + '\146' + '\x2d' + chr(0b110001 + 0o7)))(100.0 * xafqLlk3kkUe(WqUC3KWvYVup, xafqLlk3kkUe(SXOLrMavuUCe(b'\xaak\xbe\xce\x89\x8f\xd0v\xbbP\xea\xd1'), chr(0b1100011 + 0o1) + chr(0b1000101 + 0o40) + chr(0b1000000 + 0o43) + chr(111) + chr(0b1100100) + '\145')('\165' + chr(116) + '\x66' + '\055' + chr(0b111000)))(BqXETVCTZK2A[bpaEEKQUs94d]))) zLUzGokYBM2Z(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\xeb\x01\x90\xb6\xdd\xbf\xecO\xa8B\xa6\xdd=:\xd4r\xb7\x90'), chr(0b1000 + 0o134) + chr(6294 - 6193) + chr(99) + chr(164 - 53) + chr(0b1010110 + 0o16) + chr(101))(chr(11991 - 11874) + chr(116) + chr(3468 - 3366) + '\x2d' + chr(0b11010 + 0o36)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\x15\xa4\xe8\xb5\xad\xdc\x13\x8aW\xe3\xcc'), chr(0b1000101 + 0o37) + chr(101) + chr(0b110110 + 0o55) + chr(7830 - 7719) + '\x64' + '\x65')(chr(0b1010011 + 0o42) + chr(0b11001 + 0o133) + chr(0b1100110) + chr(0b101101) + '\x38'))(100.0 * xafqLlk3kkUe(WqUC3KWvYVup, xafqLlk3kkUe(SXOLrMavuUCe(b'\xaak\xbe\xce\x89\x8f\xd0v\xbbP\xea\xd1'), chr(0b1110 + 0o126) + chr(4530 - 4429) + chr(9346 - 9247) + '\x6f' + chr(0b110110 + 0o56) + chr(0b1100101))('\165' + chr(116) + '\x66' + '\x2d' + '\070'))(phohigUYsQkC[bpaEEKQUs94d]))) return (aaRyRIQ5KOar, iAbNegFZ9BMv)
allenai/allennlp
allennlp/tools/drop_eval.py
evaluate_prediction_file
def evaluate_prediction_file(prediction_path: str, gold_path: str) -> Tuple[float, float]: """ Takes a prediction file and a gold file and evaluates the predictions for each question in the gold file. Both files must be json formatted and must have query_id keys, which are used to match predictions to gold annotations. The gold file is assumed to have the format of the dev set in the DROP data release. The prediction file must be a JSON dictionary keyed by query id, where the value is either a JSON dictionary with an "answer" key, or just a string (or list of strings) that is the answer. """ predicted_answers = json.load(open(prediction_path, encoding='utf-8')) annotations = json.load(open(gold_path, encoding='utf-8')) return evaluate_json(annotations, predicted_answers)
python
def evaluate_prediction_file(prediction_path: str, gold_path: str) -> Tuple[float, float]: """ Takes a prediction file and a gold file and evaluates the predictions for each question in the gold file. Both files must be json formatted and must have query_id keys, which are used to match predictions to gold annotations. The gold file is assumed to have the format of the dev set in the DROP data release. The prediction file must be a JSON dictionary keyed by query id, where the value is either a JSON dictionary with an "answer" key, or just a string (or list of strings) that is the answer. """ predicted_answers = json.load(open(prediction_path, encoding='utf-8')) annotations = json.load(open(gold_path, encoding='utf-8')) return evaluate_json(annotations, predicted_answers)
[ "def", "evaluate_prediction_file", "(", "prediction_path", ":", "str", ",", "gold_path", ":", "str", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "predicted_answers", "=", "json", ".", "load", "(", "open", "(", "prediction_path", ",", "encoding", "=", "'utf-8'", ")", ")", "annotations", "=", "json", ".", "load", "(", "open", "(", "gold_path", ",", "encoding", "=", "'utf-8'", ")", ")", "return", "evaluate_json", "(", "annotations", ",", "predicted_answers", ")" ]
Takes a prediction file and a gold file and evaluates the predictions for each question in the gold file. Both files must be json formatted and must have query_id keys, which are used to match predictions to gold annotations. The gold file is assumed to have the format of the dev set in the DROP data release. The prediction file must be a JSON dictionary keyed by query id, where the value is either a JSON dictionary with an "answer" key, or just a string (or list of strings) that is the answer.
[ "Takes", "a", "prediction", "file", "and", "a", "gold", "file", "and", "evaluates", "the", "predictions", "for", "each", "question", "in", "the", "gold", "file", ".", "Both", "files", "must", "be", "json", "formatted", "and", "must", "have", "query_id", "keys", "which", "are", "used", "to", "match", "predictions", "to", "gold", "annotations", ".", "The", "gold", "file", "is", "assumed", "to", "have", "the", "format", "of", "the", "dev", "set", "in", "the", "DROP", "data", "release", ".", "The", "prediction", "file", "must", "be", "a", "JSON", "dictionary", "keyed", "by", "query", "id", "where", "the", "value", "is", "either", "a", "JSON", "dictionary", "with", "an", "answer", "key", "or", "just", "a", "string", "(", "or", "list", "of", "strings", ")", "that", "is", "the", "answer", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/tools/drop_eval.py#L229-L240
train
Takes a prediction file and a gold file and evaluates the predictions for each question in the .
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw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ZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(10416 - 10305) + chr(0b110011) + '\067' + '\061', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b110011) + chr(0b100011 + 0o24) + chr(1776 - 1722), ord("\x08")), ehT0Px3KOsy9(chr(1078 - 1030) + '\157' + '\x33' + chr(2670 - 2615) + chr(0b110111), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(1047 - 997) + chr(0b110010) + '\x34', 0o10), ehT0Px3KOsy9(chr(801 - 753) + '\157' + chr(49) + chr(51) + chr(0b100111 + 0o12), 0b1000), ehT0Px3KOsy9(chr(923 - 875) + chr(0b1101111) + chr(627 - 577) + chr(0b110001) + chr(51), 0o10), ehT0Px3KOsy9(chr(876 - 828) + chr(0b1101111) + '\x31' + chr(53) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1506 - 1457) + chr(0b10101 + 0o41), 42613 - 42605), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(52) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\062' + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1100111 + 0o10) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\062' + '\x36' + '\065', 0b1000), ehT0Px3KOsy9(chr(48) + chr(6939 - 6828) + chr(50) + chr(0b110000) + chr(0b110111), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b10001 + 0o42) + '\063' + chr(1660 - 1610), 0o10), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101111) + chr(0b110001) + '\x30', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b101001 + 0o106) + chr(49) + chr(0b110101) + chr(0b101100 + 0o13), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b10 + 0o155) + chr(50) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + chr(0b110 + 0o57) + chr(52), 32080 - 32072), ehT0Px3KOsy9('\x30' + '\x6f' + '\062' + chr(1227 - 1176), 8), ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(5218 - 5107) + chr(49) + '\x36' + '\x32', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(2545 - 2490) + chr(0b110001), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + chr(50), 0b1000), ehT0Px3KOsy9(chr(2199 - 2151) + '\157' + chr(0b110001) + '\063' + '\x35', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b11111 + 0o24) + '\064' + '\063', 37266 - 37258), ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\157' + chr(1541 - 1491) + chr(49) + chr(55), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\x37' + chr(302 - 252), ord("\x08")), ehT0Px3KOsy9(chr(1636 - 1588) + '\157' + chr(50) + chr(0b110001 + 0o5) + chr(2654 - 2601), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1413 - 1363) + chr(0b110000 + 0o1) + chr(55), 8), ehT0Px3KOsy9('\060' + chr(111) + '\063' + chr(54) + '\061', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + chr(52) + chr(48), 0o10), ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(111) + '\x32' + '\x37' + chr(121 - 67), 902 - 894), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(52) + chr(0b100011 + 0o20), 0o10), ehT0Px3KOsy9('\060' + chr(0b111010 + 0o65) + chr(0b100 + 0o57) + chr(0b110101) + chr(0b110111), 0o10), ehT0Px3KOsy9('\x30' + chr(10750 - 10639) + chr(0b110 + 0o54) + chr(0b110000) + '\x30', 46653 - 46645), ehT0Px3KOsy9('\060' + chr(0b1010101 + 0o32) + '\x33' + '\064' + chr(2414 - 2360), 43949 - 43941), ehT0Px3KOsy9(chr(0b110000) + chr(7214 - 7103) + '\062' + chr(2362 - 2308) + chr(53), 8), ehT0Px3KOsy9(chr(48) + chr(111) + '\x32' + chr(0b110101) + chr(53), 23769 - 23761), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110 + 0o53) + chr(0b110011) + chr(55), 50408 - 50400), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(52) + '\x37', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\157' + '\x35' + chr(0b110000), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7'), chr(3316 - 3216) + chr(0b1100101) + chr(0b110000 + 0o63) + chr(0b1101111) + chr(100) + chr(101))(chr(0b1100010 + 0o23) + chr(116) + chr(0b1100110) + chr(1909 - 1864) + chr(0b101010 + 0o16)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def uzor88NWYkIa(KS9vajbb9ibu, R2MnwjfXJB4C) -> MRK8Uzg2En3D[kkSX4ccExqw4, kkSX4ccExqw4]: GFZ18Pxw22Q7 = fXk443epxtd5.mxtdQMeiwJZJ(_fwkIVCGgtAN(KS9vajbb9ibu, encoding=xafqLlk3kkUe(SXOLrMavuUCe(b'\x8c\x8a\x99\xb9a'), chr(0b110001 + 0o63) + chr(2525 - 2424) + chr(0b1100010 + 0o1) + '\157' + '\144' + chr(0b1100101))(chr(1876 - 1759) + '\164' + chr(4822 - 4720) + '\x2d' + '\x38'))) zvbVkvaN64xd = fXk443epxtd5.mxtdQMeiwJZJ(_fwkIVCGgtAN(R2MnwjfXJB4C, encoding=xafqLlk3kkUe(SXOLrMavuUCe(b'\x8c\x8a\x99\xb9a'), chr(0b1100100) + '\x65' + chr(0b1100011) + chr(0b1101111) + chr(2900 - 2800) + chr(9950 - 9849))('\165' + chr(5765 - 5649) + chr(0b1100110) + '\x2d' + chr(0b101001 + 0o17)))) return xbHkKbdEEqS6(zvbVkvaN64xd, GFZ18Pxw22Q7)
allenai/allennlp
allennlp/data/dataset_readers/dataset_reader.py
DatasetReader.cache_data
def cache_data(self, cache_directory: str) -> None: """ When you call this method, we will use this directory to store a cache of already-processed ``Instances`` in every file passed to :func:`read`, serialized as one string-formatted ``Instance`` per line. If the cache file for a given ``file_path`` exists, we read the ``Instances`` from the cache instead of re-processing the data (using :func:`deserialize_instance`). If the cache file does `not` exist, we will `create` it on our first pass through the data (using :func:`serialize_instance`). IMPORTANT CAVEAT: It is the `caller's` responsibility to make sure that this directory is unique for any combination of code and parameters that you use. That is, if you call this method, we will use any existing cache files in that directory `regardless of the parameters you set for this DatasetReader!` If you use our commands, the ``Train`` command is responsible for calling this method and ensuring that unique parameters correspond to unique cache directories. If you don't use our commands, that is your responsibility. """ self._cache_directory = pathlib.Path(cache_directory) os.makedirs(self._cache_directory, exist_ok=True)
python
def cache_data(self, cache_directory: str) -> None: """ When you call this method, we will use this directory to store a cache of already-processed ``Instances`` in every file passed to :func:`read`, serialized as one string-formatted ``Instance`` per line. If the cache file for a given ``file_path`` exists, we read the ``Instances`` from the cache instead of re-processing the data (using :func:`deserialize_instance`). If the cache file does `not` exist, we will `create` it on our first pass through the data (using :func:`serialize_instance`). IMPORTANT CAVEAT: It is the `caller's` responsibility to make sure that this directory is unique for any combination of code and parameters that you use. That is, if you call this method, we will use any existing cache files in that directory `regardless of the parameters you set for this DatasetReader!` If you use our commands, the ``Train`` command is responsible for calling this method and ensuring that unique parameters correspond to unique cache directories. If you don't use our commands, that is your responsibility. """ self._cache_directory = pathlib.Path(cache_directory) os.makedirs(self._cache_directory, exist_ok=True)
[ "def", "cache_data", "(", "self", ",", "cache_directory", ":", "str", ")", "->", "None", ":", "self", ".", "_cache_directory", "=", "pathlib", ".", "Path", "(", "cache_directory", ")", "os", ".", "makedirs", "(", "self", ".", "_cache_directory", ",", "exist_ok", "=", "True", ")" ]
When you call this method, we will use this directory to store a cache of already-processed ``Instances`` in every file passed to :func:`read`, serialized as one string-formatted ``Instance`` per line. If the cache file for a given ``file_path`` exists, we read the ``Instances`` from the cache instead of re-processing the data (using :func:`deserialize_instance`). If the cache file does `not` exist, we will `create` it on our first pass through the data (using :func:`serialize_instance`). IMPORTANT CAVEAT: It is the `caller's` responsibility to make sure that this directory is unique for any combination of code and parameters that you use. That is, if you call this method, we will use any existing cache files in that directory `regardless of the parameters you set for this DatasetReader!` If you use our commands, the ``Train`` command is responsible for calling this method and ensuring that unique parameters correspond to unique cache directories. If you don't use our commands, that is your responsibility.
[ "When", "you", "call", "this", "method", "we", "will", "use", "this", "directory", "to", "store", "a", "cache", "of", "already", "-", "processed", "Instances", "in", "every", "file", "passed", "to", ":", "func", ":", "read", "serialized", "as", "one", "string", "-", "formatted", "Instance", "per", "line", ".", "If", "the", "cache", "file", "for", "a", "given", "file_path", "exists", "we", "read", "the", "Instances", "from", "the", "cache", "instead", "of", "re", "-", "processing", "the", "data", "(", "using", ":", "func", ":", "deserialize_instance", ")", ".", "If", "the", "cache", "file", "does", "not", "exist", "we", "will", "create", "it", "on", "our", "first", "pass", "through", "the", "data", "(", "using", ":", "func", ":", "serialize_instance", ")", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_reader.py#L72-L89
train
This method will cache the data for a given set of items in a given directory.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,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R_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + '\x30', 15220 - 15212), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + chr(48) + '\x37', 27199 - 27191), ehT0Px3KOsy9(chr(456 - 408) + '\157' + '\x31' + chr(2632 - 2579) + chr(0b10100 + 0o41), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(1267 - 1219) + chr(111) + chr(50) + chr(54) + chr(0b101111 + 0o7), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b101101 + 0o4) + chr(0b110010 + 0o0) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110110) + chr(1544 - 1489), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(6941 - 6830) + '\062' + chr(0b110110) + '\x32', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110101) + chr(1042 - 991), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1931 - 1881) + '\x32' + '\067', ord("\x08")), ehT0Px3KOsy9(chr(686 - 638) + chr(111) + chr(0b100001 + 0o26) + chr(0b101101 + 0o7), 0b1000), ehT0Px3KOsy9(chr(2155 - 2107) + '\157' + chr(2474 - 2424) + '\066' + chr(0b110101), 29412 - 29404), ehT0Px3KOsy9(chr(48) + chr(111) + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(805 - 756) + '\x33', 0o10), ehT0Px3KOsy9(chr(1390 - 1342) + '\x6f' + '\061' + chr(0b101100 + 0o6) + chr(1842 - 1792), ord("\x08")), ehT0Px3KOsy9(chr(802 - 754) + '\157' + chr(0b110010) + chr(49) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(4098 - 3987) + chr(1387 - 1336) + '\064' + chr(0b110001), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + chr(2562 - 2511) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + '\x34' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(67 - 19) + '\157' + '\x31' + '\066' + '\x31', 58309 - 58301), ehT0Px3KOsy9(chr(1620 - 1572) + chr(111) + '\064' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\x6f' + '\x33' + chr(1993 - 1940), ord("\x08")), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(0b1101111) + chr(0b110010) + chr(0b100010 + 0o17), 13349 - 13341), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + '\x31' + chr(0b100000 + 0o24), 8), ehT0Px3KOsy9(chr(0b101101 + 0o3) + '\x6f' + chr(0b11001 + 0o32) + chr(2060 - 2010) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\061' + '\x35' + chr(2647 - 2592), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\062' + chr(50) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + chr(52) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(1185 - 1137) + chr(0b110011 + 0o74) + chr(1380 - 1330), 8), ehT0Px3KOsy9(chr(1629 - 1581) + chr(3103 - 2992) + chr(0b100101 + 0o16) + '\x36' + '\x31', 0b1000), ehT0Px3KOsy9(chr(2138 - 2090) + chr(0b1101111) + chr(0b1101 + 0o44) + chr(2656 - 2603) + chr(0b111 + 0o54), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(0b110111) + chr(0b1010 + 0o47), 46515 - 46507), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + '\x37' + chr(0b110001 + 0o2), 23753 - 23745), ehT0Px3KOsy9(chr(0b110000) + chr(822 - 711) + chr(0b11 + 0o60) + chr(0b110011) + chr(0b1 + 0o64), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + '\x35' + '\061', 6490 - 6482), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(111) + chr(0b11010 + 0o30) + '\063' + '\x34', 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(1184 - 1133) + '\062' + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(7715 - 7604) + '\x31' + '\064' + '\x36', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + chr(1980 - 1932) + chr(0b10111 + 0o34), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + '\x34' + '\x30', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10100 + 0o41) + chr(0b100010 + 0o16), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'&'), chr(7853 - 7753) + '\x65' + chr(2884 - 2785) + '\157' + chr(273 - 173) + '\x65')(chr(5901 - 5784) + chr(0b1011100 + 0o30) + chr(10013 - 9911) + chr(0b101101) + '\x38') + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def gJnz1fuHCqy5(oVre8I6UXc3b, If0YRWOIVmUY) -> None: oVre8I6UXc3b.RrObmdGekwZk = WAMIfYuFYgQW.Path(If0YRWOIVmUY) xafqLlk3kkUe(oqhJDdMJfuwx, xafqLlk3kkUe(SXOLrMavuUCe(b'e&\x06g\xd2:E\xc1'), '\144' + '\x65' + '\x63' + chr(0b1101111) + '\144' + chr(0b1010 + 0o133))(chr(1228 - 1111) + chr(7012 - 6896) + '\146' + chr(0b101101) + '\070'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'Z5"`\xdb7p\xd7@\xe0f\xde'), chr(7272 - 7172) + '\145' + chr(99) + chr(10921 - 10810) + '\144' + '\145')('\x75' + '\164' + '\x66' + chr(45) + chr(881 - 825))), exist_ok=ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001), ord("\x08")))
allenai/allennlp
allennlp/data/dataset_readers/dataset_reader.py
DatasetReader.read
def read(self, file_path: str) -> Iterable[Instance]: """ Returns an ``Iterable`` containing all the instances in the specified dataset. If ``self.lazy`` is False, this calls ``self._read()``, ensures that the result is a list, then returns the resulting list. If ``self.lazy`` is True, this returns an object whose ``__iter__`` method calls ``self._read()`` each iteration. In this case your implementation of ``_read()`` must also be lazy (that is, not load all instances into memory at once), otherwise you will get a ``ConfigurationError``. In either case, the returned ``Iterable`` can be iterated over multiple times. It's unlikely you want to override this function, but if you do your result should likewise be repeatedly iterable. """ lazy = getattr(self, 'lazy', None) if lazy is None: logger.warning("DatasetReader.lazy is not set, " "did you forget to call the superclass constructor?") if self._cache_directory: cache_file = self._get_cache_location_for_file_path(file_path) else: cache_file = None if lazy: return _LazyInstances(lambda: self._read(file_path), cache_file, self.deserialize_instance, self.serialize_instance) else: # First we read the instances, either from a cache or from the original file. if cache_file and os.path.exists(cache_file): instances = self._instances_from_cache_file(cache_file) else: instances = self._read(file_path) # Then some validation. if not isinstance(instances, list): instances = [instance for instance in Tqdm.tqdm(instances)] if not instances: raise ConfigurationError("No instances were read from the given filepath {}. " "Is the path correct?".format(file_path)) # And finally we write to the cache if we need to. if cache_file and not os.path.exists(cache_file): logger.info(f"Caching instances to {cache_file}") with open(cache_file, 'w') as cache: for instance in Tqdm.tqdm(instances): cache.write(self.serialize_instance(instance) + '\n') return instances
python
def read(self, file_path: str) -> Iterable[Instance]: """ Returns an ``Iterable`` containing all the instances in the specified dataset. If ``self.lazy`` is False, this calls ``self._read()``, ensures that the result is a list, then returns the resulting list. If ``self.lazy`` is True, this returns an object whose ``__iter__`` method calls ``self._read()`` each iteration. In this case your implementation of ``_read()`` must also be lazy (that is, not load all instances into memory at once), otherwise you will get a ``ConfigurationError``. In either case, the returned ``Iterable`` can be iterated over multiple times. It's unlikely you want to override this function, but if you do your result should likewise be repeatedly iterable. """ lazy = getattr(self, 'lazy', None) if lazy is None: logger.warning("DatasetReader.lazy is not set, " "did you forget to call the superclass constructor?") if self._cache_directory: cache_file = self._get_cache_location_for_file_path(file_path) else: cache_file = None if lazy: return _LazyInstances(lambda: self._read(file_path), cache_file, self.deserialize_instance, self.serialize_instance) else: # First we read the instances, either from a cache or from the original file. if cache_file and os.path.exists(cache_file): instances = self._instances_from_cache_file(cache_file) else: instances = self._read(file_path) # Then some validation. if not isinstance(instances, list): instances = [instance for instance in Tqdm.tqdm(instances)] if not instances: raise ConfigurationError("No instances were read from the given filepath {}. " "Is the path correct?".format(file_path)) # And finally we write to the cache if we need to. if cache_file and not os.path.exists(cache_file): logger.info(f"Caching instances to {cache_file}") with open(cache_file, 'w') as cache: for instance in Tqdm.tqdm(instances): cache.write(self.serialize_instance(instance) + '\n') return instances
[ "def", "read", "(", "self", ",", "file_path", ":", "str", ")", "->", "Iterable", "[", "Instance", "]", ":", "lazy", "=", "getattr", "(", "self", ",", "'lazy'", ",", "None", ")", "if", "lazy", "is", "None", ":", "logger", ".", "warning", "(", "\"DatasetReader.lazy is not set, \"", "\"did you forget to call the superclass constructor?\"", ")", "if", "self", ".", "_cache_directory", ":", "cache_file", "=", "self", ".", "_get_cache_location_for_file_path", "(", "file_path", ")", "else", ":", "cache_file", "=", "None", "if", "lazy", ":", "return", "_LazyInstances", "(", "lambda", ":", "self", ".", "_read", "(", "file_path", ")", ",", "cache_file", ",", "self", ".", "deserialize_instance", ",", "self", ".", "serialize_instance", ")", "else", ":", "# First we read the instances, either from a cache or from the original file.", "if", "cache_file", "and", "os", ".", "path", ".", "exists", "(", "cache_file", ")", ":", "instances", "=", "self", ".", "_instances_from_cache_file", "(", "cache_file", ")", "else", ":", "instances", "=", "self", ".", "_read", "(", "file_path", ")", "# Then some validation.", "if", "not", "isinstance", "(", "instances", ",", "list", ")", ":", "instances", "=", "[", "instance", "for", "instance", "in", "Tqdm", ".", "tqdm", "(", "instances", ")", "]", "if", "not", "instances", ":", "raise", "ConfigurationError", "(", "\"No instances were read from the given filepath {}. \"", "\"Is the path correct?\"", ".", "format", "(", "file_path", ")", ")", "# And finally we write to the cache if we need to.", "if", "cache_file", "and", "not", "os", ".", "path", ".", "exists", "(", "cache_file", ")", ":", "logger", ".", "info", "(", "f\"Caching instances to {cache_file}\"", ")", "with", "open", "(", "cache_file", ",", "'w'", ")", "as", "cache", ":", "for", "instance", "in", "Tqdm", ".", "tqdm", "(", "instances", ")", ":", "cache", ".", "write", "(", "self", ".", "serialize_instance", "(", "instance", ")", "+", "'\\n'", ")", "return", "instances" ]
Returns an ``Iterable`` containing all the instances in the specified dataset. If ``self.lazy`` is False, this calls ``self._read()``, ensures that the result is a list, then returns the resulting list. If ``self.lazy`` is True, this returns an object whose ``__iter__`` method calls ``self._read()`` each iteration. In this case your implementation of ``_read()`` must also be lazy (that is, not load all instances into memory at once), otherwise you will get a ``ConfigurationError``. In either case, the returned ``Iterable`` can be iterated over multiple times. It's unlikely you want to override this function, but if you do your result should likewise be repeatedly iterable.
[ "Returns", "an", "Iterable", "containing", "all", "the", "instances", "in", "the", "specified", "dataset", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_reader.py#L91-L145
train
Reads the specified file and returns an iterable of all the inst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,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(3804 - 3693) + '\x33' + '\065' + '\067', 56980 - 56972), ehT0Px3KOsy9(chr(1891 - 1843) + chr(8490 - 8379) + '\063' + chr(0b110101) + chr(48), 37409 - 37401), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49) + '\x31' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(0b101011 + 0o104) + chr(49) + chr(0b11101 + 0o23) + '\061', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + '\062' + chr(65 - 10), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + chr(53) + chr(0b1110 + 0o45), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\062' + chr(0b110010) + '\063', 0o10), ehT0Px3KOsy9(chr(364 - 316) + '\x6f' + chr(0b10110 + 0o35) + chr(0b1001 + 0o55) + chr(0b101000 + 0o11), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b1110 + 0o43) + chr(54) + '\x31', 24915 - 24907), ehT0Px3KOsy9(chr(1719 - 1671) + '\x6f' + '\061' + chr(48) + chr(48), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(10547 - 10436) + chr(1794 - 1744) + '\x35' + '\063', 34282 - 34274), ehT0Px3KOsy9('\x30' + chr(0b1000000 + 0o57) + chr(0b11011 + 0o26) + chr(149 - 94) + chr(2253 - 2203), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(48) + '\x30', 8), ehT0Px3KOsy9(chr(1310 - 1262) + chr(10573 - 10462) + chr(2340 - 2287) + chr(0b1111 + 0o44), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110001) + chr(52) + chr(0b1001 + 0o51), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\x36' + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1000110 + 0o51) + chr(1349 - 1299) + chr(0b110011) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + chr(48) + chr(1109 - 1060), 20012 - 20004), ehT0Px3KOsy9(chr(2272 - 2224) + chr(1068 - 957) + chr(50) + '\067' + chr(54), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b11000 + 0o127) + chr(0b101001 + 0o11) + chr(0b100000 + 0o24) + chr(928 - 873), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(799 - 749) + chr(0b110001) + chr(0b11 + 0o55), 44478 - 44470), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11 + 0o57) + chr(0b11110 + 0o23) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b1101 + 0o46) + chr(1970 - 1922), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(52) + '\x32', 0b1000), ehT0Px3KOsy9(chr(657 - 609) + chr(111) + chr(0b110011) + chr(51) + chr(0b10111 + 0o31), 16170 - 16162), ehT0Px3KOsy9(chr(48) + chr(0b100010 + 0o115) + chr(0b110010) + chr(0b11010 + 0o27) + chr(631 - 576), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110110) + '\x33', 31291 - 31283), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10011 + 0o40) + '\x37' + '\x34', 48927 - 48919), ehT0Px3KOsy9('\x30' + chr(111) + chr(2507 - 2456) + chr(0b110111) + chr(0b10101 + 0o36), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(49) + '\062' + '\x36', 4965 - 4957), ehT0Px3KOsy9('\x30' + chr(0b1100000 + 0o17) + '\061' + chr(0b110000) + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b100111 + 0o110) + '\063' + '\x34' + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11001 + 0o30) + chr(0b11100 + 0o24) + '\x37', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(76 - 25) + '\061' + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(2282 - 2234) + chr(0b1101110 + 0o1) + chr(193 - 143) + '\064' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(10751 - 10640) + chr(0b110001) + chr(829 - 775), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b11010 + 0o27) + chr(53) + '\x30', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b0 + 0o62) + '\x33' + '\060', 11754 - 11746), ehT0Px3KOsy9(chr(0b110000) + chr(10530 - 10419) + chr(50) + '\065' + chr(242 - 193), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110101) + chr(0b101111 + 0o1), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc1'), '\x64' + chr(101) + chr(0b1100011) + chr(0b110001 + 0o76) + chr(5704 - 5604) + '\145')(chr(11887 - 11770) + '\x74' + '\x66' + '\x2d' + chr(0b1010 + 0o56)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def U6MiWrhuCi2Y(oVre8I6UXc3b, Ti9e_bxaCVyu) -> U1nE7SA1iyUR[_jFYXBmhzM0H]: l7fBk51Hp1xn = xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x83\x8958'), chr(100) + '\145' + chr(0b101 + 0o136) + '\x6f' + '\x64' + chr(101))(chr(0b101101 + 0o110) + chr(0b1110100) + '\x66' + chr(45) + chr(0b1111 + 0o51)), None) if l7fBk51Hp1xn is None: xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x98\x89=/\xbe\x05\xf4'), chr(100) + chr(0b1011100 + 0o11) + '\143' + chr(11295 - 11184) + chr(0b101101 + 0o67) + chr(9435 - 9334))('\x75' + chr(0b100010 + 0o122) + '\146' + chr(0b101101) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xab\x89; \xa4\x0e\xe7\xa3\x14!\xcf\x1funG\x03N\xe2\xe1\xd7\xd4\xa8\xe5wV\xf8\xfcV\x88\xd7v \x8e#\xef\xd9a\x1d\xb8\xcf\x80\x9a($\xa3K\xe7\x9eQ#\xca\x16k`_\nQ\xbb\xb2\xcb\xd7\xed\xf9{N\xb9\xfc@\xdc\x989*\x943\xbd\xd5m\x1c\xf7\xdb\xd0'), '\x64' + chr(0b1100101) + chr(0b10110 + 0o115) + '\x6f' + chr(4249 - 4149) + chr(0b1100101))('\165' + '\x74' + chr(0b1100110) + chr(0b101101) + '\070')) if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbd\x9a\x00#\xba\x0f\xd4\x94\x1a7\xf1\x11'), '\144' + '\145' + chr(0b101110 + 0o65) + '\157' + chr(0b1001010 + 0o32) + chr(0b1100101))(chr(0b1110101) + chr(116) + chr(102) + '\055' + chr(0b111 + 0o61))): vhXbYptxZ3Pz = oVre8I6UXc3b._get_cache_location_for_file_path(Ti9e_bxaCVyu) else: vhXbYptxZ3Pz = None if l7fBk51Hp1xn: return NwptC13451gD(lambda : xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb0\x9a* \xb3'), '\144' + chr(101) + chr(2815 - 2716) + chr(111) + '\144' + '\x65')(chr(0b1110101) + chr(0b1110100) + '\x66' + chr(45) + chr(0b111000)))(Ti9e_bxaCVyu), vhXbYptxZ3Pz, xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8b\x8d<$\xa5\x02\xf2\x9d\x18:\xce%n.X\x16U\xf5\xa2\xdb'), '\x64' + '\x65' + chr(0b1100011) + '\x6f' + '\144' + chr(101))(chr(0b1110101) + chr(8133 - 8017) + chr(0b1100110) + chr(1657 - 1612) + chr(0b101001 + 0o17))), xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9c\x8d=(\xb6\x07\xfa\x8b\x14\x1f\xc2\x14t4J\x0cW\xfe'), chr(0b1100100) + chr(0b10100 + 0o121) + chr(99) + '\157' + chr(7305 - 7205) + chr(0b1100101))(chr(0b1110101) + chr(5400 - 5284) + chr(102) + '\055' + chr(56)))) else: if vhXbYptxZ3Pz and xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8a\x90&2\xa3\x18'), chr(8173 - 8073) + '\145' + chr(0b1011 + 0o130) + chr(0b1101111) + chr(0b1010011 + 0o21) + '\x65')(chr(117) + '\164' + chr(0b1100011 + 0o3) + chr(45) + chr(56)))(vhXbYptxZ3Pz): RGI3k8bAy4QR = oVre8I6UXc3b._instances_from_cache_file(vhXbYptxZ3Pz) else: RGI3k8bAy4QR = oVre8I6UXc3b._read(Ti9e_bxaCVyu) if not PlSM16l2KDPD(RGI3k8bAy4QR, YyaZ4tpXu4lf): RGI3k8bAy4QR = [SsX6bRqJdu1L for SsX6bRqJdu1L in l5DR0A5LiDJi.tqdm(RGI3k8bAy4QR)] if not RGI3k8bAy4QR: raise h0iXqtiKVeKg(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b"\xa1\x87o(\xb9\x18\xe7\x90\x1f#\xce\t'7N\x10Q\xbb\xb3\xdb\xc6\xec\xab~P\xb7\xe2\x13\x88\x933d\x80.\xb9\xc5`H\xfe\xc0\x83\x8d? \xa3\x03\xb3\x8a\x0cn\x8b3t`_\nQ\xbb\xb1\xdf\xd3\xe0\xab{M\xaa\xfdV\x9f\x8fi"), '\144' + '\x65' + '\143' + '\x6f' + '\x64' + chr(4658 - 4557))('\165' + chr(13069 - 12953) + chr(0b1100110) + chr(45) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\xdc=.\x9f\n\xc0\xc2!0\xce\x10'), chr(0b1100100) + '\145' + '\143' + '\x6f' + '\x64' + '\x65')(chr(0b1011 + 0o152) + '\164' + chr(0b0 + 0o146) + chr(0b11100 + 0o21) + '\x38'))(Ti9e_bxaCVyu)) if vhXbYptxZ3Pz and (not xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8a\x90&2\xa3\x18'), chr(100) + chr(440 - 339) + '\143' + chr(111) + chr(0b1100100) + chr(0b1100101))(chr(0b1110101) + chr(0b1110100) + '\146' + chr(0b1011 + 0o42) + chr(0b111000)))(vhXbYptxZ3Pz)): xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbc\xdf\x079\xa2\x08\xf4\xc6\x1b,\xf1\x11'), chr(1813 - 1713) + '\x65' + chr(0b101011 + 0o70) + chr(7785 - 7674) + chr(100) + '\x65')('\x75' + '\164' + '\146' + '\055' + '\x38'))(f'Caching instances to {vhXbYptxZ3Pz}') with _fwkIVCGgtAN(vhXbYptxZ3Pz, xafqLlk3kkUe(SXOLrMavuUCe(b'\x98'), chr(0b1000000 + 0o44) + chr(9640 - 9539) + chr(0b1011001 + 0o12) + chr(0b1010100 + 0o33) + chr(0b1100100) + chr(0b110001 + 0o64))(chr(12167 - 12050) + chr(0b1110100) + chr(7121 - 7019) + chr(0b11010 + 0o23) + chr(0b1000 + 0o60))) as j1lPDdxcDbRB: for SsX6bRqJdu1L in xafqLlk3kkUe(l5DR0A5LiDJi, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9b\x99+,'), '\144' + chr(0b1100101) + chr(0b1011000 + 0o13) + '\157' + '\144' + chr(0b1100101))(chr(117) + chr(0b1011 + 0o151) + chr(6884 - 6782) + '\055' + chr(0b101110 + 0o12)))(RGI3k8bAy4QR): xafqLlk3kkUe(j1lPDdxcDbRB, xafqLlk3kkUe(SXOLrMavuUCe(b'\x98\x9a&5\xb2'), chr(0b1100100) + '\145' + chr(0b1100011) + '\x6f' + '\x64' + '\x65')(chr(117) + '\164' + chr(0b1000101 + 0o41) + chr(1392 - 1347) + chr(0b111000)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9c\x8d=(\xb6\x07\xfa\x8b\x14\x1f\xc2\x14t4J\x0cW\xfe'), chr(0b101110 + 0o66) + chr(502 - 401) + chr(0b1010110 + 0o15) + '\157' + chr(0b111100 + 0o50) + chr(4336 - 4235))(chr(7890 - 7773) + chr(0b1110100) + chr(102) + chr(0b10100 + 0o31) + chr(2673 - 2617)))(SsX6bRqJdu1L) + xafqLlk3kkUe(SXOLrMavuUCe(b'\xe5'), chr(100) + chr(3909 - 3808) + chr(0b100000 + 0o103) + chr(111) + '\x64' + chr(0b100001 + 0o104))('\x75' + chr(116) + '\x66' + chr(45) + '\x38')) return RGI3k8bAy4QR
allenai/allennlp
allennlp/training/checkpointer.py
Checkpointer.restore_checkpoint
def restore_checkpoint(self) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ Restores a model from a serialization_dir to the last saved checkpoint. This includes a training state (typically consisting of an epoch count and optimizer state), which is serialized separately from model parameters. This function should only be used to continue training - if you wish to load a model for inference/load parts of a model into a new computation graph, you should use the native Pytorch functions: `` model.load_state_dict(torch.load("/path/to/model/weights.th"))`` If ``self._serialization_dir`` does not exist or does not contain any checkpointed weights, this function will do nothing and return empty dicts. Returns ------- states: Tuple[Dict[str, Any], Dict[str, Any]] The model state and the training state. """ latest_checkpoint = self.find_latest_checkpoint() if latest_checkpoint is None: # No checkpoint to restore, start at 0 return {}, {} model_path, training_state_path = latest_checkpoint # Load the parameters onto CPU, then transfer to GPU. # This avoids potential OOM on GPU for large models that # load parameters onto GPU then make a new GPU copy into the parameter # buffer. The GPU transfer happens implicitly in load_state_dict. model_state = torch.load(model_path, map_location=nn_util.device_mapping(-1)) training_state = torch.load(training_state_path, map_location=nn_util.device_mapping(-1)) return model_state, training_state
python
def restore_checkpoint(self) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ Restores a model from a serialization_dir to the last saved checkpoint. This includes a training state (typically consisting of an epoch count and optimizer state), which is serialized separately from model parameters. This function should only be used to continue training - if you wish to load a model for inference/load parts of a model into a new computation graph, you should use the native Pytorch functions: `` model.load_state_dict(torch.load("/path/to/model/weights.th"))`` If ``self._serialization_dir`` does not exist or does not contain any checkpointed weights, this function will do nothing and return empty dicts. Returns ------- states: Tuple[Dict[str, Any], Dict[str, Any]] The model state and the training state. """ latest_checkpoint = self.find_latest_checkpoint() if latest_checkpoint is None: # No checkpoint to restore, start at 0 return {}, {} model_path, training_state_path = latest_checkpoint # Load the parameters onto CPU, then transfer to GPU. # This avoids potential OOM on GPU for large models that # load parameters onto GPU then make a new GPU copy into the parameter # buffer. The GPU transfer happens implicitly in load_state_dict. model_state = torch.load(model_path, map_location=nn_util.device_mapping(-1)) training_state = torch.load(training_state_path, map_location=nn_util.device_mapping(-1)) return model_state, training_state
[ "def", "restore_checkpoint", "(", "self", ")", "->", "Tuple", "[", "Dict", "[", "str", ",", "Any", "]", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "latest_checkpoint", "=", "self", ".", "find_latest_checkpoint", "(", ")", "if", "latest_checkpoint", "is", "None", ":", "# No checkpoint to restore, start at 0", "return", "{", "}", ",", "{", "}", "model_path", ",", "training_state_path", "=", "latest_checkpoint", "# Load the parameters onto CPU, then transfer to GPU.", "# This avoids potential OOM on GPU for large models that", "# load parameters onto GPU then make a new GPU copy into the parameter", "# buffer. The GPU transfer happens implicitly in load_state_dict.", "model_state", "=", "torch", ".", "load", "(", "model_path", ",", "map_location", "=", "nn_util", ".", "device_mapping", "(", "-", "1", ")", ")", "training_state", "=", "torch", ".", "load", "(", "training_state_path", ",", "map_location", "=", "nn_util", ".", "device_mapping", "(", "-", "1", ")", ")", "return", "model_state", ",", "training_state" ]
Restores a model from a serialization_dir to the last saved checkpoint. This includes a training state (typically consisting of an epoch count and optimizer state), which is serialized separately from model parameters. This function should only be used to continue training - if you wish to load a model for inference/load parts of a model into a new computation graph, you should use the native Pytorch functions: `` model.load_state_dict(torch.load("/path/to/model/weights.th"))`` If ``self._serialization_dir`` does not exist or does not contain any checkpointed weights, this function will do nothing and return empty dicts. Returns ------- states: Tuple[Dict[str, Any], Dict[str, Any]] The model state and the training state.
[ "Restores", "a", "model", "from", "a", "serialization_dir", "to", "the", "last", "saved", "checkpoint", ".", "This", "includes", "a", "training", "state", "(", "typically", "consisting", "of", "an", "epoch", "count", "and", "optimizer", "state", ")", "which", "is", "serialized", "separately", "from", "model", "parameters", ".", "This", "function", "should", "only", "be", "used", "to", "continue", "training", "-", "if", "you", "wish", "to", "load", "a", "model", "for", "inference", "/", "load", "parts", "of", "a", "model", "into", "a", "new", "computation", "graph", "you", "should", "use", "the", "native", "Pytorch", "functions", ":", "model", ".", "load_state_dict", "(", "torch", ".", "load", "(", "/", "path", "/", "to", "/", "model", "/", "weights", ".", "th", "))" ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/training/checkpointer.py#L114-L145
train
Restores a model from a serialization_dir to the last saved checkpoint.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPth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k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__ SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b100001 + 0o17) + '\157' + '\063' + '\x35' + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(1988 - 1940) + chr(0b1101111) + chr(0b10111 + 0o34) + '\x36', 0b1000), ehT0Px3KOsy9(chr(315 - 267) + chr(111) + '\x32' + chr(52) + chr(1369 - 1315), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + '\x31' + '\x36', 0o10), ehT0Px3KOsy9('\060' + chr(9483 - 9372) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(1959 - 1911) + '\157' + '\x31' + chr(468 - 417), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1011111 + 0o20) + chr(1878 - 1829) + chr(0b110101) + chr(0b11011 + 0o31), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b10001 + 0o46), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11000 + 0o32) + '\067' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(1174 - 1126) + chr(0b1101111) + chr(0b110010) + chr(0b110101) + chr(150 - 98), 0b1000), ehT0Px3KOsy9(chr(2277 - 2229) + chr(0b1101111) + '\x33' + chr(0b110001 + 0o5) + chr(0b1110 + 0o45), 0b1000), ehT0Px3KOsy9('\060' + chr(8903 - 8792) + chr(0b110001) + '\060' + chr(50), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(1382 - 1328), 30730 - 30722), ehT0Px3KOsy9(chr(656 - 608) + chr(0b1101111) + chr(0b110100) + chr(1284 - 1234), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b111 + 0o150) + '\062' + chr(0b110101) + chr(494 - 441), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\062' + '\063' + '\060', 0o10), ehT0Px3KOsy9(chr(1364 - 1316) + chr(0b10000 + 0o137) + chr(0b110001) + chr(1489 - 1438) + chr(0b11001 + 0o27), 0b1000), ehT0Px3KOsy9('\060' + chr(5049 - 4938) + chr(49) + chr(49) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(54) + chr(51), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + chr(2000 - 1950) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(0b10110 + 0o34), 54006 - 53998), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + '\x35' + chr(0b110101 + 0o2), 28094 - 28086), ehT0Px3KOsy9(chr(48) + chr(0b0 + 0o157) + '\061' + chr(1755 - 1701) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(1162 - 1114) + '\x6f' + chr(50) + chr(0b110110) + '\x33', 64161 - 64153), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(916 - 865) + chr(51) + chr(51), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(1050 - 1000) + chr(1102 - 1054) + chr(1967 - 1913), 0b1000), ehT0Px3KOsy9(chr(578 - 530) + chr(0b1010111 + 0o30) + chr(1342 - 1288) + chr(864 - 813), 8), ehT0Px3KOsy9(chr(48) + chr(2157 - 2046) + chr(52) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b1001 + 0o50) + chr(0b11101 + 0o27), 0o10), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(0b101101 + 0o102) + '\063' + '\x36' + chr(53), 0o10), ehT0Px3KOsy9(chr(349 - 301) + '\157' + '\x36' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + chr(0b110100) + chr(0b100 + 0o55), 36929 - 36921), ehT0Px3KOsy9('\060' + chr(111) + chr(53) + '\064', 0b1000), ehT0Px3KOsy9(chr(1305 - 1257) + chr(0b1101111) + chr(0b110001) + '\x33' + chr(0b101000 + 0o16), 42599 - 42591), ehT0Px3KOsy9(chr(1154 - 1106) + '\157' + chr(2428 - 2375) + '\x33', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + chr(49), 3920 - 3912), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + chr(48) + '\x31', 3754 - 3746), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(111) + '\065' + '\x32', 0o10), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1010100 + 0o33) + chr(50) + chr(0b110110) + '\066', 56805 - 56797)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(6026 - 5915) + chr(0b110101) + '\060', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)]) def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh): try: return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc5'), chr(0b1001110 + 0o26) + chr(0b11100 + 0o111) + chr(0b1010 + 0o131) + chr(0b1101111) + chr(0b100001 + 0o103) + chr(0b111010 + 0o53))(chr(0b1000010 + 0o63) + chr(0b1110100) + '\146' + '\055' + chr(0b1110 + 0o52)) + _CF03Rifpmdh) except yROw0HWBk0Qc: return jFWsnpHpAUWz(RqocVGOryNPv) def ZFf21s8bRjdm(oVre8I6UXc3b) -> MRK8Uzg2En3D[zBnV56fc6HrA[M8_cKLkHVB2V, R71nhlWr3XQi], zBnV56fc6HrA[M8_cKLkHVB2V, R71nhlWr3XQi]]: jDTFRvbCTK6i = oVre8I6UXc3b.find_latest_checkpoint() if jDTFRvbCTK6i is None: return ({}, {}) (AlxtQPEw7WKZ, ky0a_qkhy_dN) = jDTFRvbCTK6i YhrkiBBPzain = cEkFpYktkSeK.mxtdQMeiwJZJ(AlxtQPEw7WKZ, map_location=mJ5lccTj6Yky.device_mapping(-ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31', 38565 - 38557))) c1o8IdGST3HC = cEkFpYktkSeK.mxtdQMeiwJZJ(ky0a_qkhy_dN, map_location=mJ5lccTj6Yky.device_mapping(-ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49), 8))) return (YhrkiBBPzain, c1o8IdGST3HC)