Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
taku910 committed Mar 2, 2014
1 parent 25a9e06 commit 9949db1
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 6 deletions.
6 changes: 6 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
/* Define if you have the iconv() function and it works. */
#undef HAVE_ICONV

/* */
#undef HAVE_ICONV_CP932

/* */
#undef HAVE_ICONV_EUC_JP_MS

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

Expand Down
15 changes: 15 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2573,6 +2573,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu





am__api_version='1.11'

ac_aux_dir=
Expand Down Expand Up @@ -17721,6 +17723,19 @@ then
LIBS="$LIBS $MECAB_LIBS"
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether iconv supports EUC-JP-MS and CP932" >&5
$as_echo_n "checking whether iconv supports EUC-JP-MS and CP932... " >&6; }
if iconv -l | grep -i 'euc-jp-ms' > /dev/null; then
$as_echo "#define HAVE_ICONV_EUC_JP_MS 1" >>confdefs.h

fi

if iconv -l | grep -i 'cp932' > /dev/null; then
$as_echo "#define HAVE_ICONV_CP932 1" >>confdefs.h

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lstdc++" >&5
$as_echo_n "checking for main in -lstdc++... " >&6; }
if ${ac_cv_lib_stdcpp_main+:} false; then :
Expand Down
12 changes: 12 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
AC_INIT(src/cabocha.cpp)
AH_TEMPLATE([HAVE_TLS_KEYWORD], [])
AH_TEMPLATE([HAVE_ICONV_EUC_JP_MS], [])
AH_TEMPLATE([HAVE_ICONV_CP932], [])
AM_INIT_AUTOMAKE(cabocha, 0.68)
AM_MAINTAINER_MODE

Expand Down Expand Up @@ -109,6 +111,16 @@ then
LIBS="$LIBS $MECAB_LIBS"
fi


AC_MSG_CHECKING(whether iconv supports EUC-JP-MS and CP932)
if iconv -l | grep -i 'euc-jp-ms' > /dev/null; then
AC_DEFINE([HAVE_ICONV_EUC_JP_MS])
fi

if iconv -l | grep -i 'cp932' > /dev/null; then
AC_DEFINE([HAVE_ICONV_CP932])
fi

AC_CHECK_LIB(stdc++, main, STDCPP_LIBS="-lstdc++")
AC_CHECK_LIB(crfpp, crfpp_new, STDCRFPP_LIBS="-lcrfpp")
AC_CHECK_LIB(mecab, mecab_new, CRFPP_LIBS="-lmecab")
Expand Down
10 changes: 5 additions & 5 deletions man/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ CABOCHA_USE_UTF8_ONLY =
CC = gcc
CCDEPMODE = depmode=none
CFLAGS = -O3 -Wno-deprecated -Wall
CHARSET = utf8
CHARSET = EUC-JP
CPP = gcc -E
CPPFLAGS =
CXX = g++
Expand Down Expand Up @@ -131,7 +131,7 @@ LN_S = ln -s
LTLIBICONV =
LTLIBOBJS =
LTVERSION = 4:0:0
MAINT = #
MAINT =
MAKEINFO = ${SHELL} /home/taku/proj/cabocha/missing --run makeinfo
MANIFEST_TOOL = :
MECAB_CFLAGS =
Expand Down Expand Up @@ -218,7 +218,7 @@ EXTRA_DIST = $(man_MANS)
all: all-am

.SUFFIXES:
$(srcdir)/Makefile.in: # $(srcdir)/Makefile.am $(am__configure_deps)
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
Expand All @@ -243,9 +243,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh

$(top_srcdir)/configure: # $(am__configure_deps)
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): # $(am__aclocal_m4_deps)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):

Expand Down
10 changes: 9 additions & 1 deletion src/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ bool MorphAnalyzer::open(const Param &param) {
CHECK_FALSE(action_mode() == PARSING_MODE)
<< "MorphAnalyzer supports PARSING_MODE only";

const std::string mecabrc = param.get<std::string>("mecabrc");
std::vector<const char *> argv;
argv.push_back(param.program_name());

const std::string mecabrc = param.get<std::string>("mecabrc");
if (!mecabrc.empty()) {
argv.push_back("-r");
argv.push_back(mecabrc.c_str());
Expand All @@ -168,6 +169,13 @@ bool MorphAnalyzer::open(const Param &param) {
argv.push_back(mecabdic.c_str());
}

const std::string mecabuserdic =
param.get<std::string>("mecab-userdic");
if (!mecabuserdic.empty()) {
argv.push_back("-u");
argv.push_back(mecabuserdic.c_str());
}

mecab_ = mecab_new_f(argv.size(),
const_cast<char **>(&argv[0]));
CHECK_FALSE(mecab_) << mecab_strerror_f(0);
Expand Down
1 change: 1 addition & 0 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const CaboCha::Option long_options[] = {
{ "rcfile", 'r', 0, "FILE", "use FILE as resource file" },
{ "mecabrc", 'b', 0, "FILE", "use FILE as mecabrc"},
{ "mecab-dicdir", 'd', 0, "DIR", "use DIR as mecab dictionary directory"},
{ "mecab-userdic", 'u', 0, "FILE", "use FILE as mecab user directory"},
{ "output", 'o', 0, "FILE", "use FILE as output file"},
{ "version", 'v', 0, 0, "show the version and exit"},
{ "help", 'h', 0, 0, "show this help and exit"},
Expand Down
8 changes: 8 additions & 0 deletions src/ucs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,17 @@ const char *encode_charset(CharsetType charset) {
case UTF8:
return "UTF8";
case EUC_JP:
#ifdef HAVE_ICONV_EUC_JP_MS
return "EUC-JP-MS";
#else
return "EUC-JP";
#endif
case CP932:
#ifdef HAVE_ICONV_CP932
return "CP932";
#else
return "SHIFT_JIS";
#endif
default:
std::cerr << "charset " << charset
<< " is not defined, use " CABOCHA_DEFAULT_CHARSET;
Expand Down

0 comments on commit 9949db1

Please sign in to comment.