diff --git a/src/model/graph.rs b/src/model/graph.rs index bb74883..bc26aff 100644 --- a/src/model/graph.rs +++ b/src/model/graph.rs @@ -13,8 +13,7 @@ use crate::model::kge::{ get_embedding_metadata, get_entity_emb_table_name, get_relation_emb_table_name, EmbeddingMetadata, DEFAULT_MODEL_NAME, }; -use crate::model::util::match_color; -use crate::model::util::ValidationError; +use crate::model::util::{match_color, title_case, ValidationError}; use crate::query_builder::sql_builder::ComposeQuery; use lazy_static::lazy_static; use log::{debug, error}; @@ -131,8 +130,8 @@ pub struct Label { impl Label { pub fn format_name(name: &str) -> String { - if name.len() > 20 { - format!("{}...", &name[0..20]) + if name.len() > 15 { + format!("{}...", title_case(&name[0..15])) } else { name.to_string() } @@ -205,11 +204,11 @@ pub struct NodeData { #[serde(deserialize_with = "convert_null_to_empty_string")] #[oai(skip_serializing_if_is_none)] pub pmids: Option, - + #[serde(deserialize_with = "convert_null_to_empty_string")] #[oai(skip_serializing_if_is_none)] pub taxid: Option, - + #[serde(deserialize_with = "convert_null_to_empty_string")] #[oai(skip_serializing_if_is_none)] pub synonyms: Option, diff --git a/src/model/util.rs b/src/model/util.rs index 1880a6e..bd6803d 100644 --- a/src/model/util.rs +++ b/src/model/util.rs @@ -90,6 +90,23 @@ pub fn match_color(entity_type: &str) -> String { DEFAULT_COLOR.to_string() } +pub fn title_case(s: &str) -> String { + s.split_whitespace() + .map(|word| { + word.char_indices() + .map(|(i, c)| { + if i == 0 { + c.to_uppercase().collect::() + } else { + c.to_lowercase().collect::() + } + }) + .collect::() + }) + .collect::>() // 将单词收集成Vec + .join(" ") +} + pub fn read_annotation_file(filepath: &PathBuf) -> Result, Box> { let delimiter = get_delimiter(filepath).unwrap(); diff --git a/studio/package.json b/studio/package.json index 1854947..ebe4f9e 100644 --- a/studio/package.json +++ b/studio/package.json @@ -33,7 +33,7 @@ "antd": "5.7.0", "antd-schema-form": "^4.5.1", "axios": "^1.1.2", - "biominer-components": "0.3.1", + "biominer-components": "0.3.6", "classnames": "^2.3.0", "handlebars": "^4.7.7", "handsontable": "^12.1.3", diff --git a/studio/yarn.lock b/studio/yarn.lock index 9453abd..f996d74 100644 --- a/studio/yarn.lock +++ b/studio/yarn.lock @@ -5375,10 +5375,10 @@ bindings@^1.5.0: dependencies: file-uri-to-path "1.0.0" -biominer-components@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/biominer-components/-/biominer-components-0.3.1.tgz#2e77420859c90c0a55cb7ebd2e2b278779521b43" - integrity sha512-mPj2tDf1cLuKy1NugoUuEfEnWyGgprDCWaV6+/mQKAKrFRT/8nZ3WxM8G/hU8A6k8IEogohMdCa77SeAz1X6Xw== +biominer-components@0.3.6: + version "0.3.6" + resolved "https://registry.yarnpkg.com/biominer-components/-/biominer-components-0.3.6.tgz#84743106ff8c6a9182394b6d6cef457cf9121232" + integrity sha512-ORvQ4QPzA70psw7+7m83LEFVzuMNMOQSP6/lMyLTn8Bdpyy0D03EVQQPXHroG830SFJudQfW6MAa9+2SWQYHwQ== dependencies: "@fingerprintjs/fingerprintjs" "^4.2.2" ag-grid-community "^31.0.1"