package UGPGStudentsExample;

import java.sql.*;
import java.io.*;
import java.util.HashMap;
import java.util.ArrayList;
import uk.ac.ic.doc.automed.ssd.*;
import uk.ac.ic.doc.automed.*;

/**
 * An application to demonstrate how to create patterns for 
 * semistructured data
 */

public class DefinePatterns {

    public static void createPatterns()
	throws SQLException, IOException
    {
	//Create patterns for s1
	Pattern.retract("pname");
	Pattern pname=Pattern.createPattern("pname", "name\\\\s=\\\\s(.*)");
	Pattern.retract("ptutor");
	Pattern ptutor=Pattern.createPattern("ptutor", "tutor\\\\s=\\\\s(.*)");
	Pattern.retract("pppt");
	Pattern pppt=Pattern.createPattern("pppt", "ppt\\\\s=\\\\s(.*)");
	Pattern.retract("pdept");
	Pattern pdept=Pattern.createPattern("pdept", "dept\\\\s=\\\\s(.*)");
	Pattern.retract("pcode");
	Pattern pcourse=Pattern.createPattern("pcode", "course\\\\s=\\\\s(.*)");
	Pattern.retract("pyear");
	Pattern pyear=Pattern.createPattern("pyear", "year\\\\s=\\\\s(\\\\d)");
	Pattern.retract("pgrade");
	Pattern pgrade=Pattern.createPattern("pgrade", "grade\\\\s=\\\\s([A-F])?");
	//Create patterns for s2
	Pattern.retract("s2_course");
	Pattern s2_course=Pattern.createPattern("s2_course", "\\\\[(\\\\w+),(\\\\w+)\\\\]");
	Pattern.retract("s2_student");
	Pattern s2_student=Pattern.createPattern("s2_student", "(\\\\w+),(\\\\w+),(\\\\d),([A-F])?");

    }
 
    public static void main(String[] args) 
    {
	try 
	{
	    System.out.println("Creating Patterns ...");
	    createPatterns();
	}
	catch (SQLException se) { 
	    se.printStackTrace();
	}
	catch (IOException ie) {
	    ie.printStackTrace();
	}
    }

}










