这是本文档旧的修订版!
下载:绪论
JAVA_HOME: C:\Program Files\Java\jdk1.8.0_301 CLASSPATH: %JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar; PATH: %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
> java > javac
> mvn -v
<localRepository>D:/dev/maven/repo</localRepository>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>cn.edu.bjut</groupId> <artifactId>text-mining</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>text-mining</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.opennlp</groupId> <artifactId>opennlp-tools</artifactId> <version>1.9.3</version> </dependency> </dependencies> </project>
package cn.edu.bjut.chapter1; import opennlp.tools.tokenize.SimpleTokenizer; public class TokenizerExample { public static void main(String[] args) { String text = "Text analysis and text mining are amazing!"; SimpleTokenizer tokenizer = SimpleTokenizer.INSTANCE; System.out.println("Tokens:"); String[] tokens = tokenizer.tokenize(text); for (String token : tokens) { System.out.println(token); } } }
评论