Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of Chinese language processing package Hanlp

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Originally wanted to call Java through python to achieve the use of Hanlp, refer to article: http://t.cn/RUrIF7z

# python can install some software with easy_install #

Introduction to use of 1.JPype

Reference: http://michael-paul.iteye.com/blog/1055786

As a flexible software development language, Python is widely used today. In the process of software development, it is sometimes necessary to use the existing Java code in Python projects, which has achieved the purpose of saving time and development costs. Therefore, it makes a lot of sense to find a bridge between Python code and Java code. JPype is such a tool, which can make Python program call Java code conveniently, thus expand the ability of Python language and make up for the deficiency of Python language. This paper introduces some basic methods of how to use JPype to integrate Python program and Java program.

The following is a simple python program that calls Java's print function through JPype to print out a string.

Listing 1. Hello world

Import jpype

JvmPath = jpype.getDefaultJVMPath ()

Jpype.startJVM (jvmPath)

Jpype.java.lang.System.out.println ("hello world!")

Jpype.shutdownJVM ()

When running the routine, getDefaultJVMPath () cannot find the default jvm path, check and find that typing java and javac on the command line is fine, and the environment variables have been configured. Find the routine (http://jpype.sourceforge.net/doc/user-guide/userguide.html) given by the jpype official documentation, and use the instructions (http://blog.csdn.net/niuyisheng/article/details/9002926) to find that the jre file in the jdk has the client folder, but now the version only has the server folder, and then find an article that introduces the difference between the client schema and the server schema in jvm (http://ryxxlong.iteye.com/blog/1696537). Found that they all use jdk1.6, and the current version is jdk1.8, guess the new version does not have this function, change jdk to version 1.6 or found that there is no client folder, give up calling the java package Hanlp in python, and directly use hanlp in the java program.

Comparison of the usage and effect of 11 Java open source Chinese word splitters:

Http://my.oschina.net/apdplat/blog/412921?fromerr=jF95Yz4r

two。 About HanLP

HanLP is an open source Java toolkit dedicated to popularizing NLP technology to production environments, supporting:

Chinese word segmentation (N-shortest path segmentation, CRF segmentation, index segmentation, user-defined dictionary, part of speech tagging)

Named entity recognition (Chinese name, transliterated name, Japanese name, place name, entity organization name recognition)

Keywords extraction, automatic summarization, phrase extraction, Pinyin conversion, simple and complex conversion, text recommendation, dependency parsing (MaxEnt dependency parsing, neural network dependency parsing).

Installation and getting started instructions for Hanlp: http://hanlp.linrunsoft.com/doc/_build/html/getting_started.html#hanlp

The data in HanLP is divided into dictionaries and models, in which dictionaries are necessary for lexical analysis and models are necessary for syntactic analysis.

The official website demo: https://github.com/hankcs/HanLP/tree/master/src/test/java/com/hankcs/demo

The article comes from zhangqiang1104's blog.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report