Created
November 2, 2018 17:02
-
-
Save ArturTan/93715e0be7ad539d35ee2fbdc8e13183 to your computer and use it in GitHub Desktop.
morfeusz_execnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import execnet | |
def token_converter(text): | |
gw = execnet.makegateway("popen//python=python2.7") | |
channel = gw.remote_exec( | |
"""import morfeusz2 as morf | |
import gc | |
def converter(text): | |
analyzer = morf.Morfeusz() | |
text = analyzer.analyse(text) | |
return text | |
text = channel.receive() | |
channel.send(converter(text)) | |
del converter | |
del text | |
del morf | |
""") | |
channel.reconfigure(py2str_as_py3str=False) | |
channel.send(text) | |
text = channel.receive() | |
channel.close() | |
execnet.default_group.terminate() | |
return text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment