Apache Any23 配置参数详解

详解 Apache Any23 2.7 的配置体系:发行包脚本与环境变量、CLI 全局选项、rover 抽取参数与 33 个提取器选择、输出格式、核心模块配置属性与库级 Configuration API,含实测回显与性能对照。

Apache Any23Any232026/10/14

Apache Any23 配置参数详解

目标:系统梳理 Apache Any23 2.7 的全部配置入口与参数,包括发行包脚本与环境变量、CLI 全局选项、rover 抽取参数、提取器选择、输出格式、核心模块配置属性与 Java 库级 Configuration API,并给出实测回显与推荐配置模板。

一、环境信息

项目值
操作系统Ubuntu 22.04.5 LTS(实测主环境,辅以 CentOS 8.4 对照)
Any23 版本Apache Any23 2.7(最终正式发布版)
Java 版本OpenJDK 11.0.32.1(Ubuntu)/ 11.0.13(CentOS)
安装目录/opt/any23-2.7(Ubuntu)/ /opt/any23(CentOS)
配置脚本/etc/profile.d/any23.sh
插件目录/root/.any23/plugins(默认)
执行账号root

二、版本与生命周期说明

  1. Apache Any23 于 2023 年 7 月进入 Apache Attic,项目停止维护(EOL),本文全部参数基于 2.7 最终正式版实测。
  2. 2.8 仅停留在 SNAPSHOT 阶段,从未发布正式版本,archive.apache.org 与 Maven Central 均无 2.8 制品,配置以 2.7 为准。

💡 技术拓展:Any23 已停止维护,若项目仍需要"从 HTML/文档抽取结构化元数据"的能力,社区建议评估 Apache Tika(tika.apache.org),其提供更完整的文档解析、元数据提取与 REST 服务,维护活跃。

三、配置入口总览

Any23 2.7 的配置共分四层,从外到内依次生效:

层级入口控制内容生效方式
1发行包启动脚本 /opt/any23-2.7/bin/any23脚本内 REPO、JAVACMD、JAVA_OPTS 变量每次执行时读取
2环境变量 JAVA_HOME、PATH、ANY23_OPTSJVM 定位与 JVM 系统属性登录会话加载
3CLI 命令行选项提取器、输出格式、统计等本次运行行为单次命令生效
4Java 库 Configuration 与 ExtractionParametersHTTP 超时、microdata 严格模式等深度参数编程方式注入

查看运行脚本的变量定义位置:

grep -nE 'JAVA_OPTS|ANY23_OPTS|JAVACMD=' /opt/any23-2.7/bin/any23
exec "$JAVACMD" $JAVA_OPTS  \

验证结果:脚本末段以 exec 方式启动 JVM,JAVA_OPTS 直接透传给 java 进程,ANY23_OPTS 由脚本在启动前并入 JAVA_OPTS。

四、环境变量配置

4.1 JAVA_HOME 与 PATH

any23 脚本要求 JAVA_HOME 指向 JDK 根目录,否则报错 JAVA_HOME is not defined correctly。推荐写入 /etc/profile.d/any23.sh:

cat > /etc/profile.d/any23.sh <<'EOF'
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=/opt/any23-2.7/bin:$PATH
EOF

4.2 ANY23_OPTS 系统属性透传

脚本支持 ANY23_OPTS 变量携带 JVM 系统属性,例如覆盖 HTTP 最大连接数为 10:

ANY23_OPTS="-Dany23.http.client.max.connections=10" any23 rover /opt/any23-demo/sample.html

验证结果:ANY23_OPTS 中的 -D 属性会注入 JVM,可在库代码中通过 Configuration.getProperty 读取。

五、CLI 全局选项

执行 any23 -v 与 any23 --help 获取全局选项与命令清单:

any23 -v
Apache Any23 2.7 (2022-02-21 18:31:44+0000)
Java version: 11.0.32.1, vendor: Ubuntu
Java home: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "Linux", version: "6.8.0-138-generic", arch: "amd64", family: "unix"
any23 --help
Usage: any23 [options] [command] [command options]
  Options:
    -h, --help
      Display help information.
      Default: false
    --plugins-dir
      The Any23 plugins directory.
      Default: /root/.any23/plugins
    -X, --verbose
      Produce execution verbose output.
      Default: false
    -v, --version
      Display version information.
      Default: false

全局选项总览:

选项说明默认值
-h, --help打印全局帮助与命令清单无
-v, --version打印版本、Java、JVM、locale 与操作系统信息无
-X, --verbose输出执行明细(调试用)关闭
--plugins-dir指定插件目录,用于运行时注册自定义提取器/写入器/CLI 工具/root/.any23/plugins

验证结果:4 个全局选项全部实测可用,--plugins-dir 指向的目录不存在时工具自动忽略。

六、rover 抽取参数详解

rover 是 Any23 的核心抽取工具,支持 10 个选项:

any23 --help
    rover      Apache Any23 Command Line Tool.
      Usage: rover [options] input IRIs {<url>|<file>}+
        Options:
          -d, --defaultns
            Override the default namespace used to produce statements.
          -e, --extractors
            a comma-separated list of extractors, e.g. rdf-xml,rdf-turtle,
            etc. A complete extractor list can be obtained by calling ./any23
            extractor --list
            Default: [csv, html-embedded-jsonld, html-head-icbm, html-head-links, html-head-meta, html-head-title, html-mf-adr, html-mf-geo, html-mf-hcalendar, html-mf-hcard, html-mf-hlisting, html-mf-hrecipe, html-mf-hresume, html-mf-hreview, html-mf-hreview-aggregate, html-mf-license, html-mf-species, html-mf-xfn, html-microdata, html-rdfa11, html-xpath, ical, jcal, owl-functional, owl-manchester, rdf-jsonld, rdf-nq, rdf-nt, rdf-trix, rdf-turtle, rdf-xml, xcal, yaml]
          -f, --format
            a comma-separated list of writer factories, e.g.
            json,jsonld,nquads,notrivial,ntriples,trix,turtle,uri
            Default: [ntriples]
          -l, --log
            Produce log within a file.
          -n, --nesting
            Disable production of nesting triples.
            Default: false
          -t, --notrivial
            Filter trivial statements (e.g. CSS related ones). [DEPRECATED: As
            of version 2.3, use --format instead.]
            Default: false
          -o, --output
            Specify Output file (defaults to standard output)
          -p, --pedantic
            Validate and fixes HTML content detecting commons issues.
            Default: false
          -s, --stats
            Print out extraction statistics.
            Default: false

rover 选项详解:

选项参数说明默认值实测要点
-d, --defaultns命名空间 IRI覆盖生成语句的默认命名空间文档自身 IRI影响空白节点与文档节点的命名
-e, --extractors逗号分隔提取器名只启用指定提取器全部 33 个提取器指定后显著提速,实测 1s 完成
-f, --format逗号分隔写入器名输出格式,支持 json、jsonld、nquads、notrivial、ntriples、trix、turtle、urintriples-f jsonld 输出 JSON-LD 文档
-l, --log文件路径运行日志写入指定文件不写日志便于排查提取失败
-n, --nesting无关闭 Microformat 实体的嵌套三元组生成嵌套三元组输出更精简时使用
-t, --notrivial无过滤琐碎语句(CSS 相关等),2.3 起废弃不过滤建议改用 -f notrivial
-o, --output文件路径输出写入文件而非标准输出标准输出与 -f jsonld 组合导出 JSON-LD
-p, --pedantic无校验并自动修复 HTML 常见问题关闭对破损 HTML 提升提取率
-s, --stats无打印每个提取器的调用数、三元组数与耗时关闭定位性能瓶颈的利器

6.1 实测:默认全量提取

any23 rover -f nquads -s /opt/any23-demo/sample.html
------------------------------------------------------------------------
Apache Any23 :: rover
------------------------------------------------------------------------

<file:/opt/any23-demo/sample.html> <http://vocab.sindice.net/any23#author> "Apache Any23 Team"@zh-CN <file:/opt/any23-demo/sample.html> .
<file:/opt/any23-demo/sample.html> <http://vocab.sindice.net/any23#keywords> "RDF, metadata, extraction"@zh-CN <file:/opt/any23-demo/sample.html> .
<file:/opt/any23-demo/sample.html> <http://purl.org/dc/terms/title> "Any23 实测示例页面" <file:/opt/any23-demo/sample.html> .
_:node1k4r1crrmx2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> <file:/opt/any23-demo/sample.html> .
_:node1k4r1crrmx2 <http://schema.org/name> "Alice"@zh-CN <file:/opt/any23-demo/sample.html> .
<file:/opt/any23-demo/sample.html> <http://www.w3.org/1999/xhtml/microdata#item> _:node1k4r1crrmx2 <file:/opt/any23-demo/sample.html> .
<file:/opt/any23-demo/sample.html> <http://www.w3.org/1999/xhtml/vocab#license> <http://www.apache.org/licenses/LICENSE-2.0> <file:/opt/any23-demo/sample.html> .
<file:/opt/any23-demo/sample.html> <http://www.w3.org/ns/rdfa#usesVocabulary> <http://schema.org/> <file:/opt/any23-demo/sample.html> .
_:n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Book> <file:/opt/any23-demo/sample.html> .
_:n0 <http://schema.org/name> "Anything To Triples"@zh-CN <file:/opt/any23-demo/sample.html> .
_:n0 <http://schema.org/author> "Apache Any23"@zh-CN <file:/opt/any23-demo/sample.html> .

>Summary:
   -total calls: 21
   -total triples: 11
   -total runtime: 126607 ms!
   -tripls/ms: 0
   -ms/calls: 6028
>Extractor: html-head-icbm
   -total calls: 1
   -total triples: 0
   -total runtime: 3 ms!
   -tripls/ms: 0
   -ms/calls: 3
>Extractor: html-mf-geo
   -total calls: 1
   -total triples: 0
   -total runtime: 0 ms!
   -ms/calls: 0
>Extractor: html-head-meta
   -total calls: 1
   -total triples: 2
   -total runtime: 16 ms!
   -tripls/ms: 0
   -ms/calls: 16
>Extractor: html-mf-adr
   -total calls: 1
   -total triples: 0
   -total runtime: 1 ms!
   -tripls/ms: 0
   -ms/calls: 1
>Extractor: html-mf-hcalendar
   -total calls: 1
   -total triples: 0
   -total runtime: 0 ms!
   -ms/calls: 0
>Extractor: html-mf-hresume
   -total calls: 1
   -total triples: 0
   -total runtime: 1 ms!
   -tripls/ms: 0
   -ms/calls: 1
>Extractor: html-mf-hreview
   -total calls: 1
   -total triples: 0
   -total runtime: 0 ms!
   -ms/calls: 0
>Extractor: consolidation-extractor
   -total calls: 1
   -total triples: 0
   -total runtime: 0 ms!
   -ms/calls: 0
>Extractor: html-xpath
   -total calls: 1
   -total triples: 0
   -total runtime: 0 ms!
   -ms/calls: 0
>Extractor: html-head-title
   -total calls: 1
   -total triples: 1
   -total runtime: 2 ms!
   -tripls/ms: 0
   -ms/calls: 2
>Extractor: html-mf-hcard
   -total calls: 1
   -total triples: 0
   -total runtime: 0 ms!
   -ms/calls: 0
>Extractor: html-rdfa11
   -total calls: 1
   -total triples: 5
   -total runtime: 13 ms!
   -tripls/ms: 0
   -ms/calls: 13
>Extractor: html-mf-hreview-aggregate
   -total calls: 1
   -total triples: 0
   -total runtime: 0 ms!
   -ms/calls: 0
>Extractor: html-mf-license
   -total calls: 1
   -total triples: 0
   -total runtime: 1 ms!
   -tripls/ms: 0
   -ms/calls: 1
>Extractor: html-mf-xfn
   -total calls: 1
   -total triples: 0
   -total runtime: 1 ms!
   -tripls/ms: 0
   -ms/calls: 1
>Extractor: html-mf-species
   -total calls: 1
   -total triples: 0
   -total runtime: 0 ms!
   -ms/calls: 0
>Extractor: html-mf-hlisting
   -total calls: 1
   -total triples: 0
   -total runtime: 1 ms!
   -tripls/ms: 0
   -ms/calls: 1
>Extractor: html-microdata
   -total calls: 1
   -total triples: 3
   -total runtime: 13 ms!
   -tripls/ms: 0
   -ms/calls: 13
>Extractor: html-mf-hrecipe
   -total calls: 1
   -total triples: 0
   -total runtime: 0 ms!
   -ms/calls: 0
>Extractor: html-embedded-jsonld
   -total calls: 1
   -total triples: 0
   -total runtime: 126554 ms!
   -tripls/ms: 0
   -ms/calls: 126554
>Extractor: html-head-links
   -total calls: 1
   -total triples: 0
   -total runtime: 1 ms!
   -tripls/ms: 0
   -ms/calls: 1

------------------------------------------------------------------------
Apache Any23 SUCCESS
Total time: 127s
Finished at: Tue Oct 13 16:28:50 GMT 2026
Final Memory: 80M/506M
------------------------------------------------------------------------

验证结果:21 个提取器参与调用(含 12 个未注册的微格式提取器未单列),产出 11 条三元组;html-embedded-jsonld 独占 126554 毫秒且产出为 0,是默认模式约 2 分钟耗时的唯一来源。

6.2 实测:指定提取器提速

any23 rover -e html-head-title /opt/any23-demo/sample.html
------------------------------------------------------------------------
Apache Any23 :: rover
------------------------------------------------------------------------

<file:/opt/any23-demo/sample.html> <http://purl.org/dc/terms/title> "Any23 实测示例页面" .

------------------------------------------------------------------------
Apache Any23 SUCCESS
Total time: 1s
Finished at: Tue Oct 13 16:26:30 GMT 2026
Final Memory: 34M/506M
------------------------------------------------------------------------

验证结果:仅启用 html-head-title 时总耗时 1 秒,与默认模式 127 秒形成鲜明对照。生产环境建议始终用 -e 收敛提取器集合。

6.3 实测:JSON-LD 输出与输出文件

any23 rover -f jsonld -o /opt/any23-demo/out.jsonld /opt/any23-demo/sample.html
------------------------------------------------------------------------
Apache Any23 :: rover
------------------------------------------------------------------------


------------------------------------------------------------------------
Apache Any23 SUCCESS
Total time: 127s
Finished at: Tue Oct 13 16:30:58 GMT 2026
Final Memory: 82M/506M
------------------------------------------------------------------------

查看输出文件:

cat /opt/any23-demo/out.jsonld
[ {
  "@graph" : [ {
    "@id" : "_:n0",
    "@type" : [ "http://schema.org/Book" ],
    "http://schema.org/author" : [ {
      "@language" : "zh-cn",
      "@value" : "Apache Any23"
    } ],
    "http://schema.org/name" : [ {
      "@language" : "zh-cn",
      "@value" : "Anything To Triples"
    } ]
  }, {
    "@id" : "_:node1k4r1gpcbx2",
    "@type" : [ "http://schema.org/Person" ],
    "http://schema.org/name" : [ {
      "@language" : "zh-cn",
      "@value" : "Alice"
    } ]
  }, {
    "@id" : "file:/opt/any23-demo/sample.html",
    "http://purl.org/dc/terms/title" : [ {
      "@value" : "Any23 实测示例页面"
    } ],
    "http://vocab.sindice.net/any23#author" : [ {
      "@language" : "zh-cn",
      "@value" : "Apache Any23 Team"
    } ],
    "http://vocab.sindice.net/any23#keywords" : [ {
      "@language" : "zh-cn",
      "@value" : "RDF, metadata, extraction"
    } ],
    "http://www.w3.org/1999/xhtml/microdata#item" : [ {
      "@id" : "_:node1k4r1gpcbx2"
    } ],
    "http://www.w3.org/1999/xhtml/vocab#license" : [ {
      "@id" : "http://www.apache.org/licenses/LICENSE-2.0"
    } ],
    "http://www.w3.org/ns/rdfa#usesVocabulary" : [ {
      "@id" : "http://schema.org/"
    } ]
  } ],
  "@id" : "file:/opt/any23-demo/sample.html"
} ]

验证结果:-o 指定输出文件后标准输出不再打印三元组,JSON-LD 文档以 @graph 结构落盘。

七、提取器配置

7.1 提取器清单

执行 any23 extractor -l 获取全部 33 个提取器:

any23 extractor -l
------------------------------------------------------------------------
Apache Any23 :: extractor
------------------------------------------------------------------------

                      csv [org.apache.any23.extractor.csv.CSVExtractorFactory] [text/csv;q=0.1]
     html-embedded-jsonld [org.apache.any23.extractor.html.EmbeddedJSONLDExtractorFactory] [text/html;q=0.02, application/xhtml+xml;q=0.02]
           html-head-icbm [org.apache.any23.extractor.html.ICBMExtractorFactory] [text/html;q=0.01, application/xhtml+xml;q=0.01]
          html-head-links [org.apache.any23.extractor.html.HeadLinkExtractorFactory] [text/html;q=0.05, application/xhtml+xml;q=0.05]
           html-head-meta [org.apache.any23.extractor.html.HTMLMetaExtractorFactory] [text/html;q=0.02, application/xhtml+xml;q=0.02]
          html-head-title [org.apache.any23.extractor.html.TitleExtractorFactory] [text/html;q=0.02, application/xhtml+xml;q=0.02]
              html-mf-adr [org.apache.any23.extractor.html.AdrExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
              html-mf-geo [org.apache.any23.extractor.html.GeoExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
        html-mf-hcalendar [org.apache.any23.extractor.html.HCalendarExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
            html-mf-hcard [org.apache.any23.extractor.html.HCardExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
         html-mf-hlisting [org.apache.any23.extractor.html.HListingExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
          html-mf-hrecipe [org.apache.any23.extractor.html.HRecipeExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
          html-mf-hresume [org.apache.any23.extractor.html.HResumeExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
          html-mf-hreview [org.apache.any23.extractor.html.HReviewExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
html-mf-hreview-aggregate [org.apache.any23.extractor.html.HReviewAggregateExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
          html-mf-license [org.apache.any23.extractor.html.LicenseExtractorFactory] [text/html;q=0.01, application/xhtml+xml;q=0.01]
          html-mf-species [org.apache.any23.extractor.html.SpeciesExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
              html-mf-xfn [org.apache.any23.extractor.html.XFNExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
           html-microdata [org.apache.any23.extractor.microdata.MicrodataExtractorFactory] [text/html;q=0.1, application/xhtml+xml;q=0.1]
              html-rdfa11 [org.apache.any23.extractor.rdfa.RDFa11ExtractorFactory] [application/xhtml+xml;q=0.3, application/html;q=0.3, text/html;q=0.3]
               html-xpath [org.apache.any23.extractor.xpath.XPathExtractorFactory] [text/html;q=0.02, application/xhtml+xml;q=0.02]
                     ical [org.apache.any23.extractor.calendar.ICalExtractorFactory] [text/calendar]
                     jcal [org.apache.any23.extractor.calendar.JCalExtractorFactory] [application/calendar+json]
           owl-functional [org.apache.any23.extractor.rdf.FunctionalSyntaxExtractorFactory] [text/owl-functional]
           owl-manchester [org.apache.any23.extractor.rdf.ManchesterSyntaxExtractorFactory] [text/owl-manchester]
               rdf-jsonld [org.apache.any23.extractor.rdf.JSONLDExtractorFactory] [application/ld+json;q=0.1]
                   rdf-nq [org.apache.any23.extractor.rdf.NQuadsExtractorFactory] [application/n-quads, text/x-nquads;q=0.1, text/rdf+nq;q=0.1, text/nq;q=0.1, text/nquads;q=0.1, text/n-quads;q=0.1]
                   rdf-nt [org.apache.any23.extractor.rdf.NTriplesExtractorFactory] [application/n-triples;q=0.1, text/nt;q=0.1, text/ntriples;q=0.1, text/plain;q=0.1]
                 rdf-trix [org.apache.any23.extractor.rdf.TriXExtractorFactory] [application/trix]
               rdf-turtle [org.apache.any23.extractor.rdf.TurtleExtractorFactory] [text/turtle, text/rdf+n3, text/n3, application/n3, application/x-turtle, application/turtle]
                  rdf-xml [org.apache.any23.extractor.rdf.RDFXMLExtractorFactory] [application/rdf+xml, text/rdf, text/rdf+xml, application/rdf]
                     xcal [org.apache.any23.extractor.calendar.XCalExtractorFactory] [application/calendar+xml]
                     yaml [org.apache.any23.extractor.yaml.YAMLExtractorFactory] [text/x-yaml;q=0.5]

------------------------------------------------------------------------
Apache Any23 SUCCESS
Total time: 0s
Finished at: Tue Oct 13 16:21:10 GMT 2026
Final Memory: 47M/506M
------------------------------------------------------------------------

按用途分组:

分组提取器适用输入
HTML 语义标注html-rdfa11、html-microdata、html-embedded-jsonldRDFa、Microdata、内嵌 JSON-LD
微格式html-mf-hcard、html-mf-hcalendar、html-mf-hreview、html-mf-adr、html-mf-geo、html-mf-hrecipe、html-mf-hlisting、html-mf-hresume、html-mf-hreview-aggregate、html-mf-license、html-mf-species、html-mf-xfnhCard、hCalendar 等经典微格式
head 元数据html-head-title、html-head-meta、html-head-links、html-head-icbmtitle、meta、link、ICBM
日历ical、xcal、jcaliCalendar、xCal、jCal
RDF 序列化rdf-turtle、rdf-xml、rdf-nt、rdf-nq、rdf-trix、rdf-jsonldTurtle、RDF/XML、N-Triples 等文件
其他csv、html-xpath、yaml、owl-functional、owl-manchesterCSV、XPath 规则、YAML、OWL 语法

验证结果:提取器按 MIME 类型与 q 值优先级自动匹配输入,-e 参数可覆盖默认集合。

7.2 提取器行为注意点

  1. html-embedded-jsonld 初始化时尝试解析 JSON-LD 的远程上下文(如 http://schema.org),外网受限环境等待约 126 秒后放弃,产出 0 三元组;离线环境建议从 -e 集合中排除。
  2. html-head-meta 只抽取 name/content 型 meta(author、keywords 等),不抽取 http-equiv 型。
  3. html-rdfa11 在本次样例中产出最多(5 条),优先级 q=0.3 高于其余 HTML 提取器。

八、核心模块配置属性

核心库的默认配置声明在发行包 api jar 内的 default-configuration.properties,可用 JVM 系统属性或 Java API 覆盖。官方文档列出的属性如下:

属性名默认值说明
any23.http.user.agent.defaultApache Any23-CLIHTTP 请求 User-Agent
any23.http.client.timeout10000(10 秒)HTTP 请求超时(毫秒)
any23.http.client.max.connections5HTTP 客户端最大并发连接数
any23.rdfa.extractor.xsltrdfa.xsltRDFa 1.0 XSLT 提取所用样式表
any23.extraction.metadata.timesizeoff是否生成时间与大小元数据三元组
any23.extraction.metadata.nestingon是否生成微格式嵌套三元组
any23.extraction.metadata.domain.per.entityon是否为每个实体生成 domain 三元组
any23.extraction.rdfa.programmaticon启用程序化 RDFa 1.1 提取器(off 时退回 XSLT 方案)
any23.extraction.context.iri当前文档 IRI提取上下文 IRI 默认值
any23.plugin.dirs./plugins插件目录
any23.microdata.stricton启用 microdata 严格校验
any23.microdata.ns.defaulthttp://schema.org/microdata 默认命名空间
any23.extraction.head.metaon启用 HTMLMetaExtractor
any23.extraction.csv.field,CSV 字段分隔符
any23.extraction.csv.comment#CSV 行注释符

覆盖方式一:ANY23_OPTS 携带系统属性:

ANY23_OPTS="-Dany23.http.client.max.connections=10" any23 rover /opt/any23-demo/sample.html

覆盖方式二:Java 编程方式(ModifiableConfiguration):

ModifiableConfiguration conf = DefaultConfiguration.copy();
conf.setProperty("any23.http.client.timeout", "30000");
Any23 any23 = new Any23(conf, "html-rdfa11", "html-microdata");

单次提取参数(ExtractionParameters):

Any23 any23 = new Any23();
TripleHandler handler = new NTriplesWriter(System.out);
ExtractionParameters params = ExtractionParameters.getDefault();
params.setFlag("any23.microdata.strict", true);
any23.extract(params, "file:/opt/any23-demo/sample.html", handler);

验证结果:系统属性与 API 两条覆盖路径均指向同一份配置键,实测 ANY23_OPTS 方式无需改动任何文件。

九、推荐配置模板

生产环境推荐将提取器收敛到业务实际需要的集合,避免默认全量提取的网络等待:

any23 rover \
  -e html-head-title,html-head-meta,html-rdfa11,html-microdata \
  -f nquads \
  -o /opt/any23-demo/out.nq \
  /opt/any23-demo/sample.html

同时按需组合以下开关:-p 修复破损 HTML、-n 关闭嵌套三元组、-s 输出统计用于容量规划、-l 落日志便于排查。

十、参考链接