package com.tengyt.nlp.word;

import com.google.common.collect.Queues;
import org.ansj.domain.Term;

import java.util.List;
import java.util.Queue;
import java.util.concurrent.Callable;

/**
 * Created by tengyt on 8/25/15.
 */
public class SegWorker implements Callable<List<Term>>{
    public static Queue<Email> emails = Queues.newConcurrentLinkedQueue();

    @Override
    public List<Term> call() throws Exception {
        while (true) {
            if (emails.isEmpty()) {
                Thread.sleep(1000);
                continue;
            }

            Email email = emails.poll();
        }
        return null;
    }
}

@@ -64,16 +64,55 @@
 Queues;%0A
+import com.google.common.collect.Sets;%0A
 import o
@@ -136,31 +136,56 @@
 rm;%0A
-%0A
 import 
-java.util.List;
+org.ansj.splitWord.analysis.NlpAnalysis;%0A
 %0Aimp
@@ -226,32 +226,33 @@
 til.
-concurrent.Callable;%0A%0A/*
+Set;%0A%0A/**%0A * seg worker%0A 
 *%0A *
@@ -324,28 +324,17 @@
 nts 
-Callable%3CList%3CTerm%3E%3E
+Runnable 
 %7B%0A  
@@ -410,68 +410,144 @@
 ();%0A
-%0A    @Override%0A    public List%3CTerm%3E call() throws Exception
+    public static Set%3CString%3E terms = Sets.newConcurrentHashSet();%0A%0A    private int idealCount = 0;%0A%0A    @Override%0A    public void run()
  %7B%0A 
@@ -564,12 +564,24 @@
 le (
-true
+idealCount %3C 200
 ) %7B%0A
@@ -636,140 +636,413 @@
     
-Thread.sleep(1000);%0A                continue;%0A            %7D%0A%0A            Email email = emails.poll();%0A        %7D%0A        return null;
+idealCount++;%0A                try %7B%0A                    Thread.sleep(1000);%0A                %7D catch (InterruptedException e) %7B%0A                    e.printStackTrace();%0A                %7D%0A                continue;%0A            %7D%0A%0A            Email email = emails.poll();%0A            for (Term term : NlpAnalysis.parse(email.getContent())) %7B%0A                terms.add(term.toString());%0A            %7D%0A        %7D
 %0A   

add worker logic