def eval(inputJson, docType, docTopType): # inputArr = json.loads(inputJson.encode("ascii", "ignore").decode()) # 20180911 수직기준으로 가까운 엔트리라벨을 체크하는데 만약 거리가 80이 넘는것만 있을경우 unknown # 수직 수평 조회중 our share와 PAID(100%), OSL(100%) 잡히면 PAID(Our Share), OSL(Our Share)로 변경 # 엔트리라벨이 하나만 잡혔는데 PAID(100%), OSL(100%)일경우 y축 기준 200까지 위 x축기준 200까지를 조회 our share 가 있으면 Our share 로 변경 inputArr = getSidParsing(getSid(inputJson), docType) try: for inputItem in inputArr: if 'sid' in inputItem: colResult = findLabelDB(inputItem['mappingSid'], docType, docTopType) inputItem['colLbl'] = colResult[0] inputItem['colAccu'] = colResult[1] # 전 아이템 중 엔트리 라벨 추출 entryLabel = [] for inputItem in inputArr: if 'colLbl' in inputItem: if bUtil.selectLabelDefLabelType(inputItem['colLbl']) == 'T': entryLabel.append(inputItem) for label in entryLabel: if label['colLbl'] == 136 or label['colLbl'] == 137: label['colLbl'] = bUtil.selectLabelBehaviorDrug( label, entryLabel) if label['colLbl'] == 25: label['colLbl'] = bUtil.selectLabelAmountPaid( label, entryLabel) # 전 아이템 중 엔트리 추출 후 같은 열이나 같은 행에 엔트리 라벨 검색 for inputItem in inputArr: if inputItem['colLbl'] == 0: entLoc = inputItem['mappingSid'].split(",")[0:4] horizItem = 9999 vertItem = 9999 entryPlus = 0 for lblItem in entryLabel: lblLoc = lblItem['mappingSid'].split(",")[0:4] # 같은 문서 검사 if entLoc[0] == lblLoc[0]: # 같은 라인 검사 if boundaryCheck(entLoc[2], lblLoc[2]) and leftLabelCheck( entLoc, lblLoc): inputItem['entryLbl'] = lblItem['colLbl'] horizItem = lblItem['colLbl'] if priceCheck(entLoc[2], lblLoc[2]) and leftLabelCheck( entLoc, lblLoc): if lblItem['colLbl'] == 126 or lblItem[ 'colLbl'] == 145: inputItem['entryLbl'] = lblItem['colLbl'] # 20180911 수직기준으로 가까운 엔트리라벨을 체크하는데 만약 거리가 80이 넘는것만 있을경우 unknown if bUtil.checkVerticalEntry(entLoc, lblLoc): if lblItem['colLbl'] == 141: entryPlus = 25 elif lblItem['colLbl'] == 142: entryPlus = 50 elif lblItem['colLbl'] == 143: entryPlus = 75 elif lblItem['colLbl'] == 144: entryPlus = 100 if 'entryLbl' not in inputItem: inputItem['entryLbl'] = 999 inputItem['entryLbl'] = inputItem['entryLbl'] + entryPlus # for item in inputArr: # print(item) return inputArr except Exception as e: raise Exception( str({ 'code': 500, 'message': 'column mapping predict fail', 'error': str(e).replace("'", "").replace('"', '') }))
def eval(inputJson, docType): # inputArr = json.loads(inputJson.encode("ascii", "ignore").decode()) # 20180911 수직기준으로 가까운 엔트리라벨을 체크하는데 만약 거리가 80이 넘는것만 있을경우 unknown # 수직 수평 조회중 our share와 PAID(100%), OSL(100%) 잡히면 PAID(Our Share), OSL(Our Share)로 변경 # 엔트리라벨이 하나만 잡혔는데 PAID(100%), OSL(100%)일경우 y축 기준 200까지 위 x축기준 200까지를 조회 our share 가 있으면 Our share 로 변경 inputArr = bUtil.getSidParsing(bUtil.getSid(inputJson), docType) try: for inputItem in inputArr: if 'sid' in inputItem: inputItem['colLbl'] = findLabelDB(inputItem['mappingSid']) inputItem['colAccu'] = 0.99 inputItem['sid'] = inputItem['mappingSid'] del inputItem['mappingSid'] # column mapping에만 사용되는 가공 sid 제거 # 전 아이템 중 엔트리 라벨 추출 entryLabel = [] for inputItem in inputArr: if 'colLbl' in inputItem: if bUtil.getEntryLabelYN(inputItem['colLbl']) == 'Y': entryLabel.append(inputItem) # 전 아이템 중 엔트리 추출 후 같은 열이나 같은 행에 엔트리 라벨 검색 for inputItem in inputArr: if inputItem['colLbl'] == 37: entLoc = inputItem['sid'].split(",")[0:4] vertMin = 999999 horizItem = 9999 vertItem = 9999 for lblItem in entryLabel: lblLoc = lblItem['sid'].split(",")[0:4] # 같은 문서 검사 if entLoc[0] == lblLoc[0]: # 같은 라인 검사 if boundaryCheck(entLoc[2], lblLoc[2]): inputItem['entryLbl'] = entryLabelDB( lblItem['colLbl']) horizItem = entryLabelDB(lblItem['colLbl']) # 상위 해더 왼쪽 오른쪽 정렬 검사 # if boundaryCheck(entLoc[1], lblLoc[1]) or boundaryCheck(entLoc[3], lblLoc[3]): # inputItem['entryLbl'] = entryLabelDB(lblItem['colLbl']) # vertItem = entryLabelDB(lblItem['colLbl']) # vertColLbl = lblItem['colLbl'] # 20180911 수직기준으로 가까운 엔트리라벨을 체크하는데 만약 거리가 80이 넘는것만 있을경우 unknown if bUtil.checkVerticalEntry(entLoc, lblLoc): # 수직으로 같은 라인에 entryLabel이 여러개 일경우 가장 가까운 entryLabel 검색 if int(entLoc[2]) - int( lblLoc[2]) > 0 and vertMin > int( entLoc[2]) - int(lblLoc[2]): vertMin = int(entLoc[2]) - int(lblLoc[2]) inputItem['entryLbl'] = entryLabelDB( lblItem['colLbl']) vertItem = entryLabelDB(lblItem['colLbl']) # PAID : 100% 와 Our Share 같이 있을경우 PAID(Our Share) if bUtil.chekOurShareEntry(horizItem, vertItem): inputItem['entryLbl'] = entryLabelDB(6) # OSL : 100% 와 Our Share 같이 있을경우 OSL(Our Share) if bUtil.chekOurShareEntry(horizItem, vertItem): inputItem['entryLbl'] = entryLabelDB(8) # 엔트리라벨이 하나만 잡혔는데 PAID(100%), OSL(100%)일경우 y축 기준 200까지 위 x축기준 200까지를 조회 our share 가 있으면 Our share 로 변경 if 'entryLbl' in inputItem and ( int(inputItem['entryLbl']) == 0 or int(inputItem['entryLbl']) == 2): for shareItem in entryLabel: shareLoc = shareItem['sid'].split(",")[0:4] if int(shareItem['colLbl']) == 36 and ( abs(int(lblLoc[1]) - int(shareLoc[1])) < 200 and -200 < int(shareLoc[2]) - int(lblLoc[2]) < 0 and boundaryCheck( entLoc[2], lblLoc[2])): if int(inputItem['entryLbl']) == 0: inputItem['entryLbl'] = 1 elif int(inputItem['entryLbl']) == 2: inputItem['entryLbl'] = 3 if 'entryLbl' not in inputItem or int( inputItem['entryLbl']) == 30: inputItem['entryLbl'] = 31 # for item in inputArr: # print(item) return str(inputArr) except Exception as e: raise Exception( str({ 'code': 500, 'message': 'column mapping predict fail', 'error': str(e).replace("'", "").replace('"', '') }))
def eval(inputJson, docType): # inputArr = json.loads(inputJson.encode("ascii", "ignore").decode()) # 20180911 수직기준으로 가까운 엔트리라벨을 체크하는데 만약 거리가 80이 넘는것만 있을경우 unknown # 수직 수평 조회중 our share와 PAID(100%), OSL(100%) 잡히면 PAID(Our Share), OSL(Our Share)로 변경 # 엔트리라벨이 하나만 잡혔는데 PAID(100%), OSL(100%)일경우 y축 기준 200까지 위 x축기준 200까지를 조회 our share 가 있으면 Our share 로 변경 inputArr = getSidParsing(getSid(inputJson), docType) try: for inputItem in inputArr: if 'sid' in inputItem: colResult = findLabelDB(inputItem['mappingSid']) inputItem['colLbl'] = colResult[0] inputItem['colAccu'] = colResult[1] # Azure ml 컬럼 매핑 추출 params = {"data": json.dumps(inputArr), "type": "columnMapping"} response = requests.post(url='http://172.16.53.150:8888/ml/api', data=params) #response = requests.post(url='http://172.16.53.143:8888/ml/api', data=params) inputArr = response.json() # 전 아이템 중 엔트리 라벨 추출 entryLabel = [] for inputItem in inputArr: if 'colLbl' in inputItem: if bUtil.getEntryLabelYN(inputItem['colLbl']) == 'Y': entryLabel.append(inputItem) # 전 아이템 중 엔트리 추출 후 같은 열이나 같은 행에 엔트리 라벨 검색 for inputItem in inputArr: if inputItem['colLbl'] == 37: entLoc = inputItem['mappingSid'].split(",")[0:4] horizItem = 9999 vertItem = 9999 for lblItem in entryLabel: lblLoc = lblItem['mappingSid'].split(",")[0:4] # 같은 문서 검사 if entLoc[0] == lblLoc[0]: # 같은 라인 검사 if boundaryCheck(entLoc[2], lblLoc[2]): inputItem['entryLbl'] = entryLabelDB( lblItem['colLbl']) horizItem = entryLabelDB(lblItem['colLbl']) # 상위 해더 왼쪽 오른쪽 정렬 검사 # if boundaryCheck(entLoc[1], lblLoc[1]) or boundaryCheck(entLoc[3], lblLoc[3]): # inputItem['entryLbl'] = entryLabelDB(lblItem['colLbl']) # vertItem = entryLabelDB(lblItem['colLbl']) # vertColLbl = lblItem['colLbl'] # 20180911 수직기준으로 가까운 엔트리라벨을 체크하는데 만약 거리가 80이 넘는것만 있을경우 unknown if bUtil.checkVerticalEntry(entLoc, lblLoc): inputItem['entryLbl'] = entryLabelDB( lblItem['colLbl']) vertItem = entryLabelDB(lblItem['colLbl']) # PAID : 100% 와 Our Share 같이 있을경우 PAID(Our Share) if bUtil.chekOurShareEntry(horizItem, vertItem): inputItem['entryLbl'] = entryLabelDB(6) # OSL : 100% 와 Our Share 같이 있을경우 OSL(Our Share) if bUtil.chekOurShareEntry(horizItem, vertItem): inputItem['entryLbl'] = entryLabelDB(8) # 엔트리라벨이 하나만 잡혔는데 PAID(100%), OSL(100%)일경우 y축 기준 200까지 위 x축기준 200까지를 조회 our share 가 있으면 Our share 로 변경 if 'entryLbl' in inputItem and ( inputItem['entryLbl'] == 0 or inputItem['entryLbl'] == 2): for shareItem in entryLabel: shareLoc = shareItem['mappingSid'].split( ",")[0:4] if shareItem['colLbl'] == 36 and ( abs(int(lblLoc[1]) - int(shareLoc[1])) < 200 and -200 < int(lblLoc[2]) - int(shareLoc[2]) < 0): if int(inputItem['entryLbl']) == 0: inputItem['entryLbl'] = 1 elif int(inputItem['entryLbl']) == 2: inputItem['entryLbl'] = 3 # NOT ENTRY Check # if horizColLbl == 36 or vertColLbl == 36: # inputItem['entryLbl'] = 31 if 'entryLbl' not in inputItem or int( inputItem['entryLbl']) == 30: inputItem['entryLbl'] = 31 # for item in inputArr: # print(item) return inputArr except Exception as e: raise Exception( str({ 'code': 500, 'message': 'column mapping predict fail', 'error': str(e).replace("'", "").replace('"', '') }))