diff --git a/hdt-lib/qmake/hdt-lib.pro b/hdt-lib/qmake/hdt-lib.pro index c348c78f..4cb6572a 100644 --- a/hdt-lib/qmake/hdt-lib.pro +++ b/hdt-lib/qmake/hdt-lib.pro @@ -102,7 +102,6 @@ SOURCES += \ ../src/util/bitutil.cpp \ ../src/util/filemap.cpp \ ../third/gzstream.cpp \ - ../src/rdf/RDFParserNtriplesCallback.cpp \ ../src/triples/predicateindex.cpp HEADERS += \ @@ -187,7 +186,6 @@ HEADERS += \ ../src/util/filemap.h \ ../third/fdstream.hpp \ ../third/gzstream.h \ - ../src/rdf/RDFParserNtriplesCallback.hpp \ ../src/triples/predicateindex.hpp #For hdt-lib diff --git a/hdt-lib/src/rdf/RDFParserNtriplesCallback.cpp b/hdt-lib/src/rdf/RDFParserNtriplesCallback.cpp deleted file mode 100644 index ebe5bafd..00000000 --- a/hdt-lib/src/rdf/RDFParserNtriplesCallback.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* - * RDFParserNtriplesCallback.cpp - * - * Created on: 05/03/2011 - * Author: mck - */ - -#include "RDFParserNtriplesCallback.hpp" -#include "RDFParser.hpp" -#include "../util/fileUtil.hpp" -#include "../util/unicode.hpp" -#include -#include -#include - -using namespace std; - -namespace hdt { - -RDFParserNtriplesCallback::RDFParserNtriplesCallback() -{ -} - -RDFParserNtriplesCallback::~RDFParserNtriplesCallback() { - -} - -void RDFParserNtriplesCallback::doParse(const char *fileName, const char *baseUri, RDFNotation notation, bool ignoreErrors,RDFCallback *callback) { - - DecompressStream stream(fileName); - istream *in=stream.getStream(); - - string line; - string origLine; - size_t numline=0; - uint64_t numByte=0; - TripleString ts; - - while(in->good()){ - getline(*in, line); - origLine.assign(line); - - numByte+=line.length()+1; - numline++; - - int pos = 0; - size_t firstIndex = 0; - size_t lastIndex = 0; - bool errorParsing = false; - - vector node(3); - - while (true) { - line = line.substr(firstIndex); - - if (line == "." || line == "\n" || line == "" || line.at(0) == '#') - break; - - //obvious space - if (line.at(0) == ' ') { - //do nothing - lastIndex = 0; - } - //URI - else if (line.at(0) == '<') { - lastIndex = line.find(">"); - //check size of pos - if (pos > 2) { - errorParsing = true; - break; - } - node[pos] = line.substr(1, lastIndex-1); - pos++; - } - //Literal - else if (line.at(0) == '"') { - lastIndex = line.find('"', 1); - //check if literal is escaped - while (true) { - bool escaped = false; - int temp = lastIndex - 1; - - while (temp > 0 && line.at(temp) == '\\') { - if (escaped) - escaped = false; - else - escaped = true; - temp--; - } - - if (!escaped) - break; - lastIndex++; - if (lastIndex == line.length()) - //Cannot find the (unescaped) end - errorParsing = true; - lastIndex = line.find('"', lastIndex); - if (lastIndex == string::npos) - //Cannot find the (unescaped) end - errorParsing = true; - } - - // literal can extend to a bit more than just the ", - // also take into account lang and datatype strings - if (line.at(lastIndex + 1) == '@') { - // find end of literal/lang tag - lastIndex = line.find(' ', lastIndex + 1) - 1; - } else if (line.at(lastIndex + 1) == '^') { - lastIndex = line.find('>', lastIndex + 1); - } - //check size of pos - if (pos > 2) { - errorParsing = true; - break; - } - - // Substitute encoded unicode chars \uXXXX - string replaced; - - int previous=0, current=0; - - try { - // If the string is bigger than 6 chars (otherwise it wont have any \uXXXX code) - - // Check until 2 characters before end. - while(current 2) { - errorParsing = true; - break; - } - node[pos] = line.substr(0, lastIndex); - pos++; - } - //parameter or variable ---> obviate for Triples. In future, add to a Hash - else if (line.at(0) == '@' || line.at(0) == '?') { - break; - } - // test if number - else { - // else it is a parsing error - lastIndex = line.find(" "); - - if(lastIndex!=string::npos) { - for (size_t j = 0; j < lastIndex; j++) { - if (!isdigit(line.at(j)) && line.at(j) != '.' && line.at(j) - != ',' && line.at(j) != '-') { - errorParsing = true; - } - } - } else { - errorParsing = true; - } - - if (errorParsing == false) { - node[pos] = line.substr(0, lastIndex); - pos++; - } - - break; - } - - firstIndex = lastIndex + 1; - } - - if (errorParsing == true || (pos != 0 && pos != 3)) { - // cerr << endl << "Error parsing file at line " << numline << "|" << origLine << "|" << endl << endl; - throw ParseException(numline, "Error parsing file: |" + origLine + "|"); - } - - if(pos==3) { - ts.setAll(node[0], node[1], node[2]); - callback->processTriple(ts, numByte); - } - } - - stream.close(); -} - -} diff --git a/hdt-lib/src/rdf/RDFParserNtriplesCallback.hpp b/hdt-lib/src/rdf/RDFParserNtriplesCallback.hpp deleted file mode 100644 index 0bbe07e8..00000000 --- a/hdt-lib/src/rdf/RDFParserNtriplesCallback.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * RDFParserN3.h - * - * Created on: 05/03/2011 - * Author: mck - */ - -#ifndef RDFPARSERNTRIPLESCALLBACK_H_ -#define RDFPARSERNTRIPLESCALLBACK_H_ - -#include - -#include - -#include "RDFParser.hpp" - -namespace hdt { - -class RDFParserNtriplesCallback : public RDFParserCallback { - -private: - RDFCallback *callback; - - const char *getParserType(RDFNotation notation); -public: - RDFParserNtriplesCallback(); - virtual ~RDFParserNtriplesCallback(); - - void doParse(const char *fileName, const char *baseUri, RDFNotation notation, bool ignoreErrors, RDFCallback *callback); -}; - - - -} - -#endif