当前位置: 首页>>代码示例>>Python>>正文


Python Vocabulary.text方法代码示例

本文整理汇总了Python中nengo.spa.Vocabulary.text方法的典型用法代码示例。如果您正苦于以下问题:Python Vocabulary.text方法的具体用法?Python Vocabulary.text怎么用?Python Vocabulary.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nengo.spa.Vocabulary的用法示例。


在下文中一共展示了Vocabulary.text方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_text

# 需要导入模块: from nengo.spa import Vocabulary [as 别名]
# 或者: from nengo.spa.Vocabulary import text [as 别名]
def test_text(rng):
    v = Vocabulary(64, rng=rng)
    x = v.parse("A+B+C")
    y = v.parse("-D-E-F")
    ptr = r"-?[01]\.[0-9]{2}[A-F]"
    assert re.match(";".join([ptr] * 3), v.text(x))
    assert re.match(";".join([ptr] * 2), v.text(x, maximum_count=2))
    assert re.match(ptr, v.text(x, maximum_count=1))
    assert len(v.text(x, maximum_count=10).split(";")) <= 10
    assert re.match(";".join([ptr] * 4), v.text(x, minimum_count=4))
    assert re.match(";".join([ptr.replace("F", "C")] * 3), v.text(x, minimum_count=4, terms=["A", "B", "C"]))

    assert re.match(ptr, v.text(y, threshold=0.6))
    assert v.text(y, minimum_count=None, threshold=0.6) == ""

    assert v.text(x, join=",") == v.text(x).replace(";", ",")
    assert re.match(";".join([ptr] * 2), v.text(x, normalize=True))

    assert v.text([0] * 64) == "0.00F"
    assert v.text(v["D"].v) == "1.00D"
开发者ID:qqming113,项目名称:nengo,代码行数:22,代码来源:test_vocabulary.py

示例2: test_text

# 需要导入模块: from nengo.spa import Vocabulary [as 别名]
# 或者: from nengo.spa.Vocabulary import text [as 别名]
def test_text(rng):
    v = Vocabulary(64, rng=rng)
    x = v.parse('A+B+C')
    y = v.parse('-D-E-F')
    ptr = r'-?[01]\.[0-9]{2}[A-F]'
    assert re.match(';'.join([ptr] * 3), v.text(x))
    assert re.match(';'.join([ptr] * 2), v.text(x, maximum_count=2))
    assert re.match(ptr, v.text(x, maximum_count=1))
    assert len(v.text(x, maximum_count=10).split(';')) <= 10
    assert re.match(';'.join([ptr] * 4), v.text(x, minimum_count=4))
    assert re.match(';'.join([ptr.replace('F', 'C')] * 3),
                    v.text(x, minimum_count=4, terms=['A', 'B', 'C']))

    assert re.match(ptr, v.text(y, threshold=0.6))
    assert v.text(y, minimum_count=None, threshold=0.6) == ''

    assert v.text(x, join=',') == v.text(x).replace(';', ',')
    assert re.match(';'.join([ptr] * 2), v.text(x, normalize=True))

    assert v.text([0]*64) == '0.00F'
    assert v.text(v['D'].v) == '1.00D'
开发者ID:CamZHU,项目名称:nengo,代码行数:23,代码来源:test_vocabulary.py

示例3: test_text

# 需要导入模块: from nengo.spa import Vocabulary [as 别名]
# 或者: from nengo.spa.Vocabulary import text [as 别名]
def test_text():
    rng = np.random.RandomState(1)
    v = Vocabulary(64, rng=rng)
    x = v.parse('A+B+C')
    y = v.parse('-D-E-F')
    assert v.text(x) == '0.99A;0.96C;0.90B'
    assert v.text(x, maximum_count=2) == '0.99A;0.96C'
    assert v.text(x, maximum_count=1) == '0.99A'
    assert v.text(x, maximum_count=10) == '0.99A;0.96C;0.90B'
    assert v.text(x, minimum_count=4) == '0.99A;0.96C;0.90B;-0.02D'
    assert v.text(y) == '0.50C;0.15B'
    assert v.text(y, threshold=0.6) == '0.50C'
    assert v.text(y, minimum_count=None, threshold=0.6) == ''
    assert (v.text(x, minimum_count=4, terms=['A', 'B', 'C']) ==
            '0.99A;0.96C;0.90B')

    assert v.text(x, join=',') == '0.99A,0.96C,0.90B'
    assert v.text(x, normalize=True) == '0.59A;0.57C;0.53B'

    assert v.text([0]*64) == '0.00F'
    assert v.text(v['D'].v) == '1.00D'
开发者ID:Ocode,项目名称:nengo,代码行数:23,代码来源:test_vocabulary.py


注:本文中的nengo.spa.Vocabulary.text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。