コード例 #1
0
def loading_reg_ftr(list_line_, command):
    if command == 'sgforums':
        path_ = 'D:/Project/Transportation_SMU-NEC_collaboration/Data/sgforums/20152207_singaporebuses_all_posts/labeling_CRF/crf_features/features'
    elif command == 'twitter':
        path_ = 'D:/Project/Transportation_SMU-NEC_collaboration/Data/twitter/labeling_CRF/crf_features/features_rmLink'
    elif command == 'facebook':
        path_ = 'D:/Project/Transportation_SMU-NEC_collaboration/Data/facebook/BusNews/labeling_CRF/crf_features/features'
    else:
        print 'You need to give the correct command'
        quit()

    name_svc = 'ftr_reg_svc.csv'
    name_road = 'ftr_reg_match_road.csv'
    name_busstop = 'ftr_reg_match_busstop.csv'

    list_svc = convert_label_CRF(convert_list_CRF(load_file(path_, name_svc)), 'svc')
    list_road = convert_label_CRF(convert_list_CRF(load_file(path_, name_road)), 'road')
    list_busstop = convert_label_CRF(convert_list_CRF(load_file(path_, name_busstop)), 'busstop')
    CRF_F1_reg(list_line_, list_svc, list_road, list_busstop)
コード例 #2
0
    name_svc = 'ftr_reg_svc.csv'
    name_road = 'ftr_reg_match_road.csv'
    name_busstop = 'ftr_reg_match_busstop.csv'

    list_svc = convert_label_CRF(convert_list_CRF(load_file(path_, name_svc)), 'svc')
    list_road = convert_label_CRF(convert_list_CRF(load_file(path_, name_road)), 'road')
    list_busstop = convert_label_CRF(convert_list_CRF(load_file(path_, name_busstop)), 'busstop')
    CRF_F1_reg(list_line_, list_svc, list_road, list_busstop)


if __name__ == '__main__':
    # Calculate the F1 of regular expression
    # SGFORUMS
    # path = 'D:/Project/Transportation_SMU-NEC_collaboration/Data/sgforums/20152207_singaporebuses_all_posts/labeling_CRF'
    # name_ = 'Label_all_crf.txt'
    # list_line = convert_list_CRF(load_target_label(load_file(path, name_)))
    # loading_reg_ftr(list_line, command='sgforums')

    # TWITTER
    # path_ = 'D:/Project/Transportation_SMU-NEC_collaboration/Data/twitter/labeling_CRF'
    # name_ = 'labeling_all.txt'
    # list_line = convert_list_CRF(load_target_label(filterTxt_CRF(load_file(path_, name_), command='removeLink')))
    # loading_reg_ftr(list_line, command='twitter')

    # FACEBOOK
    path_ = 'D:/Project/Transportation_SMU-NEC_collaboration/Data/facebook/BusNews/labeling_CRF'
    name_ = 'label.txt'
    list_line = convert_list_CRF(load_target_label(filterTxt_CRF(load_file(path_, name_), command='removePunc')))
    loading_reg_ftr(list_line, command='facebook')