本文整理匯總了Python中philologic.OHCOVector.Record.attrib[column]方法的典型用法代碼示例。如果您正苦於以下問題:Python Record.attrib[column]方法的具體用法?Python Record.attrib[column]怎麽用?Python Record.attrib[column]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類philologic.OHCOVector.Record
的用法示例。
在下文中一共展示了Record.attrib[column]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: normalize_these_columns
# 需要導入模塊: from philologic.OHCOVector import Record [as 別名]
# 或者: from philologic.OHCOVector.Record import attrib[column] [as 別名]
def normalize_these_columns(loader_obj,text):
current_values = {}
tmp_file = open(text["sortedtoms"] + ".tmp","w")
for column in columns:
current_values[column] = ""
for line in open(text["sortedtoms"]):
type, word, id, attrib = line.split('\t')
id = id.split()
record = Record(type, word, id)
record.attrib = eval(attrib)
if type == "div1":
for column in columns:
if column in record.attrib:
current_values[column] = record.attrib[column]
else:
current_values[column] = ""
elif type == "div2":
for column in columns:
if column in record.attrib:
current_values[column] = record.attrib[column]
elif type == "div3":
for column in columns:
if column not in record.attrib:
record.attrib[column] = current_values[column]
print >> tmp_file, record
tmp_file.close()
os.remove(text["sortedtoms"])
os.rename(text["sortedtoms"] + ".tmp",text["sortedtoms"])