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


Python Output.generate_html方法代码示例

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


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

示例1: creatingLexiconEntry_for_singleURI

# 需要导入模块: import Output [as 别名]
# 或者: from Output import generate_html [as 别名]

#.........这里部分代码省略.........
        if sparql.askObjectProperty(uri) == True:
            print "Object property given"
            term_list = createTermsForObjectProperty(PropertyEntities,anchor_index)
            print ("number of terms",len(term_list))
            Lookup.lookupSortAndParse(term_list,index,live_index,flag,uri)
    
        else:
            #here add function for DataProperty
            print "Datatype property given"
            term_list = createTermsForDataTypeProperty(uri,PropertyEntities,anchor_index)
            print ("number of terms",len(term_list))
            Lookup.lookupSortAndParse(term_list,index,live_index,flag,uri)
        


    x_y_array = live_index.searchForXY(uri)
    print "Number of entity pairs returned from the index:"+str(len(x_y_array))
    for entry1 in x_y_array:
        x = entry1[0]
        y = entry1[1]

        for parsed_sentence in live_index.searchXYPair(x,y):
            #only uses x/y/sentence combination once!
            try:
                sentence = parsed_sentence
#                 s_t = ""
#                 for item in sentence:
#                     s_t += item.__return_as_string__()+"  "
#                 print (x,y,s_t)
                total_number_sentence+=1
                used_sentence+=1       
                try:
                    
                    try:
                        pattern = PatternFinder.find_pattern_between_x_and_y(x,y,sentence)
                        print ("pattern",pattern)
                    except:
#                        print "Unexpected error in finding pattern:", sys.exc_info()[0]
                        #TODO: Fix exceptions.AttributeError'> in pattern generation!!!!!!!
                        pattern = None
                        

                    if pattern != None:
                        if pattern in hm_res_sentences:
                            string = hm_res_sentences[pattern]
                            string += "x="+x+" y="+y+"   "+IndexUtils.reverse_sentence_wrapper(sentence)+"\n\n"
                            hm_res_sentences[pattern] = string
                        else:
                            string = "x="+x+" y="+y+"   "+IndexUtils.reverse_sentence_wrapper(sentence)+"\n\n"
                            hm_res_sentences[pattern] = string
                except:
                    pattern = None
                    
                if pattern != None:
                    sentence_for_rules+=1  
                    if pattern in hm:
                        hm[pattern]=int(hm[pattern])+1
                        hm_used[pattern]=sentence
                    else:
                        hm[pattern]=1
                else:
                    pass
                    
                    
            except Exception:
                print "Unexpected error:", sys.exc_info()[0]
                print "error in creatingLexiconEntry_for_singleURI in lookup or some other function \n\n"

    
    return_string = uri+";"+str(total_number_sentence)+";"+str(len(hm))+"\n"

    pattern_once = 0
    
    hm , overall_pattern_numer = Output.createPatternFile(uri, path, name, hm)
    
    
    print "Created Pattern File"
    lexico_array, tmp_pattern_once, patterns_without_entry , mapping_pattern_entry_list = PatternUtil.create_lexico_array(hm,uri,1,en_de_lexicon)
    pattern_once += tmp_pattern_once    
    
    lemonEntriesHm = {}
    for item in lexico_array:
#         item[2] == value
        lemonEntriesHm[item[0]]=item[2]


    Output.generate_html(mapping_pattern_entry_list,hm_res_sentences,lemonEntriesHm,path,name)
    
    Output.pattern_error(patterns_without_entry,path,name)


    web = ""
    
    #print "Number of used sentences: "+str(len(hm_res_sentences))
    print "created html side"
    print ("total_number_sentence used:",total_number_sentence)
    hm.clear()
    
    #return web, lemonEntriesHm ,return_string
    return web, lemonEntriesHm , total_number_sentence
开发者ID:swalter2,项目名称:knowledgeLexicalisation,代码行数:104,代码来源:DependencyApproach.py


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