Beispiel #1
0
def testall(directory, pred_file=None, label_file=None, out_path=None):
    folders = os.listdir(directory)
    networks = []
    for folder in folders:
        if os.path.isfile(directory+folder+"/network.cfg") and os.path.exists(directory+folder+"/results"):
            networks.append(folder)
    
    config_file = directory+networks[0]+"/network.cfg"
    config = ConfigParser.ConfigParser()
    config.read(config_file)
    
    test_data = LoadData(directory = config.get('Testing Data', 'folders').split(','), 
                         data_file_name = config.get('Testing Data', 'data_file'),
                         label_file_name = config.get('Testing Data', 'label_file'),
                         seg_file_name = config.get('Testing Data', 'seg_file'))
    
    res = Analyzer(raw = test_data.get_data()[0], 
                   target = test_data.get_labels()[0])
                   
    for net in networks:
        config_file = directory+net+"/network.cfg"
        config = ConfigParser.ConfigParser()
        config.read(config_file)
        
        res.add_results(results_folder = config.get('General','directory'),
                        name = net,
                        prediction_file = config.get('Testing', 'prediction_file')+'_0', 
                        learning_curve_file = 'learning_curve')
                           
        res.analyze(-1, pred_file=pred_file, label_file=label_file, out_path=out_path)
        
    return res
Beispiel #2
0
 def test_analyze_judgement_weight(self):
     """
     Testing the value order
     of arbitrary tweets
     """
     ana = Analyzer()
     assert ana.analyze("i am so happy, great day :D") > ana.analyze("i am so happy :D")
     assert ana.analyze("so sad, feeling depressed :'(") < ana.analyze("so depressed :'(")
Beispiel #3
0
 def test_analyze_empty(self):
     """
     Testing empty tweets
     and tweets including words not
     in the dictionary
     """
     ana = Analyzer()
     assert ana.analyze("") == 0.5
     assert ana.analyze("hzoehfsdl") == 0.5
Beispiel #4
0
 def test_analyze_empty(self):
     """
     Testing empty tweets
     and tweets including words not
     in the dictionary
     """
     ana = Analyzer()
     assert ana.analyze("") == 0.5
     assert ana.analyze("hzoehfsdl") == 0.5
Beispiel #5
0
 def test_analyze_judgement(self):
     """
     Testing the proper judgement of the sentiment analysis:
     * positive and negative
     * best and worse tweet values
     """
     ana = Analyzer()
     assert ana.analyze(":)") > 0.5 and ana.analyze(":'(") < 0.5
     assert ana.analyze("yahoo yahoo yahoo") == 1.0
     assert ana.analyze("zzz zzz zzz zzz zzz") == 0.0
Beispiel #6
0
 def test_analyze_judgement_weight(self):
     """
     Testing the value order
     of arbitrary tweets
     """
     ana = Analyzer()
     assert ana.analyze("i am so happy, great day :D") > ana.analyze(
         "i am so happy :D")
     assert ana.analyze("so sad, feeling depressed :'(") < ana.analyze(
         "so depressed :'(")
Beispiel #7
0
 def test_analyze_judgement(self):
     """
     Testing the proper judgement of the sentiment analysis:
     * positive and negative
     * best and worse tweet values
     """
     ana = Analyzer()
     assert ana.analyze(":)") > 0.5 and ana.analyze(":'(") < 0.5
     assert ana.analyze("yahoo yahoo yahoo") == 1.0
     assert ana.analyze("zzz zzz zzz zzz zzz") == 0.0
Beispiel #8
0
 def test_analyze_bounds(self):
     """
     Testing the bounds of the tweets values
     """
     ana = Analyzer()
     assert ana.analyze("this is a test neutral tweet") <= 1.0
     assert ana.analyze("this is a test neutral tweet") >= 0.0
Beispiel #9
0
 def test_analyze_bounds(self):
     """
     Testing the bounds of the tweets values
     """
     ana = Analyzer()
     assert ana.analyze("this is a test neutral tweet") <= 1.0
     assert ana.analyze("this is a test neutral tweet") >= 0.0
Beispiel #10
0
def testprediction(config_file, pred_file=None, label_file=None, out_path=None):     
    config = ConfigParser.ConfigParser()
    config.read(config_file)
    
    test_data = LoadData(directory = config.get('Testing Data', 'folders').split(','), 
                         data_file_name = config.get('Testing Data', 'data_file'),
                         label_file_name = config.get('Testing Data', 'label_file'), 
                         seg_file_name = config.get('Testing Data', 'seg_file'))
    
    res = Analyzer(raw = test_data.get_data()[0],
                   target = test_data.get_labels()[0])
    res.add_results(results_folder = config.get('General','directory'),
                    name = config_file.split('/')[-3],
                    prediction_file = config.get('Testing', 'prediction_file')+'_0', 
                    learning_curve_file = 'learning_curve')           
    res.analyze(-1, pred_file=pred_file, label_file=label_file, out_path=out_path)
    
    return res