From: <jen...@us...> - 2008-02-08 09:04:02
|
Revision: 528 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=528&view=rev Author: jenslehmann Date: 2008-02-08 01:04:00 -0800 (Fri, 08 Feb 2008) Log Message: ----------- wrote Prolog parser test (found problems with negative numbers) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/utilities/Files.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java Added: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-08 09:04:00 UTC (rev 528) @@ -0,0 +1,62 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.examples; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.dllearner.parser.ParseException; +import org.dllearner.parser.PrologParser; +import org.dllearner.utilities.Files; + +/** + * This class maps the carcinogenesis Prolog files to an OWL file. In a first + * step, a Prolog parser is used to read all files. The main step involves + * applying mapping Prolog clauses to OWL axioms through domain specific mapping + * rules. + * + * @author Jens Lehmann + * + */ +public class Carcinogenesis { + + /** + * @param args + */ + public static void main(String[] args) { + + try { + String prologFile = "examples/carcinogenesis/prolog/atoms.pl"; + File file = new File(prologFile); + String content = Files.readFile(file); + PrologParser pp = new PrologParser(); + pp.parseProgram(content); + } catch (ParseException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + +} Modified: trunk/src/dl-learner/org/dllearner/utilities/Files.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-02-08 08:59:26 UTC (rev 527) +++ trunk/src/dl-learner/org/dllearner/utilities/Files.java 2008-02-08 09:04:00 UTC (rev 528) @@ -19,10 +19,14 @@ */ package org.dllearner.utilities; +import java.io.BufferedReader; +import java.io.DataInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStreamReader; /** * @author Jens Lehmann @@ -31,6 +35,26 @@ public class Files { /** + * Reads in a file. + * + * @param file + * The file to read. + * @return Content of the file. + */ + public static String readFile(File file) throws FileNotFoundException, IOException { + FileInputStream fstream = new FileInputStream(file); + DataInputStream in = new DataInputStream(fstream); + BufferedReader br = new BufferedReader(new InputStreamReader(in)); + String line; + StringBuffer content = new StringBuffer(); + while ((line = br.readLine()) != null) { + content.append(line); + } + in.close(); + return content.toString(); + } + + /** * Creates a new file with the given content or replaces the content of a * file. * @@ -74,7 +98,7 @@ e.printStackTrace(); } } - + public static void clearFile(File file) { createFile(file, ""); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |