Ejemplo n.º 1
0
 def procesar(self, file, type):
     if type == 1:
         comentarios = []
         obj = Reader(file, 1)
         for i in obj.read():
             for j in i:
                 proc = TextCleaner(j[0])
                 value = [proc.get_processed_comment(), j[2]]
                 if value[0] != "None!":
                     comentarios.append(value)
         return comentarios
     else:
         obj = Reader(file, 4)
         comentarios = []
         for i in obj.read():
             proc = TextCleaner(i[0])
             value = [proc.get_processed_comment(), i[1]]
             if value[0] != "None!":
                 comentarios.append(value)
         return comentarios
Ejemplo n.º 2
0
        y_true = []
        y_predicted = []
        for i in sentences:
            obj = Unsupervised(i[0])
            result = obj.classify()
            y_true.append(i[1])
            y_predicted.append(result)
            print i[0] + " " + i[1] + " " + result

        print classification_report(y_true, y_predicted)


if __name__ == "__main__":

    obj = Manager()
    reader = Reader("Corpus/edu.xml", 5)
    sentences = reader.read()

    obj.test_only_sentiments(sentences)

    # obj.trainClassifiers(corpusTrain1, 1)
    # obj.trainClassifiers(corpusTrain2, 1)
    # obj.trainClassifiers(corpusFinal, 1)  # Para entrenar los clasificadores España
    # obj.trainClassifiers(corpusPeruvianTrain, 2) # Para entrenar de Peru

    # pruebas
    """
    actores = {}
    actores["Barcelona"] = 3
    actores["Madrid"] = 65