简体   繁体   English

如何突出显示搜索查询结果中的单词

[英]how highlight a word from result of search query

I have a trouble to make a highlight from search result this is my code (python file)我很难从搜索结果中突出显示这是我的代码(python 文件)

#proses cari artikel
@app.route('/pakar/hasil_artikel', methods=['GET', 'POST'])
def hasil_artikel_pakar():
halaman = 'cari artikel'
iduser = session.get('id_user')
cari = request.form['cari']
cari_kecil = cari.lower()
cari_clear =  cari_kecil.split()

data_model = "model/idwiki_word2vec_100.model"
model_baru = gensim.models.Word2Vec.load(data_model)
hasil = model_baru.most_similar(positive=cari_clear)

y = ' '.join('{}'.format(*el) for el in hasil)
x = cari+ " " + y
z = x.split(" ")

cursor1 = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
cursor1.execute('SELECT * FROM user WHERE id_user = %s', (iduser,))
sesinfo = cursor1.fetchone()

cursor2 = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
cursor2.execute('SELECT * FROM artikel JOIN user ON artikel.id_user = user.id_user WHERE artikel.judul_artikel LIKE %s OR artikel.isi_artikel LIKE %s', ("%" + z[0] + "%","%" + z[0] + "%",))
artikel = cursor2.fetchall()

return render_template('pakar/hasil_artikel.html', hasil=hasil, hal=halaman, sesinfo=sesinfo, artikel=artikel, cari=cari)

and this is my code (html code)这是我的代码(html代码)

<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
{% for artikels in artikel %}
                <div class="card">
                    <div class="header bg-red">
                        <h2>
                            {{ artikels.judul_artikel }}
                        </h2>
                        <ul class="header-dropdown m-r--5">
                            <i class="material-icons">person</i><span> Ditulis Oleh : {{ artikels.nama }} </span>
                        </ul>
                    </div>
                    <div class="body">
                    <img src="/static/foto_artikel/{{ artikels.foto_artikel }}" width="100px" height="100px"><br><br>    
                    <b>Tanggal Pembuatan Artikel : {{ artikels.tanggal_artikel.strftime('%d %B %Y') }}</b><br><br>
                    {{ artikels.isi_artikel | truncate(500) | safe }}<a href="/pakar/baca_artikel/{{ artikels.id_artikel }}" class="btn btn-success"> Baca Selengkapnya</a>    
                    </div>
                </div>          
{% endfor %}
            </div>

The problem is, How to Make A Highlight From The Result Of That Like CTRL+F in Browser?问题是,如何从浏览器中的 CTRL+F 之类的结果中突出显示? thank you for attention感谢您的关注

use the link tag that will help you get the highlighted version使用可以帮助您获得突出显示的版本的链接标签

thank you for your attention finally i found my problem solving for this question谢谢你的关注终于我找到了解决这个问题的问题

i using jquery highlight plugin我使用 jquery 高亮插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何根据查询从搜索结果中突出显示单词? - How can I highlight words from my search result based on my query? 快速突出显示搜索查询的完整结果 - highlight search query full result in whoosh 如何突出显示 Flask/HTML 中的搜索结果? - How to highlight result of a search in Flask/HTML? 如何从弹性搜索查询中获得准确的搜索结果 - how to get exact search result from elastic search query Python从pos序列中搜索特定的单词序列并突出显示它 - Python Search the specific word sequence from the pos sequence and highlight it 如何对单词搜索的结果进行编码以计算单词的出现次数 - How to code result of word search to count number of occurence of word 如何使用从小部件文本框中输入的单词搜索数据框,然后使用 python、ipywidgets 显示搜索结果? - How to use a word typed in from a widget text box to search a data frame, then display the search result using python, ipywidgets? 如何在pyqt5 python的qtextedit中突出显示文本中的单词? - How to highlight a word from the text in qtextedit in pyqt5 python? 如何使用 Django 将搜索查询结果保存到模型中? - How to save search query result into the model with Django? 如何在python help()内置函数结果中搜索某些单词? - How to search some word in python help() built-in function result?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM