commit
2708b5da5f
9 changed files with 1181 additions and 0 deletions
-
1.gitignore
-
441Cargo.lock
-
12Cargo.toml
-
5justfile
-
35src/errors.rs
-
80src/main.rs
-
107src/models.rs
-
1tests/words.txt
-
499tests/나무.xml
@ -0,0 +1 @@ |
|||
/target |
@ -0,0 +1,441 @@ |
|||
# This file is automatically @generated by Cargo. |
|||
# It is not intended for manual editing. |
|||
[[package]] |
|||
name = "argh" |
|||
version = "0.1.4" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "91792f088f87cdc7a2cfb1d617fa5ea18d7f1dc22ef0e1b5f82f3157cdc522be" |
|||
dependencies = [ |
|||
"argh_derive", |
|||
"argh_shared", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "argh_derive" |
|||
version = "0.1.4" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "c4eb0c0c120ad477412dc95a4ce31e38f2113e46bd13511253f79196ca68b067" |
|||
dependencies = [ |
|||
"argh_shared", |
|||
"heck", |
|||
"proc-macro2", |
|||
"quote", |
|||
"syn", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "argh_shared" |
|||
version = "0.1.4" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "781f336cc9826dbaddb9754cb5db61e64cab4f69668bd19dcc4a0394a86f4cb1" |
|||
|
|||
[[package]] |
|||
name = "base64" |
|||
version = "0.13.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" |
|||
|
|||
[[package]] |
|||
name = "bumpalo" |
|||
version = "3.7.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" |
|||
|
|||
[[package]] |
|||
name = "carajillo" |
|||
version = "0.1.0" |
|||
dependencies = [ |
|||
"argh", |
|||
"quick-xml", |
|||
"serde", |
|||
"ureq", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "cc" |
|||
version = "1.0.68" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" |
|||
|
|||
[[package]] |
|||
name = "cfg-if" |
|||
version = "1.0.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" |
|||
|
|||
[[package]] |
|||
name = "chunked_transfer" |
|||
version = "1.4.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e" |
|||
|
|||
[[package]] |
|||
name = "form_urlencoded" |
|||
version = "1.0.1" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" |
|||
dependencies = [ |
|||
"matches", |
|||
"percent-encoding", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "heck" |
|||
version = "0.3.3" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" |
|||
dependencies = [ |
|||
"unicode-segmentation", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "idna" |
|||
version = "0.2.3" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" |
|||
dependencies = [ |
|||
"matches", |
|||
"unicode-bidi", |
|||
"unicode-normalization", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "js-sys" |
|||
version = "0.3.51" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" |
|||
dependencies = [ |
|||
"wasm-bindgen", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "lazy_static" |
|||
version = "1.4.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" |
|||
|
|||
[[package]] |
|||
name = "libc" |
|||
version = "0.2.95" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" |
|||
|
|||
[[package]] |
|||
name = "log" |
|||
version = "0.4.14" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" |
|||
dependencies = [ |
|||
"cfg-if", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "matches" |
|||
version = "0.1.8" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" |
|||
|
|||
[[package]] |
|||
name = "memchr" |
|||
version = "2.4.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" |
|||
|
|||
[[package]] |
|||
name = "once_cell" |
|||
version = "1.7.2" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" |
|||
|
|||
[[package]] |
|||
name = "percent-encoding" |
|||
version = "2.1.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" |
|||
|
|||
[[package]] |
|||
name = "proc-macro2" |
|||
version = "1.0.27" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" |
|||
dependencies = [ |
|||
"unicode-xid", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "quick-xml" |
|||
version = "0.22.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" |
|||
dependencies = [ |
|||
"memchr", |
|||
"serde", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "quote" |
|||
version = "1.0.9" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" |
|||
dependencies = [ |
|||
"proc-macro2", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "ring" |
|||
version = "0.16.20" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" |
|||
dependencies = [ |
|||
"cc", |
|||
"libc", |
|||
"once_cell", |
|||
"spin", |
|||
"untrusted", |
|||
"web-sys", |
|||
"winapi", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "rustls" |
|||
version = "0.19.1" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" |
|||
dependencies = [ |
|||
"base64", |
|||
"log", |
|||
"ring", |
|||
"sct", |
|||
"webpki", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "sct" |
|||
version = "0.6.1" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" |
|||
dependencies = [ |
|||
"ring", |
|||
"untrusted", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "serde" |
|||
version = "1.0.126" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" |
|||
dependencies = [ |
|||
"serde_derive", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "serde_derive" |
|||
version = "1.0.126" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" |
|||
dependencies = [ |
|||
"proc-macro2", |
|||
"quote", |
|||
"syn", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "spin" |
|||
version = "0.5.2" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" |
|||
|
|||
[[package]] |
|||
name = "syn" |
|||
version = "1.0.72" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" |
|||
dependencies = [ |
|||
"proc-macro2", |
|||
"quote", |
|||
"unicode-xid", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "tinyvec" |
|||
version = "1.2.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" |
|||
dependencies = [ |
|||
"tinyvec_macros", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "tinyvec_macros" |
|||
version = "0.1.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" |
|||
|
|||
[[package]] |
|||
name = "unicode-bidi" |
|||
version = "0.3.5" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" |
|||
dependencies = [ |
|||
"matches", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "unicode-normalization" |
|||
version = "0.1.19" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" |
|||
dependencies = [ |
|||
"tinyvec", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "unicode-segmentation" |
|||
version = "1.7.1" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" |
|||
|
|||
[[package]] |
|||
name = "unicode-xid" |
|||
version = "0.2.2" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" |
|||
|
|||
[[package]] |
|||
name = "untrusted" |
|||
version = "0.7.1" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" |
|||
|
|||
[[package]] |
|||
name = "ureq" |
|||
version = "2.1.1" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "2475a6781e9bc546e7b64f4013d2f4032c8c6a40fcffd7c6f4ee734a890972ab" |
|||
dependencies = [ |
|||
"base64", |
|||
"chunked_transfer", |
|||
"log", |
|||
"once_cell", |
|||
"rustls", |
|||
"url", |
|||
"webpki", |
|||
"webpki-roots", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "url" |
|||
version = "2.2.2" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" |
|||
dependencies = [ |
|||
"form_urlencoded", |
|||
"idna", |
|||
"matches", |
|||
"percent-encoding", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "wasm-bindgen" |
|||
version = "0.2.74" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" |
|||
dependencies = [ |
|||
"cfg-if", |
|||
"wasm-bindgen-macro", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "wasm-bindgen-backend" |
|||
version = "0.2.74" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" |
|||
dependencies = [ |
|||
"bumpalo", |
|||
"lazy_static", |
|||
"log", |
|||
"proc-macro2", |
|||
"quote", |
|||
"syn", |
|||
"wasm-bindgen-shared", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "wasm-bindgen-macro" |
|||
version = "0.2.74" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" |
|||
dependencies = [ |
|||
"quote", |
|||
"wasm-bindgen-macro-support", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "wasm-bindgen-macro-support" |
|||
version = "0.2.74" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" |
|||
dependencies = [ |
|||
"proc-macro2", |
|||
"quote", |
|||
"syn", |
|||
"wasm-bindgen-backend", |
|||
"wasm-bindgen-shared", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "wasm-bindgen-shared" |
|||
version = "0.2.74" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" |
|||
|
|||
[[package]] |
|||
name = "web-sys" |
|||
version = "0.3.51" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" |
|||
dependencies = [ |
|||
"js-sys", |
|||
"wasm-bindgen", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "webpki" |
|||
version = "0.21.4" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" |
|||
dependencies = [ |
|||
"ring", |
|||
"untrusted", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "webpki-roots" |
|||
version = "0.21.1" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" |
|||
dependencies = [ |
|||
"webpki", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "winapi" |
|||
version = "0.3.9" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" |
|||
dependencies = [ |
|||
"winapi-i686-pc-windows-gnu", |
|||
"winapi-x86_64-pc-windows-gnu", |
|||
] |
|||
|
|||
[[package]] |
|||
name = "winapi-i686-pc-windows-gnu" |
|||
version = "0.4.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" |
|||
|
|||
[[package]] |
|||
name = "winapi-x86_64-pc-windows-gnu" |
|||
version = "0.4.0" |
|||
source = "registry+https://github.com/rust-lang/crates.io-index" |
|||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" |
@ -0,0 +1,12 @@ |
|||
[package] |
|||
name = "carajillo" |
|||
version = "0.1.0" |
|||
authors = ["Andrew Zah <zah@andrewzah.com>"] |
|||
edition = "2018" |
|||
license = "AGPL-3.0-only" |
|||
|
|||
[dependencies] |
|||
argh = "0.1" |
|||
quick-xml = { version = "0.22", features = [ "serialize" ] } |
|||
serde = { version = "1.0", features = [ "derive" ] } |
|||
ureq = "2.1" |
@ -0,0 +1,5 @@ |
|||
run: |
|||
cargo run -- tests/words.txt |
|||
|
|||
build: |
|||
cargo build |
@ -0,0 +1,35 @@ |
|||
#[derive(Debug)]
|
|||
pub enum CarajilloError {
|
|||
// 3rd-party
|
|||
Ureq(ureq::Error),
|
|||
QuickxmlDe(quick_xml::de::DeError),
|
|||
|
|||
|
|||
// std
|
|||
IO(std::io::Error),
|
|||
Var(std::env::VarError),
|
|||
}
|
|||
|
|||
impl From<std::io::Error> for CarajilloError {
|
|||
fn from(err: std::io::Error) -> CarajilloError {
|
|||
CarajilloError::IO(err)
|
|||
}
|
|||
}
|
|||
|
|||
impl From<std::env::VarError> for CarajilloError {
|
|||
fn from(err: std::env::VarError) -> CarajilloError {
|
|||
CarajilloError::Var(err)
|
|||
}
|
|||
}
|
|||
|
|||
impl From<quick_xml::de::DeError> for CarajilloError {
|
|||
fn from(err: quick_xml::de::DeError) -> CarajilloError {
|
|||
CarajilloError::QuickxmlDe(err)
|
|||
}
|
|||
}
|
|||
|
|||
impl From<ureq::Error> for CarajilloError {
|
|||
fn from(err: ureq::Error) -> CarajilloError {
|
|||
CarajilloError::Ureq(err)
|
|||
}
|
|||
}
|
@ -0,0 +1,80 @@ |
|||
use std::env;
|
|||
use std::fs::File;
|
|||
use std::io::{BufRead, BufReader};
|
|||
use std::path::PathBuf;
|
|||
use std::result::Result;
|
|||
|
|||
use argh::{self, FromArgs};
|
|||
|
|||
mod errors;
|
|||
mod models;
|
|||
|
|||
use crate::errors::CarajilloError;
|
|||
use crate::models::{OpenDictRequest, OpenDictResponse};
|
|||
|
|||
|
|||
static API_BASE_URL: &str = "https://opendict.korean.go.kr/api/";
|
|||
|
|||
// https://opendict.korean.go.kr/api/search?certkey_no=2727&key=D2D5C90646A9451DECA5E7AB3E30F727&target_type=search&part=word&q=%EC%88%98%EB%A9%B4&sort=dict&start=1&num=10
|
|||
|
|||
/// application args
|
|||
#[derive(FromArgs)]
|
|||
struct Args {
|
|||
/// input file path: plaintext file with words, separated by newlines
|
|||
#[argh(positional, short = 'f')]
|
|||
input_file: PathBuf,
|
|||
|
|||
/// cache file db path
|
|||
#[argh(option, short = 'c', default = "PathBuf::from(\"cache.sql\")")]
|
|||
cache_file: PathBuf,
|
|||
|
|||
/// output csv file path
|
|||
#[argh(option, short = 'o', default = "PathBuf::from(\"out.csv\")")]
|
|||
out_file: PathBuf,
|
|||
}
|
|||
|
|||
fn main() -> Result<(), CarajilloError> {
|
|||
let args: Args = argh::from_env();
|
|||
|
|||
let kdict_key = env::var("OPEN_KDICT_KEY")?;
|
|||
|
|||
let input_file = File::open(&args.input_file)?;
|
|||
let buf = BufReader::new(input_file);
|
|||
|
|||
let words: Vec<String> = buf.lines()
|
|||
.filter_map(Result::ok)
|
|||
.collect();
|
|||
|
|||
let dict_results: Vec<()> = words
|
|||
.into_iter()
|
|||
.filter_map(|w| process_word(&w, &kdict_key).ok())
|
|||
.collect();
|
|||
|
|||
Ok(())
|
|||
}
|
|||
|
|||
// 1. make request to
|
|||
// 2.
|
|||
fn process_word(word: &str, key: &str) -> Result<(), CarajilloError> {
|
|||
let req_conf = OpenDictRequest::new(key, word);
|
|||
let url = req_conf.build_url();
|
|||
|
|||
let body: String = ureq::post(&url)
|
|||
.call()?
|
|||
.into_string()?;
|
|||
|
|||
println!("{}", body.chars().take(750).collect::<String>());
|
|||
|
|||
// println!("{}", &body);
|
|||
|
|||
match quick_xml::de::from_str::<OpenDictResponse>(&body) {
|
|||
Ok(parsed) => {
|
|||
println!("ok:\n{:?}", parsed);
|
|||
},
|
|||
Err(e) => {
|
|||
eprintln!("err!\n{}", e);
|
|||
},
|
|||
}
|
|||
|
|||
Ok(())
|
|||
}
|
@ -0,0 +1,107 @@ |
|||
use serde::Deserialize;
|
|||
|
|||
use crate::API_BASE_URL;
|
|||
|
|||
pub struct OpenDictRequest {
|
|||
pub key: String,
|
|||
pub target_type: String,
|
|||
pub part: String,
|
|||
pub query: String,
|
|||
pub start: String,
|
|||
pub num: String,
|
|||
}
|
|||
|
|||
impl OpenDictRequest {
|
|||
pub fn new(key: &str, word: &str) -> Self {
|
|||
OpenDictRequest {
|
|||
key: String::from(key),
|
|||
target_type: String::from("search"),
|
|||
part: String::from("word"),
|
|||
query: String::from(word),
|
|||
start: String::from("1"),
|
|||
num: String::from("10"),
|
|||
}
|
|||
}
|
|||
|
|||
pub fn build_url(&self) -> String {
|
|||
let mut output = String::from(API_BASE_URL);
|
|||
|
|||
output.push_str(&self.target_type);
|
|||
output.push('?');
|
|||
|
|||
output.push_str("key=");
|
|||
output.push_str(&self.key);
|
|||
output.push('&');
|
|||
|
|||
output.push_str("target_type=");
|
|||
output.push_str(&self.target_type);
|
|||
output.push('&');
|
|||
|
|||
output.push_str("part=");
|
|||
output.push_str(&self.part);
|
|||
output.push('&');
|
|||
|
|||
output.push_str("q=");
|
|||
output.push_str(&self.query);
|
|||
output.push('&');
|
|||
|
|||
output.push_str("start=");
|
|||
output.push_str(&self.start);
|
|||
output.push('&');
|
|||
|
|||
output.push_str("num=");
|
|||
output.push_str(&self.num);
|
|||
|
|||
output
|
|||
}
|
|||
}
|
|||
|
|||
#[derive(Debug, Deserialize)]
|
|||
pub struct OpenDictResponse {
|
|||
#[serde(rename = "$value")]
|
|||
pub channel: OpenDictChannel,
|
|||
}
|
|||
|
|||
|
|||
#[derive(Debug, Deserialize)]
|
|||
pub struct OpenDictChannel {
|
|||
// #[serde(rename = "$value")]
|
|||
// pub item: Vec<OpenDictItem>,
|
|||
|
|||
pub description: String,
|
|||
|
|||
pub link: String,
|
|||
|
|||
// #[serde(rename = "$value")]
|
|||
pub num: i32,
|
|||
|
|||
// #[serde(rename = "$value")]
|
|||
pub start: i32,
|
|||
|
|||
// #[serde(rename = "$value")]
|
|||
pub title: String,
|
|||
|
|||
// #[serde(rename = "$value")]
|
|||
pub total: i32,
|
|||
}
|
|||
|
|||
#[derive(Debug, Deserialize)]
|
|||
pub struct OpenDictItem {
|
|||
// #[serde(rename = "sense")]
|
|||
// pub sense: Vec<OpenDictSense>,
|
|||
|
|||
// pub word: String,
|
|||
}
|
|||
|
|||
// TODO: typ->type
|
|||
#[derive(Debug, Deserialize)]
|
|||
pub struct OpenDictSense {
|
|||
definition: String,
|
|||
link: Vec<String>,
|
|||
origin: String,
|
|||
pos: String,
|
|||
sense_no: i32,
|
|||
target_code: String,
|
|||
typ: String,
|
|||
}
|
|||
|
@ -0,0 +1 @@ |
|||
수면 |
@ -0,0 +1,499 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
|
|||
|
|||
|
|||
|
|||
<channel> |
|||
<title>우리말샘 개발 지원(Open API) - 사전 어휘 검색</title> |
|||
<link>http://opendict.korean.go.kr</link> |
|||
<description>우리말샘 개발 지원(Open API) - 사전 어휘 검색 결과</description> |
|||
<lastBuildDate>20210605141340</lastBuildDate> |
|||
<total>251</total> |
|||
<start>1</start> |
|||
<num>10</num> |
|||
|
|||
<item> |
|||
<word>수면</word> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>203249</target_code> |
|||
<sense_no>001</sense_no> |
|||
<definition>물의 겉면.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=203249</link> |
|||
<type>일반어</type> |
|||
|
|||
|
|||
<origin>水面</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
</item> |
|||
|
|||
<item> |
|||
<word>수면</word> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>463440</target_code> |
|||
<sense_no>005</sense_no> |
|||
<definition>부끄러움을 띤 얼굴.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=463440</link> |
|||
<type>일반어</type> |
|||
|
|||
|
|||
<origin>羞面</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
</item> |
|||
|
|||
<item> |
|||
<word>수면</word> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>463479</target_code> |
|||
<sense_no>006</sense_no> |
|||
<definition>걱정하면서 잠을 잠. 또는 그 잠.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=463479</link> |
|||
<type>일반어</type> |
|||
|
|||
|
|||
<origin>愁眠</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
</item> |
|||
|
|||
<item> |
|||
<word>수면</word> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>369035</target_code> |
|||
<sense_no>007</sense_no> |
|||
<definition>잠을 자는 일.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=369035</link> |
|||
<type>일반어</type> |
|||
|
|||
|
|||
<origin>睡眠</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>372433</target_code> |
|||
<sense_no>008</sense_no> |
|||
<definition>활동을 쉬는 상태를 비유적으로 이르는 말.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=372433</link> |
|||
<type>일반어</type> |
|||
|
|||
|
|||
<origin>睡眠</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
</item> |
|||
|
|||
<item> |
|||
<word>수면</word> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>203465</target_code> |
|||
<sense_no>009</sense_no> |
|||
<definition>수척한 얼굴.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=203465</link> |
|||
<type>일반어</type> |
|||
|
|||
|
|||
<origin>瘦面</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
</item> |
|||
|
|||
<item> |
|||
<word>수면</word> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>479463</target_code> |
|||
<sense_no>011</sense_no> |
|||
<definition>짐승의 얼굴. 또는 짐승의 얼굴과 같이 험상궂게 생긴 얼굴.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=479463</link> |
|||
<type>일반어</type> |
|||
|
|||
|
|||
<origin>獸面</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>482889</target_code> |
|||
<sense_no>012</sense_no> |
|||
<definition>짐승의 얼굴 모양을 본떠서 만든 탈이나 조각.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=482889</link> |
|||
<type>일반어</type> |
|||
|
|||
|
|||
<origin>獸面</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
</item> |
|||
|
|||
<item> |
|||
<word>수면</word> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>537126</target_code> |
|||
<sense_no>003</sense_no> |
|||
<definition>삼짇날에 먹는 음식의 하나. 녹두로 국수를 만드는데, 붉은 물을 들이고 꿀물을 탄다.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=537126</link> |
|||
<type>일반어</type> |
|||
|
|||
<cat>민속</cat> |
|||
|
|||
|
|||
<origin>水麵</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
</item> |
|||
|
|||
<item> |
|||
<word>수면</word> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>203466</target_code> |
|||
<sense_no>010</sense_no> |
|||
<definition>‘번뇌’를 달리 이르는 말. 번뇌가 중생을 늘 따라다니며 마음을 혼미하게 하는 것이 잠자는 것과 같다는 뜻으로 이르는 말이다.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=203466</link> |
|||
<type>일반어</type> |
|||
|
|||
<cat>불교</cat> |
|||
|
|||
|
|||
<origin>隨眠</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
</item> |
|||
|
|||
<item> |
|||
<word>수면</word> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>203250</target_code> |
|||
<sense_no>002</sense_no> |
|||
<definition>녹조류 별해캄과에 속하는 담수 조류. 머리카락 모양의 사상체로 분열법과 접합에 의하여 번식한다. 생리학ㆍ분류학의 실험 재료로 쓰고 식용하거나 약용한다. 전 세계에 150여 종이 분포한다. 호수나 늪 따위의 민물에서 볼 수 있다.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=203250</link> |
|||
<type>일반어</type> |
|||
|
|||
<cat>생명</cat> |
|||
|
|||
|
|||
<origin>水綿</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
</item> |
|||
|
|||
<item> |
|||
<word>수면</word> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sense> |
|||
<target_code>203251</target_code> |
|||
<sense_no>004</sense_no> |
|||
<definition>어떠한 평면이나 직선과 수직을 이루는 면.</definition > |
|||
|
|||
<pos>명사</pos> |
|||
|
|||
<link>http://opendict.korean.go.kr/dictionary/view?sense_no=203251</link> |
|||
<type>일반어</type> |
|||
|
|||
<cat>수학</cat> |
|||
|
|||
|
|||
<origin>垂面</origin> |
|||
|
|||
|
|||
|
|||
</sense> |
|||
|
|||
</item> |
|||
|
|||
</channel> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue