Skip to content

Commit

Permalink
流式改进
Browse files Browse the repository at this point in the history
  • Loading branch information
ysc committed May 23, 2015
1 parent 07c3767 commit 06ffce5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/org/apdplat/word/dictionary/DictionaryFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@

package org.apdplat.word.dictionary;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import org.apdplat.word.dictionary.impl.DictionaryTrie;
import org.apdplat.word.recognition.PersonName;
import org.apdplat.word.util.AutoDetector;
Expand All @@ -34,6 +28,16 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* 词典工厂
通过系统属性及配置文件指定词典实现类(dic.class)和词典文件(dic.path)
Expand Down Expand Up @@ -198,7 +202,7 @@ private static void test(String dicClass) throws Exception{
Thread.sleep(60000);
AtomicInteger h = new AtomicInteger();
AtomicInteger e = new AtomicInteger();
List<String> words = Files.readAllLines(Paths.get("src/test/resources/dic.txt"));
Stream<String> words = Files.lines(Paths.get("src/test/resources/dic.txt"));
System.gc();
Thread.sleep(60000);
long start = System.currentTimeMillis();
Expand Down

0 comments on commit 06ffce5

Please sign in to comment.