You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2011/10/20 23:28:50 UTC

svn commit: r1187056 [3/3] - in /incubator/opennlp/sandbox/opennlp-similarity: ./ src/main/java/opennlp/tools/similarity/apps/ src/main/java/opennlp/tools/similarity/apps/utils/ src/main/java/opennlp/tools/textsimilarity/ src/main/java/opennlp/tools/te...

Added: incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/ParserConstants.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/ParserConstants.java?rev=1187056&view=auto
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/ParserConstants.java (added)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/ParserConstants.java Thu Oct 20 21:28:45 2011
@@ -0,0 +1,74 @@
+package opennlp.tools.textsimilarity.chunker2matcher;
+
+public interface ParserConstants {
+	// added new POS types for infinitive phrase and participle phrase
+	public static final String TYPE_STP = "STP"; // infinitive phrase
+	public static final String TYPE_SGP = "SGP"; // present participle phrase
+	public static final String TYPE_SNP = "SNP"; // past participle phrase
+
+	// below are the standard POS types,
+	// http://bulba.sdsu.edu/jeanette/thesis/PennTags.html
+	public static final String TYPE_ADJP = "ADJP";
+	public static final String TYPE_ADVP = "ADVP";
+	public static final String TYPE_CC = "CC";
+	public static final String TYPE_CD = "CD";
+	public static final String TYPE_CONJP = "CONJP";
+	public static final String TYPE_DT = "DT";
+	public static final String TYPE_EX = "EX";
+	public static final String TYPE_FRAG = "FRAG";
+	public static final String TYPE_FW = "FW";
+	public static final String TYPE_IN = "IN";
+	public static final String TYPE_INTJ = "INTJ";
+	public static final String TYPE_JJ = "JJ";
+	public static final String TYPE_JJR = "JJR";
+	public static final String TYPE_JJS = "JJS";
+	public static final String TYPE_LS = "LS";
+	public static final String TYPE_LST = "LST";
+	public static final String TYPE_MD = "MD";
+	public static final String TYPE_NAC = "NAC";
+	public static final String TYPE_NN = "NN";
+	public static final String TYPE_NNS = "NNS";
+	public static final String TYPE_NNP = "NNP";
+	public static final String TYPE_NNPS = "NNPS";
+	public static final String TYPE_NP = "NP";
+	public static final String TYPE_NX = "NX";
+	public static final String TYPE_PDT = "PDT";
+	public static final String TYPE_POS = "POS";
+	public static final String TYPE_PP = "PP";
+	public static final String TYPE_PRN = "PRN";
+	public static final String TYPE_PRP = "PRP";
+	public static final String TYPE_PRP$ = "PRP$";
+	public static final String TYPE_PRT = "PRT";
+	public static final String TYPE_QP = "QP";
+	public static final String TYPE_RB = "RB";
+	public static final String TYPE_RBR = "RBR";
+	public static final String TYPE_RBS = "RBS";
+	public static final String TYPE_RP = "RP";
+	public static final String TYPE_RRC = "RRC";
+	public static final String TYPE_S = "S";
+	public static final String TYPE_SBAR = "SBAR";
+	public static final String TYPE_SBARQ = "SBARQ";
+	public static final String TYPE_SINV = "SINV";
+	public static final String TYPE_SQ = "SQ";
+	public static final String TYPE_SYM = "SYM";
+	public static final String TYPE_TO = "TO";
+	public static final String TYPE_TOP = "TOP";
+	public static final String TYPE_UCP = "UCP";
+	public static final String TYPE_UH = "UH";
+	public static final String TYPE_VB = "VB";
+	public static final String TYPE_VBD = "VBD";
+	public static final String TYPE_VBG = "VBG";
+	public static final String TYPE_VBN = "VBN";
+	public static final String TYPE_VBP = "VBP";
+	public static final String TYPE_VBZ = "VBZ";
+	public static final String TYPE_VP = "VP";
+	public static final String TYPE_WDT = "WDT";
+	public static final String TYPE_WHADJP = "WHADJP";
+	public static final String TYPE_WHADVP = "WHADVP";
+	public static final String TYPE_WHNP = "WHNP";
+	public static final String TYPE_WHPP = "WHPP";
+	public static final String TYPE_WP = "WP";
+	public static final String TYPE_WP$ = "WP$";
+	public static final String TYPE_WRB = "WRB";
+	public static final String TYPE_X = "X";
+}

Propchange: incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/ParserConstants.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/PhraseNode.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/PhraseNode.java?rev=1187056&view=auto
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/PhraseNode.java (added)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/PhraseNode.java Thu Oct 20 21:28:45 2011
@@ -0,0 +1,102 @@
+package opennlp.tools.textsimilarity.chunker2matcher;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PhraseNode extends SyntacticTreeNode {
+	// children nodes within a phrase node
+	private List<SyntacticTreeNode> children;
+
+	public PhraseNode(String type, List<SyntacticTreeNode> children) {
+		super(type);
+		setChildren(children);
+	}
+
+	@Override
+	public List<SyntacticTreeNode> getChildren() {
+		return children;
+	}
+
+	public void setChildren(List<SyntacticTreeNode> children) {
+		this.children = children;
+
+		// set the parent of the children nodes
+		if (children != null && children.size() > 0) {
+			for (SyntacticTreeNode child : children) {
+				if (child != null)
+					child.setParentNode(this);
+			}
+		}
+	}
+
+	public void addChild(SyntacticTreeNode child) {
+		if (child == null)
+			return;
+
+		if (children == null) {
+			children = new ArrayList<SyntacticTreeNode>();
+		}
+
+		// set the parent of the child node
+		child.setParentNode(this);
+
+		children.add(child);
+	}
+
+	@Override
+	public String getText() {
+		return getText(false, false);
+	}
+
+	@Override
+	public String getLemma(boolean removeStopWord) {
+		return getText(true, removeStopWord);
+	}
+
+	private String getText(boolean useLemma, boolean removeStopWord) {
+		if (children == null || children.size() == 0)
+			return null;
+
+		StringBuilder builder = new StringBuilder();
+		boolean first = true;
+		for (SyntacticTreeNode child : children) {
+			String childText = null;
+			if (useLemma)
+				childText = child.getLemma(removeStopWord);
+			else
+				childText = child.getText();
+
+			if (childText == null || childText.length() == 0)
+				continue;
+
+			// add a leading space for children other than the first
+			if (first)
+				first = false;
+			else
+				builder.append(" ");
+
+			// add the child
+			builder.append(childText);
+		}
+
+		return builder.toString();
+	}
+
+	@Override
+	public String toStringIndented(int numTabs) {
+		StringBuilder builder = new StringBuilder();
+
+		String indent = SyntacticTreeNode.getIndent(numTabs);
+		builder.append(indent).append("type = ").append(getType());
+
+		// output all the children
+		if (children != null && children.size() > 0) {
+			numTabs++;
+			for (SyntacticTreeNode child : children) {
+				builder.append("\n").append(child.toStringIndented(numTabs));
+			}
+		}
+
+		return builder.toString();
+	}
+}

Propchange: incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/PhraseNode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/SentenceNode.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/SentenceNode.java?rev=1187056&view=auto
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/SentenceNode.java (added)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/SentenceNode.java Thu Oct 20 21:28:45 2011
@@ -0,0 +1,42 @@
+package opennlp.tools.textsimilarity.chunker2matcher;
+
+import java.util.List;
+
+/**
+ * Sentence node is the first clause node contained in the top node
+ * 
+ */
+public class SentenceNode extends PhraseNode {
+	private String sentence;
+
+	public SentenceNode(String sentence, List<SyntacticTreeNode> children) {
+		super(ParserConstants.TYPE_S, children);
+
+		this.sentence = sentence;
+	}
+
+	@Override
+	public String getText() {
+		return sentence;
+	}
+
+	public String getSentence() {
+		return sentence;
+	}
+
+	public void setSentence(String sentence) {
+		this.sentence = sentence;
+	}
+
+	@Override
+	public String toStringIndented(int numTabs) {
+		StringBuilder builder = new StringBuilder();
+		String indent = SyntacticTreeNode.getIndent(numTabs);
+
+		// output the sentence
+		builder.append(indent).append(sentence).append("\n");
+		builder.append(super.toStringIndented(numTabs));
+
+		return builder.toString();
+	}
+}

Propchange: incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/SentenceNode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/SyntacticTreeNode.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/SyntacticTreeNode.java?rev=1187056&view=auto
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/SyntacticTreeNode.java (added)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/SyntacticTreeNode.java Thu Oct 20 21:28:45 2011
@@ -0,0 +1,132 @@
+package opennlp.tools.textsimilarity.chunker2matcher;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import opennlp.tools.parser.AbstractBottomUpParser;
+
+public abstract class SyntacticTreeNode {
+	// the POS type
+	private String type;
+
+	// parent node, it is null for the root node
+	private PhraseNode parentNode;
+
+	public abstract List<SyntacticTreeNode> getChildren();
+
+	public abstract String getText();
+
+	public abstract String getLemma(boolean removeStopWord);
+
+	public abstract String toStringIndented(int numTabs);
+
+	public SyntacticTreeNode(String type) {
+		this.type = type;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getLemma() {
+		return getLemma(false);
+	}
+
+	public PhraseNode getParentNode() {
+		return parentNode;
+	}
+
+	public void setParentNode(PhraseNode parentNode) {
+		this.parentNode = parentNode;
+	}
+
+	public int getChildrenCount() {
+		List<SyntacticTreeNode> childrenList = getChildren();
+		if (childrenList == null)
+			return 0;
+
+		return childrenList.size();
+	}
+
+	public String toString() {
+		return toStringIndented(0);
+	}
+
+	public static String getIndent(int numTabs) {
+		if (numTabs <= 0)
+			return "";
+
+		StringBuilder builder = new StringBuilder();
+		for (int i = 0; i < numTabs; i++) {
+			builder.append("\t");
+		}
+
+		return builder.toString();
+	}
+
+	public static boolean isJunkType(String type) {
+		if (type == null)
+			return true;
+
+		// the token node is useless
+		if (type.equals(AbstractBottomUpParser.TOK_NODE))
+			return true;
+
+		// the punctuation nodes are not useful, '.', '.', '?', '!', ';', etc
+		if (type.equals(",") || type.equals(".") || type.equals("?")
+				|| type.equals("!") || type.equals(";"))
+			return true;
+
+		return false;
+	}
+
+	public static void replaceNode(SyntacticTreeNode nodeToReplace,
+			SyntacticTreeNode newNode) {
+		List<SyntacticTreeNode> newNodeList = null;
+		if (newNode != null) {
+			newNodeList = new ArrayList<SyntacticTreeNode>(1);
+			newNodeList.add(newNode);
+		}
+
+		replaceNode(nodeToReplace, newNodeList);
+	}
+
+	public static void replaceNode(SyntacticTreeNode nodeToReplace,
+			List<SyntacticTreeNode> newNodeList) {
+		if (nodeToReplace == null)
+			throw new NullPointerException("The node to replace cannot be null");
+
+		PhraseNode parentNode = nodeToReplace.getParentNode();
+
+		if (parentNode == null) {
+			// the node to replace is the root node
+			// clear all children of the existing root node and use it as the
+			// new root node
+			if (nodeToReplace instanceof PhraseNode)
+				((PhraseNode) nodeToReplace).setChildren(newNodeList);
+			return;
+		}
+
+		List<SyntacticTreeNode> childrenNodes = parentNode.getChildren();
+		int index = childrenNodes.indexOf(nodeToReplace);
+		if (index >= 0) {
+			// remove the old node
+			childrenNodes.remove(index);
+
+			// put the new node list at the place of the old node if there are
+			// any
+			if (newNodeList != null && newNodeList.size() > 0) {
+				childrenNodes.addAll(index, newNodeList);
+
+				// set the parent node of the new children
+				for (SyntacticTreeNode newNode : newNodeList) {
+					newNode.setParentNode(parentNode);
+				}
+			}
+		}
+	}
+}

Propchange: incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/SyntacticTreeNode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/WordNode.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/WordNode.java?rev=1187056&view=auto
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/WordNode.java (added)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/WordNode.java Thu Oct 20 21:28:45 2011
@@ -0,0 +1,60 @@
+package opennlp.tools.textsimilarity.chunker2matcher;
+
+import java.util.List;
+
+public class WordNode extends SyntacticTreeNode {
+	// the word in the sentence
+	private String word;
+	private String lemma;
+
+	public WordNode(String type, String word) {
+		super(type);
+
+		setWord(word);
+	}
+
+	public String getWord() {
+		return word;
+	}
+
+	public void setWord(String word) {
+		this.word = word;
+
+		// update lemma accordingly
+		this.lemma = null;
+		/*WordDictionary.getInstance().getLemmaOrWord(word,
+				getType()); */
+	}
+
+	@Override
+	public String getLemma(boolean removeStopWord) {
+		if (removeStopWord) // && Feature.isStopWord(lemma, getType()))
+			return null;
+
+		return lemma;
+	}
+
+	@Override
+	public List<SyntacticTreeNode> getChildren() {
+		// a word node is a leaf and has no children
+		return null;
+	}
+
+	@Override
+	public String getText() {
+		return word;
+	}
+
+	@Override
+	public String toStringIndented(int numTabs) {
+		String indent = SyntacticTreeNode.getIndent(numTabs);
+		StringBuilder builder = new StringBuilder();
+		builder.append(indent).append("type = ").append(getType())
+				.append(", word = ").append(word);
+
+		return builder.toString();
+	}
+
+	public static void main(String[] args) {
+	}
+}

Propchange: incubator/opennlp/sandbox/opennlp-similarity/src/main/java/opennlp/tools/textsimilarity/chunker2matcher/WordNode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/GeneralizationListReducerTest.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/GeneralizationListReducerTest.java?rev=1187056&r1=1187055&r2=1187056&view=diff
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/GeneralizationListReducerTest.java (original)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/GeneralizationListReducerTest.java Thu Oct 20 21:28:45 2011
@@ -22,26 +22,18 @@ import static junit.framework.Assert.ass
 import java.util.ArrayList;
 import java.util.List;
 
+import junit.framework.TestCase;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "/applicationContext-dedupe-test.xml" })
-@ActiveProfiles("UnitTest")
-public class GeneralizationListReducerTest {
-  @Autowired
-  private GeneralizationListReducer generalizationListReducer;
 
-  @Test
+public class GeneralizationListReducerTest extends TestCase{
+  private GeneralizationListReducer generalizationListReducer = new  GeneralizationListReducer();
+
   public void notNull() {
     assertNotNull(generalizationListReducer);
   }
 
-  @Test
   public void test() {
     ParseTreeChunk ch1 = new ParseTreeChunk("VP", new String[] { "run",
         "around", "tigers", "zoo" }, new String[] { "VB", "IN", "NP", "NP" });
@@ -70,13 +62,14 @@ public class GeneralizationListReducerTe
     inp.add(ch3);
     inp.add(ch4);
 
-    Boolean b = ch1.isASubChunk(ch2);
-    b = ch2.isASubChunk(ch1);
-    b = ch5.isASubChunk(ch4);
-    b = ch4.isASubChunk(ch5);
+    assertTrue(ch1.isASubChunk(ch2));
+    assertTrue(ch2.isASubChunk(ch1));
+    assertTrue(ch5.isASubChunk(ch4));
+    assertTrue(ch4.isASubChunk(ch5));
 
     List<ParseTreeChunk> res = generalizationListReducer
         .applyFilteringBySubsumption(inp);
+    assertEquals(res.toString(), "[VP [VB-run IN-around NP-tigers NP-zoo ], NP [DT-the NP-tigers ], NP [DT-the NN-* VBG-flying NN-car ]]");
     System.out.println(res);
 
   }

Modified: incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/LemmaFormManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/LemmaFormManagerTest.java?rev=1187056&r1=1187055&r2=1187056&view=diff
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/LemmaFormManagerTest.java (original)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/LemmaFormManagerTest.java Thu Oct 20 21:28:45 2011
@@ -21,26 +21,18 @@ import static junit.framework.Assert.ass
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "/applicationContext-dedupe-test.xml" })
-@ActiveProfiles("UnitTest")
+
 public class LemmaFormManagerTest {
 
-  @Autowired
   private LemmaFormManager lemmaFormManager;
 
-  @Test
-  public void notNull() {
+
+  public void notNullTest() {
     assertNotNull(lemmaFormManager);
   }
 
-  @Test
-  public void matches() {
+
+  public void matchesTest() {
 
     String res = lemmaFormManager.matchLemmas(null, "loud", "loudness", "NN");
     res = lemmaFormManager.matchLemmas(null, "24", "12", "CD");

Modified: incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkFactoryTest.java?rev=1187056&r1=1187055&r2=1187056&view=diff
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkFactoryTest.java (original)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkFactoryTest.java Thu Oct 20 21:28:45 2011
@@ -22,26 +22,17 @@ import static org.junit.Assert.assertTru
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "/applicationContext-dedupe-test.xml" })
-@ActiveProfiles("UnitTest")
+
 public class ParseTreeChunkFactoryTest {
-  @Autowired
-  private ParseTreeChunkFactory parseTreeChunkFactory;
 
-  @Test
+
   public void testScopePrototype() {
 
-    ParseTreeChunk parseTreeChunk = parseTreeChunkFactory.getParseTreeChunk();
+    ParseTreeChunk parseTreeChunk = new ParseTreeChunk();
     assertNotNull(parseTreeChunk);
     assertNotNull(parseTreeChunk.getParseTreeMatcher());
 
-    ParseTreeChunk parseTreeChunk2 = parseTreeChunkFactory.getParseTreeChunk();
+    ParseTreeChunk parseTreeChunk2 = new ParseTreeChunk();
     assertTrue(parseTreeChunk != parseTreeChunk2);
   }
 

Modified: incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkListScorerTest.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkListScorerTest.java?rev=1187056&r1=1187055&r2=1187056&view=diff
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkListScorerTest.java (original)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkListScorerTest.java Thu Oct 20 21:28:45 2011
@@ -21,19 +21,9 @@ import java.util.List;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "/applicationContext-dedupe-test.xml" })
-@ActiveProfiles("UnitTest")
 public class ParseTreeChunkListScorerTest {
-  @Autowired
   private ParseTreeChunkListScorer parseTreeChunkListScorer;
-
-  @Autowired
   private ParseTreeChunk parseTreeChunk;
 
   @Test

Modified: incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkTest.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkTest.java?rev=1187056&r1=1187055&r2=1187056&view=diff
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkTest.java (original)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeChunkTest.java Thu Oct 20 21:28:45 2011
@@ -23,17 +23,12 @@ import java.util.List;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 public class ParseTreeChunkTest {
   private ParseTreeMatcherDeterministic parseTreeMatcher = new ParseTreeMatcherDeterministic();
   private ParseTreeChunk parseTreeChunk = new ParseTreeChunk();
   private ParseTreeChunkListScorer parseTreeChunkListScorer = new ParseTreeChunkListScorer();
 
-  @Test
   public void test() {
     ParseTreeChunk ch1, ch2;
     List<List<ParseTreeChunk>> chRes;

Modified: incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeMatcherDeterministicTest.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeMatcherDeterministicTest.java?rev=1187056&r1=1187055&r2=1187056&view=diff
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeMatcherDeterministicTest.java (original)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/ParseTreeMatcherDeterministicTest.java Thu Oct 20 21:28:45 2011
@@ -19,20 +19,11 @@ package opennlp.tools.textsimilarity;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "/applicationContext-dedupe-test.xml" })
-@ActiveProfiles("UnitTest")
+
 public class ParseTreeMatcherDeterministicTest {
 
-  @Autowired
   private ParseTreeMatcherDeterministic parseTreeMatcherDeterministic;
 
-  @Test
   public void test() {
 
     ParseTreeChunk ch1 = new ParseTreeChunk("NP", new String[] { "love", "to",

Modified: incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/SyntMatcherTest.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/SyntMatcherTest.java?rev=1187056&r1=1187055&r2=1187056&view=diff
==============================================================================
--- incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/SyntMatcherTest.java (original)
+++ incubator/opennlp/sandbox/opennlp-similarity/src/test/java/opennlp/tools/textsimilarity/SyntMatcherTest.java Thu Oct 20 21:28:45 2011
@@ -22,30 +22,33 @@ import static org.junit.Assert.assertNot
 
 import java.util.List;
 
+import opennlp.tools.textsimilarity.chunker2matcher.ParserChunker2MatcherProcessor;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 public class SyntMatcherTest {
 
-  private SyntMatcher syntMatcher;
+  private ParserChunker2MatcherProcessor parserChunker2MatcherOlderOpenNLP;
 
   private ParseTreeChunk parseTreeChunk = new ParseTreeChunk();
 
-  @Test
   public void notNullTest() {
-    syntMatcher = SyntMatcher.getInstance();
-    assertNotNull(syntMatcher);
+    parserChunker2MatcherOlderOpenNLP = ParserChunker2MatcherProcessor.getInstance();
+    assertNotNull(parserChunker2MatcherOlderOpenNLP);
   }
 
-  @Test
   public void matchTest() {
-    syntMatcher = SyntMatcher.getInstance();
-    List<List<ParseTreeChunk>> matchResult = syntMatcher
-        .matchOrigSentencesCache(
+    parserChunker2MatcherOlderOpenNLP = ParserChunker2MatcherProcessor.getInstance();
+    List<List<ParseTreeChunk>> matchResult = parserChunker2MatcherOlderOpenNLP
+        .assessRelevance(
             // "Can I get auto focus lens for digital camera",
             // "How can I get short focus zoom lens for digital camera"
             "Pulitzer Prize-Winning Reporter is an Illegal Immigrant",
-            "Gay Pulitzer Prize-Winning Reporter Jose Antonio Vargas Comes Out as Undocumented Immigrant Jose Antonio Vargas, a gay journalist who won a Pulitzer Prize for his coverage of the Virginia Tech shootings in the Washington Post");
+            "Gay Pulitzer Prize-Winning Reporter Jose Antonio Vargas Comes Out as Undocumented " +
+            "Immigrant Jose Antonio Vargas, a gay journalist who won a Pulitzer Prize " +
+            "for his coverage of the Virginia Tech shootings in the Washington Post")
+           .getMatchResult();
 
     System.out.println(matchResult);
     assertEquals(
@@ -56,10 +59,11 @@ public class SyntMatcherTest {
         parseTreeChunk.listToString(matchResult),
         " np [ [NNP-pulitzer JJ-prize-winning NN-reporter ],  [NNP-* ],  [JJ-* NN-immigrant ]] vp [ [JJ-* NN-immigrant ]]");
 
-    matchResult = syntMatcher
-        .matchOrigSentencesCache(
+    matchResult = parserChunker2MatcherOlderOpenNLP
+        .assessRelevance(
             "Sounds too good to be true but it actually is, the world's first flying car is finally here. ",
-            "While it may seem like something straight out of a sci-fi movie, the  flying  car  might soon become a reality. ");
+            "While it may seem like something straight out of a sci-fi " +
+            "movie, the  flying  car  might soon become a reality. ").getMatchResult();
 
     System.out.println(matchResult);
     assertEquals(matchResult.toString(),
@@ -72,11 +76,10 @@ public class SyntMatcherTest {
 
   @Test
   public void matchTestDigitalCamera() {
-    syntMatcher = SyntMatcher.getInstance();
-    List<List<ParseTreeChunk>> matchResult = syntMatcher
-        .matchOrigSentencesCache(
+    parserChunker2MatcherOlderOpenNLP = ParserChunker2MatcherProcessor.getInstance();
+    List<List<ParseTreeChunk>> matchResult = parserChunker2MatcherOlderOpenNLP.assessRelevance(       
             "I am curious how to use the digital zoom of this camera for filming insects",
-            "How can I get short focus zoom lens for digital camera");
+            "How can I get short focus zoom lens for digital camera").getMatchResult();
 
     System.out.println(matchResult);
     assertEquals(
@@ -87,9 +90,9 @@ public class SyntMatcherTest {
         parseTreeChunk.listToString(matchResult),
         " np [ [NN-zoom ],  [JJ-digital NN-* ],  [NN-camera ]] vp [ [JJ-digital NN-* ],  [NN-zoom NN-camera ],  [NN-* IN-for ]]");
 
-    matchResult = syntMatcher.matchOrigSentencesCache(
+    matchResult = parserChunker2MatcherOlderOpenNLP.assessRelevance(
         "Can I get auto focus lens for digital camera",
-        "How can I get short focus zoom lens for digital camera");
+        "How can I get short focus zoom lens for digital camera").getMatchResult();
 
     System.out.println(matchResult);
     assertEquals(