Giter Site home page Giter Site logo

likejazz / korean-sentence-splitter Goto Github PK

View Code? Open in Web Editor NEW
204.0 204.0 26.0 884 KB

Split Korean text into sentences using heuristic algorithm.

License: BSD 3-Clause "New" or "Revised" License

CMake 0.02% Dockerfile 0.03% C++ 99.04% C 0.78% Python 0.12% Makefile 0.01%

korean-sentence-splitter's People

Contributors

kobikun avatar likejazz avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

korean-sentence-splitter's Issues

아무런 것도 안되는 케이스

text = "사랑이란 건 한 번쯤은 해본 것 같은 아픔의 반복이 아니길 바래, 니가 더 행복했으면 좋겠어 니가 행복했음 좋겠어 [Chorus: Jin, Jimin] I'm so sick of this fake love, fake love, fake love I'm so sorry but it's fake love, fake love, fake love [Outro: Jimin, Jungkook] But it's fake love, fake love, fake love! <|endoftext|> Hangul (English Translation) I don't know why I said it's fake love, fake love, fake love! I don't know why I said it's fake love, fake love, fake love, fake love! I don't know why I said it's fake love, fake love, fake love, fake love, fake love! I don't know why I said it's fake love, fake love, fake love, fake love! I don't know why I said it's fake love, fake love, fake love, fake love, fake love! I don't know why I said it's fake love, fake love, fake love, fake love! I don't know why I said it's fake love, fake love, fake love, fake lo</s>"
for sent in kss.split_sentences(text):
    print(sent)

text = 사랑할   모습처럼 빛나고 싶어 I love you I love you, love you I love you, love you I love you, love you <|endoftext|> [Intro] [Chorus] Are you talkin' to me? (You talkin' to me?) Oh, yeah, yeah, yeah, yeah, yeah, yeah, yeah [Verse 1] Yeah, it's a new face, new face, new face 내 모든 wonder 에 대한 answer I call you her, her 'Cause you're my tear, tear, tear 내 모든 wonder 에 대한 answer I call you her, her 'Cause you're my tear, tear, tear, tear, tear [Verse 2] Baby, you are my tear, tear, tear, tear, tear, tear, tear, tear, you are my tear, tear You are my tear, tear, tear, tear, tear, you are my tear You are my tear, tear, tear, you are my tear You are my tear, tear, tear, tear, you are my, tear, tear You are my, tear, tear, you are my, tear You are my, tear, tear, you are my, tear [Verse 3] Are you talkin' to me? (You talkin' to me?) I don't know you, you are my tear, tear, tear I call you her, her 'Cause you're my tear, tear, tear, tear You are my, tear, tear, you are my, tear [Chorus] Are you talkin' to me? (You talkin' to me?) Oh, yeah, yeah, yeah, yeah, yeah, yeah, yeah, yeah, yeah, yeah, yeah,

text = 사랑한다 <|endoftext|> [Verse 1: J-Hope] 힙합이란 것은 원래 그런 거지 원래 그런 거지 원래 그런 거지 원래 그런 거지 , 그냥 그런 거지 , 그냥 그런 거지 , 그냥 그런 거지 , 그냥 그런 거지 , 그냥 그런 거지 , 그냥 그런 거지  [Verse 2: Suga]  어쩌겠어 그딴  <unk> Hangul [Verse 3: RM, Suga] 그래 내가  틀린 말했어 내가  거짓말했어 이길  있을까  기적 아닌 기적을 우리가 만든 걸까 (No)  여기 있었고 니가 내게 다가와준 거야 I do believe your galaxy 듣고 싶어 너의 멜로디 너의 은하수의 별들은 너의 하늘을 과연 어떻게 수놓을지 나의 절망 끝에 결국 내가  찾았음을 잊지마  절벽 끝에  있던  마지막 이유야 Live [Pre-Chorus: Jin, RM] 나의 Daydream Daydream Daydream Daydream Daydream Daydream Last Daydream Daydream Daydream Daydream</s>

text = 사랑하지 않을래  위해서라면  아파도 강한   수가 있었어 사랑이 사랑만으로 완벽하길  모든 약점들은  숨겨지길 이뤄지지 않는 꿈속에서 피울  없는 꽃을 키웠어 [Hook: Jimin, Jin] I'm so sick of this fake love, fake love, fake love I'm so sorry but it's fake love, fake love, fake love [Verse 2: RM, RM & Jungkook, J-Hope] I wanna be a good man just for you 세상을 줬네 just for you 전부 바꿨어 just for you Now I don't know me, who are you? 우리만의  너는 없었어 나도 내가 되고 싶었던 거야 나도 내가 되고 싶었던 거야 너의 최고가 되고 싶었던 거야 baby I wanna know you I don't know you</s>

위에 케이스들은 전부 아무것도 안 되는군요. 이거는 어쩔 수 없는 걸까요?

양쪽 따옴표 쌍이 안맞거나, 따옴표 수가 홀수인 문구가 등장하면 문장 분리가 되지 않는 경우들이 있습니다.

안녕하세요 박상길님,

한국어 처리에 필수적인, 문장 분리 코드를 공개해주신 점 감사합니다.

다음은 문장 분리가 되지 않는 경우 예제들입니다.

예제 1) 양쪽 따옴표 쌍이 안맞는 문구
우리 팀 촬영 PD는 “지금까지 탔던 차 중에 가장 편했다"라고 말했다. 이런 쉐슬람 같은! 아니다.
http://www.autoview.co.kr/content/article.asp?num_code=69736&news_section=car_ride&pageshow=3

예제 2) 양쪽 따옴표 쌍이 안맞는 문구
연비테스트를 진행하면서 들었던 의문점인 ‘트립 컴퓨터 정보'에 대한 신뢰도 문제였다. 3대의 차량 모두 연료를 더 이상 들어가지 않을 때 까지 가득 주유한 뒤 193km를 이동했다.
http://www.autoview.co.kr/content/article.asp?num_code=53652&news_section=car_r

예제 3) 따옴표 수가 홀수인 문구 (1개)
과거 씨드(Cee'd)를 시승하면서 만족감을 표한바 있다면 이제 내수시장서 판매되는 포르테 쿱에서 만족감을 표할 수 있게 되었다. 연비는 일반 주행을 기준으로 10km/L 정도를 예상하는 것이 좋다.
http://www.autoview.co.kr/content/buyer_guide/guide_road_article.asp?num_code=32587&news_section=car_ride&pageshow=3

이 문제와 이어지는 다른 문제점은 이후 텍스트들이 문장분리가 되지 않고 끝까지 한 문장으로 인식된다는 점입니다.

전처리로 따옴표들을 일치시켜보면 (ex. “ -> ", ” -> ") 예제 1번과 2번 경우는 사라지지만 예제 3번 같은 경우는 해결되지 않고 남아있습니다.

감사합니다. 좋은 하루 보내세요.

'다', '요' 외의 다른 끝음절 요청

코드에 보면, '다', '요'를 예외처리 하셔서, 문장 끝을 인식했는데, 실제로 문장의 끝은 그것 외에 더 다양하게 끝나잖아요. 마침형 문장부호 (. ? !)와 이런 끝 글자들이 조합되면, 문장의 끝으로 봐도 될 것 같습니다만...

예를 들어 '함. ', '(했)음. ', '(나)감. ', '(나)옴. ', '(보)냄. ', '(하)기. ', '(랄)까. ', '(카)노. ', '(하)오. ', '(이)지. ', '~냐. ' 이런 끝 글자들을 좀 폭 넓게 받아 주면 더 좋을 것 같습니다.

또는 점세개(...)로 끝난다거나...

그 외에도 마침부호(. ? !)와 같이 나타나면 다 잘라 줄 수 있을 거 같습니다. 특히 이런 한글 + 마침 부호(. ? !) 다음에 공백(' ', '\t', '\n')이 오면 백프로 문장 끝으로 봐도 될 것 같습니다.
'~(까)요? ', '나. ', '까? ', '(뭔)가? ', '(느)낌. ', '뿐. ', '(때문)에. ', '~뜻. '

페이스 친구들 포스팅에서 한 10분 정도 눈 대중으로 찾아보면, 이런 문장 끝 패턴들이 나옵니다. 이것들은 현재의 kss 에서는 분리가 안되고 연결되어 나오는 것 같습니다.

설치 에러

안녕하세요. 좋은 오픈소스 만들어주셔서 감사합니다.
동료에게 문장 분리가 잘 된다는 이야기를 듣고 사용하려 했는데, 설치가 되지 않아 문의드립니다.
mac 10.15.6 catalina
python 3.7.7
환경이고, 아래와 같이 설치 시 에러가 뜹니다.
빌드 환경 문제인가 하여, 여러 시도를 해보았으나 설치가 되지 않습니다.
혹시 짐작가시는 원인과 해결방법이 있을까요?
확인 부탁드립니다. 감사합니다.

/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/functional:742:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from kss.cpp:656:
In file included from ./sentence_splitter.h:16:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/unordered_map:409:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__hash_table:18:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:324:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/functional:771:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from kss.cpp:656:
In file included from ./sentence_splitter.h:16:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/unordered_map:409:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__hash_table:18:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:325:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:326:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:327:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:328:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:329:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
kss.cpp:3511:16: warning: absolute value function 'abs' given an argument of type 'const Py_ssize_t' (aka 'const long') but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
    if (likely(__Pyx_sst_abs(size) <= 1)) {
               ^
kss.cpp:691:34: note: expanded from macro '__Pyx_sst_abs'
    #define __Pyx_sst_abs(value) std::abs(value)
                                 ^
kss.cpp:3511:16: note: use function 'std::abs' instead
kss.cpp:691:34: note: expanded from macro '__Pyx_sst_abs'
    #define __Pyx_sst_abs(value) std::abs(value)
                                 ^
kss.cpp:3511:16: note: include the header <cstdlib> or explicitly provide a declaration for 'std::abs'
kss.cpp:691:34: note: expanded from macro '__Pyx_sst_abs'
    #define __Pyx_sst_abs(value) std::abs(value)
                                 ^
198 warnings and 13 errors generated.
error: command 'clang' failed with exit status 1

KSS 설치

먼저 KSS개발 해주셔서 감사의 말씀을 드립니다

kss패키지를 설치하기 위해 pip install kss 명령을 이용했는데 계속 설치에러가 다음과 같이 납니다.

command errored out with exit status.

자세한 것은 첨부파일에 있는 스크린샷을 참조해 주십시오.

현재 파이썬은 버전 3.7.6, 아나콘다 버전은 4.81을 쓰고 있습니다.

아마도 환경설정 문제인 것 같은데 제 수준에선 해결하기 어렵습니다.

감사합니다.

kss

segmentation fault when passing english text

Some of my text (~1%) includes un-detected english content in otherwise korean corpuses. In the worst case I would expect the package to do nothing, however I get a segmentation fault and the program dies.

Example:

>>> import kss
>>> s = "The reason I booked this hostel was there'a a only for women's room. But my room was mixed room that doesn't have partitions or curtains. I claimed and asked for changing the room but there's no extra bed for me in only women's room. So I stayed other place 1st day."
>>>
>>> kss.split_sentences(s)
Segmentation fault (core dumped)

I am using Python 3 on Ubuntu 18

' 또는 ’ 다음에 오는 문장들이 전부 다 하나의 문장으로 인식됩니다.

특히 예시1 (’가 포함) 같은 경우는 예전 버전(1.2.5)에선 잘 분리가 되었는데 현재 버전(1.3.1)에서 안 되었습니다.

예시1)

입력 문서:

부부 싸움 규칙 가운데 ‘돈 히트 언더 더 벨트’(Don’t hit under the belt)가 있다. 권투할 때 벨트 아래를 치면 반칙이듯이, 상대가 너무 아파할 만한 것을 건드리면 회복하기 어렵다. 그 부분은 사람마다 다르다.

출력 결과(1.3.1):

(입력 문서와 동일)

출력 결과(1.2.5):

부부 싸움 규칙 가운데 ‘돈 히트 언더 더 벨트’(Don’t hit under the belt)가 있다.
권투할 때 벨트 아래를 치면 반칙이듯이, 상대가 너무 아파할 만한 것을 건드리면 회복하기 어렵다.
그 부분은 사람마다 다르다.

예시2)

입력 문서:
삼성전자가 11월 13일 삼성전자 서초사옥 다목적홀 5층에서 진행되는 2013 S'데이 멤버십 블루 강연회 "Challenge BLUE, 박찬호&이동우의 삶과 도전" 멤버십 블루 고객 480명을 초청한다.강연회는 삼성전자 멤버십 블루 회원들을 위해 마련된 고객 혜택 행사로 한국인 최초의 메이저리거 박찬호와 시각장애 개그맨 이동우를 초청, 그들의 삶 속에서 펼쳐진 다양한 도전기를 들을 수 있도록 마련했다.

출력 결과(1.2.5, 1.3.1 공통):

(입력 문서와 동일)

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.