adapt to win32

This commit is contained in:
fanlumaster
2025-01-02 06:19:47 +08:00
parent 155d6eb410
commit 12abe936bf
13 changed files with 2864 additions and 2714 deletions

View File

@ -1,55 +1,59 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "../src/include/dicttrie.h"
using namespace ime_pinyin;
/**
* Build binary dictionary model. Make sure that ___BUILD_MODEL___ is defined
* in dictdef.h.
*/
int main(int argc, char* argv[]) {
DictTrie* dict_trie = new DictTrie();
bool success;
if (argc >= 3)
success = dict_trie->build_dict(argv[1], argv[2]);
else
success = dict_trie->build_dict("../data/rawdict_utf16_65105_freq.txt", "../data/valid_utf16.txt");
if (success) {
printf("Build dictionary successfully.\n");
} else {
printf("Build dictionary unsuccessfully.\n");
return -1;
}
success = dict_trie->save_dict("./dict/dict_pinyin.dat");
if (success) {
printf("Save dictionary successfully.\n");
} else {
printf("Save dictionary unsuccessfully.\n");
return -1;
}
return 0;
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include "../src/include/dicttrie.h"
using namespace ime_pinyin;
/**
* Build binary dictionary model. Make sure that ___BUILD_MODEL___ is defined
* in dictdef.h.
*/
int main(int argc, char* argv[]) {
DictTrie* dict_trie = new DictTrie();
bool success;
if (argc >= 3)
success = dict_trie->build_dict(argv[1], argv[2]);
else
success = dict_trie->build_dict("../data/rawdict_utf16_65105_freq.txt", "../data/valid_utf16.txt");
if (success) {
printf("Build dictionary successfully.\n");
} else {
printf("Build dictionary unsuccessfully.\n");
return -1;
}
success = dict_trie->save_dict("./dict/dict_pinyin.dat");
if (success) {
printf("Save dictionary successfully.\n");
} else {
printf("Save dictionary unsuccessfully.\n");
return -1;
}
return 0;
}

46
command/lcompile.sh → command/scripts/lcompile.sh Executable file → Normal file
View File

@ -1,23 +1,23 @@
#!/bin/bash
currentDirectory=$(pwd)
cmakeListsPath="${currentDirectory}/CMakeLists.txt"
if [ ! -f "$cmakeListsPath" ]; then
echo "No CMakeLists.txt in current directory, please check."
exit 1
fi
echo "Start generating and compiling..."
buildFolderPath="./build"
if [ ! -d "$buildFolderPath" ]; then
mkdir -p "$buildFolderPath"
echo "build folder created."
fi
cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -S . -B ./build/
if [ $? -eq 0 ]; then
cmake --build ./build/ --config DEBUG
fi
#!/bin/bash
currentDirectory=$(pwd)
cmakeListsPath="${currentDirectory}/CMakeLists.txt"
if [ ! -f "$cmakeListsPath" ]; then
echo "No CMakeLists.txt in current directory, please check."
exit 1
fi
echo "Start generating and compiling..."
buildFolderPath="./build"
if [ ! -d "$buildFolderPath" ]; then
mkdir -p "$buildFolderPath"
echo "build folder created."
fi
cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -S . -B ./build/
if [ $? -eq 0 ]; then
cmake --build ./build/ --config DEBUG
fi

90
command/llaunch.sh → command/scripts/llaunch.sh Executable file → Normal file
View File

@ -1,45 +1,45 @@
#!/bin/bash
currentDirectory=$(pwd)
cmakeListsPath="${currentDirectory}/CMakeLists.txt"
if [ ! -f "$cmakeListsPath" ]; then
echo "No CMakeLists.txt in current directory, please check."
exit 1
fi
echo "Start generating and compiling..."
buildFolderPath="./build"
if [ ! -d "$buildFolderPath" ]; then
mkdir -p "$buildFolderPath"
echo "build folder created."
fi
cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -S . -B ./build/
if [ $? -eq 0 ]; then
cmake --build ./build/ --config DEBUG
if [ $? -eq 0 ]; then
content=$(<"./CMakeLists.txt")
exePath=""
while IFS= read -r line; do
if [[ $line == "set(MY_EXECUTABLE_NAME"* ]]; then
pattern="\"([^\"]+)\""
if [[ $line =~ $pattern ]]; then
contentInParentheses="${BASH_REMATCH[1]}"
result=($contentInParentheses)
exePath="./build/bin/${result[0]}"
echo "start running as follows..."
echo "=================================================="
fi
fi
done <<<"$content"
# execute the binary file
if [ -n "$exePath" ]; then
$exePath
else
echo "cannot find executable file path"
fi
fi
fi
#!/bin/bash
currentDirectory=$(pwd)
cmakeListsPath="${currentDirectory}/CMakeLists.txt"
if [ ! -f "$cmakeListsPath" ]; then
echo "No CMakeLists.txt in current directory, please check."
exit 1
fi
echo "Start generating and compiling..."
buildFolderPath="./build"
if [ ! -d "$buildFolderPath" ]; then
mkdir -p "$buildFolderPath"
echo "build folder created."
fi
cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -S . -B ./build/
if [ $? -eq 0 ]; then
cmake --build ./build/ --config DEBUG
if [ $? -eq 0 ]; then
content=$(<"./CMakeLists.txt")
exePath=""
while IFS= read -r line; do
if [[ $line == "set(MY_EXECUTABLE_NAME"* ]]; then
pattern="\"([^\"]+)\""
if [[ $line =~ $pattern ]]; then
contentInParentheses="${BASH_REMATCH[1]}"
result=($contentInParentheses)
exePath="./build/bin/${result[0]}"
echo "start running as follows..."
echo "=================================================="
fi
fi
done <<<"$content"
# execute the binary file
if [ -n "$exePath" ]; then
$exePath
else
echo "cannot find executable file path"
fi
fi
fi

36
command/lrun.sh → command/scripts/lrun.sh Executable file → Normal file
View File

@ -1,18 +1,18 @@
content=$(<"./CMakeLists.txt")
exePath=""
while IFS= read -r line; do
if [[ $line == "set(MY_EXECUTABLE_NAME"* ]]; then
pattern="\"([^\"]+)\""
if [[ $line =~ $pattern ]]; then
contentInParentheses="${BASH_REMATCH[1]}"
result=($contentInParentheses)
exePath="./build/bin/${result[0]}"
fi
fi
done <<<"$content"
if [ -n "$exePath" ]; then
$exePath
else
echo "cannot find executable file path"
fi
content=$(<"./CMakeLists.txt")
exePath=""
while IFS= read -r line; do
if [[ $line == "set(MY_EXECUTABLE_NAME"* ]]; then
pattern="\"([^\"]+)\""
if [[ $line =~ $pattern ]]; then
contentInParentheses="${BASH_REMATCH[1]}"
result=($contentInParentheses)
exePath="./build/bin/${result[0]}"
fi
fi
done <<<"$content"
if [ -n "$exePath" ]; then
$exePath
else
echo "cannot find executable file path"
fi