// @copyright@ // This file is part of nzdis-kif package. See the file LICENSE for copyright information // and the terms and conditions for copying, distribution and modification of nzdis-kif package. package nzdis.lang.kif.app; /**/ import nzdis.lang.kif.node.*; import nzdis.lang.kif.pattern.*; import nzdis.lang.kif.tool.PatternMatcher; import nzdis.lang.kif.tool.TreeBuilder; import java.io.*; import java.util.*; /** * Testing application class for KIF pattern matcher. * The pattern should be embedded into the string and given as * a second parameter, and interpreted against given KIF file, which name * is given as first parameter e.g. numbers.kif "(plus :x :y)" * *@author Mariusz Nowostawski *@version @version@ $Revision: 1.2 $ */ public class MatchPattern { public static void main(String[] arguments) { if(arguments.length != 2) { System.out.println("usage:"); System.out.println(" java MatcherTest file.kif \"pattern\""); System.exit(1); } try { Node astKIF = TreeBuilder.getNode( new PushbackReader( new BufferedReader( new FileReader(arguments[0])), 1024)); Hashtable[] h = PatternMatcher.match(astKIF, arguments[1]); System.out.println("** ** ** **"); System.out.println(" results number: "+h.length); for(int i=0; i