I have code :
fileAspect = []
id_filename = -1
for filename in glob.glob(os.path.join(path, '*.dat')):
id_filename += 1
f = open(filename, 'r')
content = f.read()
soup = BeautifulSoup(content, 'html.parser')
all_paragraph = (soup.find_all('content'))
result_polarity = []
for all_sentences in all_paragraph:
sentences = nlp.parse(all_sentences.get_text())
for sentence in sentences['sentences']:
for words in sentence['dependencies']:
if(words[1]<>"ROOT"):
result_proccess = proccess1(myOntology, words) if(result_proccess):
result_polarity.append(words)
ini+=1
else:
out+=1
ont = ''
ont = myOntology
for idx_compare1 in range(len(ont)):
for idy in range(len(result_polarity)):
for idw in range(len(result_polarity[idy])):
if(result_polarity[idy][1]<>"ROOT" and idw<>0):
try:
closest = model.similarity(ont[idx_compare1][0], result_polarity[idy][idw])
if closest >= 0.1 :
valpolar = valuePol(result_polarity[idy][idw])
if(valpolar==1):
ont[idx_compare1][2]+=1
elif(valpolar==2):
ont[idx_compare1][3]+=1
tp += 1
break
except Exception as inst:
fn += 1
break
print "^^^^^^^^^^^^^"
print id_filename
print ont
fileAspect.append(ont)
print 'overall'
#print fileAspect
for aspek in fileAspect:
print aspek
print "---"
Why the result is replace previous data
sample i hope :
a = []
a.append('q')
a.append('w')
a.append('e')
print a
the result is : ['q','w','e']
but with my previous code i got : ['e','e','e']
so the problem is, when i append in variable array "fileAspect", it's didn't only append but also replace the previous code. i use simple code and it's fine, but when it's come in my code, i very confused.. more than 1 hour i try but..
Thanks, any help i'am very apreciated..