Coder Social home page Coder Social logo

text-cleaning's Introduction

text-cleaning: A Japanese powerful text cleaner

Description

This project cleans dirty Japanese texts, which include a lot of emoji and kaomoji in a whitelist method.

Cleaning Example

INPUT: これはサンプルです(≧∇≦*)!見てみて→http://a.bc/defGHIjkl
OUTPUT: これはサンプルです!見てみて。

INPUT: 一緒に応援してるよ(o^^o)。ありがとう😃
OUTPUT: 一緒に応援してるよ。ありがとう。

INPUT: いいぞ〜⸜(* ॑꒳ ॑*  )⸝⋆*
OUTPUT: いいぞ。

INPUT: えっ((((;゚Д゚)))))))
OUTPUT: えっ。

INPUT: 確かに「嘘でしょww」って笑ってたね
OUTPUT: 確かに「嘘でしょ。」って笑ってたね。

INPUT: おはようございますヽ(*´∀`)ノ。。今日は雨ですね・・・・・(T_T)
OUTPUT: おはようございます。今日は雨ですね。

INPUT: (灬º﹃º灬)おいしそうです♡
OUTPUT: おいしそうです。

INPUT: 今日の夜、友達とラーメン行くよ(((o(*゚▽゚*)o)))
OUTPUT: 今日の夜、友達とラーメン行くよ。

# When using the twitter option.
INPUT: @abcde0123 おっとっとwwそうでした✋!!よろしくお願いします♪‼ #挨拶
OUTPUT: おっとっと。そうでした!よろしくお願いします。

Requirements

  • Python 3.7+
  • mojimoji
  • neologdn
  • joblib

How to Run

Using python script directly

cat input.txt | python src/text_cleaning/main.py <options> > output.txt

Using makefile

When input files are located in directories hierarchically you can clean them keeping directory structure by using makefile. If input is compressed files, Makefile detect their format from their suffix and output cleaned files in the same format.

make INPUT_DIR=/somewhere/in OUTPUT_DIR=/somewhere/out PYTHON=/somewhere/.venv/bin/python

Options:

  • FILE_FORMAT=txt: Format of input file (txt or csv or tsv)
  • NUM_JOBS_PER_MACHINE=10: The maximum number of concurrently running jobs per machine
  • TWITTER=1: Perform twitter specific cleaning
  • PYTHON: Path to python interpreter of virtual environment

text-cleaning's People

Contributors

dependabot[bot] avatar nobu-g avatar taka008 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

text-cleaning's Issues

Input is separated by "〆"

To reproduce:

$ echo "帰ってきたら新年会の応募が届いておりまして、〆切後に参加したくなって" | python src/main.py

Actual output:

帰ってきたら新年会の応募が届いておりまして。切後に参加したくなって。

Expected output:

帰ってきたら新年会の応募が届いておりまして、〆切後に参加したくなって。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.