Comments (7)
KoalaNLP PyPi 패키지 2.1.3부터 적용되었습니다. 감사합니다.
from python-support.
문제점을 파악하여 말씀드립니다.
Util.initialize()
코드상에서
start_jvm()
이후,
check_jvm()
을 하는데요,
check_jvm()
은
class_of('java.lang.String')('123')
코드로
Java String class를 만들고 JavaClass.__call()__
까지 실행합니다.
그 후, finalize()
를 해도, 'java.lang.String
이 _CLASS_DIC
에 남아 있어서
새로운 initialize()
과정에서
class_of('java.lang.String')('123')
코드를 실행하면
class_of()
의 level = level.__getattr__()
를 실행하면서
__init__
하고, __call__
을 하는 게 아니라,
이미 'java.lang.String'이 '_CLASS_DIC' 안에 남아있기 때문에 바로 리턴이 되고, __call__
이 실행됩니다.
이 JavaClass 인스턴스는 이전 jvm을 finalize()
하면서 is_connected = False
가 된 GatewayClient
를 갖고 있습니다.
그래서
def check_jvm():
class_of('java.lang.String')('123')
del _CLASS_DIC['java.lang.String']
로 수정해봤습니다.
from python-support.
완벽한 해결책은 아닌 것 같아요.
다른 부분들에서도 문제가 생겨서 좀 더 알아보고 있습니다.
from python-support.
finalize -> initialize를 하려는 이유는,
10기가 정도 되는 코퍼스를 대상으로 문장분리 작업을 하고 있는데,
일정한 위치에서 문장 분리가 멈추는 현상이 일어나기 때문입니다.
한 번에 처리하는 텍스트 양을 바꾸면 또 전혀 상관없는 위치에서 문장 분리가 멈춰 버립니다.
코드는 대략 아래와 같습니다.
initialize(java_options="-Xmx10g -Xms10g -Dfile.encoding=utf-8", HNN='2.0.3')
splitter = SentenceSplitter('hnn')
while i < len(corpus):
corpus_segment = corpus[i: min(i+char_count, len(corpus))]
sentences.extend(splitter(corpus_segment))
그래서 재시작하면 멈추는 현상이 안 일어날 것 같아 재시작을 해보려고 했는데, 그것도 여의치 않네요.
from python-support.
- 위에 말씀드린
Java.lang.String
관련 문제가 다른 클래스들에서도 일어납니다. 그래서shutdown_jvm()
을 아래와 같이 수정했습니다.
def shutdown_jvm():
global GATEWAY
global _CLASS_DIC
GATEWAY.shutdown()
GATEWAY = None
_CLASS_DIC = {}
return is_jvm_running()
- 한 프로세스 안에서 jvm을 다시 시작하면
initialize()
의_resolve_artifacts_modified()
를 실행할 때 이미 필요한 라이브러리가 이미 있다고 생각해서 그런지 다시 다운받지 않습니다. 그래서 리턴값을 받는down_list
가 비어 있고, 결과적으로start_jvm(java_options, classpaths)
의classpaths
가 없습니다. 그래서 필요한 SentenceSplitter()를 다시 생성하지 못합니다. 일단 저는 글로벌 변수 하나를 만들어서 해결했습니다.
def initialize():
...
down_list.sort(key=lambda a: a.repos.uri)
if len(down_list) == 0:
global _DOWN_LIST
down_list = _DOWN_LIST
else:
_DOWN_LIST = down_list
for artifact in down_list:
...
from python-support.
@kwonmha 인사가 늦었습니다. 말씀하신 대로 재초기화 관련 코드에 문제가 있습니다.
알려주신 방법으로 임시 조치가 가능하지만, 더 좋은 방법이 있어 수정하고 push하였으니 변경사항을 확인하실 수 있을 것 같습니다.
지금은 몇 가지 더 고칠 사항이 있어서, 새 버전 업로드 때에 다시 알려드리겠습니다.
from python-support.
네 감사합니다.
from python-support.
Related Issues (12)
- 장고서버에 koalanlp를 이용한 프로젝트를 올리려고 합니다.. HOT 1
- KSS 탑재 문의 HOT 5
- Py4JJavaError HOT 1
- 'JavaPackage' object is not callable koalanlp
- koalanlp 2.1.7, initialize 에러 HOT 1
- initialize error `'xml.etree.ElementTree.Element' object has no attribute 'getchildren'` HOT 1
- 초기화 함수 initialize 관련 HOT 3
- Tagger API를 통해서 문장을 분석하면 원문의 띄어쓰기가 무조건 변경되어 분석의 어려움이 있습니다. HOT 3
- Failed to initialize()
- 초기화 문제(Java와 통신 중에 필요한 클래스가 없다는 것을 확인했습니다.) HOT 9
- initialize with 2 process. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-support.