当前位置: 首页>>代码示例>>Python>>正文


Python A.print_results方法代码示例

本文整理汇总了Python中A.print_results方法的典型用法代码示例。如果您正苦于以下问题:Python A.print_results方法的具体用法?Python A.print_results怎么用?Python A.print_results使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在A的用法示例。


在下文中一共展示了A.print_results方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    results = {}

    total = len(train)
    counter = 1

    s = build_s(train, language)
    #s = {}

    # if language == 'English':
    #     tagger = set_tagger(language)
    # else:
    tagger = None
    #tagger = set_tagger(language)
    stemmer = set_stemmer(language)

    for lexelt in train:
        train_features, y_train = extract_features(train[lexelt], language, tagger, stemmer, s[lexelt])
        test_features, _ = extract_features(test[lexelt], language, tagger, stemmer, s[lexelt])

        X_train, X_test = vectorize(train_features,test_features)
        X_train_new, X_test_new = feature_selection(X_train, X_test,y_train, language)
        results[lexelt] = classify(X_train_new, X_test_new,y_train)

        print str(counter) + ' out of ' + str(total) + ' completed'
        counter += 1

    A.print_results(results, answer)
开发者ID:JFulgoni,项目名称:Natural-Language-Processing,代码行数:30,代码来源:B.py

示例2: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    results = {}
    if language == 'English':
        _POS_TAGGER = 'taggers/maxent_treebank_pos_tagger/english.pickle'
        tagger = load(_POS_TAGGER)
    elif language == 'Spanish':
        tagger = ut(cess_esp.tagged_sents())
    elif language == 'Catalan':
        tagger  = ut(cess_cat.tagged_sents())

    for lexelt in train:

        train_features, y_train = extract_features(train[lexelt],language,tagger)
        test_features, _ = extract_features(test[lexelt],language,tagger)

        X_train, X_test = vectorize(train_features,test_features)
        X_train_new, X_test_new = feature_selection(X_train, X_test,y_train)
        results[lexelt] = classify(X_train_new, X_test_new,y_train)
    """
    B1.c
    for lexelt in train:
        features = getBestWords(train[lexelt], 30)
        train_features = countFeature(features, train[lexelt])
        _, y_train = extract_features(train[lexelt], language)
        test_features = countFeature(features, test[lexelt])

        X_train, X_test = vectorize(train_features, test_features)
        results[lexelt] = classify(X_train, X_test, y_train)
    B1.c
    """
    A.print_results(results, answer)
开发者ID:Xochitlxie,项目名称:EECS595-NLP,代码行数:33,代码来源:B.py

示例3: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    results = {}

    for lexelt in train:

        train_features, y_train = extract_features(train[lexelt])
        test_features, _ = extract_features(test[lexelt])

        X_train, X_test = vectorize(train_features,test_features)
        X_train_new, X_test_new = feature_selection(X_train, X_test,y_train)
        results[lexelt] = classify(X_train_new, X_test_new,y_train)

    A.print_results(results, answer)
开发者ID:jpgard,项目名称:NLP,代码行数:15,代码来源:B.py

示例4: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    results = {}
    #calc_high_frequency_words(train)
    print 'Calling A'
    s = A.build_s(train)
    for lexelt in train:

        train_features, y_train = extract_features(train[lexelt],language,lexelt,s[lexelt])
        test_features, _ = extract_features(test[lexelt],language,lexelt,s[lexelt])

        X_train, X_test = vectorize(train_features,test_features)
        X_train_new, X_test_new = feature_selection(X_train, X_test,y_train,language)
        results[lexelt] = classify(X_train_new, X_test_new,y_train)
    A.print_results(results, answer)
    print 'ended'
开发者ID:vshetty2410,项目名称:COMS4705,代码行数:17,代码来源:B.py

示例5: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    results = {}
    l = len(train)
    for i, lexelt in enumerate(train):
        sys.stdout.write('\r{} / {} ({}%)'.format(i, l, int(float(i) / l * 100)))
        sys.stdout.flush()

        train_features, y_train = extract_features(train[lexelt], language)
        test_features, _ = extract_features(test[lexelt], language)

        X_train, X_test = vectorize(train_features,test_features)
        X_train_new, X_test_new = feature_selection(X_train, X_test,y_train)
        results[lexelt] = classify(X_train_new, X_test_new,y_train)

    A.print_results(results, answer)
开发者ID:behappycc,项目名称:nlp-coursera,代码行数:17,代码来源:B.py

示例6: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    results = {}

    if language == 'English': language = 'en'
    if language == 'Spanish': language = 'spa'
    if language == 'Catalan': language = 'cat'

    for lexelt in train:
        rel_dict = relevance(train[lexelt])
        train_features, y_train = extract_features(train[lexelt], language, rel_dict=rel_dict)
        test_features, _ = extract_features(test[lexelt], language, rel_dict=rel_dict)

        X_train, X_test = vectorize(train_features,test_features)
        X_train_new, X_test_new = feature_selection(X_train, X_test,y_train)
        results[lexelt] = classify(X_train_new, X_test_new,y_train)

    A.print_results(results, answer)
开发者ID:mothaibatacungmua,项目名称:AI-course,代码行数:19,代码来源:B.py

示例7: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    results = {}

    tagger = get_tagger(language)
    stemmer = get_stemmer(language)
    s = build_s(train, stemmer)

    for lexelt in train:

        words_count, senses_count = get_relavence_info(train[lexelt], stemmer)
        train_features, y_train = extract_features(train[lexelt], tagger, words_count, senses_count, stemmer, s[lexelt])
        test_features, _ = extract_features(test[lexelt], tagger, words_count, senses_count, stemmer, s[lexelt])

        X_train, X_test = vectorize(train_features, test_features)
        X_train_new, X_test_new, y_train_new, ids_test = feature_selection(X_train, X_test, y_train)
        results[lexelt] = classify(X_train_new, X_test_new, y_train_new, ids_test)

    A.print_results(results, answer)
开发者ID:keyu-lai,项目名称:NLP,代码行数:20,代码来源:B.py

示例8: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    results = {}
    s = build_s(train, language)

    for lexelt in train:

        feas_set = build_feas_set(train[lexelt], language)
        #feas_set = None
        train_features, y_train = extract_features(train[lexelt], language, feas_set, s[lexelt])
        test_features, _ = extract_features(test[lexelt], language, feas_set, s[lexelt])
    #    print train_features
        X_train, X_test = vectorize(train_features,test_features)
    #    print X_train
    #    X_train_new, X_test_new = feature_selection(X_train, X_test,y_train)
    #    results[lexelt] = classify(X_train_new, X_test_new,y_train)
        results[lexelt] = classify(X_train, X_test,y_train)

    A.print_results(results, answer)
开发者ID:qychen,项目名称:NLP_Projects_COMS4705_Columbia,代码行数:20,代码来源:B_best.py

示例9: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    print 'running B for language:', language
    results = {}
    if language.lower() in ['english', 'spanish']:
        extract_features.stemmer = nltk.SnowballStemmer(language.lower())

    for lexelt in train:

        train_features, y_train = extract_features(train[lexelt], language=language)
        test_features, _ = extract_features(test[lexelt], language=language)

        X_train, X_test = vectorize(train_features,test_features)
        if language.lower() in ['english', 'spanish']:
            X_train_new, X_test_new = feature_selection(X_train, X_test,y_train)
        else:
            X_train_new = X_train
            X_test_new = X_test
        results[lexelt] = classify(X_train_new, X_test_new,y_train)

    A.print_results(results, answer)
开发者ID:Alexoner,项目名称:mooc,代码行数:22,代码来源:B.py

示例10: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    results = {}

    # tag_and_save(train, test, language)

    # load cached POS tags
    # print 'loading cached pos tags...'
    # train_name = language + '-train.p'
    # test_name = language + '-test.p'
    # train_pos_tags = pickle.load(open(train_name, 'rb'))
    # test_pos_tags = pickle.load(open(test_name, 'rb'))

    tagger = None
    if POS_WINDOW > 0 or POS_HEAD or FORCE_TAGGER_USE:
        tagger = UniversalTagger.EnglishTagger()
        if language is 'Spanish':
            tagger = UniversalTagger.SpanishTagger()

        if language is 'Catalan':
            tagger = UniversalTagger.CatalanTagger()

    stemmer = None
    if STEM:
        stemmer = PorterStemmer()

    for lexelt in train:
        relevance_key = None
        if USE_RELEVANCY_SCORES:
            relevance_key = top_relevant_words_from_data(train[lexelt])

        train_features, y_train = extract_features(train[lexelt], tagger, stemmer, relevance_key)
        test_features, _ = extract_features(test[lexelt], tagger, stemmer, relevance_key)

        X_train, X_test = vectorize(train_features,test_features)
        X_train_new, X_test_new = feature_selection(X_train, X_test,y_train)
        results[lexelt] = classify(X_train_new, X_test_new,y_train)

    A.print_results(results, answer)
开发者ID:williamFalcon,项目名称:NLP_HW3,代码行数:40,代码来源:B.py

示例11: run

# 需要导入模块: import A [as 别名]
# 或者: from A import print_results [as 别名]
def run(train, test, language, answer):
    global global_language
    global stop_words
    global punctuation_unicode
    global unigram_tagger
    global bigram_tagger
    global trigram_tagger
    global stemmer
    global window_size


    global_language = language

    if global_language == "english":
        window_size = 3
    elif global_language == "spanish":
        window_size = 2
    else:
        window_size = 3

    global_language = language.lower()
    
    if global_language == "english" or global_language == "spanish":
        stop_words = [word.lower() for word in stopwords.words(global_language)]
    else:
       stop_words =  [u'\ufeffa', u'abans', u'algun', u'alguna', u'algunes', u'alguns', u'altre', u'amb', u'ambd\xf3s', u'anar', u'ans', u'aquell', u'aquelles', u'aquells', u'aqu\xed', u'bastant', u'b\xe9', u'cada', u'com', u'consegueixo', u'conseguim', u'conseguir', u'consigueix', u'consigueixen', u'consigueixes', u'dalt', u'de', u'des de', u'dins', u'el', u'elles', u'ells', u'els', u'en', u'ens', u'entre', u'era', u'erem', u'eren', u'eres', u'es', u'\xe9s', u'\xe9ssent', u'est\xe0', u'estan', u'estat', u'estava', u'estem', u'esteu', u'estic', u'ets', u'fa', u'faig', u'fan', u'fas', u'fem', u'fer', u'feu', u'fi', u'haver', u'i', u'incl\xf2s', u'jo', u'la', u'les', u'llarg', u'llavors', u'mentre', u'meu', u'mode', u'molt', u'molts', u'nosaltres', u'o', u'on', u'per', u'per', u'per que', u'per\xf2', u'perqu\xe8', u'podem', u'poden', u'poder', u'podeu', u'potser', u'primer', u'puc', u'quan', u'quant', u'qui', u'sabem', u'saben', u'saber', u'sabeu', u'sap', u'saps', u'sense', u'ser', u'seu', u'seus', u'si', u'soc', u'solament', u'sols', u'som', u'sota', u'tamb\xe9', u'te', u'tene', u'tenim', u'tenir', u'teniu', u'teu', u'tinc', u'tot', u'\xfaltim', u'un', u'un', u'una', u'unes', u'uns', u'\xfas', u'va', u'vaig', u'van', u'vosaltres', u'']


    if global_language == "catalan":
        stemmer = SnowballStemmer("spanish")
    else:
        stemmer = SnowballStemmer(global_language)    
    
    #train the taggers here and keep the reference global

    if global_language == "english":

        _POS_TAGGER = 'taggers/maxent_treebank_pos_tagger/english.pickle'
        trigram_tagger = load(_POS_TAGGER)


    elif global_language == "spanish":
        train_sents = nltk.corpus.cess_esp.tagged_sents()
        unigram_tagger = nltk.UnigramTagger(train_sents)
        bigram_tagger = nltk.BigramTagger(train_sents, backoff = unigram_tagger)
        trigram_tagger = nltk.TrigramTagger(train_sents, backoff = bigram_tagger)

    else:
        train_sents = nltk.corpus.cess_cat.tagged_sents()
        unigram_tagger = nltk.UnigramTagger(train_sents)
        bigram_tagger = nltk.BigramTagger(train_sents, backoff = unigram_tagger)
        trigram_tagger = nltk.TrigramTagger(train_sents, backoff = bigram_tagger)

    #we have the taggers ready now. use them to extract the features!

    punctuation = list(string.punctuation)   
    punctuation_unicode = [unicode(punc) for punc in punctuation]
    punctuation_unicode.append(unicode("''")) 
    results = {}

    for lexelt in train:
        #print lexelt
        train_features, y_train = extract_features(train[lexelt])
        test_features, _ = extract_features(test[lexelt])

        X_train, X_test = vectorize(train_features,test_features)
        X_train_new, X_test_new = feature_selection(X_train, X_test,y_train)
        results[lexelt] = classify(X_train_new, X_test_new,y_train)

    A.print_results(results, answer)
开发者ID:ss91,项目名称:nlp,代码行数:72,代码来源:B.py


注:本文中的A.print_results方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。