Python和.NET集成 [英] Python and .NET integration

查看:384
本文介绍了Python和.NET集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在看蟒蛇,因为我真的很喜欢的文本分析能力和NLTK库,但传统上我是一个.net / C#程序员。我不认为IronPython的是一个集成点对我来说,因为我使用NLTK和presumably将需要该库的CLR端口。我看过一点点在的Python .NET ,并想知道,这是一个良好的开端。有没有办法封送一个Python类到C#?此外,在该解决方案仍在使用?更重要的是,有没有人这样做呢?有一件事我正在考虑是只使用一个持久性介质作为中间人(解析Python中,存储在MongoDB中,并运行网站.NET)。

I'm currently looking at python because I really like the text parsing capabilities and the nltk library, but traditionally I am a .Net/C# programmer. I don't think IronPython is an integration point for me because I am using NLTK and presumably would need a port of that library to the CLR. I've looked a little at Python for .NET and was wondering if this was a good place to start. Is there a way to marshal a python class into C#? Also, is this solution still being used? Better yet, has anyone done this? One thing I am considering is just using a persistence medium as a go-between (parse in Python, store in MongoDB, and run site in .NET).

推荐答案

NLTK是纯Python,因此可对IronPython的轻松运行。一个搜索止跌回升这张票 - 都是一个需要做的是安装了几个额外的Python库不来默认与IronPython的。

NLTK is pure-python and thus can be made to run on IronPython easily. A search turned up this ticket - all one has to do is install a couple of extra Python libraries that don't come by default with IronPython.

这可能是为您整合了最简单的方法。否则,你就必须要么运行Python作为子进程,这听起来复杂,或者运行Python作为回答您的请求的服务器。这可能是最具可扩展性,虽然复杂,方法。如果你走这条路,考虑扭简化服务器code。

This is probably the easiest way for you to integrate. Otherwise, you'll have to either run Python as a subprocess, which sounds complex, or run Python as a server that answers your requests. This is probably the most scalable, though complex, approach. If you go this way, consider Twisted to simplify the server code.

但不要尝试IronPython的第一...

But do try IronPython first...

这篇关于Python和.NET集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆