Skip to content

Commit

Permalink
kv named
Browse files Browse the repository at this point in the history
  • Loading branch information
brook hong committed Jun 9, 2013
1 parent 25e9f87 commit 7adee8e
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 8 deletions.
15 changes: 10 additions & 5 deletions README.md
@@ -1,13 +1,18 @@
Dictionary Compiler for StarDict
#Command line dictionary tool -- `kv`

The `dc` can help to extract plain text from a dictionary of StarDict, for example,
The `kv` can

dc extract oxford.idx
extract plain text from a dictionary of StarDict, for example,

kv extract oxford.idx

Also can help to build a dictionary of StarDict from a plain text file, like,
build a dictionary of StarDict from a plain text file, like,

dc build oxford.txt
kv build oxford.txt

query by keyword from a specified dictionary,

kv query oxford.idx key


The plain text file should be formated like this:
Expand Down
25 changes: 25 additions & 0 deletions indexfile.cpp
@@ -1,3 +1,28 @@
/*
* Copyright (c) 2013 Brook Hong
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify,
* merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "indexfile.h"
const char *IndexFile::CACHE_MAGIC="StarDict's Cache, Version: 0.1";

Expand Down
25 changes: 25 additions & 0 deletions indexfile.h
@@ -1,3 +1,28 @@
/*
* Copyright (c) 2013 Brook Hong
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify,
* merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef _INDEXFILE_HPP_
#define _INDEXFILE_HPP_
#include <string>
Expand Down
6 changes: 3 additions & 3 deletions dc.cpp → kv.cpp
Expand Up @@ -24,8 +24,8 @@
*
*
* BUILD INSTRUCTIONS
* LINUX : g++ -DHAVE_MMAP dc.cpp md5.cpp indexfile.cpp
* WINDOWS : cl -D_WIN32 dc.cpp md5.cpp indexfile.cpp
* LINUX : g++ -DHAVE_MMAP kv.cpp md5.cpp indexfile.cpp
* WINDOWS : cl -D_WIN32 kv.cpp md5.cpp indexfile.cpp
*/
#include "mapfile.hpp"
#include "indexfile.h"
Expand Down Expand Up @@ -273,7 +273,7 @@ void queryDict(const char *idxFileName, const char *keyword) {
}
}
int showUsage() {
printf( "Usage: dc -- a simple dict tool to build dict, extract dict and query\n\n"
printf( "Usage: kv -- a simple dict tool to build dict, extract dict and query\n\n"
"Build\n\tdc build [-t <title>] [-k <key marker>] <path to plain txt file>\n\n"
"Extract\n\tdc extract <path to .idx file>\n\n"
"Query\n\tdc query <path to .idx file> <keyword>\n"
Expand Down
25 changes: 25 additions & 0 deletions mapfile.hpp
@@ -1,3 +1,28 @@
/*
* Copyright (c) 2013 Brook Hong
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify,
* merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef _MAPFILE_HPP_
#define _MAPFILE_HPP_

Expand Down

0 comments on commit 7adee8e

Please sign in to comment.