mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
add debug and release in makefile
This commit is contained in:
parent
b2775888d1
commit
7e1186a4ba
2
demo.cpp
2
demo.cpp
@ -23,7 +23,7 @@ int main(int argc, char ** argv)
|
||||
cerr<<"1"<<endl;
|
||||
return 1;
|
||||
}
|
||||
ifstream ifile("dress.gbk");
|
||||
ifstream ifile(argv[1]);
|
||||
vector<string> res;
|
||||
string line;
|
||||
while(getline(ifile, line))
|
||||
|
@ -136,10 +136,14 @@ namespace CppJieba
|
||||
}
|
||||
|
||||
_sortWLIDF(wordInfos);
|
||||
//LogDebug(string_format("calc weight & sorted:%s",joinWordInfos(wordInfos).c_str()));
|
||||
#ifdef DEBUG
|
||||
LogDebug(string_format("calc weight & sorted:%s",joinWordInfos(wordInfos).c_str()));
|
||||
#endif
|
||||
|
||||
_prioritizeSubWords(wordInfos);
|
||||
//LogDebug(string_format("_prioritizeSubWords res:%s", joinWordInfos(wordInfos).c_str()));
|
||||
#ifdef DEBUG
|
||||
LogDebug(string_format("_prioritizeSubWords res:%s", joinWordInfos(wordInfos).c_str()));
|
||||
#endif
|
||||
//extract TopN
|
||||
for(uint i = 0; i < topN && i < wordInfos.size(); i++)
|
||||
{
|
||||
@ -150,7 +154,9 @@ namespace CppJieba
|
||||
|
||||
bool KeyWordExt::extract(const string& title, vector<string>& keywords, uint topN)
|
||||
{
|
||||
//LogDebug(string_format("title:[%s]",title.c_str()));
|
||||
#ifdef DEBUG
|
||||
LogDebug(string_format("title:[%s]",title.c_str()));
|
||||
#endif
|
||||
|
||||
bool retFlag;
|
||||
vector<string> words;
|
||||
@ -160,7 +166,9 @@ namespace CppJieba
|
||||
LogError(string_format("cutDAG(%s) failed.", title.c_str()));
|
||||
return false;
|
||||
}
|
||||
//LogDebug(string_format("cutDAG result:[%s]", joinStr(words, ",").c_str()));
|
||||
#ifdef DEBUG
|
||||
LogDebug(string_format("cutDAG result:[%s]", joinStr(words, ",").c_str()));
|
||||
#endif
|
||||
|
||||
retFlag = _filter(words);
|
||||
if(!retFlag)
|
||||
@ -168,7 +176,9 @@ namespace CppJieba
|
||||
LogError("_filter failed.");
|
||||
return false;
|
||||
}
|
||||
//LogDebug(string_format("_filter res:[%s]", joinStr(words, ",").c_str()));
|
||||
#ifdef DEBUG
|
||||
LogDebug(string_format("_filter res:[%s]", joinStr(words, ",").c_str()));
|
||||
#endif
|
||||
|
||||
retFlag = _extractTopN(words, keywords, topN);
|
||||
if(!retFlag)
|
||||
@ -178,7 +188,9 @@ namespace CppJieba
|
||||
}
|
||||
//LogDebug("_extractTopN finished.");
|
||||
|
||||
//LogDebug(string_format("ext res:[%s]", joinStr(keywords, ",").c_str()));
|
||||
#ifdef DEBUG
|
||||
LogDebug(string_format("ext res:[%s]", joinStr(keywords, ",").c_str()));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -297,7 +309,6 @@ namespace CppJieba
|
||||
{
|
||||
if(subs.end() != subs.find(*it))
|
||||
{
|
||||
//LogDebug(string_format("_filterSubstr filter [%s].", it->c_str()));
|
||||
it = strs.erase(it);
|
||||
}
|
||||
else
|
||||
|
52
src/Makefile
52
src/Makefile
@ -1,20 +1,32 @@
|
||||
CC = g++
|
||||
CCOPT = -Wall -c
|
||||
LINK = g++
|
||||
LINKOPT =
|
||||
PACKA = ar
|
||||
PACKAOPT = rc
|
||||
DOLINK = $(LINK) $(LINKOPT) -o $@ $^
|
||||
DOPACK = $(PACKA) $(PACKAOPT) $@
|
||||
|
||||
CXX := g++
|
||||
LD := g++
|
||||
AR := ar rc
|
||||
|
||||
INCS := -I. -I./cppcommon
|
||||
|
||||
DEBUG_CXXFLAGS := -g -DDEBUG
|
||||
RELEASE_CXXFLAGS := -Wall
|
||||
|
||||
ifeq (YES, ${DEBUG})
|
||||
CXXFLAGS := ${DEBUG_CXXFLAGS}
|
||||
LDFLAGS := ${DEBUG_LDFLAGS}
|
||||
else
|
||||
CXXFLAGS := ${RELEASE_CXXFLAGS}
|
||||
LDFLAGS := ${RELEASE_LDFLAGS}
|
||||
endif
|
||||
|
||||
DOLINK := $(LD) $(LDFLAGS) -o $@ $^
|
||||
DOPACK := $(AR)
|
||||
SOURCES := $(wildcard *.cpp)
|
||||
OBJS := $(patsubst %.cpp,%.o,$(SOURCES))
|
||||
|
||||
CMDIR = ./cppcommon
|
||||
CMLIB = $(CMDIR)/libcm.a
|
||||
CMDIR := ./cppcommon
|
||||
CMLIB := $(CMDIR)/libcm.a
|
||||
|
||||
TMPDIR = ./cppjiebatmp
|
||||
TMPDIR := ./cppjiebatmp
|
||||
|
||||
LIBA = libcppjieba.a
|
||||
LIBA := libcppjieba.a
|
||||
|
||||
# remove the objs after compilation
|
||||
.INTERMEDIATE:
|
||||
@ -25,11 +37,11 @@ all: $(LIBA)
|
||||
# This is a suffix rule
|
||||
#.c.o:
|
||||
%.o: %.cpp
|
||||
$(CC) $(CCOPT) $<
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
|
||||
$(LIBA): $(TMPDIR) $(OBJS) $(CMLIB)
|
||||
${LIBA}: $(TMPDIR) $(OBJS) $(CMLIB)
|
||||
cp $(CMLIB) $(TMPDIR) && cd $(TMPDIR) && ar x `basename $(CMLIB)`
|
||||
$(DOPACK) $(OBJS) $(TMPDIR)/*.o
|
||||
$(DOPACK) $@ $(OBJS) $(TMPDIR)/*.o
|
||||
rm -rf $(TMPDIR)
|
||||
|
||||
$(TMPDIR):
|
||||
@ -40,16 +52,16 @@ $(CMLIB):
|
||||
|
||||
#unit test
|
||||
Trie.ut: Trie.cpp Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB)
|
||||
$(CC) -o $@ Trie.cpp TransCode.cpp -DTRIE_UT $(CMLIB)
|
||||
$(CXX) -o $@ Trie.cpp TransCode.cpp -DTRIE_UT $(CMLIB)
|
||||
|
||||
Segment.ut: Segment.cpp Trie.cpp Segment.h Trie.h globals.h $(CMLIB)
|
||||
$(CC) -o $@ Segment.cpp Trie.cpp TransCode.cpp -DSEGMENT_UT $(CMLIB)
|
||||
$(CXX) -o $@ Segment.cpp Trie.cpp TransCode.cpp -DSEGMENT_UT $(CMLIB)
|
||||
|
||||
KeyWordExt.ut: KeyWordExt.cpp KeyWordExt.h Segment.h Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB)
|
||||
$(CC) -o $@ KeyWordExt.cpp Segment.cpp Trie.cpp TransCode.cpp -DKEYWORDEXT_UT $(CMLIB)
|
||||
$(CXX) -o $@ KeyWordExt.cpp Segment.cpp Trie.cpp TransCode.cpp -DKEYWORDEXT_UT $(CMLIB)
|
||||
|
||||
TransCode.ut: TransCode.cpp TransCode.h globals.h $(CMLIB)
|
||||
$(CC) -o $@ TransCode.cpp -DCPPJIEBA_TRANSCODE_UT $(CMLIB)
|
||||
$(CXX) -o $@ TransCode.cpp -DCPPJIEBA_TRANSCODE_UT $(CMLIB)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.d *.ut $(LIBA)
|
||||
@ -59,6 +71,6 @@ clean:
|
||||
sinclude $(SOURCES:.cpp=.d)
|
||||
%.d:%.cpp
|
||||
@set -e; rm -f $@; \
|
||||
$(CC) -MM $< > $@.$$$$; \
|
||||
$(CXX) -MM $< > $@.$$$$; \
|
||||
sed 's,\($*\).o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
||||
rm -f $@.$$$$
|
||||
|
Loading…
x
Reference in New Issue
Block a user