Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

varnamc CLI utility in C #157

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ examples/stemmer
distribution-tarball/
testrun.log
testrun.xml

varnamc
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/deps/cma

set(VARNAM_LIBRARY_NAME "varnam")
set(VARNAM_LIBRARY_NAME_STATIC "varnamstatic")
set(VARNAM_BINARY_NAME "varnamc")
set(DEPS_LIBRARY_NAME "deps")

set(VARNAM_VERSION_MAJOR 3)
Expand Down Expand Up @@ -156,7 +157,7 @@ if (BUILD_VST)
# Each scheme will have a target to compile
# vst will have a dependency to all these targets so that running vst will compile all the scheme files
foreach(scheme ${SUPPORTED_SCHEMES})
add_custom_target (${scheme}.vst COMMAND ./varnamc --compile schemes/${scheme})
add_custom_target (${scheme}.vst COMMAND ./varnamc.rb --compile schemes/${scheme})
add_dependencies (vst "${scheme}.vst")
install (FILES schemes/${scheme}.vst DESTINATION ${CMAKE_INSTALL_PREFIX}/share/varnam/vst OPTIONAL)
endforeach()
Expand Down Expand Up @@ -189,6 +190,7 @@ INSTALL ( FILES ${CMAKE_BINARY_DIR}/varnamstatic.pc DESTINATION ${VARNAM_LIB_INS
INSTALL ( FILES varnamruby.rb DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
INSTALL_PROGRAMS(/bin FILES varnamc)
INSTALL ( FILES varnamc.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)
INSTALL_PROGRAMS(/bin FILES varnamc.rb)

# uninstall target
configure_file(
Expand All @@ -207,3 +209,10 @@ else()
target_link_libraries(${VARNAM_LIBRARY_NAME} pthread dl ${SQLITE3_LIBRARIES})
ENDIF()

# argp doesn't by default exist for windows
# TODO make varnamc work on windows too
IF(!MSVC)
FILE(GLOB_RECURSE SOURCES varnamc.c)
ADD_EXECUTABLE(${VARNAM_BINARY_NAME} ${SOURCES})
target_link_libraries(${VARNAM_BINARY_NAME} ${VARNAM_LIBRARY_NAME})
ENDIF()
6 changes: 3 additions & 3 deletions tests/varnamc_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
START_TEST (learn_failures_file_should_not_be_created_always)
{
int exitcode;
exitcode = system ("../varnamc -s ml -t varnam -d output/");
exitcode = system ("../varnamc.rb -s ml -t varnam -d output/");
ck_assert_int_eq (0, exitcode);
ck_assert_int_eq (0, file_exist ("output/varnamc-learn-failures.txt"));
ck_assert_int_eq (0, file_exist ("output/varnamc-train-failures.txt"));
Expand All @@ -27,7 +27,7 @@ START_TEST (learn_failures_file_should_be_created_upon_failures)

filename = create_text_file ("not-valid-indic-word");
command = strbuf_init (20);
strbuf_addf (command, "../varnamc -s ml --learn-from %s -d output/", filename);
strbuf_addf (command, "../varnamc.rb -s ml --learn-from %s -d output/", filename);
exitcode = system (strbuf_to_s (command));
ck_assert_int_eq (0, exitcode);
ck_assert_int_eq (1, file_exist ("output/varnamc-learn-failures.txt"));
Expand All @@ -50,7 +50,7 @@ START_TEST (training_failures_file_should_be_created_upon_failures)

filename = create_text_file ("not-valid-indic-word");
command = strbuf_init (20);
strbuf_addf (command, "../varnamc -s ml --train-from %s -d output/", filename);
strbuf_addf (command, "../varnamc.rb -s ml --train-from %s -d output/", filename);
exitcode = system (strbuf_to_s (command));
ck_assert_int_eq (0, exitcode);
ck_assert_int_eq (1, file_exist ("output/varnamc-train-failures.txt"));
Expand Down
Loading