GithubHelp home page GithubHelp logo

uoneway / kakaotalk_msg_preprocessor Goto Github PK

View Code? Open in Web Editor NEW
15.0 2.0 4.0 19 KB

카카오톡 채팅방에서 대화 내보내기를 통해 생성한 파일을 전처리해주는 라이브러리입니다.

Python 100.00%
kakaotalk preprocessor parser url

kakaotalk_msg_preprocessor's Introduction

kakaotalk_msg_preprocessor

카카오톡 채팅방에서 대화 내보내기를 통해 생성한 파일에 있는 메시지를 전처리해주는 라이브러리입니다.

주요 기능은 다음과 같습니다.

  • parse: 카카오톡에서 export한 txt파일을 여러 메시지 정보(dict)를 담고있는 list로 파싱합니다.
    • 각 메시지 정보는 메시지를 보낸 시간(datetime), 메시지를 보낸 사람(user_name), 메시지 본문(text)를 key로 가지는 dictionary입니다.
    • [{'datetime': datetime.datetime(2020, 6, 28, 1, 1), 'user_name': '김한길', 'text': '사진'}, {'datetime': datetime.datetime(2020, 8, 11, 12, 3), 'user_name': '김한길', 'text': 'https://www.youtube.com'}]
  • url_msg_extract: 파싱한 데이터에서 URL이 포함되어 있는 메시지만 추출하여, URL과 메시지 정보를 담고 있는 list로 반환해줍니다.
    • [{'datetime': datetime.datetime(2020, 8, 11, 12, 3), 'user_name': '김한길', 'url': 'https://www.youtube.com'}]

Guide

Install

pip install kakaotalk_msg_tokenizer

Usage

import kakaotalk_msg_preprocessor

카카오톡 메시지 파싱하기

# get the device type and language of kakaotalk_export_file
file_type = kakaotalk_msg_preprocessor.check_export_file_type(file_path)
print(file_type)

#  Parsing the text from a kaotalk_export_file
messages = kakaotalk_msg_preprocessor.parse(file_type, file_path)
print(messages)

예시 결과

window_ko
[{'datetime': datetime.datetime(2020, 6, 28, 1, 1), 'user_name': '김한길', 'text': '사진'}, {'datetime': datetime.datetime(2020, 6, 28, 1, 3), 'user_name': '김한길', 'text': '공부하기'}, 
{'datetime': datetime.datetime(2020, 8, 11, 2, 41), 'user_name': '김한길', 'text': '화 19:30-22:30\n\n\n자유석권(선착순)\n오후 6시 녹화장 앞 번호표대로 줄서기, 6시 50분부터 입장\n- 번호표 배부 : 녹화일 9:00 ~ 18:20까지 (입장순서가 부여된 방청권 선착순 배부)\n- 입장시간: 18시까지 녹화장 앞에서 번호표대로 줄서기(번호표 지참), 18:50부터 입장\n- 번호표 배부는 오후 6시 20분에 마감. 마감 이후에 오신 분들은 별도로 통제합니다'}, 
{'datetime': datetime.datetime(2020, 8, 11, 12, 3), 'user_name': '김한길', 'text': 'https://www.youtube.com'}]

카카오톡 메시지에서 URL만 추출하기

url_messages = kakaotalk_msg_preprocessor.url_msg_extract(file_type, messages)
print(url_messages)

예시 결과

[{'datetime': datetime.datetime(2020, 8, 11, 12, 3), 'user_name': '김한길', 'url': 'https://www.youtube.com'}]

지원 export 파일 종류

카카오톡은 카카오톡 앱 실행 환경에 따라 상이한 형식의 txt파일을 export합니다.

현재 정상작동이 확인된 환경은 다음과 같습니다.

  • 윈도우(OS언어: 한글)
  • 안드로이드(OS언어: 한글)
  • 안드로이드(OS언어: 영어)

kakaotalk_msg_preprocessor's People

Contributors

uoneway avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.