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 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.2.tar.gz (4.2 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: ngram_extration-0.0.2.tar.gz
  • Upload date:
  • Size: 4.2 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.2.tar.gz
Algorithm Hash digest
SHA256 7ed50ba8f47304ac6c7944923f394512d4f03fe0e6da8bc471c1341b31a0145c
MD5 b901b4cf723c0a8a9f3c70d7a731a443
BLAKE2b-256 ab01ce69a0c0912228d7db47d84eb2f1e93c5627c30a9827ffc6b5c83781cfb1

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