+
+def makesentidict(infile, language) :
+ #'/home/pierre/workspace/iramuteq/dev/langues/NRC/NRC-Emotion-Lexicon.csv'
+ with codecs.open(infile,'r', 'utf8') as f :
+ content = f.read()
+ content = [line.split('\t') for line in content.splitlines()]
+ titles = content.pop(0)
+ senti = ['Positive', 'Negative', 'Anger', 'Anticipation', 'Disgust', 'Fear', 'Joy', 'Sadness', 'Surprise', 'Trust']
+ sentid = {}
+ for sent in senti :
+ sentid[sent] = titles.index(sent)
+ frtitle = [val for val in titles if '(fr)' in val]
+ frid = titles.index(frtitle[0])
+ sentidict = [[line[frid].lower(), [line[sentid[sent]] for sent in senti]] for line in content]
+ pos = ['positive'] + [line[0] for line in sentidict if line[1][0] == '1']
+ neg = ['negative'] + [line[0] for line in sentidict if line[1][1] == '1']
+ anger = ['anger'] + [line[0] for line in sentidict if line[1][2] == '1']
+ anticipation = ['anticipation'] + [line[0] for line in sentidict if line[1][3] == '1']
+ disgust = ['disgust'] + [line[0] for line in sentidict if line[1][4] == '1']
+ fear = ['fear'] + [line[0] for line in sentidict if line[1][5] == '1']
+ joy = ['joy'] + [line[0] for line in sentidict if line[1][6] == '1']
+ sadness = ['sadness'] + [line[0] for line in sentidict if line[1][7] == '1']
+ surprise = ['surprise'] + [line[0] for line in sentidict if line[1][8] == '1']
+ trust = ['trust'] + [line[0] for line in sentidict if line[1][9] == '1']
+ with open('/tmp/tgenemo.csv', 'w') as f :
+ for val in [pos, neg, anger, anticipation, disgust, fear, joy, sadness, surprise, trust] :
+ f.write('\t'.join(val).encode('utf8') + '\n')
+
+def countsentfromprof(prof, encoding, sentidict) :
+ with codecs.open(prof, 'r', encoding) as f :
+ content = f.read()
+ content = [line.split(';') for line in content.splitlines()]
+ print content
+ content = [[line[0], [int(val) for val in line[1:]]] for line in content]
+ print content
+ content = dict(content)
+ print content
+
+def iratolexico(infile, outfile, encoding) :
+ with codecs.open(infile, 'r', encoding) as f :
+ for line in f :
+ if line.startswith(u'**** ') :
+ line = line.split()
+