diff --git a/CRF/java/.am b/CRF/java/.am
index 0608003b7dc378ad7a8674445fd2dbf8094b1a81..2c3332e83629c844a656374dbc551e7171724454 100644
--- a/CRF/java/.am
+++ b/CRF/java/.am
@@ -1,27 +1,27 @@
-TARGET=MeCab
-JAVAC=javac
-JAVA=java
-JAR=jar
-CXX=c++
-INCLUDE=/usr/lib/jvm/java-6-openjdk/include
-
-PACKAGE=org/chasen/mecab
-
-LIBS=`mecab-config --libs`
-INC=`mecab-config --cflags` -I$(INCLUDE) -I$(INCLUDE)/linux
-
-all:
- $(CXX) -O3 -c -fpic $(TARGET)_wrap.cxx $(INC)
- $(CXX) -shared $(TARGET)_wrap.o -o lib$(TARGET).so $(LIBS)
- $(JAVAC) $(PACKAGE)/*.java
- $(JAVAC) test.java
- $(JAR) cfv $(TARGET).jar $(PACKAGE)/*.class
-
-test:
- env LD_LIBRARY_PATH=. $(JAVA) test
-
-clean:
- rm -fr *.jar *.o *.so *.class $(PACKAGE)/*.class
-
-cleanall:
- rm -fr $(TARGET).java *.cxx
+TARGET=MeCab
+JAVAC=javac
+JAVA=java
+JAR=jar
+CXX=c++
+INCLUDE=/usr/lib/jvm/java-6-openjdk/include
+
+PACKAGE=org/chasen/mecab
+
+LIBS=`mecab-config --libs`
+INC=`mecab-config --cflags` -I$(INCLUDE) -I$(INCLUDE)/linux
+
+all:
+ $(CXX) -O3 -c -fpic $(TARGET)_wrap.cxx $(INC)
+ $(CXX) -shared $(TARGET)_wrap.o -o lib$(TARGET).so $(LIBS)
+ $(JAVAC) $(PACKAGE)/*.java
+ $(JAVAC) test.java
+ $(JAR) cfv $(TARGET).jar $(PACKAGE)/*.class
+
+test:
+ env LD_LIBRARY_PATH=. $(JAVA) test
+
+clean:
+ rm -fr *.jar *.o *.so *.class $(PACKAGE)/*.class
+
+cleanall:
+ rm -fr $(TARGET).java *.cxx
diff --git a/CRF/java/org/chasen/crfpp/Model.java b/CRF/java/org/chasen/crfpp/Model.java
index 2ec8ad6b5d0d483d21e4d216498914b5c5fc0709..8e4f880f42022e35573b980bfc6a3a9f5843f799 100644
--- a/CRF/java/org/chasen/crfpp/Model.java
+++ b/CRF/java/org/chasen/crfpp/Model.java
@@ -1,51 +1,51 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.40
- *
- * Do not make changes to this file unless you know what you are doing--modify
- * the SWIG interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package org.chasen.crfpp;
-
-public class Model {
- private long swigCPtr;
- protected boolean swigCMemOwn;
-
- protected Model(long cPtr, boolean cMemoryOwn) {
- swigCMemOwn = cMemoryOwn;
- swigCPtr = cPtr;
- }
-
- protected static long getCPtr(Model obj) {
- return (obj == null) ? 0 : obj.swigCPtr;
- }
-
- protected void finalize() {
- delete();
- }
-
- public synchronized void delete() {
- if (swigCPtr != 0) {
- if (swigCMemOwn) {
- swigCMemOwn = false;
- CRFPPJNI.delete_Model(swigCPtr);
- }
- swigCPtr = 0;
- }
- }
-
- public Tagger createTagger() {
- long cPtr = CRFPPJNI.Model_createTagger(swigCPtr, this);
- return (cPtr == 0) ? null : new Tagger(cPtr, false);
- }
-
- public String what() {
- return CRFPPJNI.Model_what(swigCPtr, this);
- }
-
- public Model(String arg) {
- this(CRFPPJNI.new_Model(arg), true);
- }
-
-}
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.chasen.crfpp;
+
+public class Model {
+ private long swigCPtr;
+ protected boolean swigCMemOwn;
+
+ protected Model(long cPtr, boolean cMemoryOwn) {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = cPtr;
+ }
+
+ protected static long getCPtr(Model obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+
+ protected void finalize() {
+ delete();
+ }
+
+ public synchronized void delete() {
+ if (swigCPtr != 0) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ CRFPPJNI.delete_Model(swigCPtr);
+ }
+ swigCPtr = 0;
+ }
+ }
+
+ public Tagger createTagger() {
+ long cPtr = CRFPPJNI.Model_createTagger(swigCPtr, this);
+ return (cPtr == 0) ? null : new Tagger(cPtr, false);
+ }
+
+ public String what() {
+ return CRFPPJNI.Model_what(swigCPtr, this);
+ }
+
+ public Model(String arg) {
+ this(CRFPPJNI.new_Model(arg), true);
+ }
+
+}
diff --git a/CRF/perl/Makefile.old b/CRF/perl/Makefile.old
index c66615cf2588d54aa540d85c7716175cbd333766..1eef3c46b868e14a74c86cf94dce322594a4ddb3 100644
--- a/CRF/perl/Makefile.old
+++ b/CRF/perl/Makefile.old
@@ -1,931 +1,931 @@
-# This Makefile is for the CRFPP extension to perl.
-#
-# It was generated automatically by MakeMaker version
-# 6.56 (Revision: 65600) from the contents of
-# Makefile.PL. Don't edit this file, edit Makefile.PL instead.
-#
-# ANY CHANGES MADE HERE WILL BE LOST!
-#
-# MakeMaker ARGV: ()
-#
-
-# MakeMaker Parameters:
-
-# BUILD_REQUIRES => { }
-# CC => q[c++]
-# INC => q[]
-# LD => q[c++]
-# LIBS => q[-lpthread -lcrfpp]
-# NAME => q[CRFPP]
-# OBJECT => q[CRFPP_wrap.o]
-# PREREQ_PM => { }
-
-# --- MakeMaker post_initialize section:
-
-
-# --- MakeMaker const_config section:
-
-# These definitions are from config.sh (via /usr/lib/perl/5.12/Config.pm).
-# They may have been overridden via Makefile.PL or on the command line.
-AR = ar
-CC = c++
-CCCDLFLAGS = -fPIC
-CCDLFLAGS = -Wl,-E
-DLEXT = so
-DLSRC = dl_dlopen.xs
-EXE_EXT =
-FULL_AR = /usr/bin/ar
-LD = c++
-LDDLFLAGS = -shared -O2 -g -L/usr/local/lib -fstack-protector
-LDFLAGS = -fstack-protector -L/usr/local/lib
-LIBC =
-LIB_EXT = .a
-OBJ_EXT = .o
-OSNAME = linux
-OSVERS = 2.6.24-28-server
-RANLIB = :
-SITELIBEXP = /usr/local/share/perl/5.12.4
-SITEARCHEXP = /usr/local/lib/perl/5.12.4
-SO = so
-VENDORARCHEXP = /usr/lib/perl5
-VENDORLIBEXP = /usr/share/perl5
-
-
-# --- MakeMaker constants section:
-AR_STATIC_ARGS = cr
-DIRFILESEP = /
-DFSEP = $(DIRFILESEP)
-NAME = CRFPP
-NAME_SYM = CRFPP
-VERSION =
-VERSION_MACRO = VERSION
-VERSION_SYM =
-DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\"
-XS_VERSION =
-XS_VERSION_MACRO = XS_VERSION
-XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"
-INST_ARCHLIB = blib/arch
-INST_SCRIPT = blib/script
-INST_BIN = blib/bin
-INST_LIB = blib/lib
-INST_MAN1DIR = blib/man1
-INST_MAN3DIR = blib/man3
-MAN1EXT = 1p
-MAN3EXT = 3pm
-INSTALLDIRS = site
-DESTDIR =
-PREFIX = /usr
-PERLPREFIX = $(PREFIX)
-SITEPREFIX = $(PREFIX)/local
-VENDORPREFIX = $(PREFIX)
-INSTALLPRIVLIB = $(PERLPREFIX)/share/perl/5.12
-DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB)
-INSTALLSITELIB = $(SITEPREFIX)/share/perl/5.12.4
-DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB)
-INSTALLVENDORLIB = $(VENDORPREFIX)/share/perl5
-DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB)
-INSTALLARCHLIB = $(PERLPREFIX)/lib/perl/5.12
-DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB)
-INSTALLSITEARCH = $(SITEPREFIX)/lib/perl/5.12.4
-DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH)
-INSTALLVENDORARCH = $(VENDORPREFIX)/lib/perl5
-DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH)
-INSTALLBIN = $(PERLPREFIX)/bin
-DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN)
-INSTALLSITEBIN = $(SITEPREFIX)/bin
-DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN)
-INSTALLVENDORBIN = $(VENDORPREFIX)/bin
-DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN)
-INSTALLSCRIPT = $(PERLPREFIX)/bin
-DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT)
-INSTALLSITESCRIPT = $(SITEPREFIX)/bin
-DESTINSTALLSITESCRIPT = $(DESTDIR)$(INSTALLSITESCRIPT)
-INSTALLVENDORSCRIPT = $(VENDORPREFIX)/bin
-DESTINSTALLVENDORSCRIPT = $(DESTDIR)$(INSTALLVENDORSCRIPT)
-INSTALLMAN1DIR = $(PERLPREFIX)/share/man/man1
-DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR)
-INSTALLSITEMAN1DIR = $(SITEPREFIX)/man/man1
-DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR)
-INSTALLVENDORMAN1DIR = $(VENDORPREFIX)/share/man/man1
-DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR)
-INSTALLMAN3DIR = $(PERLPREFIX)/share/man/man3
-DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR)
-INSTALLSITEMAN3DIR = $(SITEPREFIX)/man/man3
-DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR)
-INSTALLVENDORMAN3DIR = $(VENDORPREFIX)/share/man/man3
-DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR)
-PERL_LIB = /usr/share/perl/5.12
-PERL_ARCHLIB = /usr/lib/perl/5.12
-LIBPERL_A = libperl.a
-FIRST_MAKEFILE = Makefile
-MAKEFILE_OLD = Makefile.old
-MAKE_APERL_FILE = Makefile.aperl
-PERLMAINCC = $(CC)
-PERL_INC = /usr/lib/perl/5.12/CORE
-PERL = /usr/bin/perl
-FULLPERL = /usr/bin/perl
-ABSPERL = $(PERL)
-PERLRUN = $(PERL)
-FULLPERLRUN = $(FULLPERL)
-ABSPERLRUN = $(ABSPERL)
-PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
-FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
-ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
-PERL_CORE = 0
-PERM_DIR = 755
-PERM_RW = 644
-PERM_RWX = 755
-
-MAKEMAKER = /usr/share/perl/5.12/ExtUtils/MakeMaker.pm
-MM_VERSION = 6.56
-MM_REVISION = 65600
-
-# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
-# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
-# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
-# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
-MAKE = make
-FULLEXT = CRFPP
-BASEEXT = CRFPP
-PARENT_NAME =
-DLBASE = $(BASEEXT)
-VERSION_FROM =
-INC =
-OBJECT = CRFPP_wrap$(OBJ_EXT)
-LDFROM = $(OBJECT)
-LINKTYPE = dynamic
-BOOTDEP =
-
-# Handy lists of source code files:
-XS_FILES =
-C_FILES = CRFPP_wrap.cxx
-O_FILES = CRFPP_wrap.o
-H_FILES =
-MAN1PODS =
-MAN3PODS =
-
-# Where is the Config information that we are using/depend on
-CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h
-
-# Where to build things
-INST_LIBDIR = $(INST_LIB)
-INST_ARCHLIBDIR = $(INST_ARCHLIB)
-
-INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
-INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
-
-INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)
-INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT)
-INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
-
-# Extra linker info
-EXPORT_LIST =
-PERL_ARCHIVE =
-PERL_ARCHIVE_AFTER =
-
-
-TO_INST_PM = CRFPP.pm
-
-PM_TO_BLIB = CRFPP.pm \
- $(INST_LIB)/CRFPP.pm
-
-
-# --- MakeMaker platform_constants section:
-MM_Unix_VERSION = 6.56
-PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc
-
-
-# --- MakeMaker tool_autosplit section:
-# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
-AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' --
-
-
-
-# --- MakeMaker tool_xsubpp section:
-
-XSUBPPDIR = /usr/share/perl/5.12/ExtUtils
-XSUBPP = $(XSUBPPDIR)$(DFSEP)xsubpp
-XSUBPPRUN = $(PERLRUN) $(XSUBPP)
-XSPROTOARG =
-XSUBPPDEPS = /usr/share/perl/5.12/ExtUtils/typemap $(XSUBPP)
-XSUBPPARGS = -typemap /usr/share/perl/5.12/ExtUtils/typemap
-XSUBPP_EXTRA_ARGS =
-
-
-# --- MakeMaker tools_other section:
-SHELL = /bin/sh
-CHMOD = chmod
-CP = cp
-MV = mv
-NOOP = $(TRUE)
-NOECHO = @
-RM_F = rm -f
-RM_RF = rm -rf
-TEST_F = test -f
-TOUCH = touch
-UMASK_NULL = umask 0
-DEV_NULL = > /dev/null 2>&1
-MKPATH = $(ABSPERLRUN) -MExtUtils::Command -e 'mkpath' --
-EQUALIZE_TIMESTAMP = $(ABSPERLRUN) -MExtUtils::Command -e 'eqtime' --
-FALSE = false
-TRUE = true
-ECHO = echo
-ECHO_N = echo -n
-UNINST = 0
-VERBINST = 0
-MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install([ from_to => {@ARGV}, verbose => '\''$(VERBINST)'\'', uninstall_shadows => '\''$(UNINST)'\'', dir_mode => '\''$(PERM_DIR)'\'' ]);' --
-DOC_INSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'perllocal_install' --
-UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' --
-WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' --
-MACROSTART =
-MACROEND =
-USEMAKEFILE = -f
-FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' --
-
-
-# --- MakeMaker makemakerdflt section:
-makemakerdflt : all
- $(NOECHO) $(NOOP)
-
-
-# --- MakeMaker dist section:
-TAR = tar
-TARFLAGS = cvf
-ZIP = zip
-ZIPFLAGS = -r
-COMPRESS = gzip --best
-SUFFIX = .gz
-SHAR = shar
-PREOP = $(NOECHO) $(NOOP)
-POSTOP = $(NOECHO) $(NOOP)
-TO_UNIX = $(NOECHO) $(NOOP)
-CI = ci -u
-RCS_LABEL = rcs -Nv$(VERSION_SYM): -q
-DIST_CP = best
-DIST_DEFAULT = tardist
-DISTNAME = CRFPP
-DISTVNAME = CRFPP-
-
-
-# --- MakeMaker macro section:
-
-
-# --- MakeMaker depend section:
-
-
-# --- MakeMaker cflags section:
-
-CCFLAGS = -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-OPTIMIZE = -O2 -g
-PERLTYPE =
-MPOLLUTE =
-
-
-# --- MakeMaker const_loadlibs section:
-
-# CRFPP might depend on some other libraries:
-# See ExtUtils::Liblist for details
-#
-EXTRALIBS = -lcrfpp
-LDLOADLIBS = -lpthread -lcrfpp
-BSLOADLIBS =
-
-
-# --- MakeMaker const_cccmd section:
-CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \
- $(CCFLAGS) $(OPTIMIZE) \
- $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \
- $(XS_DEFINE_VERSION)
-
-# --- MakeMaker post_constants section:
-
-
-# --- MakeMaker pasthru section:
-
-PASTHRU = LIBPERL_A="$(LIBPERL_A)"\
- LINKTYPE="$(LINKTYPE)"\
- OPTIMIZE="$(OPTIMIZE)"\
- PREFIX="$(PREFIX)"\
- PASTHRU_INC="$(PASTHRU_INC)"
-
-
-# --- MakeMaker special_targets section:
-.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
-
-.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir
-
-
-
-# --- MakeMaker c_o section:
-
-.c.i:
- cc -E -c $(PASTHRU_INC) $(INC) \
- $(CCFLAGS) $(OPTIMIZE) \
- $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \
- $(XS_DEFINE_VERSION) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c > $*.i
-
-.c.s:
- $(CCCMD) -S $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
-
-.c$(OBJ_EXT):
- $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
-
-.cpp$(OBJ_EXT):
- $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cpp
-
-.cxx$(OBJ_EXT):
- $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cxx
-
-.cc$(OBJ_EXT):
- $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cc
-
-.C$(OBJ_EXT):
- $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.C
-
-
-# --- MakeMaker xs_c section:
-
-.xs.c:
- $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
-
-
-# --- MakeMaker xs_o section:
-
-.xs$(OBJ_EXT):
- $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
- $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
-
-
-# --- MakeMaker top_targets section:
-all :: pure_all manifypods
- $(NOECHO) $(NOOP)
-
-
-pure_all :: config pm_to_blib subdirs linkext
- $(NOECHO) $(NOOP)
-
-subdirs :: $(MYEXTLIB)
- $(NOECHO) $(NOOP)
-
-config :: $(FIRST_MAKEFILE) blibdirs
- $(NOECHO) $(NOOP)
-
-help :
- perldoc ExtUtils::MakeMaker
-
-
-# --- MakeMaker blibdirs section:
-blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists
- $(NOECHO) $(NOOP)
-
-# Backwards compat with 6.18 through 6.25
-blibdirs.ts : blibdirs
- $(NOECHO) $(NOOP)
-
-$(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL
- $(NOECHO) $(MKPATH) $(INST_LIBDIR)
- $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_LIBDIR)
- $(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists
-
-$(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL
- $(NOECHO) $(MKPATH) $(INST_ARCHLIB)
- $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHLIB)
- $(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists
-
-$(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL
- $(NOECHO) $(MKPATH) $(INST_AUTODIR)
- $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_AUTODIR)
- $(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists
-
-$(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL
- $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR)
- $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHAUTODIR)
- $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists
-
-$(INST_BIN)$(DFSEP).exists :: Makefile.PL
- $(NOECHO) $(MKPATH) $(INST_BIN)
- $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_BIN)
- $(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists
-
-$(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL
- $(NOECHO) $(MKPATH) $(INST_SCRIPT)
- $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_SCRIPT)
- $(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists
-
-$(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL
- $(NOECHO) $(MKPATH) $(INST_MAN1DIR)
- $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN1DIR)
- $(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists
-
-$(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL
- $(NOECHO) $(MKPATH) $(INST_MAN3DIR)
- $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN3DIR)
- $(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists
-
-
-
-# --- MakeMaker linkext section:
-
-linkext :: $(LINKTYPE)
- $(NOECHO) $(NOOP)
-
-
-# --- MakeMaker dlsyms section:
-
-
-# --- MakeMaker dynamic section:
-
-dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
- $(NOECHO) $(NOOP)
-
-
-# --- MakeMaker dynamic_bs section:
-BOOTSTRAP = $(BASEEXT).bs
-
-# As Mkbootstrap might not write a file (if none is required)
-# we use touch to prevent make continually trying to remake it.
-# The DynaLoader only reads a non-empty file.
-$(BOOTSTRAP) : $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DFSEP).exists
- $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
- $(NOECHO) $(PERLRUN) \
- "-MExtUtils::Mkbootstrap" \
- -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');"
- $(NOECHO) $(TOUCH) $@
- $(CHMOD) $(PERM_RW) $@
-
-$(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists
- $(NOECHO) $(RM_RF) $@
- - $(CP) $(BOOTSTRAP) $@
- $(CHMOD) $(PERM_RW) $@
-
-
-# --- MakeMaker dynamic_lib section:
-
-# This section creates the dynamically loadable $(INST_DYNAMIC)
-# from $(OBJECT) and possibly $(MYEXTLIB).
-ARMAYBE = :
-OTHERLDFLAGS =
-INST_DYNAMIC_DEP =
-INST_DYNAMIC_FIX =
-
-$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
- $(RM_F) $@
- $(LD) $(LDDLFLAGS) $(LDFROM) $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
- $(PERL_ARCHIVE) $(LDLOADLIBS) $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
- $(INST_DYNAMIC_FIX)
- $(CHMOD) $(PERM_RWX) $@
-
-
-# --- MakeMaker static section:
-
-## $(INST_PM) has been moved to the all: target.
-## It remains here for awhile to allow for old usage: "make static"
-static :: $(FIRST_MAKEFILE) $(INST_STATIC)
- $(NOECHO) $(NOOP)
-
-
-# --- MakeMaker static_lib section:
-
-$(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
- $(RM_RF) $@
- $(FULL_AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
- $(CHMOD) $(PERM_RWX) $@
- $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
-
-
-# --- MakeMaker manifypods section:
-
-POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
-POD2MAN = $(POD2MAN_EXE)
-
-
-manifypods : pure_all
- $(NOECHO) $(NOOP)
-
-
-
-
-# --- MakeMaker processPL section:
-
-
-# --- MakeMaker installbin section:
-
-
-# --- MakeMaker subdirs section:
-
-# none
-
-# --- MakeMaker clean_subdirs section:
-clean_subdirs :
- $(NOECHO) $(NOOP)
-
-
-# --- MakeMaker clean section:
-
-# Delete temporary files but do not touch installed files. We don't delete
-# the Makefile here so a later make realclean still has a makefile to use.
-
-clean :: clean_subdirs
- - $(RM_F) \
- *$(LIB_EXT) core \
- core.[0-9] $(INST_ARCHAUTODIR)/extralibs.all \
- core.[0-9][0-9] $(BASEEXT).bso \
- pm_to_blib.ts core.[0-9][0-9][0-9][0-9] \
- $(BASEEXT).x $(BOOTSTRAP) \
- perl$(EXE_EXT) tmon.out \
- *$(OBJ_EXT) pm_to_blib \
- $(INST_ARCHAUTODIR)/extralibs.ld blibdirs.ts \
- core.[0-9][0-9][0-9][0-9][0-9] *perl.core \
- core.*perl.*.? $(MAKE_APERL_FILE) \
- perl $(BASEEXT).def \
- core.[0-9][0-9][0-9] mon.out \
- lib$(BASEEXT).def perlmain.c \
- perl.exe so_locations \
- $(BASEEXT).exp
- - $(RM_RF) \
- blib
- - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL)
-
-
-# --- MakeMaker realclean_subdirs section:
-realclean_subdirs :
- $(NOECHO) $(NOOP)
-
-
-# --- MakeMaker realclean section:
-# Delete temporary files (via clean) and also delete dist files
-realclean purge :: clean realclean_subdirs
- - $(RM_F) \
- $(OBJECT) $(MAKEFILE_OLD) \
- $(FIRST_MAKEFILE)
- - $(RM_RF) \
- $(DISTVNAME)
-
-
-# --- MakeMaker metafile section:
-metafile : create_distdir
- $(NOECHO) $(ECHO) Generating META.yml
- $(NOECHO) $(ECHO) '--- #YAML:1.0' > META_new.yml
- $(NOECHO) $(ECHO) 'name: CRFPP' >> META_new.yml
- $(NOECHO) $(ECHO) 'version: ' >> META_new.yml
- $(NOECHO) $(ECHO) 'abstract: ~' >> META_new.yml
- $(NOECHO) $(ECHO) 'author: []' >> META_new.yml
- $(NOECHO) $(ECHO) 'license: unknown' >> META_new.yml
- $(NOECHO) $(ECHO) 'distribution_type: module' >> META_new.yml
- $(NOECHO) $(ECHO) 'configure_requires:' >> META_new.yml
- $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml
- $(NOECHO) $(ECHO) 'build_requires:' >> META_new.yml
- $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml
- $(NOECHO) $(ECHO) 'requires: {}' >> META_new.yml
- $(NOECHO) $(ECHO) 'no_index:' >> META_new.yml
- $(NOECHO) $(ECHO) ' directory:' >> META_new.yml
- $(NOECHO) $(ECHO) ' - t' >> META_new.yml
- $(NOECHO) $(ECHO) ' - inc' >> META_new.yml
- $(NOECHO) $(ECHO) 'generated_by: ExtUtils::MakeMaker version 6.56' >> META_new.yml
- $(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml
- $(NOECHO) $(ECHO) ' url: http://module-build.sourceforge.net/META-spec-v1.4.html' >> META_new.yml
- $(NOECHO) $(ECHO) ' version: 1.4' >> META_new.yml
- -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
-
-
-# --- MakeMaker signature section:
-signature :
- cpansign -s
-
-
-# --- MakeMaker dist_basics section:
-distclean :: realclean distcheck
- $(NOECHO) $(NOOP)
-
-distcheck :
- $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
-
-skipcheck :
- $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
-
-manifest :
- $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
-
-veryclean : realclean
- $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old
-
-
-
-# --- MakeMaker dist_core section:
-
-dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
- $(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \
- -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' --
-
-tardist : $(DISTVNAME).tar$(SUFFIX)
- $(NOECHO) $(NOOP)
-
-uutardist : $(DISTVNAME).tar$(SUFFIX)
- uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
-
-$(DISTVNAME).tar$(SUFFIX) : distdir
- $(PREOP)
- $(TO_UNIX)
- $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
- $(RM_RF) $(DISTVNAME)
- $(COMPRESS) $(DISTVNAME).tar
- $(POSTOP)
-
-zipdist : $(DISTVNAME).zip
- $(NOECHO) $(NOOP)
-
-$(DISTVNAME).zip : distdir
- $(PREOP)
- $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
- $(RM_RF) $(DISTVNAME)
- $(POSTOP)
-
-shdist : distdir
- $(PREOP)
- $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
- $(RM_RF) $(DISTVNAME)
- $(POSTOP)
-
-
-# --- MakeMaker distdir section:
-create_distdir :
- $(RM_RF) $(DISTVNAME)
- $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
- -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
-
-distdir : create_distdir distmeta
- $(NOECHO) $(NOOP)
-
-
-
-# --- MakeMaker dist_test section:
-disttest : distdir
- cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
- cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
- cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
-
-
-
-# --- MakeMaker dist_ci section:
-
-ci :
- $(PERLRUN) "-MExtUtils::Manifest=maniread" \
- -e "@all = keys %{ maniread() };" \
- -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \
- -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
-
-
-# --- MakeMaker distmeta section:
-distmeta : create_distdir metafile
- $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \
- -e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' --
-
-
-
-# --- MakeMaker distsignature section:
-distsignature : create_distdir
- $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } ' \
- -e ' or print "Could not add SIGNATURE to MANIFEST: $${'\''@'\''}\n"' --
- $(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE
- cd $(DISTVNAME) && cpansign -s
-
-
-
-# --- MakeMaker install section:
-
-install :: pure_install doc_install
- $(NOECHO) $(NOOP)
-
-install_perl :: pure_perl_install doc_perl_install
- $(NOECHO) $(NOOP)
-
-install_site :: pure_site_install doc_site_install
- $(NOECHO) $(NOOP)
-
-install_vendor :: pure_vendor_install doc_vendor_install
- $(NOECHO) $(NOOP)
-
-pure_install :: pure_$(INSTALLDIRS)_install
- $(NOECHO) $(NOOP)
-
-doc_install :: doc_$(INSTALLDIRS)_install
- $(NOECHO) $(NOOP)
-
-pure__install : pure_site_install
- $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
-
-doc__install : doc_site_install
- $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
-
-pure_perl_install :: all
- $(NOECHO) umask 022; $(MOD_INSTALL) \
- $(INST_LIB) $(DESTINSTALLPRIVLIB) \
- $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
- $(INST_BIN) $(DESTINSTALLBIN) \
- $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
- $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
- $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
- $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
- $(SITEARCHEXP)/auto/$(FULLEXT)
-
-
-pure_site_install :: all
- $(NOECHO) umask 02; $(MOD_INSTALL) \
- read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \
- write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \
- $(INST_LIB) $(DESTINSTALLSITELIB) \
- $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
- $(INST_BIN) $(DESTINSTALLSITEBIN) \
- $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
- $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
- $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
- $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
- $(PERL_ARCHLIB)/auto/$(FULLEXT)
-
-pure_vendor_install :: all
- $(NOECHO) umask 022; $(MOD_INSTALL) \
- $(INST_LIB) $(DESTINSTALLVENDORLIB) \
- $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
- $(INST_BIN) $(DESTINSTALLVENDORBIN) \
- $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
- $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
- $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
-
-doc_perl_install :: all
-
-doc_site_install :: all
- $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLSITEARCH)/perllocal.pod
- -$(NOECHO) umask 02; $(MKPATH) $(DESTINSTALLSITEARCH)
- -$(NOECHO) umask 02; $(DOC_INSTALL) \
- "Module" "$(NAME)" \
- "installed into" "$(INSTALLSITELIB)" \
- LINKTYPE "$(LINKTYPE)" \
- VERSION "$(VERSION)" \
- EXE_FILES "$(EXE_FILES)" \
- >> $(DESTINSTALLSITEARCH)/perllocal.pod
-
-doc_vendor_install :: all
-
-
-uninstall :: uninstall_from_$(INSTALLDIRS)dirs
- $(NOECHO) $(NOOP)
-
-uninstall_from_perldirs ::
-
-uninstall_from_sitedirs ::
- $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist
-
-uninstall_from_vendordirs ::
-
-
-
-# --- MakeMaker force section:
-# Phony target to force checking subdirectories.
-FORCE :
- $(NOECHO) $(NOOP)
-
-
-# --- MakeMaker perldepend section:
-
-PERL_HDRS = \
- $(PERL_INC)/EXTERN.h \
- $(PERL_INC)/INTERN.h \
- $(PERL_INC)/XSUB.h \
- $(PERL_INC)/av.h \
- $(PERL_INC)/cc_runtime.h \
- $(PERL_INC)/config.h \
- $(PERL_INC)/cop.h \
- $(PERL_INC)/cv.h \
- $(PERL_INC)/dosish.h \
- $(PERL_INC)/embed.h \
- $(PERL_INC)/embedvar.h \
- $(PERL_INC)/fakethr.h \
- $(PERL_INC)/form.h \
- $(PERL_INC)/gv.h \
- $(PERL_INC)/handy.h \
- $(PERL_INC)/hv.h \
- $(PERL_INC)/intrpvar.h \
- $(PERL_INC)/iperlsys.h \
- $(PERL_INC)/keywords.h \
- $(PERL_INC)/mg.h \
- $(PERL_INC)/nostdio.h \
- $(PERL_INC)/op.h \
- $(PERL_INC)/opcode.h \
- $(PERL_INC)/patchlevel.h \
- $(PERL_INC)/perl.h \
- $(PERL_INC)/perlio.h \
- $(PERL_INC)/perlsdio.h \
- $(PERL_INC)/perlsfio.h \
- $(PERL_INC)/perlvars.h \
- $(PERL_INC)/perly.h \
- $(PERL_INC)/pp.h \
- $(PERL_INC)/pp_proto.h \
- $(PERL_INC)/proto.h \
- $(PERL_INC)/regcomp.h \
- $(PERL_INC)/regexp.h \
- $(PERL_INC)/regnodes.h \
- $(PERL_INC)/scope.h \
- $(PERL_INC)/sv.h \
- $(PERL_INC)/thread.h \
- $(PERL_INC)/unixish.h \
- $(PERL_INC)/util.h
-
-$(OBJECT) : $(PERL_HDRS)
-
-
-# --- MakeMaker makefile section:
-
-$(OBJECT) : $(FIRST_MAKEFILE)
-
-# We take a very conservative approach here, but it's worth it.
-# We move Makefile to Makefile.old here to avoid gnu make looping.
-$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
- $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?"
- $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
- -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
- -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
- - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
- $(PERLRUN) Makefile.PL
- $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
- $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
- $(FALSE)
-
-
-
-# --- MakeMaker staticmake section:
-
-# --- MakeMaker makeaperl section ---
-MAP_TARGET = perl
-FULLPERL = /usr/bin/perl
-
-$(MAP_TARGET) :: static $(MAKE_APERL_FILE)
- $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
-
-$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
- $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
- $(NOECHO) $(PERLRUNINST) \
- Makefile.PL DIR= \
- MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
- MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=
-
-
-# --- MakeMaker test section:
-
-TEST_VERBOSE=0
-TEST_TYPE=test_$(LINKTYPE)
-TEST_FILE = test.pl
-TEST_FILES =
-TESTDB_SW = -d
-
-testdb :: testdb_$(LINKTYPE)
-
-test :: $(TEST_TYPE) subdirs-test
-
-subdirs-test ::
- $(NOECHO) $(NOOP)
-
-
-test_dynamic :: pure_all
- PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
-
-testdb_dynamic :: pure_all
- PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
-
-test_ : test_dynamic
-
-test_static :: pure_all $(MAP_TARGET)
- PERL_DL_NONLAZY=1 ./$(MAP_TARGET) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
-
-testdb_static :: pure_all $(MAP_TARGET)
- PERL_DL_NONLAZY=1 ./$(MAP_TARGET) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
-
-
-
-# --- MakeMaker ppd section:
-# Creates a PPD (Perl Package Description) for a binary distribution.
-ppd :
- $(NOECHO) $(ECHO) '' > $(DISTNAME).ppd
- $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
- $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
- $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
- $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
- $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
- $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
- $(NOECHO) $(ECHO) '' >> $(DISTNAME).ppd
-
-
-# --- MakeMaker pm_to_blib section:
-
-pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM)
- $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', q[$(PM_FILTER)], '\''$(PERM_DIR)'\'')' -- \
- CRFPP.pm $(INST_LIB)/CRFPP.pm
- $(NOECHO) $(TOUCH) pm_to_blib
-
-
-# --- MakeMaker selfdocument section:
-
-
-# --- MakeMaker postamble section:
-
-
-# End.
+# This Makefile is for the CRFPP extension to perl.
+#
+# It was generated automatically by MakeMaker version
+# 6.56 (Revision: 65600) from the contents of
+# Makefile.PL. Don't edit this file, edit Makefile.PL instead.
+#
+# ANY CHANGES MADE HERE WILL BE LOST!
+#
+# MakeMaker ARGV: ()
+#
+
+# MakeMaker Parameters:
+
+# BUILD_REQUIRES => { }
+# CC => q[c++]
+# INC => q[]
+# LD => q[c++]
+# LIBS => q[-lpthread -lcrfpp]
+# NAME => q[CRFPP]
+# OBJECT => q[CRFPP_wrap.o]
+# PREREQ_PM => { }
+
+# --- MakeMaker post_initialize section:
+
+
+# --- MakeMaker const_config section:
+
+# These definitions are from config.sh (via /usr/lib/perl/5.12/Config.pm).
+# They may have been overridden via Makefile.PL or on the command line.
+AR = ar
+CC = c++
+CCCDLFLAGS = -fPIC
+CCDLFLAGS = -Wl,-E
+DLEXT = so
+DLSRC = dl_dlopen.xs
+EXE_EXT =
+FULL_AR = /usr/bin/ar
+LD = c++
+LDDLFLAGS = -shared -O2 -g -L/usr/local/lib -fstack-protector
+LDFLAGS = -fstack-protector -L/usr/local/lib
+LIBC =
+LIB_EXT = .a
+OBJ_EXT = .o
+OSNAME = linux
+OSVERS = 2.6.24-28-server
+RANLIB = :
+SITELIBEXP = /usr/local/share/perl/5.12.4
+SITEARCHEXP = /usr/local/lib/perl/5.12.4
+SO = so
+VENDORARCHEXP = /usr/lib/perl5
+VENDORLIBEXP = /usr/share/perl5
+
+
+# --- MakeMaker constants section:
+AR_STATIC_ARGS = cr
+DIRFILESEP = /
+DFSEP = $(DIRFILESEP)
+NAME = CRFPP
+NAME_SYM = CRFPP
+VERSION =
+VERSION_MACRO = VERSION
+VERSION_SYM =
+DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\"
+XS_VERSION =
+XS_VERSION_MACRO = XS_VERSION
+XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"
+INST_ARCHLIB = blib/arch
+INST_SCRIPT = blib/script
+INST_BIN = blib/bin
+INST_LIB = blib/lib
+INST_MAN1DIR = blib/man1
+INST_MAN3DIR = blib/man3
+MAN1EXT = 1p
+MAN3EXT = 3pm
+INSTALLDIRS = site
+DESTDIR =
+PREFIX = /usr
+PERLPREFIX = $(PREFIX)
+SITEPREFIX = $(PREFIX)/local
+VENDORPREFIX = $(PREFIX)
+INSTALLPRIVLIB = $(PERLPREFIX)/share/perl/5.12
+DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB)
+INSTALLSITELIB = $(SITEPREFIX)/share/perl/5.12.4
+DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB)
+INSTALLVENDORLIB = $(VENDORPREFIX)/share/perl5
+DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB)
+INSTALLARCHLIB = $(PERLPREFIX)/lib/perl/5.12
+DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB)
+INSTALLSITEARCH = $(SITEPREFIX)/lib/perl/5.12.4
+DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH)
+INSTALLVENDORARCH = $(VENDORPREFIX)/lib/perl5
+DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH)
+INSTALLBIN = $(PERLPREFIX)/bin
+DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN)
+INSTALLSITEBIN = $(SITEPREFIX)/bin
+DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN)
+INSTALLVENDORBIN = $(VENDORPREFIX)/bin
+DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN)
+INSTALLSCRIPT = $(PERLPREFIX)/bin
+DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT)
+INSTALLSITESCRIPT = $(SITEPREFIX)/bin
+DESTINSTALLSITESCRIPT = $(DESTDIR)$(INSTALLSITESCRIPT)
+INSTALLVENDORSCRIPT = $(VENDORPREFIX)/bin
+DESTINSTALLVENDORSCRIPT = $(DESTDIR)$(INSTALLVENDORSCRIPT)
+INSTALLMAN1DIR = $(PERLPREFIX)/share/man/man1
+DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR)
+INSTALLSITEMAN1DIR = $(SITEPREFIX)/man/man1
+DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR)
+INSTALLVENDORMAN1DIR = $(VENDORPREFIX)/share/man/man1
+DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR)
+INSTALLMAN3DIR = $(PERLPREFIX)/share/man/man3
+DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR)
+INSTALLSITEMAN3DIR = $(SITEPREFIX)/man/man3
+DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR)
+INSTALLVENDORMAN3DIR = $(VENDORPREFIX)/share/man/man3
+DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR)
+PERL_LIB = /usr/share/perl/5.12
+PERL_ARCHLIB = /usr/lib/perl/5.12
+LIBPERL_A = libperl.a
+FIRST_MAKEFILE = Makefile
+MAKEFILE_OLD = Makefile.old
+MAKE_APERL_FILE = Makefile.aperl
+PERLMAINCC = $(CC)
+PERL_INC = /usr/lib/perl/5.12/CORE
+PERL = /usr/bin/perl
+FULLPERL = /usr/bin/perl
+ABSPERL = $(PERL)
+PERLRUN = $(PERL)
+FULLPERLRUN = $(FULLPERL)
+ABSPERLRUN = $(ABSPERL)
+PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
+FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
+ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
+PERL_CORE = 0
+PERM_DIR = 755
+PERM_RW = 644
+PERM_RWX = 755
+
+MAKEMAKER = /usr/share/perl/5.12/ExtUtils/MakeMaker.pm
+MM_VERSION = 6.56
+MM_REVISION = 65600
+
+# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
+# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
+# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
+# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
+MAKE = make
+FULLEXT = CRFPP
+BASEEXT = CRFPP
+PARENT_NAME =
+DLBASE = $(BASEEXT)
+VERSION_FROM =
+INC =
+OBJECT = CRFPP_wrap$(OBJ_EXT)
+LDFROM = $(OBJECT)
+LINKTYPE = dynamic
+BOOTDEP =
+
+# Handy lists of source code files:
+XS_FILES =
+C_FILES = CRFPP_wrap.cxx
+O_FILES = CRFPP_wrap.o
+H_FILES =
+MAN1PODS =
+MAN3PODS =
+
+# Where is the Config information that we are using/depend on
+CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h
+
+# Where to build things
+INST_LIBDIR = $(INST_LIB)
+INST_ARCHLIBDIR = $(INST_ARCHLIB)
+
+INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
+INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
+
+INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)
+INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT)
+INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
+
+# Extra linker info
+EXPORT_LIST =
+PERL_ARCHIVE =
+PERL_ARCHIVE_AFTER =
+
+
+TO_INST_PM = CRFPP.pm
+
+PM_TO_BLIB = CRFPP.pm \
+ $(INST_LIB)/CRFPP.pm
+
+
+# --- MakeMaker platform_constants section:
+MM_Unix_VERSION = 6.56
+PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc
+
+
+# --- MakeMaker tool_autosplit section:
+# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
+AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' --
+
+
+
+# --- MakeMaker tool_xsubpp section:
+
+XSUBPPDIR = /usr/share/perl/5.12/ExtUtils
+XSUBPP = $(XSUBPPDIR)$(DFSEP)xsubpp
+XSUBPPRUN = $(PERLRUN) $(XSUBPP)
+XSPROTOARG =
+XSUBPPDEPS = /usr/share/perl/5.12/ExtUtils/typemap $(XSUBPP)
+XSUBPPARGS = -typemap /usr/share/perl/5.12/ExtUtils/typemap
+XSUBPP_EXTRA_ARGS =
+
+
+# --- MakeMaker tools_other section:
+SHELL = /bin/sh
+CHMOD = chmod
+CP = cp
+MV = mv
+NOOP = $(TRUE)
+NOECHO = @
+RM_F = rm -f
+RM_RF = rm -rf
+TEST_F = test -f
+TOUCH = touch
+UMASK_NULL = umask 0
+DEV_NULL = > /dev/null 2>&1
+MKPATH = $(ABSPERLRUN) -MExtUtils::Command -e 'mkpath' --
+EQUALIZE_TIMESTAMP = $(ABSPERLRUN) -MExtUtils::Command -e 'eqtime' --
+FALSE = false
+TRUE = true
+ECHO = echo
+ECHO_N = echo -n
+UNINST = 0
+VERBINST = 0
+MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install([ from_to => {@ARGV}, verbose => '\''$(VERBINST)'\'', uninstall_shadows => '\''$(UNINST)'\'', dir_mode => '\''$(PERM_DIR)'\'' ]);' --
+DOC_INSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'perllocal_install' --
+UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' --
+WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' --
+MACROSTART =
+MACROEND =
+USEMAKEFILE = -f
+FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' --
+
+
+# --- MakeMaker makemakerdflt section:
+makemakerdflt : all
+ $(NOECHO) $(NOOP)
+
+
+# --- MakeMaker dist section:
+TAR = tar
+TARFLAGS = cvf
+ZIP = zip
+ZIPFLAGS = -r
+COMPRESS = gzip --best
+SUFFIX = .gz
+SHAR = shar
+PREOP = $(NOECHO) $(NOOP)
+POSTOP = $(NOECHO) $(NOOP)
+TO_UNIX = $(NOECHO) $(NOOP)
+CI = ci -u
+RCS_LABEL = rcs -Nv$(VERSION_SYM): -q
+DIST_CP = best
+DIST_DEFAULT = tardist
+DISTNAME = CRFPP
+DISTVNAME = CRFPP-
+
+
+# --- MakeMaker macro section:
+
+
+# --- MakeMaker depend section:
+
+
+# --- MakeMaker cflags section:
+
+CCFLAGS = -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+OPTIMIZE = -O2 -g
+PERLTYPE =
+MPOLLUTE =
+
+
+# --- MakeMaker const_loadlibs section:
+
+# CRFPP might depend on some other libraries:
+# See ExtUtils::Liblist for details
+#
+EXTRALIBS = -lcrfpp
+LDLOADLIBS = -lpthread -lcrfpp
+BSLOADLIBS =
+
+
+# --- MakeMaker const_cccmd section:
+CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \
+ $(CCFLAGS) $(OPTIMIZE) \
+ $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \
+ $(XS_DEFINE_VERSION)
+
+# --- MakeMaker post_constants section:
+
+
+# --- MakeMaker pasthru section:
+
+PASTHRU = LIBPERL_A="$(LIBPERL_A)"\
+ LINKTYPE="$(LINKTYPE)"\
+ OPTIMIZE="$(OPTIMIZE)"\
+ PREFIX="$(PREFIX)"\
+ PASTHRU_INC="$(PASTHRU_INC)"
+
+
+# --- MakeMaker special_targets section:
+.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
+
+.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir
+
+
+
+# --- MakeMaker c_o section:
+
+.c.i:
+ cc -E -c $(PASTHRU_INC) $(INC) \
+ $(CCFLAGS) $(OPTIMIZE) \
+ $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \
+ $(XS_DEFINE_VERSION) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c > $*.i
+
+.c.s:
+ $(CCCMD) -S $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
+
+.c$(OBJ_EXT):
+ $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
+
+.cpp$(OBJ_EXT):
+ $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cpp
+
+.cxx$(OBJ_EXT):
+ $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cxx
+
+.cc$(OBJ_EXT):
+ $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cc
+
+.C$(OBJ_EXT):
+ $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.C
+
+
+# --- MakeMaker xs_c section:
+
+.xs.c:
+ $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
+
+
+# --- MakeMaker xs_o section:
+
+.xs$(OBJ_EXT):
+ $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
+ $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
+
+
+# --- MakeMaker top_targets section:
+all :: pure_all manifypods
+ $(NOECHO) $(NOOP)
+
+
+pure_all :: config pm_to_blib subdirs linkext
+ $(NOECHO) $(NOOP)
+
+subdirs :: $(MYEXTLIB)
+ $(NOECHO) $(NOOP)
+
+config :: $(FIRST_MAKEFILE) blibdirs
+ $(NOECHO) $(NOOP)
+
+help :
+ perldoc ExtUtils::MakeMaker
+
+
+# --- MakeMaker blibdirs section:
+blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists
+ $(NOECHO) $(NOOP)
+
+# Backwards compat with 6.18 through 6.25
+blibdirs.ts : blibdirs
+ $(NOECHO) $(NOOP)
+
+$(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL
+ $(NOECHO) $(MKPATH) $(INST_LIBDIR)
+ $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_LIBDIR)
+ $(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists
+
+$(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL
+ $(NOECHO) $(MKPATH) $(INST_ARCHLIB)
+ $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHLIB)
+ $(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists
+
+$(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL
+ $(NOECHO) $(MKPATH) $(INST_AUTODIR)
+ $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_AUTODIR)
+ $(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists
+
+$(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL
+ $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR)
+ $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHAUTODIR)
+ $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists
+
+$(INST_BIN)$(DFSEP).exists :: Makefile.PL
+ $(NOECHO) $(MKPATH) $(INST_BIN)
+ $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_BIN)
+ $(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists
+
+$(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL
+ $(NOECHO) $(MKPATH) $(INST_SCRIPT)
+ $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_SCRIPT)
+ $(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists
+
+$(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL
+ $(NOECHO) $(MKPATH) $(INST_MAN1DIR)
+ $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN1DIR)
+ $(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists
+
+$(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL
+ $(NOECHO) $(MKPATH) $(INST_MAN3DIR)
+ $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN3DIR)
+ $(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists
+
+
+
+# --- MakeMaker linkext section:
+
+linkext :: $(LINKTYPE)
+ $(NOECHO) $(NOOP)
+
+
+# --- MakeMaker dlsyms section:
+
+
+# --- MakeMaker dynamic section:
+
+dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
+ $(NOECHO) $(NOOP)
+
+
+# --- MakeMaker dynamic_bs section:
+BOOTSTRAP = $(BASEEXT).bs
+
+# As Mkbootstrap might not write a file (if none is required)
+# we use touch to prevent make continually trying to remake it.
+# The DynaLoader only reads a non-empty file.
+$(BOOTSTRAP) : $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DFSEP).exists
+ $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
+ $(NOECHO) $(PERLRUN) \
+ "-MExtUtils::Mkbootstrap" \
+ -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');"
+ $(NOECHO) $(TOUCH) $@
+ $(CHMOD) $(PERM_RW) $@
+
+$(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists
+ $(NOECHO) $(RM_RF) $@
+ - $(CP) $(BOOTSTRAP) $@
+ $(CHMOD) $(PERM_RW) $@
+
+
+# --- MakeMaker dynamic_lib section:
+
+# This section creates the dynamically loadable $(INST_DYNAMIC)
+# from $(OBJECT) and possibly $(MYEXTLIB).
+ARMAYBE = :
+OTHERLDFLAGS =
+INST_DYNAMIC_DEP =
+INST_DYNAMIC_FIX =
+
+$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
+ $(RM_F) $@
+ $(LD) $(LDDLFLAGS) $(LDFROM) $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
+ $(PERL_ARCHIVE) $(LDLOADLIBS) $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
+ $(INST_DYNAMIC_FIX)
+ $(CHMOD) $(PERM_RWX) $@
+
+
+# --- MakeMaker static section:
+
+## $(INST_PM) has been moved to the all: target.
+## It remains here for awhile to allow for old usage: "make static"
+static :: $(FIRST_MAKEFILE) $(INST_STATIC)
+ $(NOECHO) $(NOOP)
+
+
+# --- MakeMaker static_lib section:
+
+$(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
+ $(RM_RF) $@
+ $(FULL_AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
+ $(CHMOD) $(PERM_RWX) $@
+ $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
+
+
+# --- MakeMaker manifypods section:
+
+POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
+POD2MAN = $(POD2MAN_EXE)
+
+
+manifypods : pure_all
+ $(NOECHO) $(NOOP)
+
+
+
+
+# --- MakeMaker processPL section:
+
+
+# --- MakeMaker installbin section:
+
+
+# --- MakeMaker subdirs section:
+
+# none
+
+# --- MakeMaker clean_subdirs section:
+clean_subdirs :
+ $(NOECHO) $(NOOP)
+
+
+# --- MakeMaker clean section:
+
+# Delete temporary files but do not touch installed files. We don't delete
+# the Makefile here so a later make realclean still has a makefile to use.
+
+clean :: clean_subdirs
+ - $(RM_F) \
+ *$(LIB_EXT) core \
+ core.[0-9] $(INST_ARCHAUTODIR)/extralibs.all \
+ core.[0-9][0-9] $(BASEEXT).bso \
+ pm_to_blib.ts core.[0-9][0-9][0-9][0-9] \
+ $(BASEEXT).x $(BOOTSTRAP) \
+ perl$(EXE_EXT) tmon.out \
+ *$(OBJ_EXT) pm_to_blib \
+ $(INST_ARCHAUTODIR)/extralibs.ld blibdirs.ts \
+ core.[0-9][0-9][0-9][0-9][0-9] *perl.core \
+ core.*perl.*.? $(MAKE_APERL_FILE) \
+ perl $(BASEEXT).def \
+ core.[0-9][0-9][0-9] mon.out \
+ lib$(BASEEXT).def perlmain.c \
+ perl.exe so_locations \
+ $(BASEEXT).exp
+ - $(RM_RF) \
+ blib
+ - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL)
+
+
+# --- MakeMaker realclean_subdirs section:
+realclean_subdirs :
+ $(NOECHO) $(NOOP)
+
+
+# --- MakeMaker realclean section:
+# Delete temporary files (via clean) and also delete dist files
+realclean purge :: clean realclean_subdirs
+ - $(RM_F) \
+ $(OBJECT) $(MAKEFILE_OLD) \
+ $(FIRST_MAKEFILE)
+ - $(RM_RF) \
+ $(DISTVNAME)
+
+
+# --- MakeMaker metafile section:
+metafile : create_distdir
+ $(NOECHO) $(ECHO) Generating META.yml
+ $(NOECHO) $(ECHO) '--- #YAML:1.0' > META_new.yml
+ $(NOECHO) $(ECHO) 'name: CRFPP' >> META_new.yml
+ $(NOECHO) $(ECHO) 'version: ' >> META_new.yml
+ $(NOECHO) $(ECHO) 'abstract: ~' >> META_new.yml
+ $(NOECHO) $(ECHO) 'author: []' >> META_new.yml
+ $(NOECHO) $(ECHO) 'license: unknown' >> META_new.yml
+ $(NOECHO) $(ECHO) 'distribution_type: module' >> META_new.yml
+ $(NOECHO) $(ECHO) 'configure_requires:' >> META_new.yml
+ $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml
+ $(NOECHO) $(ECHO) 'build_requires:' >> META_new.yml
+ $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml
+ $(NOECHO) $(ECHO) 'requires: {}' >> META_new.yml
+ $(NOECHO) $(ECHO) 'no_index:' >> META_new.yml
+ $(NOECHO) $(ECHO) ' directory:' >> META_new.yml
+ $(NOECHO) $(ECHO) ' - t' >> META_new.yml
+ $(NOECHO) $(ECHO) ' - inc' >> META_new.yml
+ $(NOECHO) $(ECHO) 'generated_by: ExtUtils::MakeMaker version 6.56' >> META_new.yml
+ $(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml
+ $(NOECHO) $(ECHO) ' url: http://module-build.sourceforge.net/META-spec-v1.4.html' >> META_new.yml
+ $(NOECHO) $(ECHO) ' version: 1.4' >> META_new.yml
+ -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
+
+
+# --- MakeMaker signature section:
+signature :
+ cpansign -s
+
+
+# --- MakeMaker dist_basics section:
+distclean :: realclean distcheck
+ $(NOECHO) $(NOOP)
+
+distcheck :
+ $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
+
+skipcheck :
+ $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
+
+manifest :
+ $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
+
+veryclean : realclean
+ $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old
+
+
+
+# --- MakeMaker dist_core section:
+
+dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
+ $(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \
+ -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' --
+
+tardist : $(DISTVNAME).tar$(SUFFIX)
+ $(NOECHO) $(NOOP)
+
+uutardist : $(DISTVNAME).tar$(SUFFIX)
+ uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
+
+$(DISTVNAME).tar$(SUFFIX) : distdir
+ $(PREOP)
+ $(TO_UNIX)
+ $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
+ $(RM_RF) $(DISTVNAME)
+ $(COMPRESS) $(DISTVNAME).tar
+ $(POSTOP)
+
+zipdist : $(DISTVNAME).zip
+ $(NOECHO) $(NOOP)
+
+$(DISTVNAME).zip : distdir
+ $(PREOP)
+ $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
+ $(RM_RF) $(DISTVNAME)
+ $(POSTOP)
+
+shdist : distdir
+ $(PREOP)
+ $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
+ $(RM_RF) $(DISTVNAME)
+ $(POSTOP)
+
+
+# --- MakeMaker distdir section:
+create_distdir :
+ $(RM_RF) $(DISTVNAME)
+ $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
+ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
+
+distdir : create_distdir distmeta
+ $(NOECHO) $(NOOP)
+
+
+
+# --- MakeMaker dist_test section:
+disttest : distdir
+ cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
+ cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
+ cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
+
+
+
+# --- MakeMaker dist_ci section:
+
+ci :
+ $(PERLRUN) "-MExtUtils::Manifest=maniread" \
+ -e "@all = keys %{ maniread() };" \
+ -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \
+ -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
+
+
+# --- MakeMaker distmeta section:
+distmeta : create_distdir metafile
+ $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \
+ -e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' --
+
+
+
+# --- MakeMaker distsignature section:
+distsignature : create_distdir
+ $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } ' \
+ -e ' or print "Could not add SIGNATURE to MANIFEST: $${'\''@'\''}\n"' --
+ $(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE
+ cd $(DISTVNAME) && cpansign -s
+
+
+
+# --- MakeMaker install section:
+
+install :: pure_install doc_install
+ $(NOECHO) $(NOOP)
+
+install_perl :: pure_perl_install doc_perl_install
+ $(NOECHO) $(NOOP)
+
+install_site :: pure_site_install doc_site_install
+ $(NOECHO) $(NOOP)
+
+install_vendor :: pure_vendor_install doc_vendor_install
+ $(NOECHO) $(NOOP)
+
+pure_install :: pure_$(INSTALLDIRS)_install
+ $(NOECHO) $(NOOP)
+
+doc_install :: doc_$(INSTALLDIRS)_install
+ $(NOECHO) $(NOOP)
+
+pure__install : pure_site_install
+ $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
+
+doc__install : doc_site_install
+ $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
+
+pure_perl_install :: all
+ $(NOECHO) umask 022; $(MOD_INSTALL) \
+ $(INST_LIB) $(DESTINSTALLPRIVLIB) \
+ $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
+ $(INST_BIN) $(DESTINSTALLBIN) \
+ $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
+ $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
+ $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
+ $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
+ $(SITEARCHEXP)/auto/$(FULLEXT)
+
+
+pure_site_install :: all
+ $(NOECHO) umask 02; $(MOD_INSTALL) \
+ read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \
+ write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \
+ $(INST_LIB) $(DESTINSTALLSITELIB) \
+ $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
+ $(INST_BIN) $(DESTINSTALLSITEBIN) \
+ $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
+ $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
+ $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
+ $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
+ $(PERL_ARCHLIB)/auto/$(FULLEXT)
+
+pure_vendor_install :: all
+ $(NOECHO) umask 022; $(MOD_INSTALL) \
+ $(INST_LIB) $(DESTINSTALLVENDORLIB) \
+ $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
+ $(INST_BIN) $(DESTINSTALLVENDORBIN) \
+ $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
+ $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
+ $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
+
+doc_perl_install :: all
+
+doc_site_install :: all
+ $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLSITEARCH)/perllocal.pod
+ -$(NOECHO) umask 02; $(MKPATH) $(DESTINSTALLSITEARCH)
+ -$(NOECHO) umask 02; $(DOC_INSTALL) \
+ "Module" "$(NAME)" \
+ "installed into" "$(INSTALLSITELIB)" \
+ LINKTYPE "$(LINKTYPE)" \
+ VERSION "$(VERSION)" \
+ EXE_FILES "$(EXE_FILES)" \
+ >> $(DESTINSTALLSITEARCH)/perllocal.pod
+
+doc_vendor_install :: all
+
+
+uninstall :: uninstall_from_$(INSTALLDIRS)dirs
+ $(NOECHO) $(NOOP)
+
+uninstall_from_perldirs ::
+
+uninstall_from_sitedirs ::
+ $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist
+
+uninstall_from_vendordirs ::
+
+
+
+# --- MakeMaker force section:
+# Phony target to force checking subdirectories.
+FORCE :
+ $(NOECHO) $(NOOP)
+
+
+# --- MakeMaker perldepend section:
+
+PERL_HDRS = \
+ $(PERL_INC)/EXTERN.h \
+ $(PERL_INC)/INTERN.h \
+ $(PERL_INC)/XSUB.h \
+ $(PERL_INC)/av.h \
+ $(PERL_INC)/cc_runtime.h \
+ $(PERL_INC)/config.h \
+ $(PERL_INC)/cop.h \
+ $(PERL_INC)/cv.h \
+ $(PERL_INC)/dosish.h \
+ $(PERL_INC)/embed.h \
+ $(PERL_INC)/embedvar.h \
+ $(PERL_INC)/fakethr.h \
+ $(PERL_INC)/form.h \
+ $(PERL_INC)/gv.h \
+ $(PERL_INC)/handy.h \
+ $(PERL_INC)/hv.h \
+ $(PERL_INC)/intrpvar.h \
+ $(PERL_INC)/iperlsys.h \
+ $(PERL_INC)/keywords.h \
+ $(PERL_INC)/mg.h \
+ $(PERL_INC)/nostdio.h \
+ $(PERL_INC)/op.h \
+ $(PERL_INC)/opcode.h \
+ $(PERL_INC)/patchlevel.h \
+ $(PERL_INC)/perl.h \
+ $(PERL_INC)/perlio.h \
+ $(PERL_INC)/perlsdio.h \
+ $(PERL_INC)/perlsfio.h \
+ $(PERL_INC)/perlvars.h \
+ $(PERL_INC)/perly.h \
+ $(PERL_INC)/pp.h \
+ $(PERL_INC)/pp_proto.h \
+ $(PERL_INC)/proto.h \
+ $(PERL_INC)/regcomp.h \
+ $(PERL_INC)/regexp.h \
+ $(PERL_INC)/regnodes.h \
+ $(PERL_INC)/scope.h \
+ $(PERL_INC)/sv.h \
+ $(PERL_INC)/thread.h \
+ $(PERL_INC)/unixish.h \
+ $(PERL_INC)/util.h
+
+$(OBJECT) : $(PERL_HDRS)
+
+
+# --- MakeMaker makefile section:
+
+$(OBJECT) : $(FIRST_MAKEFILE)
+
+# We take a very conservative approach here, but it's worth it.
+# We move Makefile to Makefile.old here to avoid gnu make looping.
+$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
+ $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?"
+ $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
+ -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
+ -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
+ - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
+ $(PERLRUN) Makefile.PL
+ $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
+ $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
+ $(FALSE)
+
+
+
+# --- MakeMaker staticmake section:
+
+# --- MakeMaker makeaperl section ---
+MAP_TARGET = perl
+FULLPERL = /usr/bin/perl
+
+$(MAP_TARGET) :: static $(MAKE_APERL_FILE)
+ $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
+
+$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
+ $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
+ $(NOECHO) $(PERLRUNINST) \
+ Makefile.PL DIR= \
+ MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
+ MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=
+
+
+# --- MakeMaker test section:
+
+TEST_VERBOSE=0
+TEST_TYPE=test_$(LINKTYPE)
+TEST_FILE = test.pl
+TEST_FILES =
+TESTDB_SW = -d
+
+testdb :: testdb_$(LINKTYPE)
+
+test :: $(TEST_TYPE) subdirs-test
+
+subdirs-test ::
+ $(NOECHO) $(NOOP)
+
+
+test_dynamic :: pure_all
+ PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
+
+testdb_dynamic :: pure_all
+ PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
+
+test_ : test_dynamic
+
+test_static :: pure_all $(MAP_TARGET)
+ PERL_DL_NONLAZY=1 ./$(MAP_TARGET) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
+
+testdb_static :: pure_all $(MAP_TARGET)
+ PERL_DL_NONLAZY=1 ./$(MAP_TARGET) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
+
+
+
+# --- MakeMaker ppd section:
+# Creates a PPD (Perl Package Description) for a binary distribution.
+ppd :
+ $(NOECHO) $(ECHO) '' > $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) '' >> $(DISTNAME).ppd
+
+
+# --- MakeMaker pm_to_blib section:
+
+pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM)
+ $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', q[$(PM_FILTER)], '\''$(PERM_DIR)'\'')' -- \
+ CRFPP.pm $(INST_LIB)/CRFPP.pm
+ $(NOECHO) $(TOUCH) pm_to_blib
+
+
+# --- MakeMaker selfdocument section:
+
+
+# --- MakeMaker postamble section:
+
+
+# End.
diff --git a/CRF/ruby/Makefile b/CRF/ruby/Makefile
index f640229a1230c6214f2d7022d1adadf68a9a5d7c..4825f4468813527d53efd7191d2c818e2820ab72 100644
--- a/CRF/ruby/Makefile
+++ b/CRF/ruby/Makefile
@@ -1,157 +1,157 @@
-
-SHELL = /bin/sh
-
-#### Start of system configuration section. ####
-
-srcdir = .
-topdir = /usr/lib/ruby/1.8/x86_64-linux
-hdrdir = $(topdir)
-VPATH = $(srcdir):$(topdir):$(hdrdir)
-exec_prefix = $(prefix)
-prefix = $(DESTDIR)/usr
-sharedstatedir = $(prefix)/com
-mandir = $(prefix)/share/man
-psdir = $(docdir)
-oldincludedir = $(DESTDIR)/usr/include
-localedir = $(datarootdir)/locale
-bindir = $(exec_prefix)/bin
-libexecdir = $(prefix)/lib/ruby1.8
-sitedir = $(DESTDIR)/usr/local/lib/site_ruby
-htmldir = $(docdir)
-vendorarchdir = $(vendorlibdir)/$(sitearch)
-includedir = $(prefix)/include
-infodir = $(prefix)/share/info
-vendorlibdir = $(vendordir)/$(ruby_version)
-sysconfdir = $(DESTDIR)/etc
-libdir = $(exec_prefix)/lib
-sbindir = $(exec_prefix)/sbin
-rubylibdir = $(libdir)/ruby/$(ruby_version)
-docdir = $(datarootdir)/doc/$(PACKAGE)
-dvidir = $(docdir)
-vendordir = $(libdir)/ruby/vendor_ruby
-datarootdir = $(prefix)/share
-pdfdir = $(docdir)
-archdir = $(rubylibdir)/$(arch)
-sitearchdir = $(sitelibdir)/$(sitearch)
-datadir = $(datarootdir)
-localstatedir = $(DESTDIR)/var
-sitelibdir = $(sitedir)/$(ruby_version)
-
-CC = gcc
-LIBRUBY = $(LIBRUBY_SO)
-LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
-LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
-LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
-
-RUBY_EXTCONF_H =
-CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC $(cflags)
-INCFLAGS = -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I.
-DEFS =
-CPPFLAGS = -DHAVE_CRFPP_H
-CXXFLAGS = $(CFLAGS)
-ldflags = -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic
-dldflags =
-archflag =
-DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
-LDSHARED = $(CC) -shared
-AR = ar
-EXEEXT =
-
-RUBY_INSTALL_NAME = ruby1.8
-RUBY_SO_NAME = ruby1.8
-arch = x86_64-linux
-sitearch = x86_64-linux
-ruby_version = 1.8
-ruby = /usr/bin/ruby1.8
-RUBY = $(ruby)
-RM = rm -f
-MAKEDIRS = mkdir -p
-INSTALL = /usr/bin/install -c
-INSTALL_PROG = $(INSTALL) -m 0755
-INSTALL_DATA = $(INSTALL) -m 644
-COPY = cp
-
-#### End of system configuration section. ####
-
-preload =
-
-libpath = . $(libdir)
-LIBPATH = -L. -L$(libdir)
-DEFFILE =
-
-CLEANFILES = mkmf.log
-DISTCLEANFILES =
-
-extout =
-extout_prefix =
-target_prefix =
-LOCAL_LIBS =
-LIBS = $(LIBRUBYARG_SHARED) -lpthread -lcrfpp -lpthread -lrt -ldl -lcrypt -lm -lc
-SRCS = CRFPP_wrap.cpp
-OBJS = CRFPP_wrap.o
-TARGET = CRFPP
-DLLIB = $(TARGET).so
-EXTSTATIC =
-STATIC_LIB =
-
-BINDIR = $(bindir)
-RUBYCOMMONDIR = $(sitedir)$(target_prefix)
-RUBYLIBDIR = $(sitelibdir)$(target_prefix)
-RUBYARCHDIR = $(sitearchdir)$(target_prefix)
-
-TARGET_SO = $(DLLIB)
-CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
-CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
-
-all: $(DLLIB)
-static: $(STATIC_LIB)
-
-clean:
- @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
-
-distclean: clean
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
-
-realclean: distclean
-install: install-so install-rb
-
-install-so: $(RUBYARCHDIR)
-install-so: $(RUBYARCHDIR)/$(DLLIB)
-$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
-install-rb: pre-install-rb install-rb-default
-install-rb-default: pre-install-rb-default
-pre-install-rb: Makefile
-pre-install-rb-default: Makefile
-$(RUBYARCHDIR):
- $(MAKEDIRS) $@
-
-site-install: site-install-so site-install-rb
-site-install-so: install-so
-site-install-rb: install-rb
-
-.SUFFIXES: .c .m .cc .cxx .cpp .C .o
-
-.cc.o:
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
-
-.cxx.o:
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
-
-.cpp.o:
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
-
-.C.o:
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
-
-.c.o:
- $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
-
-$(DLLIB): $(OBJS) Makefile
- @-$(RM) $@
- $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
-
-
-
-$(OBJS): ruby.h defines.h
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = .
+topdir = /usr/lib/ruby/1.8/x86_64-linux
+hdrdir = $(topdir)
+VPATH = $(srcdir):$(topdir):$(hdrdir)
+exec_prefix = $(prefix)
+prefix = $(DESTDIR)/usr
+sharedstatedir = $(prefix)/com
+mandir = $(prefix)/share/man
+psdir = $(docdir)
+oldincludedir = $(DESTDIR)/usr/include
+localedir = $(datarootdir)/locale
+bindir = $(exec_prefix)/bin
+libexecdir = $(prefix)/lib/ruby1.8
+sitedir = $(DESTDIR)/usr/local/lib/site_ruby
+htmldir = $(docdir)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+includedir = $(prefix)/include
+infodir = $(prefix)/share/info
+vendorlibdir = $(vendordir)/$(ruby_version)
+sysconfdir = $(DESTDIR)/etc
+libdir = $(exec_prefix)/lib
+sbindir = $(exec_prefix)/sbin
+rubylibdir = $(libdir)/ruby/$(ruby_version)
+docdir = $(datarootdir)/doc/$(PACKAGE)
+dvidir = $(docdir)
+vendordir = $(libdir)/ruby/vendor_ruby
+datarootdir = $(prefix)/share
+pdfdir = $(docdir)
+archdir = $(rubylibdir)/$(arch)
+sitearchdir = $(sitelibdir)/$(sitearch)
+datadir = $(datarootdir)
+localstatedir = $(DESTDIR)/var
+sitelibdir = $(sitedir)/$(ruby_version)
+
+CC = gcc
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
+
+RUBY_EXTCONF_H =
+CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC $(cflags)
+INCFLAGS = -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I.
+DEFS =
+CPPFLAGS = -DHAVE_CRFPP_H
+CXXFLAGS = $(CFLAGS)
+ldflags = -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic
+dldflags =
+archflag =
+DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
+LDSHARED = $(CC) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = ruby1.8
+RUBY_SO_NAME = ruby1.8
+arch = x86_64-linux
+sitearch = x86_64-linux
+ruby_version = 1.8
+ruby = /usr/bin/ruby1.8
+RUBY = $(ruby)
+RM = rm -f
+MAKEDIRS = mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(libdir)
+LIBPATH = -L. -L$(libdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+extout =
+extout_prefix =
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lcrfpp -lpthread -lrt -ldl -lcrypt -lm -lc
+SRCS = CRFPP_wrap.cpp
+OBJS = CRFPP_wrap.o
+TARGET = CRFPP
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB =
+
+BINDIR = $(bindir)
+RUBYCOMMONDIR = $(sitedir)$(target_prefix)
+RUBYLIBDIR = $(sitelibdir)$(target_prefix)
+RUBYARCHDIR = $(sitearchdir)$(target_prefix)
+
+TARGET_SO = $(DLLIB)
+CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
+CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
+
+all: $(DLLIB)
+static: $(STATIC_LIB)
+
+clean:
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
+
+distclean: clean
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+$(RUBYARCHDIR):
+ $(MAKEDIRS) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .cxx .cpp .C .o
+
+.cc.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.cxx.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.cpp.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.C.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.c.o:
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
+
+$(DLLIB): $(OBJS) Makefile
+ @-$(RM) $@
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+
+
+$(OBJS): ruby.h defines.h
diff --git a/CRF/winmain.h b/CRF/winmain.h
index 464494b8855dfc7a0dbd7ae45220b4b1071a5abc..74d3a02cbca39dd7b898be54cfe34e778e8a8e94 100644
--- a/CRF/winmain.h
+++ b/CRF/winmain.h
@@ -1,69 +1,69 @@
-//
-// CRF++ -- Yet Another CRF toolkit
-//
-// $Id: common.h 1588 2007-02-12 09:03:39Z taku $;
-//
-// Copyright(C) 2005-2007 Taku Kudo
-//
-#if defined(_WIN32) || defined(__CYGWIN__)
-
-#include
-#include
-
-namespace {
-class CommandLine {
- public:
- CommandLine(int argc, wchar_t **argv) : argc_(argc), argv_(0) {
- argv_ = new char * [argc_];
- for (int i = 0; i < argc_; ++i) {
- const std::string arg = WideToUtf8(argv[i]);
- argv_[i] = new char[arg.size() + 1];
- ::memcpy(argv_[i], arg.data(), arg.size());
- argv_[i][arg.size()] = '\0';
- }
- }
- ~CommandLine() {
- for (int i = 0; i < argc_; ++i) {
- delete [] argv_[i];
- }
- delete [] argv_;
- }
-
- int argc() const { return argc_; }
- char **argv() const { return argv_; }
-
- private:
- static std::string WideToUtf8(const std::wstring &input) {
- const int output_length = ::WideCharToMultiByte(CP_UTF8, 0,
- input.c_str(), -1, NULL, 0,
- NULL, NULL);
- if (output_length == 0) {
- return "";
- }
-
- char *input_encoded = new char[output_length + 1];
- const int result = ::WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1,
- input_encoded,
- output_length + 1, NULL, NULL);
- std::string output;
- if (result > 0) {
- output.assign(input_encoded);
- }
- delete [] input_encoded;
- return output;
- }
-
- int argc_;
- char **argv_;
-};
-} // namespace
-
-#define main(argc, argv) wmain_to_main_wrapper(argc, argv)
-
-int wmain_to_main_wrapper(int argc, char **argv);
-
-int wmain(int argc, wchar_t **argv) {
- CommandLine cmd(argc, argv);
- return wmain_to_main_wrapper(cmd.argc(), cmd.argv());
-}
-#endif
+//
+// CRF++ -- Yet Another CRF toolkit
+//
+// $Id: common.h 1588 2007-02-12 09:03:39Z taku $;
+//
+// Copyright(C) 2005-2007 Taku Kudo
+//
+#if defined(_WIN32) || defined(__CYGWIN__)
+
+#include
+#include
+
+namespace {
+class CommandLine {
+ public:
+ CommandLine(int argc, wchar_t **argv) : argc_(argc), argv_(0) {
+ argv_ = new char * [argc_];
+ for (int i = 0; i < argc_; ++i) {
+ const std::string arg = WideToUtf8(argv[i]);
+ argv_[i] = new char[arg.size() + 1];
+ ::memcpy(argv_[i], arg.data(), arg.size());
+ argv_[i][arg.size()] = '\0';
+ }
+ }
+ ~CommandLine() {
+ for (int i = 0; i < argc_; ++i) {
+ delete [] argv_[i];
+ }
+ delete [] argv_;
+ }
+
+ int argc() const { return argc_; }
+ char **argv() const { return argv_; }
+
+ private:
+ static std::string WideToUtf8(const std::wstring &input) {
+ const int output_length = ::WideCharToMultiByte(CP_UTF8, 0,
+ input.c_str(), -1, NULL, 0,
+ NULL, NULL);
+ if (output_length == 0) {
+ return "";
+ }
+
+ char *input_encoded = new char[output_length + 1];
+ const int result = ::WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1,
+ input_encoded,
+ output_length + 1, NULL, NULL);
+ std::string output;
+ if (result > 0) {
+ output.assign(input_encoded);
+ }
+ delete [] input_encoded;
+ return output;
+ }
+
+ int argc_;
+ char **argv_;
+};
+} // namespace
+
+#define main(argc, argv) wmain_to_main_wrapper(argc, argv)
+
+int wmain_to_main_wrapper(int argc, char **argv);
+
+int wmain(int argc, wchar_t **argv) {
+ CommandLine cmd(argc, argv);
+ return wmain_to_main_wrapper(cmd.argc(), cmd.argv());
+}
+#endif
diff --git a/GeneNER_SpeAss_run.py b/GeneNER_SpeAss_run.py
index b77484e9359aaa9447bba0fa0c9b8dba03ea073f..82aece37971c4f6f56eea1043d4f7f6e03b6a1b5 100755
--- a/GeneNER_SpeAss_run.py
+++ b/GeneNER_SpeAss_run.py
@@ -1,746 +1,746 @@
-# -*- coding: utf-8 -*-
-"""
-Created on Wed Jun 8 09:26:57 2022
-
-@author: luol2
-
-Pipeline: first gene NER, then species assignment
-input: species NER bioc xml file
-output: gene ner and species assignment results bioc xml file
-"""
-import argparse
-import os
-import io
-import time
-import sys
-import re
-import shutil
-from src_python.GeneNER import model_ner,ner_tag
-from src_python.SpeAss import model_sa,sa_tag
-
-import tensorflow as tf
-
-import bioc
-import stanza
-nlp_token = stanza.Pipeline(model_dir='gnorm_trained_models/stanza', lang='en', processors={'tokenize': 'spacy'},package='None', download_method=None) #package='craft' ;./gnorm_trained_models/stanza
-
-def NER_BioC(infolder,infile,outpath,nn_model):
-
- with open(infolder+"/"+infile, 'r',encoding='utf-8') as fin:
- with open(outpath+"/"+infile,'w', encoding='utf8') as fout:
- collection = bioc.load(fin)
-
- Total_n=len(collection.documents)
- print('Total number of sub-documents:', Total_n)
- pmid_n=0
- for document in collection.documents:
- print("Processing:{0}%".format(round(pmid_n * 100 / Total_n)), end="\r")
- pmid_n+=1
- # print(document.id)
- mention_num_new=0
- for passage in document.passages:
- if passage.text!='' and (not passage.text.isspace()) and passage.infons['type']!='ref': # have text and is not ref
- passage_offset=passage.offset
- tag_result=ner_tag.ML_Tag(passage.text,nn_model,nlp_token)
- mention_num=0
- for ele in tag_result:
- bioc_note = bioc.BioCAnnotation()
- bioc_note.id = str(mention_num)
- mention_num+=1
- bioc_note.infons['type'] = ele[2]
- start = int(ele[0])
- last = int(ele[1])
- loc = bioc.BioCLocation(offset=str(passage_offset+start), length= str(last-start))
- bioc_note.locations.append(loc)
- bioc_note.text = passage.text[start:last]
- passage.annotations.append(bioc_note)
- #update id
- for temp_annotation in passage.annotations:
- temp_annotation.id=str(mention_num_new)
- mention_num_new+=1
- bioc.dump(collection, fout, pretty_print=True)
-
-def NER_PubTator(infolder,infile,outpath,nn_model):
- with open(infolder+"/"+infile, 'r',encoding='utf-8') as fin:
- with open(outpath+"/"+infile,'w', encoding='utf-8') as fout:
- title=''
- abstract=''
- all_text=fin.read().strip().split('\n\n')
- Total_n=len(all_text)
- print('Total number of sub-documents:', Total_n)
- pmid_n=0
- for doc in all_text:
- print("Processing:{0}%".format(round(pmid_n * 100 / Total_n)), end="\r")
- pmid_n+=1
- lines = doc.split('\n')
- seg=lines[0].split('|t|')
- pmid=seg[0]
- title=""
- if len(seg)>1:
- title=seg[1]
- abstract=""
- if len(lines)>1:
- seg=lines[1].split('|a|')
- abstract=seg[1]
- if len(seg)>1:
- abstract=seg[1]
-
- intext=title+' '+abstract
- tag_result=ner_tag.ML_Tag(intext,nn_model,nlp_token)
- fout.write(doc+'\n')
- for ele in tag_result:
- ent_start = ele[0]
- ent_last = ele[1]
- ent_mention = intext[int(ele[0]):int(ele[1])]
- ent_type=ele[2]
- fout.write(pmid+"\t"+ent_start+"\t"+ent_last+"\t"+ent_mention+"\t"+ent_type+"\n")
- fout.write('\n')
- title=''
- abstract=''
-
-def geneNER(infolder, outpath, modelfile):
-
- print('loading NER models........')
-
- if modelfile.lower().find('bioformer')>=0:
- vocabfiles={'labelfile':'./vocab/GeneNER_label.vocab',
- 'checkpoint_path':'./gnorm_trained_models/bioformer-cased-v1.0/', #bioformer-cased-v1.0
- 'lowercase':False,
- }
- else:
- vocabfiles={'labelfile':'./vocab/GeneNER_label.vocab',
- 'checkpoint_path':'./gnorm_trained_models/BiomedNLP-PubMedBERT-base-uncased-abstract/',
- 'lowercase':True,
- }
-
- nn_model=model_ner.HUGFACE_NER(vocabfiles)
- nn_model.build_encoder()
- nn_model.build_softmax_decoder()
- nn_model.load_model(modelfile)
-
- #tagging text
- print("begin GeneNER tagging........")
- start_time=time.time()
-
- for infile in os.listdir(infolder):
- if os.path.isfile(outpath+"/"+infile):
- print(infile+' has exsited.')
- else:
- print('processing:',infile)
- fin = open(infolder+"/"+infile, 'r',encoding='utf-8')
- input_format=""
- for line in fin:
- pattern_bioc = re.compile('.*.*')
- pattern_pubtator = re.compile('^([^\|]+)\|[^\|]+\|(.*)')
- if pattern_bioc.search(line):
- input_format="BioC"
- break
- elif pattern_pubtator.search(line):
- input_format="PubTator"
- break
- fin.close()
- if(input_format == "PubTator"):
- NER_PubTator(infolder,infile,outpath,nn_model)
- elif(input_format == "BioC"):
- NER_BioC(infolder,infile,outpath,nn_model)
-
- print('tag done:',time.time()-start_time)
-
-
-#SA for bioc format
-def SA_BioC(infolder,infile,outpath,nn_model,virus_set,prefix_dict):
-
- #BioC xml to pubtator
- # pmid|t|text1
- #pmid|a|text2
- #pmid sid eid entity_txt entity_type entity_id (gene is blank)
- fin = open(infolder+"/"+infile, 'r',encoding='utf-8')
- # fout_pubtator=open(outpath+'tmp/input_xml.pubtator','w', encoding='utf-8')
- fin_pubtator0=io.StringIO() #none *species
- fin_pubtator1=io.StringIO() #one *species
- fin_pubtator2=io.StringIO() #two or more species
- collection = bioc.load(fin)
- fin.close()
- ori_ann_index={} #{'pmid':{'ent.id':'ent_s-ent_e'}}
- species_count={} #{pmid:{speid:num}}
- gene_set=['Gene','FamilyName']
- final_sa_results={} #{'pmid':{'entity_id':species_id}}
- for document in collection.documents:
- doc_pmid=document.id
- doc_title=''
- doc_abstract=''
- doc_annotation=[]
- _ann_index={}
- _species_num={} #{*speciesid:num}
- _gene_num=0
- _passage_num=0
- if len(document.passages)<=2: #abstract xml or PMC only have title
- for passage in document.passages:
- passage_offset=passage.offset
- _passage_num+=1
- #print(passage_offset,type(passage_offset))
- #if passage.infons['type']=='title' or passage.infons['type']=='front':
- if _passage_num==1:
- doc_title=passage.text
- for temp_annotation in passage.annotations:
- if temp_annotation.infons['type'] in gene_set:
- _gene_num+=1
- ent_start=temp_annotation.locations[0].offset-passage_offset
- ent_end=ent_start+temp_annotation.locations[0].length
- #print(ent_start,ent_end)
- _ann_index[temp_annotation.id]=str(ent_start)+'-'+str(ent_end)
- # print(temp_annotation.infons)
- if 'Identifier' in temp_annotation.infons.keys():
- # print(temp_annotation.infons.keys['Identifier'])
- species_ID=temp_annotation.infons['Identifier']
- if species_ID.find('*')>=0:
- if species_ID not in _species_num.keys():
- _species_num[species_ID]=1
- else:
- _species_num[species_ID]+=1
- doc_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type']+'\t'+species_ID)
- else:
- doc_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type'])
-
- #elif passage.infons['type']=='abstract' or passage.infons['type']=='paragraph':
- else:
- doc_abstract=passage.text
- for temp_annotation in passage.annotations:
- if temp_annotation.infons['type'] in gene_set:
- _gene_num+=1
- ent_start=len(doc_title)+1+temp_annotation.locations[0].offset-passage_offset
- ent_end=ent_start+temp_annotation.locations[0].length
- #print(ent_start,ent_end)
- _ann_index[temp_annotation.id]=str(ent_start)+'-'+str(ent_end)
- if 'Identifier' in temp_annotation.infons.keys():
- # print(temp_annotation.infons.keys['Identifier'])
- species_ID=temp_annotation.infons['Identifier']
- if species_ID.find('*')>=0:
- if species_ID not in _species_num.keys():
- _species_num[species_ID]=1
- else:
- _species_num[species_ID]+=1
- doc_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type']+'\t'+species_ID)
- else:
- doc_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type'])
-
- if len(_species_num)>=2 and _gene_num>0:
- fin_pubtator2.write(doc_pmid+'|t|'+doc_title+'\n')
- fin_pubtator2.write(doc_pmid+'|a|'+doc_abstract+'\n')
- for ele in doc_annotation:
- fin_pubtator2.write(ele+'\n')
- fin_pubtator2.write('\n')
- elif len(_species_num)==1 and _gene_num>0: #可以直接给结果
- fin_pubtator1.write(doc_pmid+'|t|'+doc_title+'\n')
- fin_pubtator1.write(doc_pmid+'|a|'+doc_abstract+'\n')
- major_speicesid,=_species_num
- fin_pubtator1.write(major_speicesid[1:]+'\n')
- for ele in doc_annotation:
- fin_pubtator1.write(ele+'\n')
- fin_pubtator1.write('\n')
- elif len(_species_num)==0 and _gene_num>0:
- fin_pubtator0.write(doc_pmid+'|t|'+doc_title+'\n')
- fin_pubtator0.write(doc_pmid+'|a|'+doc_abstract+'\n')
- for ele in doc_annotation:
- fin_pubtator0.write(ele+'\n')
- fin_pubtator0.write('\n')
-
- else: # full text xml
- for passage in document.passages:
- passage_annotation=[]
- _species_num_passage={}
- _gene_num_passage=0
- passage_offset=passage.offset
- #print(passage_offset,type(passage_offset))
- if passage.text!='' and (not passage.text.isspace()) and passage.infons['type']!='ref':
- doc_title=passage.text
- for temp_annotation in passage.annotations:
- if temp_annotation.infons['type'] in gene_set:
- _gene_num_passage+=1
- ent_start=temp_annotation.locations[0].offset-passage_offset
- ent_end=ent_start+temp_annotation.locations[0].length
- #print(ent_start,ent_end)
- _ann_index[temp_annotation.id]=str(ent_start)+'-'+str(ent_end)
- # print(temp_annotation.infons)
- if 'Identifier' in temp_annotation.infons.keys():
- # print(temp_annotation.infons.keys['Identifier'])
- species_ID=temp_annotation.infons['Identifier']
- if species_ID.find('*')>=0:
- if species_ID not in _species_num.keys():
- _species_num[species_ID]=1
- else:
- _species_num[species_ID]+=1
- if species_ID not in _species_num_passage.keys():
- _species_num_passage[species_ID]=1
- else:
- _species_num_passage[species_ID]+=1
- passage_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type']+'\t'+species_ID)
- else:
- passage_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type'])
-
-
- if len(_species_num_passage)>=2 and _gene_num_passage>0:
- fin_pubtator2.write(doc_pmid+'|t|'+doc_title+'\n')
- fin_pubtator2.write(doc_pmid+'|a|'+doc_abstract+'\n')
- for ele in passage_annotation:
- fin_pubtator2.write(ele+'\n')
- fin_pubtator2.write('\n')
- elif len(_species_num_passage)==1 and _gene_num_passage>0: #可以直接给结果
- fin_pubtator1.write(doc_pmid+'|t|'+doc_title+'\n')
- fin_pubtator1.write(doc_pmid+'|a|'+doc_abstract+'\n')
- major_speicesid,=_species_num_passage
- fin_pubtator1.write(major_speicesid[1:]+'\n')
- for ele in passage_annotation:
- fin_pubtator1.write(ele+'\n')
- fin_pubtator1.write('\n')
- elif len(_species_num_passage)==0 and _gene_num_passage>0:
- fin_pubtator0.write(doc_pmid+'|t|'+doc_title+'\n')
- fin_pubtator0.write(doc_pmid+'|a|'+doc_abstract+'\n')
- for ele in passage_annotation:
- fin_pubtator0.write(ele+'\n')
- fin_pubtator0.write('\n')
- # print(ori_ann_index)
-
- ori_ann_index[doc_pmid]=_ann_index
- species_count[doc_pmid]=_species_num
-
-
- cache_geneid={} #{pmid:{gene1:{id1:num,id2:num}}}
-
- if fin_pubtator2.getvalue()!='':
- #pubtator format ML tagging
- # print(fin_pubtator2.getvalue())
- ml_out= sa_tag.ml_tag_main(fin_pubtator2,nlp_token, nn_model)
- #print(ml_out.getvalue())
- fin_result=io.StringIO(ml_out.getvalue())
- all_in=fin_result.read().strip().split('\n\n')
- #print('+2 species:',len(all_in))
- fin_result.close()
-
- prefix_speid_allset=set(prefix_dict.keys())
-
- for doc in all_in:
- lines=doc.split('\n')
- pmid=lines[0].split('|t|')[0]
- _prefix_str2id_dict={}
- doc_species=list(species_count[pmid].keys())
- for _spe_ele in doc_species:
- if _spe_ele[1:] in prefix_speid_allset:
- for ele in prefix_dict[_spe_ele[1:]]:
- _prefix_str2id_dict[ele]=_spe_ele[1:]
-
- for i in range(2,len(lines)):
- segs=lines[i].split('\t')
- if pmid not in final_sa_results.keys():
- final_sa_results[pmid]={segs[1]:'Focus:'+segs[-1]}
- else:
- final_sa_results[pmid][segs[1]]='Focus:'+segs[-1]
-
- if segs[5] in gene_set:
- if segs[4][0:2] in _prefix_str2id_dict: #prefix rule
- #print('prefix rule:', pmid)
- # print(_prefix_str2id_dict)
- if pmid not in final_sa_results.keys():
- final_sa_results[pmid]={segs[1]:'Focus:'+_prefix_str2id_dict[segs[4][0:2]]}
- else:
- final_sa_results[pmid][segs[1]]='Focus:'+_prefix_str2id_dict[segs[4][0:2]]
- if pmid not in cache_geneid.keys():
- cache_geneid[pmid]={segs[4]:{'Focus:'+segs[-1]:1}}
- else:
- if segs[4] not in cache_geneid[pmid].keys():
- cache_geneid[pmid][segs[4]]={'Focus:'+segs[-1]:1}
- else:
- if segs[-1] not in cache_geneid[pmid][segs[4]].keys():
- cache_geneid[pmid][segs[4]]['Focus:'+segs[-1]]=1
- else:
- cache_geneid[pmid][segs[4]]['Focus:'+segs[-1]]+=1
-
- #print(final_sa_results)
-
- #one species
- if fin_pubtator1.getvalue()!='':
- fin_result=io.StringIO(fin_pubtator1.getvalue())
- all_in=fin_result.read().strip().split('\n\n')
- fin_result.close()
- #print('1 species:',len(all_in))
- for doc in all_in:
- lines=doc.split('\n')
- pmid=lines[0].split('|t|')[0]
- major_speicesid=lines[2]
- for i in range(3,len(lines)):
- segs=lines[i].split('\t')
- if len(segs)>=7:#species
- if pmid not in final_sa_results.keys():
- final_sa_results[pmid]={segs[1]:segs[-1]}
- else:
- final_sa_results[pmid][segs[1]]=segs[-1]
- else:#gene
- marjor_species='Focus:'+major_speicesid
- if pmid not in final_sa_results.keys():
- final_sa_results[pmid]={segs[1]:marjor_species}
- else:
- final_sa_results[pmid][segs[1]]=marjor_species
- if pmid not in cache_geneid.keys():
- cache_geneid[pmid]={segs[4]:{marjor_species:1}}
- else:
- if segs[4] not in cache_geneid[pmid].keys():
- cache_geneid[pmid][segs[4]]={marjor_species:1}
- else:
- if segs[-1] not in cache_geneid[pmid][segs[4]].keys():
- cache_geneid[pmid][segs[4]][marjor_species]=1
- else:
- cache_geneid[pmid][segs[4]][marjor_species]+=1
-
-
- #no species
- fin_result=io.StringIO(fin_pubtator0.getvalue())
- all_in=fin_result.read().strip().split('\n\n')
- fin_result.close()
- #print('no species:',len(all_in))
- for doc in all_in:
- lines=doc.split('\n')
- pmid=lines[0].split('|t|')[0]
-
- for i in range(2,len(lines)):
- segs=lines[i].split('\t')
- if (pmid in cache_geneid.keys()) and (segs[4] in cache_geneid[pmid].keys()):#same gene in doc
- marjor_species = max(zip(cache_geneid[pmid][segs[4]].values(), cache_geneid[pmid][segs[4]].keys()))
- if pmid not in final_sa_results.keys():
- final_sa_results[pmid]={segs[1]:marjor_species[1]}
- else:
- final_sa_results[pmid][segs[1]]=marjor_species[1]
- else: #marjor species in doc
- if (pmid in species_count.keys()) and len(species_count[pmid])>0:#marjor species in doc
- marjor_species = max(zip(species_count[pmid].values(), species_count[pmid].keys()))
-
- if pmid not in final_sa_results.keys():
- final_sa_results[pmid]={segs[1]:'Focus:'+marjor_species[1][1:]}
- else:
- final_sa_results[pmid][segs[1]]='Focus:'+marjor_species[1][1:]
- else:#no any species in doc,assign human
- if pmid not in final_sa_results.keys():
- final_sa_results[pmid]={segs[1]:'Focus:9606'}
- else:
- final_sa_results[pmid][segs[1]]='Focus:9606'
-
-
-
- # print(final_sa_results)
- fin = open(infolder+"/"+infile, 'r',encoding='utf-8')
- fout_xml=open(outpath+"/"+infile,'w', encoding='utf8')
- collection = bioc.load(fin)
- for document in collection.documents:
- doc_pmid=document.id
- # print(final_sa_results[doc_pmid])
- # print(doc_pmid)
- for passage in document.passages:
- for temp_annotation in passage.annotations:
- if 'Identifier' not in temp_annotation.infons.keys():
- if temp_annotation.id in final_sa_results[doc_pmid].keys():
- if final_sa_results[doc_pmid][temp_annotation.id][6:] in virus_set:
- temp_annotation.infons['Identifier']=final_sa_results[doc_pmid][temp_annotation.id]+',9606'
- # print('!!! virus:', doc_pmid)
- else:
- temp_annotation.infons['Identifier']=final_sa_results[doc_pmid][temp_annotation.id]
- else: #same text bug
- if (doc_pmid in cache_geneid.keys()) and (temp_annotation.text in cache_geneid[doc_pmid].keys()):#same gene in doc
- marjor_species = max(zip(cache_geneid[doc_pmid][temp_annotation.text].values(), cache_geneid[doc_pmid][temp_annotation.text].keys()))
- temp_annotation.infons['Identifier']=marjor_species[1]
- else:
-
- temp_annotation.infons['Identifier']='Focus:9606'
- bioc.dump(collection, fout_xml, pretty_print=True)
- fin.close()
- fout_xml.close()
-
-
-#SA for PubTator format
-def SA_PubTator(infolder,infile,outpath,nn_model,virus_set,prefix_dict):
-
-
- # pmid|t|text1
- #pmid|a|text2
- #pmid entity_id sid eid entity_txt entity_type (gene is blank)
- fin = open(infolder+"/"+infile, 'r',encoding='utf-8')
- # fout_pubtator=open(outpath+'tmp/input_xml.pubtator','w', encoding='utf-8')
- fin_pubtator2=io.StringIO() #two or more species
- all_in_ori=fin.read().strip().split('\n\n')
- fin.close()
- species_gene_count={} #{pmid:{'spec':_species_num;'gene':_gene_num}}
- gene_set=['Gene','FamilyName']
- ML_results={} #{'pmid':{'sid-eid':species_id}}
-
- prefix_speid_allset=set(prefix_dict.keys())
-
- for document in all_in_ori:
- lines=document.split('\n')
- doc_pmid=lines[0].split('|t|')[0]
- doc_title=lines[0].split('|t|')[1]
- doc_abstract=lines[1].split('|a|')[1]
- doc_annotation=[]
- _species_num=set() #(*speciesid)
- _gene_num=0
- _ML_gene_num=0
- _entity_num=0
- _prefix_str2id_dict={} #{prestr:id}
- for i in range(2,len(lines)):
- segs=lines[i].split('\t')
- if segs[4] in gene_set:
- _gene_num+=1
- if len(segs)>=6: #species
- doc_annotation.append(segs[0]+'\t'+str(_entity_num)+'\t'+'\t'.join(segs[1:]))
- species_ID=segs[-1]
- if species_ID.find('*')>=0:
- _species_num.add(species_ID)
- if species_ID[1:] in prefix_speid_allset:
- for ele in prefix_dict[species_ID[1:]]:
- _prefix_str2id_dict[ele]=species_ID[1:]
- else: #gene
- if segs[3][0:2] in _prefix_str2id_dict:#prefix rule
- if _prefix_str2id_dict[segs[3][0:2]] in virus_set:
- doc_annotation.append(segs[0]+'\t'+str(_entity_num)+'\t'+'\t'.join(segs[1:])+'\tFocus:'+_prefix_str2id_dict[segs[3][0:2]]+',9606')
- if doc_pmid not in ML_results.keys():
- ML_results[doc_pmid]={segs[1]+'-'+segs[2]:_prefix_str2id_dict[segs[3][0:2]]+',9606'}
- else:
- ML_results[doc_pmid][segs[1]+'-'+segs[2]]=_prefix_str2id_dict[segs[3][0:2]]+',9606'
-
- # print('!!! prefixr and virus:', doc_pmid)
- else:
- doc_annotation.append(segs[0]+'\t'+str(_entity_num)+'\t'+'\t'.join(segs[1:])+'\tFocus:'+_prefix_str2id_dict[segs[3][0:2]])
- if doc_pmid not in ML_results.keys():
- ML_results[doc_pmid]={segs[1]+'-'+segs[2]:_prefix_str2id_dict[segs[3][0:2]]}
- else:
- ML_results[doc_pmid][segs[1]+'-'+segs[2]]=_prefix_str2id_dict[segs[3][0:2]]
- # print('prefix rule!!',_prefix_str2id_dict)
- # print(doc_pmid)
- else:
- doc_annotation.append(segs[0]+'\t'+str(_entity_num)+'\t'+'\t'.join(segs[1:]))
- if segs[4] in gene_set:
- _ML_gene_num+=1
- _entity_num+=1
-
- if len(_species_num)>=2 and _ML_gene_num>0:
- fin_pubtator2.write(doc_pmid+'|t|'+doc_title+'\n')
- fin_pubtator2.write(doc_pmid+'|a|'+doc_abstract+'\n')
- for ele in doc_annotation:
- fin_pubtator2.write(ele+'\n')
- fin_pubtator2.write('\n')
-
- species_gene_count[doc_pmid]={'spec':_species_num,'gene':_gene_num}
-
- if fin_pubtator2.getvalue()!='':
- #pubtator format ML tagging
- #print(fin_pubtator2.getvalue())
- ml_out= sa_tag.ml_tag_main(fin_pubtator2,nlp_token, nn_model)
- #print(ml_out.getvalue())
- fin_result=io.StringIO(ml_out.getvalue())
- all_in=fin_result.read().strip().split('\n\n')
- #print('+2 species:',len(all_in))
- fin_result.close()
- for doc in all_in:
- lines=doc.split('\n')
- pmid=lines[0].split('|t|')[0]
-
- for i in range(2,len(lines)):
- segs=lines[i].split('\t')
- if pmid not in ML_results.keys():
- ML_results[pmid]={segs[2]+'-'+segs[3]:segs[-1]}
- else:
- ML_results[pmid][segs[2]+'-'+segs[3]]=segs[-1]
-
- #output
- fout_pubtator=open(outpath+"/"+infile,'w', encoding='utf8')
- for doc in all_in_ori:
- lines=doc.split('\n')
- pmid=lines[0].split('|t|')[0]
- fout_pubtator.write(lines[0]+'\n'+lines[1]+'\n')
- if len(species_gene_count[pmid]['spec'])>1 and species_gene_count[pmid]['gene']>0: # ML
- for i in range(2,len(lines)):
- segs=lines[i].split('\t')
- if len(segs)>=6: #species
- fout_pubtator.write(lines[i]+'\n')
- else:#gene
- if ML_results[pmid][segs[1]+'-'+segs[2]] in virus_set:
- fout_pubtator.write(lines[i]+'\tFocus:'+ML_results[pmid][segs[1]+'-'+segs[2]]+',9606'+'\n')
- # print('!!! virus:', pmid)
- else:
- fout_pubtator.write(lines[i]+'\tFocus:'+ML_results[pmid][segs[1]+'-'+segs[2]]+'\n')
- fout_pubtator.write('\n')
-
- elif len(species_gene_count[pmid]['spec'])==1 and species_gene_count[pmid]['gene']>0: #only one species
- for i in range(2,len(lines)):
- segs=lines[i].split('\t')
- if len(segs)>=6: #species
- fout_pubtator.write(lines[i]+'\n')
- else:#gene
- major_species,=species_gene_count[pmid]['spec']
- if major_species[1:] in virus_set:
- fout_pubtator.write(lines[i]+'\tFocus:'+major_species[1:]+',9606'+'\n')
- # print('!!! virus:', pmid)
- fout_pubtator.write(lines[i]+'\tFocus:'+major_species[1:]+'\n')
- fout_pubtator.write('\n')
-
- elif len(species_gene_count[pmid]['spec'])==0 and species_gene_count[pmid]['gene']>0:#no species
- for i in range(2,len(lines)):
- segs=lines[i].split('\t')
- if len(segs)>=6: #species
- fout_pubtator.write(lines[i]+'\n')
- else:#gene
- fout_pubtator.write(lines[i]+'\tFocus:9606'+'\n')
- fout_pubtator.write('\n')
-
- else:
- for i in range(2,len(lines)):
- fout_pubtator.write(lines[i]+'\n')
- fout_pubtator.write('\n')
- fout_pubtator.close()
-
-
-#SA main
-def speciesAss(infolder,outpath, modelfile):
-
- if modelfile.lower().find('bioformer')>=0:
- model_type='bioformer'
- else:
- model_type='pubmedbert'
-
- print('loading SA models........')
- if model_type=='bioformer':
-
- vocabfiles={'labelfile':'./vocab/SpeAss_IO_label.vocab',
- 'checkpoint_path':'./gnorm_trained_models/bioformer-cased-v1.0/',
- 'lowercase':False,
- }
- else:
- vocabfiles={'labelfile':'./vocab/SpeAss_IO_label.vocab',
- 'checkpoint_path':'./gnorm_trained_models/BiomedNLP-PubMedBERT-base-uncased-abstract/',
- 'lowercase':True,
- }
-
- nn_model=model_sa.HUGFACE_NER(vocabfiles)
- nn_model.build_encoder()
- nn_model.build_softmax_decoder()
- nn_model.load_model(modelfile)
-
- dict_filename={'prefix':'./Dictionary/SPPrefix.txt',
- 'virus':'./Dictionary/SP_Virus2HumanList.txt'}
- fin=open(dict_filename['virus'],'r',encoding='utf-8')
- virus_set=set(fin.read().strip().split('\n'))
- fin.close()
-
- prefix_dict={}#{id:[prefix1,prefix2]}
- fin=open(dict_filename['prefix'],'r',encoding='utf-8')
- for line in fin:
- seg= line.strip().split('\t')
- if seg[0] not in prefix_dict.keys():
- prefix_dict[seg[0]]=seg[1].split('|')
- else:
- prefix_dict[seg[0]].extend(seg[1].split('|'))
- fin.close()
-
-
-
- print("begin species assignment........")
- start_time=time.time()
-
- for infile in os.listdir(infolder):
- if os.path.isfile(outpath+"/"+infile):
- print(infile+' has exsited.')
- else:
- print('Processing:',infile)
- fin=open(infolder+"/"+infile, 'r',encoding='utf-8')
- file_format=""
- for line in fin:
- pattern_bioc = re.compile('.*.*')
- pattern_pubtator = re.compile('^([^\|]+)\|[^\|]+\|(.*)')
- if pattern_bioc.search(line):
- file_format="BioC"
- break
- elif pattern_pubtator.search(line):
- file_format="PubTator"
- break
- fin.close()
- if(file_format == "PubTator"):
- SA_PubTator(infolder,infile,outpath,nn_model,virus_set,prefix_dict)
- elif(file_format == "BioC"):
- SA_BioC(infolder,infile,outpath,nn_model,virus_set,prefix_dict)
-
-
- print('species assignment done:',time.time()-start_time)
-
-if __name__=='__main__':
-
- parser = argparse.ArgumentParser(description='run GeneNER and species assignment, python GeneNER_SpeAss_run.py -i input -n NERmodel -s SAmodel -r neroutput -a saoutput')
- parser.add_argument('--infolder', '-i', help="input folder",default='./example/input/')
- parser.add_argument('--NERmodel', '-n', help="trained deep learning NER model file",default='')
- parser.add_argument('--SAmodel', '-s', help="trained deep learning species assignment model file",default='')
- parser.add_argument('--NERoutpath', '-r', help="output folder to save the NER tagged results",default='./example/ner_output/')
- parser.add_argument('--SAoutpath', '-a', help="output folder to save the SA tagged results",default='./example/sa_output/')
- parser.add_argument('--NUM_THREADS', '-t', help="Number of threads",default='3')
- args = parser.parse_args()
-
-
- if args.NUM_THREADS.isdigit() == False:
- args.NUM_THREADS='3'
-
- tf.config.threading.set_inter_op_parallelism_threads(int(args.NUM_THREADS))
- tf.config.threading.set_intra_op_parallelism_threads(int(args.NUM_THREADS))
-
- if args.NERmodel!='' and args.SAmodel!='':
-
- #pipleline
- print('==============\n| GeneNER and SpeAss |\n==============')
-
- #creat output folder
-
- if args.infolder[-1]!='/':
- args.infolder+='/'
- if not os.path.exists(args.infolder):
- os.makedirs(args.infolder)
-
- if args.NERoutpath[-1]!='/':
- args.NERoutpath+='/'
- if not os.path.exists(args.NERoutpath):
- os.makedirs(args.NERoutpath)
-
- if args.SAoutpath[-1]!='/':
- args.SAoutpath+='/'
- if not os.path.exists(args.SAoutpath):
- os.makedirs(args.SAoutpath)
-
- #1. gene NER, the results are saved in outpath/ner_tmp/
- geneNER(args.infolder,args.NERoutpath, args.NERmodel)
-
-
- #2. species assignment, the results are saved in outpath/sa_tmp/
- speciesAss(args.NERoutpath,args.SAoutpath, args.SAmodel)
-
- elif args.NERmodel!='' and args.SAmodel=='':
- if args.infolder[-1]!='/':
- args.infolder+='/'
- if not os.path.exists(args.infolder):
- os.makedirs(args.infolder)
-
- # only geneNER
- if args.NERoutpath[-1]!='/':
- args.NERoutpath+='/'
- if not os.path.exists(args.NERoutpath):
- os.makedirs(args.NERoutpath)
-
- print('==============\n| GeneNER |\n==============')
- geneNER(args.infolder,args.NERoutpath,args.NERmodel)
-
- elif args.NERmodel=='' and args.SAmodel!='':
- # only speass
- if args.SAoutpath[-1]!='/':
- args.SAoutpath+='/'
- if not os.path.exists(args.SAoutpath):
- os.makedirs(args.SAoutpath)
-
- print('==============\n| SpeAss |\n==============')
- speciesAss(args.infolder,args.SAoutpath,args.SAmodel)
- else:
- print('Please provide models!')
-
-
+# -*- coding: utf-8 -*-
+"""
+Created on Wed Jun 8 09:26:57 2022
+
+@author: luol2
+
+Pipeline: first gene NER, then species assignment
+input: species NER bioc xml file
+output: gene ner and species assignment results bioc xml file
+"""
+import argparse
+import os
+import io
+import time
+import sys
+import re
+import shutil
+from src_python.GeneNER import model_ner,ner_tag
+from src_python.SpeAss import model_sa,sa_tag
+
+import tensorflow as tf
+
+import bioc
+import stanza
+nlp_token = stanza.Pipeline(model_dir='gnorm_trained_models/stanza', lang='en', processors={'tokenize': 'spacy'},package='None', download_method=None) #package='craft' ;./gnorm_trained_models/stanza
+
+def NER_BioC(infolder,infile,outpath,nn_model):
+
+ with open(infolder+"/"+infile, 'r',encoding='utf-8') as fin:
+ with open(outpath+"/"+infile,'w', encoding='utf8') as fout:
+ collection = bioc.load(fin)
+
+ Total_n=len(collection.documents)
+ print('Total number of sub-documents:', Total_n)
+ pmid_n=0
+ for document in collection.documents:
+ print("Processing:{0}%".format(round(pmid_n * 100 / Total_n)), end="\r")
+ pmid_n+=1
+ # print(document.id)
+ mention_num_new=0
+ for passage in document.passages:
+ if passage.text!='' and (not passage.text.isspace()) and passage.infons['type']!='ref': # have text and is not ref
+ passage_offset=passage.offset
+ tag_result=ner_tag.ML_Tag(passage.text,nn_model,nlp_token)
+ mention_num=0
+ for ele in tag_result:
+ bioc_note = bioc.BioCAnnotation()
+ bioc_note.id = str(mention_num)
+ mention_num+=1
+ bioc_note.infons['type'] = ele[2]
+ start = int(ele[0])
+ last = int(ele[1])
+ loc = bioc.BioCLocation(offset=str(passage_offset+start), length= str(last-start))
+ bioc_note.locations.append(loc)
+ bioc_note.text = passage.text[start:last]
+ passage.annotations.append(bioc_note)
+ #update id
+ for temp_annotation in passage.annotations:
+ temp_annotation.id=str(mention_num_new)
+ mention_num_new+=1
+ bioc.dump(collection, fout, pretty_print=True)
+
+def NER_PubTator(infolder,infile,outpath,nn_model):
+ with open(infolder+"/"+infile, 'r',encoding='utf-8') as fin:
+ with open(outpath+"/"+infile,'w', encoding='utf-8') as fout:
+ title=''
+ abstract=''
+ all_text=fin.read().strip().split('\n\n')
+ Total_n=len(all_text)
+ print('Total number of sub-documents:', Total_n)
+ pmid_n=0
+ for doc in all_text:
+ print("Processing:{0}%".format(round(pmid_n * 100 / Total_n)), end="\r")
+ pmid_n+=1
+ lines = doc.split('\n')
+ seg=lines[0].split('|t|')
+ pmid=seg[0]
+ title=""
+ if len(seg)>1:
+ title=seg[1]
+ abstract=""
+ if len(lines)>1:
+ seg=lines[1].split('|a|')
+ abstract=seg[1]
+ if len(seg)>1:
+ abstract=seg[1]
+
+ intext=title+' '+abstract
+ tag_result=ner_tag.ML_Tag(intext,nn_model,nlp_token)
+ fout.write(doc+'\n')
+ for ele in tag_result:
+ ent_start = ele[0]
+ ent_last = ele[1]
+ ent_mention = intext[int(ele[0]):int(ele[1])]
+ ent_type=ele[2]
+ fout.write(pmid+"\t"+ent_start+"\t"+ent_last+"\t"+ent_mention+"\t"+ent_type+"\n")
+ fout.write('\n')
+ title=''
+ abstract=''
+
+def geneNER(infolder, outpath, modelfile):
+
+ print('loading NER models........')
+
+ if modelfile.lower().find('bioformer')>=0:
+ vocabfiles={'labelfile':'./vocab/GeneNER_label.vocab',
+ 'checkpoint_path':'./gnorm_trained_models/bioformer-cased-v1.0/', #bioformer-cased-v1.0
+ 'lowercase':False,
+ }
+ else:
+ vocabfiles={'labelfile':'./vocab/GeneNER_label.vocab',
+ 'checkpoint_path':'./gnorm_trained_models/BiomedNLP-PubMedBERT-base-uncased-abstract/',
+ 'lowercase':True,
+ }
+
+ nn_model=model_ner.HUGFACE_NER(vocabfiles)
+ nn_model.build_encoder()
+ nn_model.build_softmax_decoder()
+ nn_model.load_model(modelfile)
+
+ #tagging text
+ print("begin GeneNER tagging........")
+ start_time=time.time()
+
+ for infile in os.listdir(infolder):
+ if os.path.isfile(outpath+"/"+infile):
+ print(infile+' has exsited.')
+ else:
+ print('processing:',infile)
+ fin = open(infolder+"/"+infile, 'r',encoding='utf-8')
+ input_format=""
+ for line in fin:
+ pattern_bioc = re.compile('.*.*')
+ pattern_pubtator = re.compile('^([^\|]+)\|[^\|]+\|(.*)')
+ if pattern_bioc.search(line):
+ input_format="BioC"
+ break
+ elif pattern_pubtator.search(line):
+ input_format="PubTator"
+ break
+ fin.close()
+ if(input_format == "PubTator"):
+ NER_PubTator(infolder,infile,outpath,nn_model)
+ elif(input_format == "BioC"):
+ NER_BioC(infolder,infile,outpath,nn_model)
+
+ print('tag done:',time.time()-start_time)
+
+
+#SA for bioc format
+def SA_BioC(infolder,infile,outpath,nn_model,virus_set,prefix_dict):
+
+ #BioC xml to pubtator
+ # pmid|t|text1
+ #pmid|a|text2
+ #pmid sid eid entity_txt entity_type entity_id (gene is blank)
+ fin = open(infolder+"/"+infile, 'r',encoding='utf-8')
+ # fout_pubtator=open(outpath+'tmp/input_xml.pubtator','w', encoding='utf-8')
+ fin_pubtator0=io.StringIO() #none *species
+ fin_pubtator1=io.StringIO() #one *species
+ fin_pubtator2=io.StringIO() #two or more species
+ collection = bioc.load(fin)
+ fin.close()
+ ori_ann_index={} #{'pmid':{'ent.id':'ent_s-ent_e'}}
+ species_count={} #{pmid:{speid:num}}
+ gene_set=['Gene','FamilyName']
+ final_sa_results={} #{'pmid':{'entity_id':species_id}}
+ for document in collection.documents:
+ doc_pmid=document.id
+ doc_title=''
+ doc_abstract=''
+ doc_annotation=[]
+ _ann_index={}
+ _species_num={} #{*speciesid:num}
+ _gene_num=0
+ _passage_num=0
+ if len(document.passages)<=2: #abstract xml or PMC only have title
+ for passage in document.passages:
+ passage_offset=passage.offset
+ _passage_num+=1
+ #print(passage_offset,type(passage_offset))
+ #if passage.infons['type']=='title' or passage.infons['type']=='front':
+ if _passage_num==1:
+ doc_title=passage.text
+ for temp_annotation in passage.annotations:
+ if temp_annotation.infons['type'] in gene_set:
+ _gene_num+=1
+ ent_start=temp_annotation.locations[0].offset-passage_offset
+ ent_end=ent_start+temp_annotation.locations[0].length
+ #print(ent_start,ent_end)
+ _ann_index[temp_annotation.id]=str(ent_start)+'-'+str(ent_end)
+ # print(temp_annotation.infons)
+ if 'Identifier' in temp_annotation.infons.keys():
+ # print(temp_annotation.infons.keys['Identifier'])
+ species_ID=temp_annotation.infons['Identifier']
+ if species_ID.find('*')>=0:
+ if species_ID not in _species_num.keys():
+ _species_num[species_ID]=1
+ else:
+ _species_num[species_ID]+=1
+ doc_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type']+'\t'+species_ID)
+ else:
+ doc_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type'])
+
+ #elif passage.infons['type']=='abstract' or passage.infons['type']=='paragraph':
+ else:
+ doc_abstract=passage.text
+ for temp_annotation in passage.annotations:
+ if temp_annotation.infons['type'] in gene_set:
+ _gene_num+=1
+ ent_start=len(doc_title)+1+temp_annotation.locations[0].offset-passage_offset
+ ent_end=ent_start+temp_annotation.locations[0].length
+ #print(ent_start,ent_end)
+ _ann_index[temp_annotation.id]=str(ent_start)+'-'+str(ent_end)
+ if 'Identifier' in temp_annotation.infons.keys():
+ # print(temp_annotation.infons.keys['Identifier'])
+ species_ID=temp_annotation.infons['Identifier']
+ if species_ID.find('*')>=0:
+ if species_ID not in _species_num.keys():
+ _species_num[species_ID]=1
+ else:
+ _species_num[species_ID]+=1
+ doc_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type']+'\t'+species_ID)
+ else:
+ doc_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type'])
+
+ if len(_species_num)>=2 and _gene_num>0:
+ fin_pubtator2.write(doc_pmid+'|t|'+doc_title+'\n')
+ fin_pubtator2.write(doc_pmid+'|a|'+doc_abstract+'\n')
+ for ele in doc_annotation:
+ fin_pubtator2.write(ele+'\n')
+ fin_pubtator2.write('\n')
+ elif len(_species_num)==1 and _gene_num>0: #可以直接给结果
+ fin_pubtator1.write(doc_pmid+'|t|'+doc_title+'\n')
+ fin_pubtator1.write(doc_pmid+'|a|'+doc_abstract+'\n')
+ major_speicesid,=_species_num
+ fin_pubtator1.write(major_speicesid[1:]+'\n')
+ for ele in doc_annotation:
+ fin_pubtator1.write(ele+'\n')
+ fin_pubtator1.write('\n')
+ elif len(_species_num)==0 and _gene_num>0:
+ fin_pubtator0.write(doc_pmid+'|t|'+doc_title+'\n')
+ fin_pubtator0.write(doc_pmid+'|a|'+doc_abstract+'\n')
+ for ele in doc_annotation:
+ fin_pubtator0.write(ele+'\n')
+ fin_pubtator0.write('\n')
+
+ else: # full text xml
+ for passage in document.passages:
+ passage_annotation=[]
+ _species_num_passage={}
+ _gene_num_passage=0
+ passage_offset=passage.offset
+ #print(passage_offset,type(passage_offset))
+ if passage.text!='' and (not passage.text.isspace()) and passage.infons['type']!='ref':
+ doc_title=passage.text
+ for temp_annotation in passage.annotations:
+ if temp_annotation.infons['type'] in gene_set:
+ _gene_num_passage+=1
+ ent_start=temp_annotation.locations[0].offset-passage_offset
+ ent_end=ent_start+temp_annotation.locations[0].length
+ #print(ent_start,ent_end)
+ _ann_index[temp_annotation.id]=str(ent_start)+'-'+str(ent_end)
+ # print(temp_annotation.infons)
+ if 'Identifier' in temp_annotation.infons.keys():
+ # print(temp_annotation.infons.keys['Identifier'])
+ species_ID=temp_annotation.infons['Identifier']
+ if species_ID.find('*')>=0:
+ if species_ID not in _species_num.keys():
+ _species_num[species_ID]=1
+ else:
+ _species_num[species_ID]+=1
+ if species_ID not in _species_num_passage.keys():
+ _species_num_passage[species_ID]=1
+ else:
+ _species_num_passage[species_ID]+=1
+ passage_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type']+'\t'+species_ID)
+ else:
+ passage_annotation.append(doc_pmid+'\t'+temp_annotation.id+'\t'+str(ent_start)+'\t'+str(ent_end)+'\t'+temp_annotation.text+'\t'+temp_annotation.infons['type'])
+
+
+ if len(_species_num_passage)>=2 and _gene_num_passage>0:
+ fin_pubtator2.write(doc_pmid+'|t|'+doc_title+'\n')
+ fin_pubtator2.write(doc_pmid+'|a|'+doc_abstract+'\n')
+ for ele in passage_annotation:
+ fin_pubtator2.write(ele+'\n')
+ fin_pubtator2.write('\n')
+ elif len(_species_num_passage)==1 and _gene_num_passage>0: #可以直接给结果
+ fin_pubtator1.write(doc_pmid+'|t|'+doc_title+'\n')
+ fin_pubtator1.write(doc_pmid+'|a|'+doc_abstract+'\n')
+ major_speicesid,=_species_num_passage
+ fin_pubtator1.write(major_speicesid[1:]+'\n')
+ for ele in passage_annotation:
+ fin_pubtator1.write(ele+'\n')
+ fin_pubtator1.write('\n')
+ elif len(_species_num_passage)==0 and _gene_num_passage>0:
+ fin_pubtator0.write(doc_pmid+'|t|'+doc_title+'\n')
+ fin_pubtator0.write(doc_pmid+'|a|'+doc_abstract+'\n')
+ for ele in passage_annotation:
+ fin_pubtator0.write(ele+'\n')
+ fin_pubtator0.write('\n')
+ # print(ori_ann_index)
+
+ ori_ann_index[doc_pmid]=_ann_index
+ species_count[doc_pmid]=_species_num
+
+
+ cache_geneid={} #{pmid:{gene1:{id1:num,id2:num}}}
+
+ if fin_pubtator2.getvalue()!='':
+ #pubtator format ML tagging
+ # print(fin_pubtator2.getvalue())
+ ml_out= sa_tag.ml_tag_main(fin_pubtator2,nlp_token, nn_model)
+ #print(ml_out.getvalue())
+ fin_result=io.StringIO(ml_out.getvalue())
+ all_in=fin_result.read().strip().split('\n\n')
+ #print('+2 species:',len(all_in))
+ fin_result.close()
+
+ prefix_speid_allset=set(prefix_dict.keys())
+
+ for doc in all_in:
+ lines=doc.split('\n')
+ pmid=lines[0].split('|t|')[0]
+ _prefix_str2id_dict={}
+ doc_species=list(species_count[pmid].keys())
+ for _spe_ele in doc_species:
+ if _spe_ele[1:] in prefix_speid_allset:
+ for ele in prefix_dict[_spe_ele[1:]]:
+ _prefix_str2id_dict[ele]=_spe_ele[1:]
+
+ for i in range(2,len(lines)):
+ segs=lines[i].split('\t')
+ if pmid not in final_sa_results.keys():
+ final_sa_results[pmid]={segs[1]:'Focus:'+segs[-1]}
+ else:
+ final_sa_results[pmid][segs[1]]='Focus:'+segs[-1]
+
+ if segs[5] in gene_set:
+ if segs[4][0:2] in _prefix_str2id_dict: #prefix rule
+ #print('prefix rule:', pmid)
+ # print(_prefix_str2id_dict)
+ if pmid not in final_sa_results.keys():
+ final_sa_results[pmid]={segs[1]:'Focus:'+_prefix_str2id_dict[segs[4][0:2]]}
+ else:
+ final_sa_results[pmid][segs[1]]='Focus:'+_prefix_str2id_dict[segs[4][0:2]]
+ if pmid not in cache_geneid.keys():
+ cache_geneid[pmid]={segs[4]:{'Focus:'+segs[-1]:1}}
+ else:
+ if segs[4] not in cache_geneid[pmid].keys():
+ cache_geneid[pmid][segs[4]]={'Focus:'+segs[-1]:1}
+ else:
+ if segs[-1] not in cache_geneid[pmid][segs[4]].keys():
+ cache_geneid[pmid][segs[4]]['Focus:'+segs[-1]]=1
+ else:
+ cache_geneid[pmid][segs[4]]['Focus:'+segs[-1]]+=1
+
+ #print(final_sa_results)
+
+ #one species
+ if fin_pubtator1.getvalue()!='':
+ fin_result=io.StringIO(fin_pubtator1.getvalue())
+ all_in=fin_result.read().strip().split('\n\n')
+ fin_result.close()
+ #print('1 species:',len(all_in))
+ for doc in all_in:
+ lines=doc.split('\n')
+ pmid=lines[0].split('|t|')[0]
+ major_speicesid=lines[2]
+ for i in range(3,len(lines)):
+ segs=lines[i].split('\t')
+ if len(segs)>=7:#species
+ if pmid not in final_sa_results.keys():
+ final_sa_results[pmid]={segs[1]:segs[-1]}
+ else:
+ final_sa_results[pmid][segs[1]]=segs[-1]
+ else:#gene
+ marjor_species='Focus:'+major_speicesid
+ if pmid not in final_sa_results.keys():
+ final_sa_results[pmid]={segs[1]:marjor_species}
+ else:
+ final_sa_results[pmid][segs[1]]=marjor_species
+ if pmid not in cache_geneid.keys():
+ cache_geneid[pmid]={segs[4]:{marjor_species:1}}
+ else:
+ if segs[4] not in cache_geneid[pmid].keys():
+ cache_geneid[pmid][segs[4]]={marjor_species:1}
+ else:
+ if segs[-1] not in cache_geneid[pmid][segs[4]].keys():
+ cache_geneid[pmid][segs[4]][marjor_species]=1
+ else:
+ cache_geneid[pmid][segs[4]][marjor_species]+=1
+
+
+ #no species
+ fin_result=io.StringIO(fin_pubtator0.getvalue())
+ all_in=fin_result.read().strip().split('\n\n')
+ fin_result.close()
+ #print('no species:',len(all_in))
+ for doc in all_in:
+ lines=doc.split('\n')
+ pmid=lines[0].split('|t|')[0]
+
+ for i in range(2,len(lines)):
+ segs=lines[i].split('\t')
+ if (pmid in cache_geneid.keys()) and (segs[4] in cache_geneid[pmid].keys()):#same gene in doc
+ marjor_species = max(zip(cache_geneid[pmid][segs[4]].values(), cache_geneid[pmid][segs[4]].keys()))
+ if pmid not in final_sa_results.keys():
+ final_sa_results[pmid]={segs[1]:marjor_species[1]}
+ else:
+ final_sa_results[pmid][segs[1]]=marjor_species[1]
+ else: #marjor species in doc
+ if (pmid in species_count.keys()) and len(species_count[pmid])>0:#marjor species in doc
+ marjor_species = max(zip(species_count[pmid].values(), species_count[pmid].keys()))
+
+ if pmid not in final_sa_results.keys():
+ final_sa_results[pmid]={segs[1]:'Focus:'+marjor_species[1][1:]}
+ else:
+ final_sa_results[pmid][segs[1]]='Focus:'+marjor_species[1][1:]
+ else:#no any species in doc,assign human
+ if pmid not in final_sa_results.keys():
+ final_sa_results[pmid]={segs[1]:'Focus:9606'}
+ else:
+ final_sa_results[pmid][segs[1]]='Focus:9606'
+
+
+
+ # print(final_sa_results)
+ fin = open(infolder+"/"+infile, 'r',encoding='utf-8')
+ fout_xml=open(outpath+"/"+infile,'w', encoding='utf8')
+ collection = bioc.load(fin)
+ for document in collection.documents:
+ doc_pmid=document.id
+ # print(final_sa_results[doc_pmid])
+ # print(doc_pmid)
+ for passage in document.passages:
+ for temp_annotation in passage.annotations:
+ if 'Identifier' not in temp_annotation.infons.keys():
+ if temp_annotation.id in final_sa_results[doc_pmid].keys():
+ if final_sa_results[doc_pmid][temp_annotation.id][6:] in virus_set:
+ temp_annotation.infons['Identifier']=final_sa_results[doc_pmid][temp_annotation.id]+',9606'
+ # print('!!! virus:', doc_pmid)
+ else:
+ temp_annotation.infons['Identifier']=final_sa_results[doc_pmid][temp_annotation.id]
+ else: #same text bug
+ if (doc_pmid in cache_geneid.keys()) and (temp_annotation.text in cache_geneid[doc_pmid].keys()):#same gene in doc
+ marjor_species = max(zip(cache_geneid[doc_pmid][temp_annotation.text].values(), cache_geneid[doc_pmid][temp_annotation.text].keys()))
+ temp_annotation.infons['Identifier']=marjor_species[1]
+ else:
+
+ temp_annotation.infons['Identifier']='Focus:9606'
+ bioc.dump(collection, fout_xml, pretty_print=True)
+ fin.close()
+ fout_xml.close()
+
+
+#SA for PubTator format
+def SA_PubTator(infolder,infile,outpath,nn_model,virus_set,prefix_dict):
+
+
+ # pmid|t|text1
+ #pmid|a|text2
+ #pmid entity_id sid eid entity_txt entity_type (gene is blank)
+ fin = open(infolder+"/"+infile, 'r',encoding='utf-8')
+ # fout_pubtator=open(outpath+'tmp/input_xml.pubtator','w', encoding='utf-8')
+ fin_pubtator2=io.StringIO() #two or more species
+ all_in_ori=fin.read().strip().split('\n\n')
+ fin.close()
+ species_gene_count={} #{pmid:{'spec':_species_num;'gene':_gene_num}}
+ gene_set=['Gene','FamilyName']
+ ML_results={} #{'pmid':{'sid-eid':species_id}}
+
+ prefix_speid_allset=set(prefix_dict.keys())
+
+ for document in all_in_ori:
+ lines=document.split('\n')
+ doc_pmid=lines[0].split('|t|')[0]
+ doc_title=lines[0].split('|t|')[1]
+ doc_abstract=lines[1].split('|a|')[1]
+ doc_annotation=[]
+ _species_num=set() #(*speciesid)
+ _gene_num=0
+ _ML_gene_num=0
+ _entity_num=0
+ _prefix_str2id_dict={} #{prestr:id}
+ for i in range(2,len(lines)):
+ segs=lines[i].split('\t')
+ if segs[4] in gene_set:
+ _gene_num+=1
+ if len(segs)>=6: #species
+ doc_annotation.append(segs[0]+'\t'+str(_entity_num)+'\t'+'\t'.join(segs[1:]))
+ species_ID=segs[-1]
+ if species_ID.find('*')>=0:
+ _species_num.add(species_ID)
+ if species_ID[1:] in prefix_speid_allset:
+ for ele in prefix_dict[species_ID[1:]]:
+ _prefix_str2id_dict[ele]=species_ID[1:]
+ else: #gene
+ if segs[3][0:2] in _prefix_str2id_dict:#prefix rule
+ if _prefix_str2id_dict[segs[3][0:2]] in virus_set:
+ doc_annotation.append(segs[0]+'\t'+str(_entity_num)+'\t'+'\t'.join(segs[1:])+'\tFocus:'+_prefix_str2id_dict[segs[3][0:2]]+',9606')
+ if doc_pmid not in ML_results.keys():
+ ML_results[doc_pmid]={segs[1]+'-'+segs[2]:_prefix_str2id_dict[segs[3][0:2]]+',9606'}
+ else:
+ ML_results[doc_pmid][segs[1]+'-'+segs[2]]=_prefix_str2id_dict[segs[3][0:2]]+',9606'
+
+ # print('!!! prefixr and virus:', doc_pmid)
+ else:
+ doc_annotation.append(segs[0]+'\t'+str(_entity_num)+'\t'+'\t'.join(segs[1:])+'\tFocus:'+_prefix_str2id_dict[segs[3][0:2]])
+ if doc_pmid not in ML_results.keys():
+ ML_results[doc_pmid]={segs[1]+'-'+segs[2]:_prefix_str2id_dict[segs[3][0:2]]}
+ else:
+ ML_results[doc_pmid][segs[1]+'-'+segs[2]]=_prefix_str2id_dict[segs[3][0:2]]
+ # print('prefix rule!!',_prefix_str2id_dict)
+ # print(doc_pmid)
+ else:
+ doc_annotation.append(segs[0]+'\t'+str(_entity_num)+'\t'+'\t'.join(segs[1:]))
+ if segs[4] in gene_set:
+ _ML_gene_num+=1
+ _entity_num+=1
+
+ if len(_species_num)>=2 and _ML_gene_num>0:
+ fin_pubtator2.write(doc_pmid+'|t|'+doc_title+'\n')
+ fin_pubtator2.write(doc_pmid+'|a|'+doc_abstract+'\n')
+ for ele in doc_annotation:
+ fin_pubtator2.write(ele+'\n')
+ fin_pubtator2.write('\n')
+
+ species_gene_count[doc_pmid]={'spec':_species_num,'gene':_gene_num}
+
+ if fin_pubtator2.getvalue()!='':
+ #pubtator format ML tagging
+ #print(fin_pubtator2.getvalue())
+ ml_out= sa_tag.ml_tag_main(fin_pubtator2,nlp_token, nn_model)
+ #print(ml_out.getvalue())
+ fin_result=io.StringIO(ml_out.getvalue())
+ all_in=fin_result.read().strip().split('\n\n')
+ #print('+2 species:',len(all_in))
+ fin_result.close()
+ for doc in all_in:
+ lines=doc.split('\n')
+ pmid=lines[0].split('|t|')[0]
+
+ for i in range(2,len(lines)):
+ segs=lines[i].split('\t')
+ if pmid not in ML_results.keys():
+ ML_results[pmid]={segs[2]+'-'+segs[3]:segs[-1]}
+ else:
+ ML_results[pmid][segs[2]+'-'+segs[3]]=segs[-1]
+
+ #output
+ fout_pubtator=open(outpath+"/"+infile,'w', encoding='utf8')
+ for doc in all_in_ori:
+ lines=doc.split('\n')
+ pmid=lines[0].split('|t|')[0]
+ fout_pubtator.write(lines[0]+'\n'+lines[1]+'\n')
+ if len(species_gene_count[pmid]['spec'])>1 and species_gene_count[pmid]['gene']>0: # ML
+ for i in range(2,len(lines)):
+ segs=lines[i].split('\t')
+ if len(segs)>=6: #species
+ fout_pubtator.write(lines[i]+'\n')
+ else:#gene
+ if ML_results[pmid][segs[1]+'-'+segs[2]] in virus_set:
+ fout_pubtator.write(lines[i]+'\tFocus:'+ML_results[pmid][segs[1]+'-'+segs[2]]+',9606'+'\n')
+ # print('!!! virus:', pmid)
+ else:
+ fout_pubtator.write(lines[i]+'\tFocus:'+ML_results[pmid][segs[1]+'-'+segs[2]]+'\n')
+ fout_pubtator.write('\n')
+
+ elif len(species_gene_count[pmid]['spec'])==1 and species_gene_count[pmid]['gene']>0: #only one species
+ for i in range(2,len(lines)):
+ segs=lines[i].split('\t')
+ if len(segs)>=6: #species
+ fout_pubtator.write(lines[i]+'\n')
+ else:#gene
+ major_species,=species_gene_count[pmid]['spec']
+ if major_species[1:] in virus_set:
+ fout_pubtator.write(lines[i]+'\tFocus:'+major_species[1:]+',9606'+'\n')
+ # print('!!! virus:', pmid)
+ fout_pubtator.write(lines[i]+'\tFocus:'+major_species[1:]+'\n')
+ fout_pubtator.write('\n')
+
+ elif len(species_gene_count[pmid]['spec'])==0 and species_gene_count[pmid]['gene']>0:#no species
+ for i in range(2,len(lines)):
+ segs=lines[i].split('\t')
+ if len(segs)>=6: #species
+ fout_pubtator.write(lines[i]+'\n')
+ else:#gene
+ fout_pubtator.write(lines[i]+'\tFocus:9606'+'\n')
+ fout_pubtator.write('\n')
+
+ else:
+ for i in range(2,len(lines)):
+ fout_pubtator.write(lines[i]+'\n')
+ fout_pubtator.write('\n')
+ fout_pubtator.close()
+
+
+#SA main
+def speciesAss(infolder,outpath, modelfile):
+
+ if modelfile.lower().find('bioformer')>=0:
+ model_type='bioformer'
+ else:
+ model_type='pubmedbert'
+
+ print('loading SA models........')
+ if model_type=='bioformer':
+
+ vocabfiles={'labelfile':'./vocab/SpeAss_IO_label.vocab',
+ 'checkpoint_path':'./gnorm_trained_models/bioformer-cased-v1.0/',
+ 'lowercase':False,
+ }
+ else:
+ vocabfiles={'labelfile':'./vocab/SpeAss_IO_label.vocab',
+ 'checkpoint_path':'./gnorm_trained_models/BiomedNLP-PubMedBERT-base-uncased-abstract/',
+ 'lowercase':True,
+ }
+
+ nn_model=model_sa.HUGFACE_NER(vocabfiles)
+ nn_model.build_encoder()
+ nn_model.build_softmax_decoder()
+ nn_model.load_model(modelfile)
+
+ dict_filename={'prefix':'./Dictionary/SPPrefix.txt',
+ 'virus':'./Dictionary/SP_Virus2HumanList.txt'}
+ fin=open(dict_filename['virus'],'r',encoding='utf-8')
+ virus_set=set(fin.read().strip().split('\n'))
+ fin.close()
+
+ prefix_dict={}#{id:[prefix1,prefix2]}
+ fin=open(dict_filename['prefix'],'r',encoding='utf-8')
+ for line in fin:
+ seg= line.strip().split('\t')
+ if seg[0] not in prefix_dict.keys():
+ prefix_dict[seg[0]]=seg[1].split('|')
+ else:
+ prefix_dict[seg[0]].extend(seg[1].split('|'))
+ fin.close()
+
+
+
+ print("begin species assignment........")
+ start_time=time.time()
+
+ for infile in os.listdir(infolder):
+ if os.path.isfile(outpath+"/"+infile):
+ print(infile+' has exsited.')
+ else:
+ print('Processing:',infile)
+ fin=open(infolder+"/"+infile, 'r',encoding='utf-8')
+ file_format=""
+ for line in fin:
+ pattern_bioc = re.compile('.*.*')
+ pattern_pubtator = re.compile('^([^\|]+)\|[^\|]+\|(.*)')
+ if pattern_bioc.search(line):
+ file_format="BioC"
+ break
+ elif pattern_pubtator.search(line):
+ file_format="PubTator"
+ break
+ fin.close()
+ if(file_format == "PubTator"):
+ SA_PubTator(infolder,infile,outpath,nn_model,virus_set,prefix_dict)
+ elif(file_format == "BioC"):
+ SA_BioC(infolder,infile,outpath,nn_model,virus_set,prefix_dict)
+
+
+ print('species assignment done:',time.time()-start_time)
+
+if __name__=='__main__':
+
+ parser = argparse.ArgumentParser(description='run GeneNER and species assignment, python GeneNER_SpeAss_run.py -i input -n NERmodel -s SAmodel -r neroutput -a saoutput')
+ parser.add_argument('--infolder', '-i', help="input folder",default='./example/input/')
+ parser.add_argument('--NERmodel', '-n', help="trained deep learning NER model file",default='')
+ parser.add_argument('--SAmodel', '-s', help="trained deep learning species assignment model file",default='')
+ parser.add_argument('--NERoutpath', '-r', help="output folder to save the NER tagged results",default='./example/ner_output/')
+ parser.add_argument('--SAoutpath', '-a', help="output folder to save the SA tagged results",default='./example/sa_output/')
+ parser.add_argument('--NUM_THREADS', '-t', help="Number of threads",default='3')
+ args = parser.parse_args()
+
+
+ if args.NUM_THREADS.isdigit() == False:
+ args.NUM_THREADS='3'
+
+ tf.config.threading.set_inter_op_parallelism_threads(int(args.NUM_THREADS))
+ tf.config.threading.set_intra_op_parallelism_threads(int(args.NUM_THREADS))
+
+ if args.NERmodel!='' and args.SAmodel!='':
+
+ #pipleline
+ print('==============\n| GeneNER and SpeAss |\n==============')
+
+ #creat output folder
+
+ if args.infolder[-1]!='/':
+ args.infolder+='/'
+ if not os.path.exists(args.infolder):
+ os.makedirs(args.infolder)
+
+ if args.NERoutpath[-1]!='/':
+ args.NERoutpath+='/'
+ if not os.path.exists(args.NERoutpath):
+ os.makedirs(args.NERoutpath)
+
+ if args.SAoutpath[-1]!='/':
+ args.SAoutpath+='/'
+ if not os.path.exists(args.SAoutpath):
+ os.makedirs(args.SAoutpath)
+
+ #1. gene NER, the results are saved in outpath/ner_tmp/
+ geneNER(args.infolder,args.NERoutpath, args.NERmodel)
+
+
+ #2. species assignment, the results are saved in outpath/sa_tmp/
+ speciesAss(args.NERoutpath,args.SAoutpath, args.SAmodel)
+
+ elif args.NERmodel!='' and args.SAmodel=='':
+ if args.infolder[-1]!='/':
+ args.infolder+='/'
+ if not os.path.exists(args.infolder):
+ os.makedirs(args.infolder)
+
+ # only geneNER
+ if args.NERoutpath[-1]!='/':
+ args.NERoutpath+='/'
+ if not os.path.exists(args.NERoutpath):
+ os.makedirs(args.NERoutpath)
+
+ print('==============\n| GeneNER |\n==============')
+ geneNER(args.infolder,args.NERoutpath,args.NERmodel)
+
+ elif args.NERmodel=='' and args.SAmodel!='':
+ # only speass
+ if args.SAoutpath[-1]!='/':
+ args.SAoutpath+='/'
+ if not os.path.exists(args.SAoutpath):
+ os.makedirs(args.SAoutpath)
+
+ print('==============\n| SpeAss |\n==============')
+ speciesAss(args.infolder,args.SAoutpath,args.SAmodel)
+ else:
+ print('Please provide models!')
+
+
\ No newline at end of file
diff --git a/Library/Ab3P.C b/Library/Ab3P.C
index bd811b8907b48441af337dda13edd5091c3b0737..a6b93029de6d5050c016f206c2f7a55bc3cbddda 100644
--- a/Library/Ab3P.C
+++ b/Library/Ab3P.C
@@ -1,110 +1,110 @@
-#include "Ab3P.h"
-
-Ab3P::Ab3P ( void ) :
- buffer(""),
- wrdData( new WordData )
-{
-
- string sf_grp, sf_nchr, strat;
- double value;
-
- char file_name[1000];
- get_pathw( file_name, "Ab3P", "prec", "dat" );
- ifstream fin(file_name);
- if(!fin) {
- cout << "Cannot open Ab3P_prec.dat\n";
- exit(1);
- }
- //get precision of a given #-ch SF's strategy
- while(fin>>sf_grp>>sf_nchr>>strat) {
- fin>>value; //precision
- stratPrec.insert(pair(sf_grp+sf_nchr+strat, value));
- util.push_back_strat(sf_grp+sf_nchr, strat); //set strategy sequence
- }
-}
-
-void Ab3P::get_abbrs( char * text, vector & abbrs ) {
- abbrs.clear();
-
- if( ! text[0] ) return; // skip empty line
-
- ab.Proc(text); //extract potential SF & LF pairs
-
- for(int i=0; i 0 ) {
- abbrs.push_back( result );
- }
- }
- ab.cleara();
-
- }
-
-
-void Ab3P::try_pair( char * sf, char * lf, AbbrOut & result ) {
-
- //process i) lf (sf)
- try_strats( sf, lf, false, result );
-
- //process ii) sf (lf)
- ab.token(lf);
- try_strats( ab.lst[ab.num-1], sf, true, result );
-}
-
-
- /**
- psf -- pointer short form
- plf -- pointer long form
- **/
-void Ab3P::try_strats ( char * psf, char * plf, bool swap,
- AbbrOut & result ) {
-
- string sfg; //SF group eg) Al1, Num2, Spec3
- //false if sf is not ok, sfg will be assigned
-
- if(!util.group_sf(psf,plf,sfg)) return;
- if (swap) if(!util.exist_upperal(psf)) return;
-
- char sf[1000], sfl[1000];
-
- //strategy sequence for a given #-ch SF group
- vector strats = util.get_strats(sfg);
- util.remove_nonAlnum(psf,sf); //sf will be w/o non-alnum
-
- //go through strategies
- for( int j=0; jwData = wrdData; //set wordset, stopword
- if(strat->strategy(sf,plf)) { //case sensitive
- strat->str_tolower(sf,sfl);
-
- if( strat->lf_ok(psf,strat->lf) ) {
-
- map::iterator p =
- stratPrec.find(sfg+strats[j]);
- if(p==stratPrec.end()) {
- cout << "No precision assigned" << endl;
- exit(1);
- }
-
- //add outputs
- if( p->second>result.prec ) {
- result.sf = psf;
- result.lf = strat->lf;
- result.prec = p->second;
- result.strat = strats[j];
- }
-
- delete strat;
- return;
- }
- }
- delete strat;
- }
-
-}
+#include "Ab3P.h"
+
+Ab3P::Ab3P ( void ) :
+ buffer(""),
+ wrdData( new WordData )
+{
+
+ string sf_grp, sf_nchr, strat;
+ double value;
+
+ char file_name[1000];
+ get_pathw( file_name, "Ab3P", "prec", "dat" );
+ ifstream fin(file_name);
+ if(!fin) {
+ cout << "Cannot open Ab3P_prec.dat\n";
+ exit(1);
+ }
+ //get precision of a given #-ch SF's strategy
+ while(fin>>sf_grp>>sf_nchr>>strat) {
+ fin>>value; //precision
+ stratPrec.insert(pair(sf_grp+sf_nchr+strat, value));
+ util.push_back_strat(sf_grp+sf_nchr, strat); //set strategy sequence
+ }
+}
+
+void Ab3P::get_abbrs( char * text, vector & abbrs ) {
+ abbrs.clear();
+
+ if( ! text[0] ) return; // skip empty line
+
+ ab.Proc(text); //extract potential SF & LF pairs
+
+ for(int i=0; i 0 ) {
+ abbrs.push_back( result );
+ }
+ }
+ ab.cleara();
+
+ }
+
+
+void Ab3P::try_pair( char * sf, char * lf, AbbrOut & result ) {
+
+ //process i) lf (sf)
+ try_strats( sf, lf, false, result );
+
+ //process ii) sf (lf)
+ ab.token(lf);
+ try_strats( ab.lst[ab.num-1], sf, true, result );
+}
+
+
+ /**
+ psf -- pointer short form
+ plf -- pointer long form
+ **/
+void Ab3P::try_strats ( char * psf, char * plf, bool swap,
+ AbbrOut & result ) {
+
+ string sfg; //SF group eg) Al1, Num2, Spec3
+ //false if sf is not ok, sfg will be assigned
+
+ if(!util.group_sf(psf,plf,sfg)) return;
+ if (swap) if(!util.exist_upperal(psf)) return;
+
+ char sf[1000], sfl[1000];
+
+ //strategy sequence for a given #-ch SF group
+ vector strats = util.get_strats(sfg);
+ util.remove_nonAlnum(psf,sf); //sf will be w/o non-alnum
+
+ //go through strategies
+ for( int j=0; jwData = wrdData; //set wordset, stopword
+ if(strat->strategy(sf,plf)) { //case sensitive
+ strat->str_tolower(sf,sfl);
+
+ if( strat->lf_ok(psf,strat->lf) ) {
+
+ map::iterator p =
+ stratPrec.find(sfg+strats[j]);
+ if(p==stratPrec.end()) {
+ cout << "No precision assigned" << endl;
+ exit(1);
+ }
+
+ //add outputs
+ if( p->second>result.prec ) {
+ result.sf = psf;
+ result.lf = strat->lf;
+ result.prec = p->second;
+ result.strat = strats[j];
+ }
+
+ delete strat;
+ return;
+ }
+ }
+ delete strat;
+ }
+
+}
diff --git a/Library/Ab3P.h b/Library/Ab3P.h
index 60e2c7cac33a4512dba9812db2164bccd4be99cd..4a9aa8ed867667ece1a38f80000d1dd7b32a27a3 100644
--- a/Library/Ab3P.h
+++ b/Library/Ab3P.h
@@ -1,83 +1,83 @@
-/*
-Identify sf & lf pairs from free text using multi-stage algorithm
-process one line at a time and print out:
-line
- sf|lf|P-precision|strategy
-*/
-
-#include "AbbrvE.h"
-#include "AbbrStra.h"
-#include
-#include