gpt4 book ai didi

django - 显示更多突出显示的上下文

转载 作者:行者123 更新时间:2023-12-01 12:46:53 24 4
gpt4 key购买 nike

我想知道如何让 django-haystack 高亮模板标签在高亮之前显示更多文本?

它当前显示“突出显示的文本此处必须显示更多以前的上下文,例如:“此处的其他文本 突出显示的文本这里有一些其他文本"

谢谢。

最佳答案

我认为最好的方法是按照 the docs 中的描述扩展 Highlighter .

类似于:

from haystack.utils import Highlighter

class ShowMoreTextHighlighter(Highlighter):
def find_window(self, highlight_locations):
their_start, their_end = super(ShowMoreTextHighlighter, self).find_window(highlight_locations)
# perform some clever operations here to find an earlier start location
my_start = their_start/2 # or just do something simple
return (my_start, their_end)

关于django - 显示更多突出显示的上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15010967/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com