Tree @upstream/1.12.1599.102 (Download .tar.gz)
- ..
- calculator
- __init__.py
- calculator_rewriter.cc
- calculator_rewriter.h
- calculator_rewriter_test.cc
- collocation_rewriter.cc
- collocation_rewriter.h
- collocation_rewriter_test.cc
- collocation_util.cc
- collocation_util.h
- collocation_util_test.cc
- command_rewriter.cc
- command_rewriter.h
- command_rewriter_test.cc
- correction_rewriter.cc
- correction_rewriter.h
- correction_rewriter_test.cc
- counter_suffix.h
- date_rewriter.cc
- date_rewriter.h
- date_rewriter_test.cc
- dice_rewriter.cc
- dice_rewriter.h
- dice_rewriter_test.cc
- dictionary_generator.cc
- dictionary_generator.h
- dictionary_generator_test.cc
- embedded_dictionary.cc
- embedded_dictionary.h
- embedded_dictionary_compiler.py
- emoji_rewriter.cc
- emoji_rewriter.h
- emoji_rewriter_test.cc
- emoticon_rewriter.cc
- emoticon_rewriter.h
- emoticon_rewriter_test.cc
- english_variants_rewriter.cc
- english_variants_rewriter.h
- english_variants_rewriter_test.cc
- focus_candidate_rewriter.cc
- focus_candidate_rewriter.h
- focus_candidate_rewriter_test.cc
- fortune_rewriter.cc
- fortune_rewriter.h
- fortune_rewriter_test.cc
- gen_collocation_data_main.cc
- gen_collocation_suppression_data_main.cc
- gen_counter_suffix_array.py
- gen_emoji_rewriter_data.py
- gen_emoticon_rewriter_data.py
- gen_existence_data.cc
- gen_existence_data.h
- gen_reading_correction_data.py
- gen_single_kanji_rewriter_data.py
- gen_symbol_rewriter_dictionary_main.cc
- gen_usage_rewriter_dictionary_main.cc
- language_aware_rewriter.cc
- language_aware_rewriter.h
- language_aware_rewriter_test.cc
- merger_rewriter.h
- merger_rewriter_test.cc
- normalization_rewriter.cc
- normalization_rewriter.h
- normalization_rewriter_test.cc
- number_compound_util.cc
- number_compound_util.h
- number_compound_util_test.cc
- number_rewriter.cc
- number_rewriter.h
- number_rewriter_test.cc
- remove_redundant_candidate_rewriter.cc
- remove_redundant_candidate_rewriter.h
- remove_redundant_candidate_rewriter_test.cc
- rewriter.cc
- rewriter.gyp
- rewriter.h
- rewriter_base.gyp
- rewriter_interface.h
- rewriter_test.cc
- rewriter_test.gyp
- single_kanji_rewriter.cc
- single_kanji_rewriter.h
- single_kanji_rewriter_test.cc
- symbol_rewriter.cc
- symbol_rewriter.h
- symbol_rewriter_test.cc
- transliteration_rewriter.cc
- transliteration_rewriter.h
- transliteration_rewriter_test.cc
- unicode_rewriter.cc
- unicode_rewriter.h
- unicode_rewriter_test.cc
- usage_rewriter.cc
- usage_rewriter.h
- usage_rewriter_data_structs.h
- usage_rewriter_test.cc
- user_boundary_history_rewriter.cc
- user_boundary_history_rewriter.h
- user_boundary_history_rewriter_test.cc
- user_dictionary_rewriter.cc
- user_dictionary_rewriter.h
- user_dictionary_rewriter_test.cc
- user_segment_history_rewriter.cc
- user_segment_history_rewriter.h
- user_segment_history_rewriter_test.cc
- variants_rewriter.cc
- variants_rewriter.h
- variants_rewriter_test.cc
- version_rewriter.cc
- version_rewriter.h
- version_rewriter_test.cc
- zipcode_rewriter.cc
- zipcode_rewriter.h
- zipcode_rewriter_test.cc
gen_collocation_data_main.cc @upstream/1.12.1599.102 — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | // Copyright 2010-2013, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Converts collocation text file into existence filter header file. // input format: // <collocation1> // <collocation2> // ... // // example: // ./gen_collocation_data_main.cc --collocation_data=collocation.txt // > embedded_collocation_data.h #include <iostream> #include <vector> #include "base/file_stream.h" #include "base/flags.h" #include "base/logging.h" #include "rewriter/gen_existence_data.h" DEFINE_string(collocation_data, "", "collocation data text"); DEFINE_string(output, "", "output file name (default: stdout)"); DEFINE_double(error_rate, 0.00001, "error rate"); DEFINE_bool(binary_mode, false, "outputs binary file"); DECLARE_bool(logtostderr); namespace mozc { namespace { void Convert() { InputFileStream ifs(FLAGS_collocation_data.c_str()); string line; vector<string> entries; while (!getline(ifs, line).fail()) { if (line.empty()) { continue; } entries.push_back(line); } ostream *ofs = &cout; if (!FLAGS_output.empty()) { if (FLAGS_binary_mode) { ofs = new OutputFileStream(FLAGS_output.c_str(), ios::out | ios::binary); } else { ofs = new OutputFileStream(FLAGS_output.c_str()); } } if (FLAGS_binary_mode) { OutputExistenceBinary(entries, ofs, FLAGS_error_rate); } else { const string kNameSpace = "CollocationData"; OutputExistenceHeader(entries, kNameSpace, ofs, FLAGS_error_rate); } if (ofs != &cout) { delete ofs; } } } // namespace } // namespace mozc int main(int argc, char *argv[]) { FLAGS_logtostderr = true; InitGoogle(argv[0], &argc, &argv, true); if (FLAGS_collocation_data.empty() && argc > 1) { FLAGS_collocation_data = argv[1]; } LOG(INFO) << FLAGS_collocation_data; mozc::Convert(); return 0; } |