MS html IFilter nlhtml.dll有时无法提取文本

时间:2015-06-28 09:29:16

标签: html ifilter

为html文件提供的MS IFilter nlhtml.dll(文件版本2008.0.9600.17415)有时无法提取标签外的文本并返回标签内容,但在某些html文件上工作正常。 IFilter是从https://github.com/Sicos1977/IFilterTextReader的C#文本提取器调用的。

IFilter的参数是

 const NativeMethods.IFILTER_INIT iflags = NativeMethods.IFILTER_INIT.CANON_HYPHENS |
      NativeMethods.IFILTER_INIT.CANON_PARAGRAPHS |
      NativeMethods.IFILTER_INIT.CANON_SPACES |
      NativeMethods.IFILTER_INIT.APPLY_INDEX_ATTRIBUTES |
      NativeMethods.IFILTER_INIT.HARD_LINE_BREAKS |
      NativeMethods.IFILTER_INIT.FILTER_OWNED_VALUE_OK;

为索引搜索提取的文本似乎没问题,我想这会使用相同的IFilter。如何使用nlhtml.dll仅提取标签外的文本,因为MS似乎能够创建搜索索引?

提取工作正常的文件开头如下所示:

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-16">
<title>Electronic Activity Statement</title>
</head>
<body>
<H5>
Main Name: ALEKA CONSULTING PTY LTD<BR>
ABN: 89 160 421 821<BR><BR>

以及提取包含标记内容的文件的开头以

开头
<!DOCTYPE html>
<!--[if IE 6]>
<html class="no-js" id="ie6" dir="ltr" lang="en-US">
<![endif]-->
<!--[if IE 7]>
<html class="no-js" id="ie7" dir="ltr" lang="en-US">
<![endif]-->
<!--[if IE 8]>
<html class="no-js" id="ie8" dir="ltr" lang="en-US">
<![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8)  ]><!-->
<html class="no-js" dir="ltr" lang="en-US">
<!--<![endif]-->

此文件中的摘录文字包含标记内容,以

开头
[if IE 6]> <html class="no-js" id="ie6" dir="ltr" lang="en-US"> <![endif]
[if IE 7]> <html class="no-js" id="ie7" dir="ltr" lang="en-US"> <![endif]
[if IE 8]> <html class="no-js" id="ie8" dir="ltr" lang="en-US"> <![endif]
[if !(IE 6) | !(IE 7) | !(IE 8)  ]><!   <![endif]     Mirrored from 
nrha.org.au/12nrhc/musical-delegates-wanted/?pfstyle=wp by HTTrack 
Website Copier/3.x [XR&CO'2013], Sat, 27 Jun 2015 11:36:14 GMT    
Added by HTTrack  /Added by HTTrack           

1 个答案:

答案 0 :(得分:0)

从一些html文件中提取标记内容被阻止从IFilter标记中删除Apply_Index_Attributes,如下所示:

 $( "#grid-list" ).droppable({
        over: function(event, ui) {
          count = 0;
          $("#grid-list").find("li").each(function () {
            count++;

            if(count > $("#grid-list").data("albumlist")){
              alert("limit reached");
            }
          });
        }
      });