Beispiel #1
0
 def __transform(self, section):
     clazzes = adapter.classes(section)
     if clazzes:
         ret_val = []
         for clazz in clazzes:
             ret_val.append(len(clazz['fields']))
         return ret_val
     else:
         return [0]
 def __transform(self, section):
     clazzes = adapter.classes(section)
     if clazzes:
         ret_val = []
         for clazz in clazzes:
             if ((len(clazz['methods']) == 0)
                     and (len(clazz['fields']) == 0)):
                 ret_val.append(1)
             else:
                 ret_val.append(0)
         return ret_val
     else:
         return [0]
 def __transform(self, section):
     stat = get_stat_function(self.stat)
     clazzes = adapter.classes(section)
     if clazzes:
         ret_val = []
         for clazz in clazzes:
             clazz_values = []
             for field in clazz['fields']:
                 clazz_values.append(len(field['name']))
             if not clazz_values:
                 clazz_values = [0]  # if a class does not contain any field
             ret_val.append(stat(clazz_values))
         return ret_val
     else:
         return [0]
Beispiel #4
0
    if score == "RMSE":
        return make_scorer(mse, greater_is_better=False)
    elif score == 'PC':
        return make_scorer(pearson, greater_is_better=True)
    else:
        raise ValueError('Scoring {} is not supported!'.format(score))


# FEATURES = powerset(FEATURES)
FEATURES = [FEATURES]
X, Y = load(corpus_path=os.path.join(BASEPATH, 'data/training'),
            labels=DIMENSIONS)
for x in X:
    sections = extract_sections(x)
    for section in sections:
        classes(section)

recognizer = RECOGNIZER[0]
result = {'recognizer_name': recognizer[0]}

number_features = args.nfeatures

output_filename = os.path.join(
    BASEPATH, 'result_{}_{}_{}_{}.json'.format(DIMENSIONS[0], SCORE,
                                               recognizer[0], number_features))

# print(output_filename)
with open(output_filename, 'w') as outfile:
    outfile.write('Job started')

print '***Number of features: {}'.format(number_features)
Beispiel #5
0
 def __transform(self, section):
     clazzes = adapter.classes(section)
     if clazzes:
         return len(clazzes)
     else:
         return 0