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


Python StringCharFeatures.enable_on_the_fly_preprocessing方法代码示例

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


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

示例1: features_string_char_compressed_modular

# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import enable_on_the_fly_preprocessing [as 别名]
def features_string_char_compressed_modular(fname):
    from shogun.Features import StringCharFeatures, StringFileCharFeatures, RAWBYTE
    from shogun.Library import UNCOMPRESSED, SNAPPY, LZO, GZIP, BZIP2, LZMA, MSG_DEBUG
    from shogun.Preprocessor import DecompressCharString

    f = StringFileCharFeatures(fname, RAWBYTE)

    # print "original strings", f.get_features()

    # uncompressed
    f.save_compressed("foo_uncompressed.str", UNCOMPRESSED, 1)
    f2 = StringCharFeatures(RAWBYTE)
    f2.load_compressed("foo_uncompressed.str", True)
    # print "uncompressed strings", f2.get_features()
    # print

    # load compressed data and uncompress on load

    # snappy - not stable yet?!
    # f.save_compressed("foo_snappy.str", SNAPPY, 9)
    # f2=StringCharFeatures(RAWBYTE);
    # f2.load_compressed("foo_snappy.str", True)
    # print "snappy strings", f2.get_features()
    # print

    # lzo
    f.save_compressed("foo_lzo.str", LZO, 9)
    f2 = StringCharFeatures(RAWBYTE)
    f2.load_compressed("foo_lzo.str", True)
    # print "lzo strings", f2.get_features()
    # print

    ##gzip
    f.save_compressed("foo_gzip.str", GZIP, 9)
    f2 = StringCharFeatures(RAWBYTE)
    f2.load_compressed("foo_gzip.str", True)
    # print "gzip strings", f2.get_features()
    # print

    # bzip2
    f.save_compressed("foo_bzip2.str", BZIP2, 9)
    f2 = StringCharFeatures(RAWBYTE)
    f2.load_compressed("foo_bzip2.str", True)
    # print "bzip2 strings", f2.get_features()
    # print

    # lzma
    f.save_compressed("foo_lzma.str", LZMA, 9)
    f2 = StringCharFeatures(RAWBYTE)
    f2.load_compressed("foo_lzma.str", True)
    # print "lzma strings", f2.get_features()
    # print

    # load compressed data and uncompress via preprocessor
    f2 = StringCharFeatures(RAWBYTE)
    f2.load_compressed("foo_lzo.str", False)
    f2.add_preprocessor(DecompressCharString(LZO))
    f2.apply_preprocessor()
    # print "lzo strings", f2.get_features()
    # print

    # load compressed data and uncompress on-the-fly via preprocessor
    f2 = StringCharFeatures(RAWBYTE)
    f2.load_compressed("foo_lzo.str", False)
    # f2.io.set_loglevel(MSG_DEBUG)
    f2.add_preprocessor(DecompressCharString(LZO))
    f2.enable_on_the_fly_preprocessing()
    # print "lzo strings", f2.get_features()
    # print

    # clean up
    import os

    for f in [
        "foo_uncompressed.str",
        "foo_snappy.str",
        "foo_lzo.str",
        "foo_gzip.str",
        "foo_bzip2.str",
        "foo_lzma.str",
        "foo_lzo.str",
        "foo_lzo.str",
    ]:
        if os.path.exists(f):
            os.unlink(f)
开发者ID:joseph-chan,项目名称:rqpersonalsvn,代码行数:87,代码来源:features_string_char_compressed_modular.py

示例2:

# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import enable_on_the_fly_preprocessing [as 别名]
print

# load compressed data and uncompress via preprocessor
f2=StringCharFeatures(RAWBYTE);
f2.load_compressed("foo_lzo.str", False)
f2.add_preproc(DecompressCharString(LZO))
f2.apply_preproc()
print "lzo strings", f2.get_features()
print

# load compressed data and uncompress on-the-fly via preprocessor
f2=StringCharFeatures(RAWBYTE);
f2.load_compressed("foo_lzo.str", False)
f2.io.set_loglevel(MSG_DEBUG)
f2.add_preproc(DecompressCharString(LZO))
f2.enable_on_the_fly_preprocessing()
print "lzo strings", f2.get_features()
print

##########################################################################################
# some perfectly compressible stuff follows
##########################################################################################
##########################################################################################
##########################################################################################
##########################################################################################
##########################################################################################
##########################################################################################
##########################################################################################
##########################################################################################
##########################################################################################
##########################################################################################
开发者ID:memimo,项目名称:shogun-liblinear,代码行数:33,代码来源:features_string_char_compressed_modular.py


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