Skip to main content

用于提取语料库的最大词频情况下的最长字符串,即用于挖掘语料库中的高频长字符串

Project description

ngram_extration

概述

  • 目的
    用于提取语料库的最大词频情况下的最长字符串,即用于挖掘语料库中的高频长字符串,这类字符串可能是脏文本,也可能是特征文本;
    示例:
    corpus.txt中存在大量的高频字符串,如:
<sprite=3>  
【坐标分享】3级土地 (777,225)  
新技术!苹果手机三年冲的钱退回,你和代褪失败可以,不影响游戏,威信T9883K  
1级码头-(372,737) 

通过ngram_extration可以快速挖掘这类特征字符串。

  • 安装
pip install ngram_extration
  • 用法
from ngram_extration.ngram_extration import NgramExtration

def load_list_from_text(path):
    res = []
    with open(path) as f:
        for l in f:
            res.append(l[:-1])
    return res

ngram_extration = NgramExtration()
contents = load_list_from_text('corpus.txt')
final_feature_list = ngram_extration.extract_ngram(contents, min_df=10, ngram_range=(5,30), analyzer='char', lowercase=False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ngram_extration-0.0.1.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file ngram_extration-0.0.1.tar.gz.

File metadata

  • Download URL: ngram_extration-0.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.11

File hashes

Hashes for ngram_extration-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e4f23c6c3507aedd007f3180658c5a8ee4b90ab465e6092a8162740317a08fa7
MD5 3c52bd04d0aec6d7ff5810958e52959f
BLAKE2b-256 746ef5929f52d2fa2d82a4ffad4805c7d8254ace9e35d2628b0fddba4de3c734

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page