【发布时间】:2015-10-27 18:01:18
【问题描述】:
给定一个子字符串定义
<Apply function="substring">
<FieldRef field="Input"/>
<Constant>1</Constant>
<Constant>2</Constant>
</Apply>
如果输入字符串“helloworld”会发生什么,官方的规范是什么?
这是不允许的,还是应该发生其他事情?
【问题讨论】:
标签: pmml
给定一个子字符串定义
<Apply function="substring">
<FieldRef field="Input"/>
<Constant>1</Constant>
<Constant>2</Constant>
</Apply>
如果输入字符串“helloworld”会发生什么,官方的规范是什么?
这是不允许的,还是应该发生其他事情?
【问题讨论】:
标签: pmml
请参考PMML built-in function "substring"的规范,基于XQuery built-in function "substring"。
在 Java 中,您的表达式转换为以下 input.substring((1 - 1), (1 - 1) + 2)。
需要注意的重要一点是,在 PMML 和 XQuery 中,字符串的索引从位置1(而不是0)开始。此外,在使用此功能时,没有 StringIndexOutOfBoundsException 这样的东西。如果您有兴趣获取字符串的其余部分,则可以将任意大的数字作为length 参数传递。
【讨论】:
substring 内置函数。这已在最新提交 b4c8cdf0dd 中修复。