Skip to content

Commit 7d92f3f

Browse files
Merge branch 'develop' of github.com:rdfhdt/hdt-cpp into develop
2 parents d16e9b1 + 54bccf9 commit 7d92f3f

2 files changed

Lines changed: 32 additions & 12 deletions

File tree

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,28 @@ Then, run:
4141
After building, these are the typical operations that you will perform:
4242

4343
- Convert your RDF data to HDT:
44-
44+
45+
NB: the input stream is assumed to be valid RDF, so you should validate your data before feeding it into rdf2hdt.
46+
47+
```
4548
$ tools/rdf2hdt data/test.nt data/test.hdt
49+
```
50+
51+
- Create only the index of an HDT file:
4652
47-
NB: the input stream is assumed to be valid RDF, so you should validate your data before feeding it into rdf2hdt.
53+
```
54+
$ tools/hdtSearch -q 0 data/test.hdt
55+
```
4856
4957
- Convert an HDT to another RDF serialization format, such as N-Triples:
5058
59+
```
5160
$ tools/hdt2rdf data/test.hdt data/test.hdtexport.nt
61+
```
5262
5363
- Open a terminal to search triple patterns within an HDT file:
5464
65+
```
5566
$ tools/hdtSearch data/test.hdt
5667
>> ? ? ?
5768
http://example.org/uri3 http://example.org/predicate3 http://example.org/uri4
@@ -72,14 +83,19 @@ NB: the input stream is assumed to be valid RDF, so you should validate your dat
7283
2 results shown.
7384
7485
>> exit
86+
```
7587
7688
- Extract the Header of an HDT file:
7789
90+
```
7891
$ tools/hdtInfo data/test.hdt > header.nt
92+
```
7993
8094
- Replace the Header of an HDT file with a new one. For example, by editing the existing one as extracted using `hdtInfo`:
8195
96+
```
8297
$ tools/replaceHeader data/test.hdt data/testOutput.hdt newHeader.nt
98+
```
8399
84100
## Contributing
85101

libhdt/tools/rdf2hdt.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,21 @@ int main(int argc, char **argv) {
164164
if (dot_position != string::npos)
165165
// Extract extension from file name
166166
rdfFormat = inputFile.substr (dot_position + 1, string::npos);
167+
168+
/**
169+
* If rdfFormat is still "", it means -f was not specified and the file
170+
* didn't have any extension. The default format is defined at the top
171+
* of this file: RDFNotation notation = NTRIPLES;
172+
*/
173+
if (rdfFormat == "")
174+
{
175+
rdfFormat = "nt";
176+
vout << "No input format detected. Using default: NTRIPLES." << endl;
177+
}
167178
}
168-
179+
180+
// ASSERT: here rdfFormat must be != ""
181+
169182
// Lower-case rdfFormat
170183
transform (rdfFormat.begin (), rdfFormat.end (), rdfFormat.begin (), ::tolower);
171184

@@ -180,15 +193,6 @@ int main(int argc, char **argv) {
180193
notation = TURTLE;
181194
else if (rdfFormat == "rdfxml" || rdfFormat == "xml")
182195
notation = XML;
183-
184-
/**
185-
* If rdfFormat is still "", it means -f was not specified and the file
186-
* didn't have any extension. The default format is defined at the top
187-
* of this file: RDFNotation notation = NTRIPLES;
188-
*/
189-
else if (rdfFormat == "")
190-
vout << "No input format detected. Using default: NTRIPLES." << endl;
191-
192196
// -f or file extension detected, but didn't match any valid format.
193197
else {
194198
cerr << "ERROR: Detected \"" << rdfFormat << "\" input format. Must be one of:" << endl

0 commit comments

Comments
 (0)