sps中的全文搜索和英文版sqlserver搜索中文的方法

sps中的全文搜索和英文版sqlserver搜索中文的方法

***********************************************************************************
*                  版权声明                        
*         此文章为ocean所有,版权归ocean所有,任何网站
*和 媒体转载必须包含此段声明,否则将视为侵权,作者将 
* 保留一切权力。此声明为此文章中不可或缺的一部分。 
* 作者网名:ocean                                  
* 作者email: ocean@forever.net.cn                   
* 作者网站: http://www.oceanstudio.net              
*                     http://sps.oceanstudio.net              
* 作者blog:博客园, http://www.cnblogs.com/ocean   
*                 ocean's blog, http://www.oceanstudio.net/sps/blog  
* 此文章发表时间:2005年2月25日                     
* 此文章源: http://www.cnblogs.com/ocean/archive/2005/02/25/109282.html                                       
************************************************************************************

    首先介绍一下Sharepoint中的搜索。Sharepoint的站点可能是一个门户站点,也可能仅仅是一个wss站点。sps的基础就是wss。但是搜索不太一样。我们先看一下sps和wss中使用的搜索服务。

    在sps中,使用SharePointPSSearch服务,显示名称为Microsoft SharePointPS Search,这个服务的描述是“Microsoft SharePoint Portal Server Search 服务提供对门户和外部内容的索引和搜索。”。如果停掉此服务,在Portal中搜索的时候就会报错。一般会报错“搜索遇到了错误。如果问题继续存在,请与门户网站管理员联系。”。sps中的搜索非常强大,因为除了搜索站点的内容本身之外,还可以搜索其它站点的内容,也即可以爬网。比如大家到 http://www.oceanstudio.net 上搜索一下,就会发现能够搜到http://www.oceanstudio.net/sps 的内容,同时还能搜http://www.cnblogs.com/ocean 的内容。搜索的站点可以是任何站点而不仅仅是wss站点。

    对于wss站点就不用了,wss使用了sql server的全文检索服务,也即MSSEARCH服务,显示名称为Microsoft Search服务,这个服务的描述是“基于结构化和半结构化数据的内容以及属性生成全文索引,以便可以对数据进行快速的单词搜索”。如果停掉了这个服务,你会发现wss的搜索不会报错,但是却搜不到任何内容了。

    要启用wss的搜索服务,首先需要确定Microsoft Search这个服务已经启动,同时需要在wss的后台管理中,启用全文搜索。如下图:

 


    然后就可以进行搜索了。

    sps的搜索设置就比较多了,我这里就不再介绍了,主要都是和爬网相关的。

    我的网站开始的时候,没法搜索中文,后来才发现不能搜索中文,最后才发现原来数据库采用的英文版sql server服务器。那么怎么办呢。最初是考虑更改排序规则。

    采用“alter database 海洋工作室1_SITE collate Chinese_PRC_CI_AS”语句更改排序规则,发现报错:

    Server: Msg 5075, Level 16, State 1, Line 1 The object 'CK_CatDef' is dependent on database collation.
    Server: Msg 5075, Level 16, State 1, Line 1 The object 'CK_CatJoint_Title' is dependent on database collation.
    Server: Msg 5075, Level 16, State 1, Line 1 The object 'CK_CatKeyword_Keyword' is dependent on database collation.
    Server: Msg 5075, Level 16, State 1, Line 1 The column 'Docs.LTCheckoutUserId' is dependent on database collation.
    Server: Msg 5075, Level 16, State 1, Line 1 The column 'Docs.Extension' is dependent on database collation.
    Server: Msg 5075, Level 16, State 1, Line 1 The object 'CK_CatPath_Depth' is dependent on database collation.
    Server: Msg 5072, Level 16, State 1, Line 1 ALTER DATABASE failed. The default collation of database '海洋工作室1_SITE' cannot be set to Chinese_PRC_CI_AS.

    也即没法更改。后来今天没办法,就更改了每个有全文索引表的分词语言。在wss数据库中有4个表,分别是userinfo,userdata,lists,docs表上有全文索引,其中userdata表是最重要的表,里面有几十个字段都有全文索引。所以我改了一中午,终于都改完了。

    第一步,在tables上点击右键,选择编辑全文索引。

    第二步,将索引的语言全部改成中文。

    第三步:在全文目录中重新填充。填充可能需要一段时间,根据你要索引的内容多少而定,完毕后就可以搜索中文了。

 

    sps搜索的例子可以到 http://www.oceanstudio.net 上看。

    wss搜索的例子可以到 http://sps.oceanstudio.net 上看。

 

在 GStreamer 获取 H264 码流 SPS 和 PPS 信息的方法如下: 1. 使用 `h264parse` 元素将 H264 码流解析为 NAL 单元。 2. 使用 `capsfilter` 元素设置 `video/x-h264, stream-format=byte-stream` 的媒体格式。 3. 使用 `splitter` 元素将 NAL 单元分离为 SPS、PPS 和 IDR 帧等单元。 4. 使用 `queue` 元素对 SPS 和 PPS 单元进行缓存。 5. 在需要使用 SPS 和 PPS 信息的地方,从 `queue` 元素获取 SPS 和 PPS 单元,并合并成完整的 SPS 和 PPS 数据。 以下是示例代码: ```python import gi gi.require_version('Gst', '1.0') from gi.repository import Gst Gst.init(None) pipeline = Gst.Pipeline() src = Gst.ElementFactory.make('filesrc', 'src') src.set_property('location', 'test.h264') h264parse = Gst.ElementFactory.make('h264parse', 'parse') caps = Gst.Caps.from_string('video/x-h264, stream-format=byte-stream') capsfilter = Gst.ElementFactory.make('capsfilter', 'caps') capsfilter.set_property('caps', caps) splitter = Gst.ElementFactory.make('splitter', 'split') queue_sps = Gst.ElementFactory.make('queue', 'sps') queue_pps = Gst.ElementFactory.make('queue', 'pps') sink = Gst.ElementFactory.make('fakesink', 'sink') pipeline.add(src) pipeline.add(h264parse) pipeline.add(capsfilter) pipeline.add(splitter) pipeline.add(queue_sps) pipeline.add(queue_pps) pipeline.add(sink) src.link(h264parse) h264parse.link(capsfilter) capsfilter.link(splitter) splitter.link(queue_sps) splitter.link(queue_pps) queue_sps.link(sink) pipeline.set_state(Gst.State.PLAYING) bus = pipeline.get_bus() msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.STATE_CHANGED | Gst.MessageType.ERROR) if msg.type == Gst.MessageType.ERROR: error, debug = msg.parse_error() print('Error received from element %s: %s' % (msg.src.get_name(), error)) print('Debugging information: %s' % debug) else: print('Pipeline started') sps_data = None pps_data = None while True: sample = queue_sps.get_upstream_buffer() if sample: buf = sample.get_buffer() sps_data = buf.extract_dup(0, buf.get_size()) break while True: sample = queue_pps.get_upstream_buffer() if sample: buf = sample.get_buffer() pps_data = buf.extract_dup(0, buf.get_size()) break print('SPS:', sps_data) print('PPS:', pps_data) pipeline.set_state(Gst.State.NULL) ``` 这段代码可以从文件读取 H264 码流,并获取其SPS 和 PPS 数据。需要注意的是,从队列获取数据时需要使用 `get_upstream_buffer()` 方法,否则可能会遇到阻塞的情况。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值