Fix imports and hardcoded values

This commit is contained in:
Patrick Jentsch 2019-11-27 10:18:15 +01:00
parent 1f95c6de46
commit 5411bd91bd

View File

@ -1,7 +1,7 @@
from CQiClient import CQiClient from .CQiClient import CQiClient
from CQi import CONST_FIELD_MATCH, CONST_FIELD_MATCHEND from .CQi import CONST_FIELD_MATCH, CONST_FIELD_MATCHEND
import re import re
# from app import logger # only works if imported into opaque web app from app import logger # only works if imported into opaque web app
class CQiWrapper(CQiClient): class CQiWrapper(CQiClient):
@ -162,11 +162,11 @@ class CQiWrapper(CQiClient):
# print(all_cpos) # print(all_cpos)
# Get all sentences IDs for all above collected cpos in all_cpos # Get all sentences IDs for all above collected cpos in all_cpos
s_ids = self.cl_cpos2struc('UTOPIEN.s', all_cpos) # CHANGE to CORPUS.s will always be like this in nopaque s_ids = self.cl_cpos2struc('CORPUS.s', all_cpos) # CHANGE to CORPUS.s will always be like this in nopaque
# Get all cpos for all sneteces boundries # Get all cpos for all sneteces boundries
s_lookup = {} s_lookup = {}
for s_id in set(s_ids): for s_id in set(s_ids):
s_start, s_end = self.cl_struc2cpos('UTOPIEN.s', s_id) # CHANGE to CORPUS.s will always be like this in nopaque s_start, s_end = self.cl_struc2cpos('CORPUS.s', s_id) # CHANGE to CORPUS.s will always be like this in nopaque
# print(s_start, s_end) # print(s_start, s_end)
s_cpos = range(s_start, s_end) s_cpos = range(s_start, s_end)
s_lookup.update({s_id: list(s_cpos)}) s_lookup.update({s_id: list(s_cpos)})
@ -200,11 +200,11 @@ class CQiWrapper(CQiClient):
tmp_dict = {} tmp_dict = {}
for struct_attr_key in self.attr_strings['struct_attrs'].keys(): for struct_attr_key in self.attr_strings['struct_attrs'].keys():
check = self.attr_strings['struct_attrs'][struct_attr_key] check = self.attr_strings['struct_attrs'][struct_attr_key]
if check == 'UTOPIEN.s': if check == 'CORPUS.s':
struct_ids = self.cl_cpos2struc(check, all_cpos) struct_ids = self.cl_cpos2struc(check, all_cpos)
for id in struct_ids: for id in struct_ids:
tmp_s_info.append({struct_attr_key: id}) tmp_s_info.append({struct_attr_key: id})
elif check == 'UTOPIEN.entry': elif check == 'CORPUS.text':
struct_ids = self.cl_cpos2struc(check, all_cpos) struct_ids = self.cl_cpos2struc(check, all_cpos)
for id in struct_ids: for id in struct_ids:
tmp_text_info.append({struct_attr_key: id}) tmp_text_info.append({struct_attr_key: id})