Hi, I wrote a code to format a triple (subject predicate object) text
file in a way that is importable by MySql. The problem is that, in
some of the triples, the object portion consists of words separated by
spaces; therefore, instead of my the entire words to be inputed as a
single string, only the first word is inputed and the remaining words
gets converted into series of SPO's (subject, object, predicate). 
Kindly help with what I could do to store the object portion as a
single string in as much as they are on the same line.

The codes and data sample is pasted below


Code

// rdef.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
        string s, p, o;
        char inLine[500];

        //opening input and output files
        ifstream inFile("c:\\rdfp\\tst.txt");
        ofstream outFile("c:\\rdfp\\out.txt");

        if(!inFile.fail()) {

                while(!inFile.eof()) {
                        //reads subject, predicate and object
                        inFile >> s ;
                        inFile >> p ;
                        inFile >> o ;
                        
                        //outputs subject predicate and object in mysql 
importable format 
                        //into the output file

                        outFile << "insert into rdf_triple values (";
                        outFile << "\"" << s << "\"" << ",";
                        outFile << "\"" << p << "\"" << ",";
                        outFile << "\"" << o << "\"";
                        outFile << ");" << endl;
                
                }
                
                cout << "Output written to file successfully \n\n";

                inFile.close();
                outFile.close();
        } else 
                cout << "Error Opening File.";

        system("PAUSE");
        return 0;
}


Data sample 

<#sd> <http://www.w3.org/2000/01/rdf-schema#comment> ResearchCyc
Ontology OpenCyc License Information\n The contents
of this file constitute portions of The OpenCyc\n Knowledge
Base. The OpenCyc Knowledge Base is protected\n under the following
license and copyrights. This license and\n copyright information
must be included with any copies.


Note:  Here <#sd> will be stored as SUBJECT,
<http://www.w3.org/2000/01/rdf-schema#comment> will be stored as
PREDICATE, while I want "ResearchCyc
Ontology OpenCyc License Information\n The contents
of this file constitute portions of The OpenCyc\n Knowledge
Base. The OpenCyc Knowledge Base is protected\n under the following
license and copyrights. This license and\n copyright information
must be included with any copies" stored as OBJECT

Reply via email to