Skip to content

web search done right

rename similar_sites -> similar_hosts

Mikkel Denker30de42675d7f
diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit
new file mode 100755
index 00000000..121094ee
--- /dev/null
+++ b/.git-hooks/pre-commit
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+just cargo check
+just cargo check --no-default-features
+cd frontend && npm run check
diff --git a/configs/api.toml b/configs/api.toml
index 2b9664d9..a87c5bf0 100644
--- a/configs/api.toml
+++ b/configs/api.toml
@@ -3,7 +3,7 @@ crossencoder_model_path = "data/cross_encoder"
gossip_addr = "0.0.0.0:3005"
gossip_seed_nodes = ["0.0.0.0:3006", "0.0.0.0:3007"]
host = "0.0.0.0:3000"
-lambda_model_path = "data/lambdamart.txt"
+# lambda_model_path = "data/lambdamart.txt"
prometheus_host = "0.0.0.0:3001"
queries_csv_path = "data/queries_us.csv"
spell_checker_path = "data/web_spell/checker"
diff --git a/configs/search_server.toml b/configs/search_server.toml
index c2a3898b..aee278bc 100644
--- a/configs/search_server.toml
+++ b/configs/search_server.toml
@@ -7,7 +7,7 @@ host_centrality_store_path = "data/centrality"
index_path = "data/index"
shard_id = 0
# linear_model_path = "data/linear_model.json"
-lambda_model_path = "data/lambdamart.txt"
+# lambda_model_path = "data/lambdamart.txt"
[snippet]
max_considered_words = 10_000
diff --git a/core/Cargo.toml b/core/Cargo.toml
index b7aa3b1e..772d43c6 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -140,7 +140,7 @@ name = "build-similarity"
[[bench]]
harness = false
-name = "similar-sites"
+name = "similar-hosts"
[[bench]]
harness = false
diff --git a/core/benches/search-preindexed.rs b/core/benches/search-preindexed.rs
index 80f0d4d7..7b177ccc 100644
--- a/core/benches/search-preindexed.rs
+++ b/core/benches/search-preindexed.rs
@@ -1,7 +1,7 @@
use std::path::Path;
use criterion::{criterion_group, criterion_main, Criterion};
-use optics::SiteRankings;
+use optics::HostRankings;
use stract::{
index::Index,
ranking::inbound_similarity::InboundSimilarity,
@@ -21,13 +21,13 @@ macro_rules! bench {
$searcher
.search(&SearchQuery {
query: $query.to_string(),
- site_rankings: Some(SiteRankings {
+ host_rankings: Some(HostRankings {
liked: vec![
"docs.rs".to_string(),
- "news.ycombinator.com".to_string(),
- "pubmed.ncbi.nlm.nih.gov".to_string(),
+ "ycombinator.com".to_string(),
+ "nih.gov".to_string(),
],
- disliked: vec!["www.pinterest.com".to_string()],
+ disliked: vec!["pinterest.com".to_string()],
blocked: vec![],
}),
..Default::default()
diff --git a/core/benches/similar-sites.rs b/core/benches/similar-hosts.rs
similarity index 66%
rename from core/benches/similar-sites.rs
rename to core/benches/similar-hosts.rs
index 9f1bf9fd..47295d84 100644
--- a/core/benches/similar-sites.rs
+++ b/core/benches/similar-hosts.rs
@@ -2,7 +2,7 @@ use std::sync::Arc;
use criterion::{criterion_group, criterion_main, Criterion};
use stract::{
- ranking::inbound_similarity::InboundSimilarity, similar_sites::SimilarSitesFinder,
+ ranking::inbound_similarity::InboundSimilarity, similar_hosts::SimilarHostsFinder,
webgraph::WebgraphBuilder,
};
@@ -13,15 +13,15 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let webgraph = Arc::new(WebgraphBuilder::new(WEBGRAPH_PATH).open());
let inbound = InboundSimilarity::open(INBOUND_SIMILARITY_PATH).unwrap();
- let finder = SimilarSitesFinder::new(
+ let finder = SimilarHostsFinder::new(
webgraph,
inbound,
- stract::config::defaults::WebgraphServer::max_similar_sites(),
+ stract::config::defaults::WebgraphServer::max_similar_hosts(),
);
for _ in 0..10 {
- c.bench_function("similar_sites", |b| {
- b.iter(|| finder.find_similar_sites(&["google.com".to_string()], 100))
+ c.bench_function("similar_hosts", |b| {
+ b.iter(|| finder.find_similar_hosts(&["google.com".to_string()], 100))
});
}
}
diff --git a/core/src/alice/mod.rs b/core/src/alice/mod.rs
index 2c416465..1e97f6f2 100644
--- a/core/src/alice/mod.rs
+++ b/core/src/alice/mod.rs
@@ -175,7 +175,7 @@ impl Searcher {
optic,
page: None,
selected_region: None,
- site_rankings: None,
+ host_rankings: None,
return_ranking_signals: false,
flatten_response: false,
safe_search: Some(false),
diff --git a/core/src/api/docs.rs b/core/src/api/docs.rs
index 2984c83b..d0c48085 100644
--- a/core/src/api/docs.rs
+++ b/core/src/api/docs.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-use super::{autosuggest, explore, search, sites, summarize, webgraph};
+use super::{autosuggest, explore, hosts, search, summarize, webgraph};
use axum::Router;
use utoipa::{Modify, OpenApi};
use utoipa_swagger_ui::SwaggerUi;
@@ -31,13 +31,13 @@ use utoipa_swagger_ui::SwaggerUi;
webgraph::page::outgoing_pages,
autosuggest::route,
summarize::summarize_route,
- sites::sites_export_optic,
+ hosts::hosts_export_optic,
explore::explore_export_optic,
),
components(
schemas(
crate::webpage::region::Region,
- optics::SiteRankings,
+ optics::HostRankings,
search::ApiSearchQuery,
search::ApiSearchResult,
crate::searcher::WebsitesResult,
@@ -74,13 +74,13 @@ use utoipa_swagger_ui::SwaggerUi;
crate::bangs::BangHit,
crate::bangs::Bang,
- webgraph::host::SimilarSitesParams,
- webgraph::KnowsSite,
- crate::entrypoint::webgraph_server::ScoredSite,
+ webgraph::host::SimilarHostsParams,
+ webgraph::KnowsHost,
+ crate::entrypoint::webgraph_server::ScoredHost,
autosuggest::Suggestion,
- sites::SitesExportOpticParams,
+ hosts::HostsExportOpticParams,
explore::ExploreExportOpticParams,
crate::webgraph::Node,
diff --git a/core/src/api/explore.rs b/core/src/api/explore.rs
index e59bf927..c4e4c7fb 100644
--- a/core/src/api/explore.rs
+++ b/core/src/api/explore.rs
@@ -16,14 +16,14 @@
use axum::extract;
use http::StatusCode;
-use optics::{Optic, SiteRankings};
+use optics::{HostRankings, Optic};
use utoipa::ToSchema;
#[derive(serde::Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct ExploreExportOpticParams {
- chosen_sites: Vec<String>,
- similar_sites: Vec<String>,
+ chosen_hosts: Vec<String>,
+ similar_hosts: Vec<String>,
}
#[allow(clippy::unused_async)]
@@ -36,13 +36,13 @@ pub struct ExploreExportOpticParams {
)]
pub async fn explore_export_optic(
extract::Json(ExploreExportOpticParams {
- chosen_sites,
- similar_sites,
+ chosen_hosts,
+ similar_hosts,
}): extract::Json<ExploreExportOpticParams>,
) -> Result<String, StatusCode> {
- let rules = similar_sites
+ let rules = similar_hosts
.into_iter()
- .chain(chosen_sites.clone().into_iter())
+ .chain(chosen_hosts.clone().into_iter())
.map(|site| optics::Rule {
matches: vec![optics::Matching {
pattern: vec![
@@ -50,15 +50,15 @@ pub async fn explore_export_optic(
optics::PatternPart::Raw(site),
optics::PatternPart::Anchor,
],
- location: optics::MatchLocation::Site,
+ location: optics::MatchLocation::Domain,
}],
action: optics::Action::Boost(0),
})
.collect();
let optic = Optic {
- site_rankings: SiteRankings {
- liked: chosen_sites,
+ host_rankings: HostRankings {
+ liked: chosen_hosts,
..Default::default()
},
rules,
diff --git a/core/src/api/sites.rs b/core/src/api/hosts.rs
similarity index 73%
rename from core/src/api/sites.rs
rename to core/src/api/hosts.rs
index d916ec08..9a7aee28 100644
--- a/core/src/api/sites.rs
+++ b/core/src/api/hosts.rs
@@ -16,28 +16,28 @@
use axum::{extract, Json};
use http::StatusCode;
-use optics::{Optic, SiteRankings};
+use optics::{HostRankings, Optic};
use utoipa::ToSchema;
#[derive(serde::Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
-pub struct SitesExportOpticParams {
- site_rankings: SiteRankings,
+pub struct HostsExportOpticParams {
+ host_rankings: HostRankings,
}
#[allow(clippy::unused_async)]
#[utoipa::path(post,
- path = "/beta/api/sites/export",
- request_body(content = SitesExportOpticParams),
+ path = "/beta/api/hosts/export",
+ request_body(content = HostsExportOpticParams),
responses(
- (status = 200, description = "Export site rankings as an optic", body = String),
+ (status = 200, description = "Export host rankings as an optic", body = String),
)
)]
-pub async fn sites_export_optic(
- extract::Json(SitesExportOpticParams { site_rankings }): extract::Json<SitesExportOpticParams>,
+pub async fn hosts_export_optic(
+ extract::Json(HostsExportOpticParams { host_rankings }): extract::Json<HostsExportOpticParams>,
) -> Result<Json<String>, StatusCode> {
let optic = Optic {
- site_rankings,
+ host_rankings,
..Default::default()
};
diff --git a/core/src/api/mod.rs b/core/src/api/mod.rs
index 5af09039..11f91d20 100644
--- a/core/src/api/mod.rs
+++ b/core/src/api/mod.rs
@@ -58,10 +58,10 @@ use self::webgraph::RemoteWebgraph;
mod autosuggest;
mod docs;
mod explore;
+mod hosts;
pub mod improvement;
mod metrics;
pub mod search;
-mod sites;
mod summarize;
pub mod user_count;
mod webgraph;
@@ -224,7 +224,7 @@ pub async fn router(config: &ApiConfig, counters: Counters) -> Result<Router> {
"/api/webgraph/page/outgoing",
post(webgraph::page::outgoing_pages),
)
- .route("/api/sites/export", post(sites::sites_export_optic))
+ .route("/api/hosts/export", post(hosts::hosts_export_optic))
.route("/api/explore/export", post(explore::explore_export_optic))
.route("/api/entity_image", get(search::entity_image))
.layer(cors_layer()),
diff --git a/core/src/api/search.rs b/core/src/api/search.rs
index 41b1e46f..b4e81688 100644
--- a/core/src/api/search.rs
+++ b/core/src/api/search.rs
@@ -16,7 +16,7 @@
use crate::config::defaults;
use http::StatusCode;
-use optics::{Optic, SiteRankings};
+use optics::{HostRankings, Optic};
use std::sync::Arc;
use utoipa::ToSchema;
@@ -33,21 +33,6 @@ use super::State;
use axum::{extract, response::IntoResponse};
-#[derive(serde::Deserialize, serde::Serialize, Clone, Debug)]
-pub struct SearchParams {
- /// Query
- pub q: Option<String>,
- /// Page
- pub p: Option<usize>,
- /// Language
- pub gl: Option<String>,
- pub optic: Option<String>,
- /// Site rankings
- pub sr: Option<String>,
- /// Safe search
- pub ss: Option<bool>,
-}
-
#[derive(Debug, serde::Serialize, serde::Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
#[schema(title = "SearchQuery", example = json!({"query": "hello world"}))]
@@ -57,7 +42,7 @@ pub struct ApiSearchQuery {
pub num_results: Option<usize>,
pub selected_region: Option<Region>,
pub optic: Option<String>,
- pub site_rankings: Option<SiteRankings>,
+ pub host_rankings: Option<HostRankings>,
pub safe_search: Option<bool>,
#[serde(default = "defaults::SearchQuery::return_ranking_signals")]
@@ -91,7 +76,7 @@ impl TryFrom<ApiSearchQuery> for SearchQuery {
num_results: api.num_results.unwrap_or(default.num_results),
selected_region: api.selected_region,
optic,
- site_rankings: api.site_rankings,
+ host_rankings: api.host_rankings,
return_ranking_signals: api.return_ranking_signals,
safe_search: api.safe_search.unwrap_or(default.safe_search),
fetch_discussions: api.fetch_discussions,
@@ -131,6 +116,7 @@ pub async fn api(
extract::State(state): extract::State<Arc<State>>,
extract::Json(query): extract::Json<ApiSearchQuery>,
) -> Result<impl IntoResponse, StatusCode> {
+ tracing::debug!(?query);
let flatten_result = query.flatten_response;
let query = SearchQuery::try_from(query);
diff --git a/core/src/api/webgraph.rs b/core/src/api/webgraph.rs
index bc57c76c..1b480458 100644
--- a/core/src/api/webgraph.rs
+++ b/core/src/api/webgraph.rs
@@ -54,34 +54,34 @@ pub mod host {
#[derive(serde::Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
- pub struct SimilarSitesParams {
- pub sites: Vec<String>,
+ pub struct SimilarHostsParams {
+ pub hosts: Vec<String>,
pub top_n: usize,
}
#[derive(serde::Deserialize, IntoParams)]
#[serde(rename_all = "camelCase")]
- pub struct KnowsSiteParams {
- pub site: String,
+ pub struct KnowsHostParams {
+ pub host: String,
}
#[derive(serde::Deserialize, IntoParams)]
#[serde(rename_all = "camelCase")]
pub struct HostLinksParams {
- pub site: String,
+ pub host: String,
}
#[allow(clippy::unused_async)]
#[utoipa::path(post,
path = "/beta/api/webgraph/host/similar",
- request_body(content = SimilarSitesParams),
+ request_body(content = SimilarHostsParams),
responses(
- (status = 200, description = "List of similar sites", body = Vec<ScoredSite>),
+ (status = 200, description = "List of similar hosts", body = Vec<ScoredHost>),
)
)]
pub async fn similar(
extract::State(state): extract::State<Arc<State>>,
- extract::Json(params): extract::Json<SimilarSitesParams>,
+ extract::Json(params): extract::Json<SimilarHostsParams>,
) -> std::result::Result<impl IntoResponse, StatusCode> {
state.counters.explore_counter.inc();
let host = state
@@ -104,8 +104,8 @@ pub mod host {
match conn
.send_with_timeout(
- &crate::entrypoint::webgraph_server::SimilarSites {
- sites: params.sites,
+ &crate::entrypoint::webgraph_server::SimilarHosts {
+ hosts: params.hosts,
top_n: params.top_n,
},
Duration::from_secs(60),
@@ -122,14 +122,14 @@ pub mod host {
#[utoipa::path(post,
path = "/beta/api/webgraph/host/knows",
- params(KnowsSiteParams),
+ params(KnowsHostParams),
responses(
- (status = 200, description = "Whether the site is known", body = KnowsSite),
+ (status = 200, description = "Whether the host is known", body = KnowsHost),
)
)]
pub async fn knows(
extract::State(state): extract::State<Arc<State>>,
- extract::Query(params): extract::Query<KnowsSiteParams>,
+ extract::Query(params): extract::Query<KnowsHostParams>,
) -> std::result::Result<impl IntoResponse, StatusCode> {
let host = state
.remote_webgraph
@@ -151,17 +151,17 @@ pub mod host {
match conn
.send_with_timeout(
- &crate::entrypoint::webgraph_server::Knows { site: params.site },
+ &crate::entrypoint::webgraph_server::Knows { host: params.host },
Duration::from_secs(60),
)
.await
{
- Ok(Some(node)) => Ok(Json(KnowsSite::Known { site: node.name })),
+ Ok(Some(node)) => Ok(Json(KnowsHost::Known { host: node.name })),
Err(err) => {
tracing::error!("Failed to send request to webgraph: {}", err);
- Ok(Json(KnowsSite::Unknown))
+ Ok(Json(KnowsHost::Unknown))
}
- _ => Ok(Json(KnowsSite::Unknown)),
+ _ => Ok(Json(KnowsHost::Unknown)),
}
}
@@ -176,7 +176,7 @@ pub mod host {
extract::State(state): extract::State<Arc<State>>,
extract::Query(params): extract::Query<HostLinksParams>,
) -> std::result::Result<impl IntoResponse, StatusCode> {
- let node = Node::from(params.site).into_host();
+ let node = Node::from(params.host).into_host();
let links = ingoing_links(state, node, GraphLevel::Host)
.await
.map_err(|_| {
@@ -198,7 +198,7 @@ pub mod host {
extract::State(state): extract::State<Arc<State>>,
extract::Query(params): extract::Query<HostLinksParams>,
) -> std::result::Result<impl IntoResponse, StatusCode> {
- let node = Node::from(params.site).into_host();
+ let node = Node::from(params.host).into_host();
let links = outgoing_links(state, node, GraphLevel::Host)
.await
.map_err(|_| {
@@ -326,7 +326,7 @@ async fn outgoing_links(
#[derive(serde::Serialize, serde::Deserialize, ToSchema)]
#[serde(tag = "type", rename_all = "camelCase")]
-pub enum KnowsSite {
- Known { site: String },
+pub enum KnowsHost {
+ Known { host: String },
Unknown,
}
diff --git a/core/src/config/defaults.rs b/core/src/config/defaults.rs
index 57c14eb4..b44829b7 100644
--- a/core/src/config/defaults.rs
+++ b/core/src/config/defaults.rs
@@ -109,7 +109,7 @@ impl Crawler {
pub struct WebgraphServer;
impl WebgraphServer {
- pub fn max_similar_sites() -> usize {
+ pub fn max_similar_hosts() -> usize {
1_000
}
}
diff --git a/core/src/config/mod.rs b/core/src/config/mod.rs
index 8829b676..ef96315d 100644
--- a/core/src/config/mod.rs
+++ b/core/src/config/mod.rs
@@ -363,8 +363,8 @@ pub struct WebgraphServerConfig {
pub gossip_seed_nodes: Option<Vec<SocketAddr>>,
pub gossip_addr: SocketAddr,
- #[serde(default = "defaults::WebgraphServer::max_similar_sites")]
- pub max_similar_sites: usize,
+ #[serde(default = "defaults::WebgraphServer::max_similar_hosts")]
+ pub max_similar_hosts: usize,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
diff --git a/core/src/entrypoint/webgraph_server.rs b/core/src/entrypoint/webgraph_server.rs
index d7707216..01525557 100644
--- a/core/src/entrypoint/webgraph_server.rs
+++ b/core/src/entrypoint/webgraph_server.rs
@@ -32,7 +32,7 @@ use crate::distributed::sonic;
use crate::distributed::sonic::service::Message;
use crate::ranking::inbound_similarity::InboundSimilarity;
use crate::searcher::DistributedSearcher;
-use crate::similar_sites::SimilarSitesFinder;
+use crate::similar_hosts::SimilarHostsFinder;
use crate::sonic_service;
use crate::webgraph::Compression;
use crate::webgraph::FullEdge;
@@ -43,70 +43,70 @@ use crate::Result;
#[derive(serde::Serialize, serde::Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
-pub struct ScoredSite {
- pub site: String,
+pub struct ScoredHost {
+ pub host: String,
pub score: f64,
pub description: Option<String>,
}
-const MAX_SITES: usize = 20;
+const MAX_HOSTS: usize = 20;
pub struct WebGraphService {
searcher: DistributedSearcher,
- similar_sites_finder: SimilarSitesFinder,
+ similar_hosts_finder: SimilarHostsFinder,
host_graph: Arc<Webgraph>,
page_graph: Arc<Webgraph>,
}
sonic_service!(
WebGraphService,
- [SimilarSites, Knows, IngoingLinks, OutgoingLinks]
+ [SimilarHosts, Knows, IngoingLinks, OutgoingLinks]
);
#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct SimilarSites {
- pub sites: Vec<String>,
+pub struct SimilarHosts {
+ pub hosts: Vec<String>,
pub top_n: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Knows {
- pub site: String,
+ pub host: String,
}
#[async_trait::async_trait]
-impl Message<WebGraphService> for SimilarSites {
- type Response = Vec<ScoredSite>;
+impl Message<WebGraphService> for SimilarHosts {
+ type Response = Vec<ScoredHost>;
async fn handle(self, server: &WebGraphService) -> sonic::Result<Self::Response> {
- let sites = &self.sites[..std::cmp::min(self.sites.len(), MAX_SITES)];
- let similar_sites = server
- .similar_sites_finder
- .find_similar_sites(sites, self.top_n);
+ let sites = &self.hosts[..std::cmp::min(self.hosts.len(), MAX_HOSTS)];
+ let similar_hosts = server
+ .similar_hosts_finder
+ .find_similar_hosts(sites, self.top_n);
- let urls = similar_sites
+ let urls = similar_hosts
.iter()
.filter_map(|s| Url::parse(&("http://".to_string() + s.node.name.as_str())).ok())
.collect_vec();
let descriptions = server.searcher.get_homepage_descriptions(&urls).await;
- let similar_sites = similar_sites
+ let similar_hosts = similar_hosts
.into_iter()
.map(|site| {
let description = Url::parse(&("http://".to_string() + site.node.name.as_str()))
.ok()
.and_then(|url| descriptions.get(&url).cloned());
- ScoredSite {
- site: site.node.name,
+ ScoredHost {
+ host: site.node.name,
score: site.score,
description,
}
})
.collect_vec();
- Ok(similar_sites)
+ Ok(similar_hosts)
}
}
@@ -115,9 +115,9 @@ impl Message<WebGraphService> for Knows {
type Response = Option<Node>;
async fn handle(self, server: &WebGraphService) -> sonic::Result<Self::Response> {
- let node = Node::from(self.site.to_string()).into_host();
+ let node = Node::from(self.host.to_string()).into_host();
- if server.similar_sites_finder.knows_about(&node) {
+ if server.similar_hosts_finder.knows_about(&node) {
Ok(Some(node))
} else {
Ok(None)
@@ -202,17 +202,17 @@ pub async fn run(config: config::WebgraphServerConfig) -> Result<()> {
);
let inbound_similarity = InboundSimilarity::open(config.inbound_similarity_path)?;
- let similar_sites_finder = SimilarSitesFinder::new(
+ let similar_hosts_finder = SimilarHostsFinder::new(
Arc::clone(&host_graph),
inbound_similarity,
- config.max_similar_sites,
+ config.max_similar_hosts,
);
let server = WebGraphService {
host_graph,
page_graph,
searcher,
- similar_sites_finder,
+ similar_hosts_finder,
}
.bind(addr)
.await
diff --git a/core/src/lib.rs b/core/src/lib.rs
index f665d8c0..adc62940 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -71,7 +71,7 @@ mod search_ctx;
mod search_prettifier;
pub mod searcher;
mod simhash;
-pub mod similar_sites;
+pub mod similar_hosts;
mod snippet;
#[cfg(feature = "libtorch")]
pub mod summarizer;
diff --git a/core/src/query/mod.rs b/core/src/query/mod.rs
index c1066cc6..05ea9e42 100644
--- a/core/src/query/mod.rs
+++ b/core/src/query/mod.rs
@@ -24,7 +24,7 @@ use crate::{
webpage::{region::Region, safety_classifier},
Result,
};
-use optics::{Optic, SiteRankings};
+use optics::{HostRankings, Optic};
use std::collections::HashMap;
use tantivy::query::{BooleanQuery, Occur, QueryClone, TermQuery};
@@ -48,7 +48,7 @@ pub struct Query {
terms: Vec<Box<Term>>,
simple_terms_text: Vec<String>,
tantivy_query: Box<BooleanQuery>,
- site_rankings: SiteRankings,
+ host_rankings: HostRankings,
offset: usize,
region: Option<Region>,
optics: Vec<Optic>,
@@ -141,7 +141,7 @@ impl Query {
.collect();
let mut optics = Vec::new();
- if let Some(site_rankigns_optic) = query.site_rankings.clone().map(|sr| sr.into_optic()) {
+ if let Some(site_rankigns_optic) = query.host_rankings.clone().map(|sr| sr.into_optic()) {
optics.push(site_rankigns_optic);
}
@@ -157,8 +157,8 @@ impl Query {
Ok(Query {
terms,
- site_rankings: optics.iter().fold(SiteRankings::default(), |mut acc, el| {
- acc.merge_into(el.site_rankings.clone());
+ host_rankings: optics.iter().fold(HostRankings::default(), |mut acc, el| {
+ acc.merge_into(el.host_rankings.clone());
acc
}),
simple_terms_text,
@@ -203,8 +203,8 @@ impl Query {
self.region.as_ref()
}
- pub fn site_rankings(&self) -> &SiteRankings {
- &self.site_rankings
+ pub fn host_rankings(&self) -> &HostRankings {
+ &self.host_rankings
}
pub fn signal_coefficients(&self) -> Option<SignalCoefficient> {
diff --git a/core/src/query/optic.rs b/core/src/query/optic.rs
index c875889a..6c3f40fb 100644
--- a/core/src/query/optic.rs
+++ b/core/src/query/optic.rs
@@ -53,7 +53,7 @@ impl AsMultipleTantivyQuery for Optic {
UnionQuery::from(
self.rules
.iter()
- .chain(self.site_rankings.rules().iter())
+ .chain(self.host_rankings.rules().iter())
.filter_map(|rule| rule.as_searchable_rule(schema, fastfields))
.map(|(occur, rule)| {
BooleanQuery::from(vec![(occur, rule.query)]).box_clone()
@@ -65,7 +65,7 @@ impl AsMultipleTantivyQuery for Optic {
} else {
self.rules
.iter()
- .chain(self.site_rankings.rules().iter())
+ .chain(self.host_rankings.rules().iter())
.filter_map(|rule| rule.as_searchable_rule(schema, fastfields))
.map(|(occur, rule)| (occur, rule.query))
.collect()
@@ -233,7 +233,7 @@ impl AsTantivyQuery for Matching {
#[cfg(test)]
mod tests {
- use optics::{Optic, SiteRankings};
+ use optics::{HostRankings, Optic};
use crate::{
gen_temp_path,
@@ -247,7 +247,7 @@ mod tests {
const CONTENT: &str = "this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever";
#[test]
- fn discard_and_boost_sites() {
+ fn discard_and_boost_hosts() {
let mut index = Index::temporary().expect("Unable to open index");
index
@@ -574,7 +574,7 @@ mod tests {
}
#[test]
- fn liked_sites() {
+ fn liked_hosts() {
let mut index = Index::temporary().expect("Unable to open index");
let mut writer = WebgraphWriter::new(
@@ -700,9 +700,9 @@ mod tests {
optic: Some(
Optic::parse(
r#"
- Like(Site("www.a.com"));
- Like(Site("www.b.com"));
- Dislike(Site("www.c.com"));
+ Like(Domain("www.a.com"));
+ Like(Domain("www.b.com"));
+ Dislike(Domain("www.c.com"));
"#,
)
.unwrap(),
@@ -1038,7 +1038,7 @@ mod tests {
)
.unwrap(),
),
- site_rankings: Some(SiteRankings {
+ host_rankings: Some(HostRankings {
liked: vec!["a.com".to_string()],
disliked: vec![],
blocked: vec![],
@@ -1251,7 +1251,7 @@ mod tests {
}
#[test]
- fn active_optic_with_blocked_sites() {
+ fn active_optic_with_blocked_hosts() {
let mut index = Index::temporary().expect("Unable to open index");
index
@@ -1306,7 +1306,7 @@ mod tests {
)
.unwrap(),
),
- site_rankings: Some(SiteRankings {
+ host_rankings: Some(HostRankings {
liked: vec![],
disliked: vec![],
blocked: vec![String::from("example.com")],
diff --git a/core/src/ranking/inbound_similarity.rs b/core/src/ranking/inbound_similarity.rs
index fb4208d7..0b2af658 100644
--- a/core/src/ranking/inbound_similarity.rs
+++ b/core/src/ranking/inbound_similarity.rs
@@ -154,17 +154,17 @@ impl InboundSimilarity {
pub fn scorer(
&self,
- liked_sites: &[NodeID],
- disliked_sites: &[NodeID],
+ liked_hosts: &[NodeID],
+ disliked_hosts: &[NodeID],
normalized: bool,
) -> Scorer {
- let liked: Vec<_> = liked_sites
+ let liked: Vec<_> = liked_hosts
.iter()
.filter_map(|id| self.vectors.get(id).cloned().map(|vec| (id, vec)))
.map(|(node, inbound)| NodeScorer::new(*node, inbound))
.collect();
- let disliked: Vec<_> = disliked_sites
+ let disliked: Vec<_> = disliked_hosts
.iter()
.filter_map(|id| self.vectors.get(id).cloned().map(|vec| (id, vec)))
.map(|(node, inbound)| NodeScorer::new(*node, inbound))
@@ -215,7 +215,7 @@ impl InboundSimilarity {
#[cfg(test)]
mod tests {
- use optics::SiteRankings;
+ use optics::HostRankings;
use crate::{
gen_temp_path,
@@ -229,7 +229,7 @@ mod tests {
use super::*;
#[test]
- fn it_favors_liked_sites() {
+ fn it_favors_liked_hosts() {
let mut wrt = WebgraphWriter::new(
gen_temp_path(),
crate::executor::Executor::single_thread(),
@@ -334,7 +334,7 @@ mod tests {
let res = searcher
.search(&SearchQuery {
query: "example".to_string(),
- site_rankings: Some(SiteRankings {
+ host_rankings: Some(HostRankings {
liked: vec!["a.com".to_string()],
disliked: vec![],
blocked: vec![],
diff --git a/core/src/ranking/optics.rs b/core/src/ranking/optics.rs
index ba051aeb..774391f7 100644
--- a/core/src/ranking/optics.rs
+++ b/core/src/ranking/optics.rs
@@ -16,7 +16,7 @@
#[cfg(test)]
mod tests {
- use optics::SiteRankings;
+ use optics::HostRankings;
use crate::{
gen_temp_path,
@@ -29,7 +29,7 @@ mod tests {
const CONTENT: &str = "this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever this is the best example website ever";
#[test]
- fn site_rankings() {
+ fn host_rankings() {
let mut index = Index::temporary().expect("Unable to open index");
let mut wrt = WebgraphWriter::new(
@@ -164,7 +164,7 @@ mod tests {
let result = searcher
.search(&SearchQuery {
query: "test".to_string(),
- site_rankings: Some(SiteRankings {
+ host_rankings: Some(HostRankings {
liked: vec!["www.first.com".to_string()],
disliked: vec![],
blocked: vec![],
@@ -181,7 +181,7 @@ mod tests {
let result = searcher
.search(&SearchQuery {
query: "test".to_string(),
- site_rankings: Some(SiteRankings {
+ host_rankings: Some(HostRankings {
liked: vec!["www.first.com".to_string()],
disliked: vec![],
blocked: vec![],
@@ -198,7 +198,7 @@ mod tests {
let result = searcher
.search(&SearchQuery {
query: "test".to_string(),
- site_rankings: Some(SiteRankings {
+ host_rankings: Some(HostRankings {
liked: vec![],
disliked: vec!["www.second.com".to_string()],
blocked: vec!["first.com".to_string()],
diff --git a/core/src/searcher/api/widget.rs b/core/src/searcher/api/widget.rs
index f27e4bcf..da15792e 100644
--- a/core/src/searcher/api/widget.rs
+++ b/core/src/searcher/api/widget.rs
@@ -102,7 +102,7 @@ impl WidgetManager {
query: query.query.clone(),
num_results: NUM_RESULTS,
optic: Some(Optic::parse(include_str!("discussions.optic")).unwrap()),
- site_rankings: query.site_rankings.clone(),
+ host_rankings: query.host_rankings.clone(),
return_ranking_signals: query.return_ranking_signals,
..Default::default()
};
diff --git a/core/src/searcher/local.rs b/core/src/searcher/local.rs
index b85c0d32..aa7e27ea 100644
--- a/core/src/searcher/local.rs
+++ b/core/src/searcher/local.rs
@@ -264,23 +264,23 @@ where
let mut aggregator = SignalAggregator::new(Some(&parsed_query));
if let Some(inbound_sim) = &self.inbound_similarity {
- let liked_sites: Vec<_> = parsed_query
- .site_rankings()
+ let liked_hosts: Vec<_> = parsed_query
+ .host_rankings()
.liked
.iter()
.map(|site| Node::from(site.clone()).into_host())
.map(|node| node.id())
.collect();
- let disliked_sites: Vec<_> = parsed_query
- .site_rankings()
+ let disliked_hosts: Vec<_> = parsed_query
+ .host_rankings()
.disliked
.iter()
.map(|site| Node::from(site.clone()).into_host())
.map(|node| node.id())
.collect();
- let scorer = inbound_sim.scorer(&liked_sites, &disliked_sites, false);
+ let scorer = inbound_sim.scorer(&liked_hosts, &disliked_hosts, false);
aggregator.set_inbound_similarity(scorer);
}
diff --git a/core/src/searcher/mod.rs b/core/src/searcher/mod.rs
index 57de3fb2..368db14b 100644
--- a/core/src/searcher/mod.rs
+++ b/core/src/searcher/mod.rs
@@ -21,7 +21,7 @@ pub mod local;
pub use distributed::*;
pub use local::*;
-use optics::{Optic, SiteRankings};
+use optics::{HostRankings, Optic};
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
@@ -67,7 +67,7 @@ pub struct SearchQuery {
pub num_results: usize,
pub selected_region: Option<Region>,
pub optic: Option<Optic>,
- pub site_rankings: Option<SiteRankings>,
+ pub host_rankings: Option<HostRankings>,
pub return_ranking_signals: bool,
pub safe_search: bool,
pub fetch_discussions: bool,
@@ -94,7 +94,7 @@ impl Default for SearchQuery {
num_results: NUM_RESULTS_PER_PAGE,
selected_region: Default::default(),
optic: Default::default(),
- site_rankings: Default::default(),
+ host_rankings: Default::default(),
return_ranking_signals: defaults::SearchQuery::return_ranking_signals(),
safe_search: defaults::SearchQuery::safe_search(),
fetch_discussions: defaults::SearchQuery::fetch_discussions(),
diff --git a/core/src/similar_sites.rs b/core/src/similar_hosts.rs
similarity index 95%
rename from core/src/similar_sites.rs
rename to core/src/similar_hosts.rs
index b0498f90..befe2ff8 100644
--- a/core/src/similar_sites.rs
+++ b/core/src/similar_hosts.rs
@@ -57,28 +57,28 @@ impl Ord for ScoredNodeID {
impl Eq for ScoredNodeID {}
-pub struct SimilarSitesFinder {
+pub struct SimilarHostsFinder {
webgraph: Arc<Webgraph>,
inbound_similarity: InboundSimilarity,
- max_similar_sites: usize,
+ max_similar_hosts: usize,
}
-impl SimilarSitesFinder {
+impl SimilarHostsFinder {
pub fn new(
webgraph: Arc<Webgraph>,
inbound_similarity: InboundSimilarity,
- max_similar_sites: usize,
+ max_similar_hosts: usize,
) -> Self {
Self {
webgraph,
inbound_similarity,
- max_similar_sites,
+ max_similar_hosts,
}
}
- pub fn find_similar_sites(&self, nodes: &[String], limit: usize) -> Vec<ScoredNode> {
+ pub fn find_similar_hosts(&self, nodes: &[String], limit: usize) -> Vec<ScoredNode> {
const DEAD_LINKS_BUFFER: usize = 30;
- let orig_limit = limit.min(self.max_similar_sites);
+ let orig_limit = limit.min(self.max_similar_hosts);
let limit = orig_limit + nodes.len() + DEAD_LINKS_BUFFER;
let nodes: Vec<_> = nodes
diff --git a/frontend/src/lib/api/index.ts b/frontend/src/lib/api/index.ts
index 31960271..28e23233 100644
--- a/frontend/src/lib/api/index.ts
+++ b/frontend/src/lib/api/index.ts
@@ -112,10 +112,10 @@ export const api = {
),
exploreExport: (body: ExploreExportOpticParams, options?: ApiOptions) =>
requestPlain('POST', `/beta/api/explore/export`, body, options),
+ hostsExport: (body: HostsExportOpticParams, options?: ApiOptions) =>
+ requestPlain('POST', `/beta/api/hosts/export`, body, options),
search: (body: ApiSearchQuery, options?: ApiOptions) =>
requestJson<ApiSearchResult>('POST', `/beta/api/search`, body, options),
- sitesExport: (body: SitesExportOpticParams, options?: ApiOptions) =>
- requestPlain('POST', `/beta/api/sites/export`, body, options),
summarize: (
query: {
query: string;
@@ -125,7 +125,7 @@ export const api = {
) => sse<string>('GET', `/beta/api/summarize?${new URLSearchParams(query)}`, options),
webgraphHostIngoing: (
query: {
- site: string;
+ host: string;
},
options?: ApiOptions,
) =>
@@ -136,18 +136,18 @@ export const api = {
),
webgraphHostKnows: (
query: {
- site: string;
+ host: string;
},
options?: ApiOptions,
) =>
- requestJson<KnowsSite>(
+ requestJson<KnowsHost>(
'POST',
`/beta/api/webgraph/host/knows?${new URLSearchParams(query)}`,
options,
),
webgraphHostOutgoing: (
query: {
- site: string;
+ host: string;
},
options?: ApiOptions,
) =>
@@ -156,8 +156,8 @@ export const api = {
`/beta/api/webgraph/host/outgoing?${new URLSearchParams(query)}`,
options,
),
- webgraphHostSimilar: (body: SimilarSitesParams, options?: ApiOptions) =>
- requestJson<ScoredSite[]>('POST', `/beta/api/webgraph/host/similar`, body, options),
+ webgraphHostSimilar: (body: SimilarHostsParams, options?: ApiOptions) =>
+ requestJson<ScoredHost[]>('POST', `/beta/api/webgraph/host/similar`, body, options),
webgraphPageIngoing: (
query: {
page: string;
@@ -186,6 +186,7 @@ export type ApiSearchQuery = {
countResults?: boolean;
fetchDiscussions?: boolean;
flattenResponse?: boolean;
+ hostRankings?: HostRankings;
numResults?: number;
optic?: string;
page?: number;
@@ -193,7 +194,6 @@ export type ApiSearchQuery = {
returnRankingSignals?: boolean;
safeSearch?: boolean;
selectedRegion?: Region;
- siteRankings?: SiteRankings;
};
export type ApiSearchResult =
| (WebsitesResult & {
@@ -282,8 +282,8 @@ export type EntitySnippetFragment =
};
export type Example = string;
export type ExploreExportOpticParams = {
- chosenSites: string[];
- similarSites: string[];
+ chosenHosts: string[];
+ similarHosts: string[];
};
export type FullEdge = {
from: Node;
@@ -294,9 +294,17 @@ export type HighlightedSpellCorrection = {
highlighted: string;
raw: string;
};
-export type KnowsSite =
+export type HostRankings = {
+ blocked: string[];
+ disliked: string[];
+ liked: string[];
+};
+export type HostsExportOpticParams = {
+ hostRankings: HostRankings;
+};
+export type KnowsHost =
| {
- site: string;
+ host: string;
type: 'known';
}
| {
@@ -320,27 +328,19 @@ export type PartOfSpeechMeaning = {
};
export type Region = 'All' | 'Denmark' | 'France' | 'Germany' | 'Spain' | 'US';
export const REGIONS = ['All', 'Denmark', 'France', 'Germany', 'Spain', 'US'] satisfies Region[];
-export type ScoredSite = {
+export type ScoredHost = {
description?: string;
+ host: string;
score: number;
- site: string;
};
export type SignalScore = {
coefficient: number;
value: number;
};
-export type SimilarSitesParams = {
- sites: string[];
+export type SimilarHostsParams = {
+ hosts: string[];
topN: number;
};
-export type SiteRankings = {
- blocked: string[];
- disliked: string[];
- liked: string[];
-};
-export type SitesExportOpticParams = {
- siteRankings: SiteRankings;
-};
export type Snippet =
| {
date?: string;
diff --git a/frontend/src/lib/components/Searchbar.svelte b/frontend/src/lib/components/Searchbar.svelte
index 295d54f9..815dac86 100644
--- a/frontend/src/lib/components/Searchbar.svelte
+++ b/frontend/src/lib/components/Searchbar.svelte
@@ -2,7 +2,7 @@
import MagnifyingGlass from '~icons/heroicons/magnifying-glass';
import Button from '$lib/components/Button.svelte';
import { api } from '$lib/api';
- import { safeSearchStore, siteRankingsStore, postSearchStore } from '$lib/stores';
+ import { safeSearchStore, hostRankingsStore, postSearchStore } from '$lib/stores';
import { browser } from '$app/environment';
import { derived } from 'svelte/store';
import { compressRanked, rankingsToRanked } from '$lib/rankings';
@@ -35,8 +35,8 @@
$: if (didChangeInput) lastRealQuery = query;
$: if (browser) updateSuggestions(lastRealQuery);
- const compressedRanked = derived(siteRankingsStore, ($siteRankings) =>
- compressRanked(rankingsToRanked($siteRankings)),
+ const compressedRanked = derived(hostRankingsStore, ($host_rankings) =>
+ compressRanked(rankingsToRanked($host_rankings)),
);
const selectSuggestion = (s: string) => (query = s);
@@ -88,7 +88,7 @@
method={$postSearchStore ? 'POST' : 'GET'}
>
<input type="hidden" value={$safeSearchStore ? 'true' : 'false'} name="ss" />
- <input type="hidden" value={$compressedRanked} name="sr" id="siteRankingsUuid" />
+ <input type="hidden" value={$compressedRanked} name="sr" id="host_rankingsUuid" />
<label
for="searchbar"
diff --git a/frontend/src/lib/search.ts b/frontend/src/lib/search.ts
index 0bd42b73..af2ff414 100644
--- a/frontend/src/lib/search.ts
+++ b/frontend/src/lib/search.ts
@@ -7,8 +7,8 @@ export type SearchParams = {
optic: string | undefined;
selectedRegion: Region | undefined;
safeSearch: boolean;
- compressedSiteRankings: string | null;
- siteRankings: RankedSites | undefined;
+ compressedhost_rankings: string | null;
+ host_rankings: RankedSites | undefined;
};
export const extractSearchParams = (searchParams: URLSearchParams | FormData): SearchParams => {
@@ -19,8 +19,8 @@ export const extractSearchParams = (searchParams: URLSearchParams | FormData): S
| Region
| undefined;
const safeSearch = (searchParams.get('ss') as string | undefined) == 'true';
- const compressedSiteRankings = (searchParams.get('sr') as string | undefined) || null;
- const siteRankings = compressedSiteRankings ? decompressRanked(compressedSiteRankings) : void 0;
+ const compressedhost_rankings = (searchParams.get('sr') as string | undefined) || null;
+ const host_rankings = compressedhost_rankings ? decompressRanked(compressedhost_rankings) : void 0;
return {
query,
@@ -28,7 +28,7 @@ export const extractSearchParams = (searchParams: URLSearchParams | FormData): S
optic,
selectedRegion,
safeSearch,
- compressedSiteRankings,
- siteRankings,
+ compressedhost_rankings,
+ host_rankings,
};
};
diff --git a/frontend/src/lib/stores.ts b/frontend/src/lib/stores.ts
index 25425f9c..5e934273 100644
--- a/frontend/src/lib/stores.ts
+++ b/frontend/src/lib/stores.ts
@@ -61,8 +61,8 @@ export const opticsShowStore = writableLocalStorage<Record<string, boolean>>(OPT
const ALLOW_STATS_KEY = 'allowStats';
export const allowStatsStore = writableLocalStorage<boolean>(ALLOW_STATS_KEY, true);
-const SITE_RANKINGS_KEY = 'siteRankings';
-export const siteRankingsStore = writableLocalStorage<SiteRakings>(SITE_RANKINGS_KEY, {});
+const HOST_RANKINGS_KEY = 'host_rankings';
+export const hostRankingsStore = writableLocalStorage<SiteRakings>(HOST_RANKINGS_KEY, {});
const SEARCH_QUERY_KEY = 'searchQuery';
export const searchQueryStore = writableLocalStorage<string | undefined>(SEARCH_QUERY_KEY, void 0);
diff --git a/frontend/src/routes/explore/+page.svelte b/frontend/src/routes/explore/+page.svelte
index 2b7ca5a4..d83b5140 100644
--- a/frontend/src/routes/explore/+page.svelte
+++ b/frontend/src/routes/explore/+page.svelte
@@ -2,7 +2,7 @@
import XMark from '~icons/heroicons/x-mark';
import PlusCircleOutline from '~icons/heroicons/plus-circle';
import ChevronDown from '~icons/heroicons/chevron-down';
- import { api, type ScoredSite } from '$lib/api';
+ import { api, type ScoredHost } from '$lib/api';
import Button from '$lib/components/Button.svelte';
import Site from '$lib/components/Site.svelte';
import Select from '$lib/components/Select.svelte';
@@ -16,43 +16,43 @@
let inputWebsite = '';
let limit = LIMIT_OPTIONS[0];
- let chosenSites: string[] = [];
- let similarSites: ScoredSite[] = [];
+ let chosenHosts: string[] = [];
+ let similarHosts: ScoredHost[] = [];
let errorMessage = false;
$: {
api
- .webgraphHostSimilar({ sites: chosenSites, topN: limit })
- .data.then((res) => (similarSites = res));
+ .webgraphHostSimilar({ hosts: chosenHosts, topN: limit })
+ .data.then((res) => (similarHosts = res));
}
- const removeWebsite = async (site: string) => {
- if (chosenSites.includes(site)) {
- chosenSites = chosenSites.filter((s) => s != site);
+ const removeWebsite = async (host: string) => {
+ if (chosenHosts.includes(host)) {
+ chosenHosts = chosenHosts.filter((s) => s != host);
}
};
- const addWebsite = async (site: string, clear = false) => {
+ const addWebsite = async (host: string, clear = false) => {
errorMessage = false;
- site = site.trim();
- if (!site) return;
+ host = host.trim();
+ if (!host) return;
- const result = await api.webgraphHostKnows({ site }).data;
+ const result = await api.webgraphHostKnows({ host }).data;
match(result)
.with({ type: 'unknown' }, () => {
errorMessage = true;
})
- .with({ type: 'known' }, async ({ site }) => {
+ .with({ type: 'known' }, async ({ host }) => {
if (clear) inputWebsite = '';
- if (!chosenSites.includes(site)) chosenSites = [...chosenSites, site];
+ if (!chosenHosts.includes(host)) chosenHosts = [...chosenHosts, host];
})
.exhaustive();
};
const exportAsOptic = async () => {
const { data } = api.exploreExport({
- chosenSites,
- similarSites: similarSites.map((site) => site.site),
+ chosenHosts: chosenHosts,
+ similarHosts: similarHosts.map((host) => host.host),
});
const optic = await data;
const { default: fileSaver } = await import('file-saver');
@@ -100,11 +100,11 @@
</div>
{/if}
<div class="flex flex-wrap justify-center gap-x-5 gap-y-3" id="sites-list">
- {#each chosenSites as site (site)}
+ {#each chosenHosts as site (site)}
<div transition:slide={{ duration: 100 }} animate:flip={{ duration: 200 }}>
<Site
href="http://{site}"
- on:delete={() => (chosenSites = chosenSites.filter((s) => s != site))}
+ on:delete={() => (chosenHosts = chosenHosts.filter((s) => s != site))}
>
{site}
</Site>
@@ -113,7 +113,7 @@
</div>
</div>
- {#if chosenSites.length > 0 && similarSites.length > 0}
+ {#if chosenHosts.length > 0 && similarHosts.length > 0}
<div class="flex flex-col space-y-4">
<div class="grid grid-cols-[auto_auto_1fr_auto] items-center gap-5">
<h2 class="text-2xl font-bold">Similar sites</h2>
@@ -129,7 +129,7 @@
<Button on:click={exportAsOptic}>Export as optic</Button>
</div>
<div class="grid items-center gap-y-2">
- {#each similarSites as site (site.site)}
+ {#each similarHosts as host (host.host)}
<div
class="col-span-full grid grid-cols-[auto_auto_minmax(auto,66%)] items-center gap-x-3"
transition:fade={{ duration: 200 }}
@@ -139,21 +139,21 @@
<button
class={twJoin('group')}
on:click={() =>
- chosenSites.includes(site.site)
- ? removeWebsite(site.site)
- : addWebsite(site.site)}
+ chosenHosts.includes(host.host)
+ ? removeWebsite(host.host)
+ : addWebsite(host.host)}
>
<PlusCircleOutline
class={twJoin(
'text-xl transition group-hover:scale-105 group-active:scale-95',
- chosenSites.includes(site.site) ? 'rotate-45 text-error' : 'text-success',
+ chosenHosts.includes(host.host) ? 'rotate-45 text-error' : 'text-success',
)}
/>
</button>
</div>
- <span>{site.score.toFixed(2)}</span>
+ <span>{host.score.toFixed(2)}</span>
<div class="flex">
- <a href="http://{site.site}" target="_blank" class="underline">{site.site}</a>
+ <a href="http://{host.host}" target="_blank" class="underline">{host.host}</a>
</div>
</div>
{/each}
diff --git a/frontend/src/routes/privacy-and-happy-lawyers/README.md b/frontend/src/routes/privacy-and-happy-lawyers/README.md
index 6fe2a411..f81ca3e2 100644
--- a/frontend/src/routes/privacy-and-happy-lawyers/README.md
+++ b/frontend/src/routes/privacy-and-happy-lawyers/README.md
@@ -1,6 +1,6 @@
# We will always respect your privacy.
-When using Stract, you can have peace of mind knowing that we do everything
+When using Stract, you can rest assured that we do everything
possible to keep your private information the way it's supposed to be - private.
We mostly do this by simply not storing any of your private information at all.
This keeps things simple, both for you and for us.
@@ -64,28 +64,25 @@ to your use of the Services.
#### Limitation of Liability
-THE SERVICES ARE PROVIDED "AS IS" WITH ALL FAULTS. TO THE EXTENT PERMITTED BY
-LAW, STRACT AND THE INDEMNIFIED PARTIES HEREBY DISCLAIM ALL WARRANTIES, WHETHER
-EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES THAT THE SERVICES
-ARE FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, AND
-NON-INFRINGING. YOU BEAR THE ENTIRE RISK AS TO SELECTING THE SERVICES FOR YOUR
-PURPOSES AND AS TO THE QUALITY AND PERFORMANCE OF THE SERVICES, INCLUDING
-WITHOUT LIMITATION THE RISK THAT YOUR CONTENT IS DELETED OR CORRUPTED OR THAT
-SOMEONE ELSE ACCESSES YOUR ONLINE ACCOUNTS. THIS LIMITATION WILL APPLY
-NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY REMEDY. SOME
-JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF IMPLIED WARRANTIES, SO
-THIS DISCLAIMER MAY NOT APPLY TO YOU. EXCEPT AS REQUIRED BY LAW, STRACT AND THE
-INDEMNIFIED PARTIES WILL NOT BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL,
-CONSEQUENTIAL, OR EXEMPLARY DAMAGES ARISING OUT OF OR IN ANY WAY RELATING TO
-THESE TERMS OR THE USE OF OR INABILITY TO USE THE SERVICES, INCLUDING WITHOUT
-LIMITATION DIRECT AND INDIRECT DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, LOST
-PROFITS, LOSS OF DATA, AND COMPUTER FAILURE OR MALFUNCTION, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE THEORY (CONTRACT, TORT, OR
-OTHERWISE) UPON WHICH SUCH CLAIM IS BASED. THE COLLECTIVE LIABILITY OF STRACT
-AND THE INDEMNIFIED PARTIES UNDER THIS AGREEMENT WILL NOT EXCEED $500 (FIVE
-HUNDRED DOLLARS). SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF
-INCIDENTAL, CONSEQUENTIAL, OR SPECIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION
-MAY NOT APPLY TO YOU.
+THE SERVICES ARE PROVIDED "AS IS" WITH ALL FAULTS. TO THE EXTENT PERMITTED BY LAW,
+STRACT AND THE INDEMNIFIED PARTIES HEREBY DISCLAIM ALL WARRANTIES, WHETHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION WARRANTIES THAT THE SERVICES ARE FREE OF DEFECTS, MERCHANTABLE,
+FIT FOR A PARTICULAR PURPOSE, AND NON-INFRINGING. YOU BEAR THE ENTIRE RISK AS TO USING THE
+SERVICES FOR YOUR PURPOSES AND AS TO THE QUALITY AND PERFORMANCE OF THE SERVICES, INCLUDING
+WITHOUT LIMITATION THE RISK THAT YOUR HARDWARE, SOFTWARE, OR CONTENT IS DELETED OR CORRUPTED,
+OR THAT SOMEONE ELSE GAINS UNAUTHORIZED ACCESS TO YOUR INFORMATION.
+THIS LIMITATION WILL APPLY NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY REMEDY.
+SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION
+OF IMPLIED WARRANTIES, SO THIS DISCLAIMER MAY NOT APPLY TO YOU.
+
+EXCEPT AS REQUIRED BY LAW, STRACT AND THE INDEMNIFIED PARTIES WILL NOT BE LIABLE FOR ANY
+INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR EXEMPLARY DAMAGES ARISING OUT OF OR IN
+ANY WAY RELATING TO THESE TERMS OR THE USE OF OR INABILITY TO USE THE SERVICES, INCLUDING
+WITHOUT LIMITATION DIRECT AND INDIRECT DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, LOST
+PROFITS, LOSS OF DATA, AND COMPUTER FAILURE OR MALFUNCTION, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGES AND REGARDLESS OF THE THEORY (CONTRACT, TORT, OR OTHERWISE) UPON WHICH SUCH
+CLAIM IS BASED. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL,
+CONSEQUENTIAL, OR SPECIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
#### Modifications to these
diff --git a/frontend/src/routes/search/+page.server.ts b/frontend/src/routes/search/+page.server.ts
index 3c28bfd5..e8379b5c 100644
--- a/frontend/src/routes/search/+page.server.ts
+++ b/frontend/src/routes/search/+page.server.ts
@@ -30,7 +30,7 @@ export const load = async ({ locals, fetch, url, getClientAddress }) => {
safeSearch: params.safeSearch,
optic: params.optic && (await fetchRemoteOptic({ opticUrl: params.optic, fetch })),
selectedRegion: params.selectedRegion,
- siteRankings: params.siteRankings,
+ hostRankings: params.host_rankings,
fetchDiscussions: true,
countResults: true,
},
diff --git a/frontend/src/routes/search/+page.svelte b/frontend/src/routes/search/+page.svelte
index a7b802d8..39507f22 100644
--- a/frontend/src/routes/search/+page.svelte
+++ b/frontend/src/routes/search/+page.svelte
@@ -13,7 +13,7 @@
import { onMount } from 'svelte';
import { twJoin } from 'tailwind-merge';
import Button from '$lib/components/Button.svelte';
- import { searchQueryStore, siteRankingsStore, summarize } from '$lib/stores';
+ import { searchQueryStore, hostRankingsStore, summarize } from '$lib/stores';
import type { Ranking } from '$lib/rankings';
import { flip } from 'svelte/animate';
import Result from './Result.svelte';
@@ -96,7 +96,7 @@
] as const;
const rankSite = (site: DisplayedWebpage, ranking: Ranking) => () => {
- siteRankingsStore?.update(($rankings) => ({
+ hostRankingsStore?.update(($rankings) => ({
...$rankings,
[site.domain]: $rankings[site.domain] == ranking ? void 0 : ranking,
}));
@@ -125,7 +125,7 @@
{#each rankingChoices as { ranking, kind, Icon }}
<Button
{kind}
- pale={$siteRankingsStore[modal.site.domain] != ranking}
+ pale={$hostRankingsStore[modal.site.domain] != ranking}
padding={false}
form="searchbar-form"
on:click={rankSite(modal.site, ranking)}
diff --git a/frontend/src/routes/settings/sites/+page.svelte b/frontend/src/routes/settings/sites/+page.svelte
index 18353e66..0eeb9eb4 100644
--- a/frontend/src/routes/settings/sites/+page.svelte
+++ b/frontend/src/routes/settings/sites/+page.svelte
@@ -3,7 +3,7 @@
import Button from '$lib/components/Button.svelte';
import Site from '$lib/components/Site.svelte';
import { rankingsToRanked } from '$lib/rankings';
- import { siteRankingsStore } from '$lib/stores';
+ import { hostRankingsStore } from '$lib/stores';
import { flip } from 'svelte/animate';
import { derived } from 'svelte/store';
@@ -34,22 +34,22 @@
{ text: 'Clear and export as optic', clear: true },
] as const;
- const ranked = derived(siteRankingsStore, ($rankings) => rankingsToRanked($rankings));
+ const ranked = derived(hostRankingsStore, ($rankings) => rankingsToRanked($rankings));
const unrankSite = (site: string) => () => {
- siteRankingsStore.update(($rankings) => ({ ...$rankings, [site]: void 0 }));
+ hostRankingsStore.update(($rankings) => ({ ...$rankings, [site]: void 0 }));
};
const clearAndExport =
({ clear }: { clear: boolean }) =>
async () => {
- const { data } = api.sitesExport({
- siteRankings: $ranked,
+ const { data } = api.hostsExport({
+ hostRankings: $ranked,
});
const { default: fileSaver } = await import('file-saver');
fileSaver.saveAs(new Blob([await data]), 'exported.optic');
- if (clear) siteRankingsStore.set({});
+ if (clear) hostRankingsStore.set({});
};
</script>
diff --git a/optics-lsp/package.json b/optics-lsp/package.json
index 6d958981..87c9af5b 100644
--- a/optics-lsp/package.json
+++ b/optics-lsp/package.json
@@ -1,6 +1,6 @@
{
"name": "Optics",
- "version": "0.0.9",
+ "version": "0.0.10",
"engines": {
"vscode": "^1.73.0"
},
@@ -57,4 +57,4 @@
}
]
}
-}
+}
\ No newline at end of file
diff --git a/optics-lsp/src/lib.rs b/optics-lsp/src/lib.rs
index 9ffd6215..85bb9c83 100644
--- a/optics-lsp/src/lib.rs
+++ b/optics-lsp/src/lib.rs
@@ -165,8 +165,7 @@ impl OpticsBackend {
A search result must match all the parts of the `Matches` block in order to match the specific rule.".to_string()),
optics::Token::Site => Some("`Site(\"...\")` matches any search result where the pattern defined in `\"...\"` matches the site of the result. \
- Note that when `Site` is used inside `Like` or `Dislike`, the pattern can only contain simple terms (no `*` and `|`). \n\n\
- When the site is used in a `Matches` block, you can use `*` as a wildcard term and `|` to indicate either the end or start of a string. \n\
+ You can use `*` as a wildcard term and `|` to indicate either the end or start of a string. \n\
Consider the pattern `\"|sub.*.com|\"`. This will ensure that the terms `sub` and `.` must appear at the beggining of the site, then followed by any \
domain-name that ends in `.` and `com`. Note that `|` can only be used in the beggining or end of a pattern and the pattern will only match full terms (no substring matching). \n\n\
This example illustrates the difference between `Domain`, `Site` and `Url`:\n\
@@ -182,7 +181,8 @@ impl OpticsBackend {
".to_string()),
optics::Token::Domain => Some("`Domain(\"...\")` matches any search result where the pattern defined in `\"...\"` matches the domain of the result. \
- You can use `*` as a wildcard term and `|` to indicate either the end or start of a domain. \n\
+ Note that when `Domain` is used inside `Like` or `Dislike`, the pattern can only contain simple terms (no `*` and `|`). \n\n\
+ When the domain is used in a `Matches` block, you can use `*` as a wildcard term and `|` to indicate either the end or start of a domain. \n\
Consider the pattern `\"example.org\"`. This is equivalent to doing a phrase search for `\"example.org\"` in the domain. Note that the pattern will only match full terms (no substring matching). \n\n\
This example illustrates the difference between `Domain`, `Site` and `Url`:\n\
Assume a search result has the url `https://sub.example.org/page`. the domain here is `example.org`, the site is `sub.example.org` and the url is the entire url (with protocol).\
@@ -230,11 +230,11 @@ impl OpticsBackend {
optics::Token::Discard => Some("`Discard` discards the matching search result completely from the results page.".to_string()),
- optics::Token::Like => Some("`Like(Site(...))` lets you like specific sites. During ranking, we will calculate a centrality meassure from all you liked sites \
+ optics::Token::Like => Some("`Like(Domain(...))` lets you like specific hosts. During ranking, we will calculate a centrality meassure from all you liked sites \
so results that are heavily linked to from your liked sites will be favored. Note therefore, that `Like` not only alters the ranking of the specifc site, \
but also sites that are heavily linked to from the liked site.".to_string()),
- optics::Token::Dislike => Some("`Dislike(Site(...))` lets you dislike specifc sites. During ranking, we will calculate a centrality meassure from all you dislike sites \
+ optics::Token::Dislike => Some("`Dislike(Domain(...))` lets you dislike specifc hosts. During ranking, we will calculate a centrality meassure from all you dislike sites \
so results that are heavily linked to from your disliked sites will be downranked. Note therefore, that `Dislike` not only alters the ranking of the specifc site, \
but also sites that are heavily linked to from the disliked site.".to_string()),
diff --git a/optics/src/ast.rs b/optics/src/ast.rs
index 57da736d..bc17ffff 100644
--- a/optics/src/ast.rs
+++ b/optics/src/ast.rs
@@ -62,7 +62,7 @@ impl ToString for RankingCoeff {
pub struct RawOptic {
pub rules: Vec<RawRule>,
pub rankings: Vec<RankingCoeff>,
- pub site_preferences: Vec<RawSitePreference>,
+ pub host_preferences: Vec<RawHostPreference>,
pub discard_non_matching: bool,
}
@@ -70,14 +70,14 @@ impl From<Vec<RawOpticBlock>> for RawOptic {
fn from(blocks: Vec<RawOpticBlock>) -> Self {
let mut rules = Vec::new();
let mut rankings = Vec::new();
- let mut site_preferences = Vec::new();
+ let mut host_preferences = Vec::new();
let mut discard_non_matching = false;
for block in blocks {
match block {
RawOpticBlock::Ranking(ranking) => rankings.push(ranking),
RawOpticBlock::Rule(rule) => rules.push(rule),
- RawOpticBlock::SitePreference(pref) => site_preferences.push(pref),
+ RawOpticBlock::HostPreference(pref) => host_preferences.push(pref),
RawOpticBlock::DiscardNonMatching => discard_non_matching = true,
}
}
@@ -85,7 +85,7 @@ impl From<Vec<RawOpticBlock>> for RawOptic {
RawOptic {
rankings,
rules,
- site_preferences,
+ host_preferences,
discard_non_matching,
}
}
@@ -94,7 +94,7 @@ impl From<Vec<RawOpticBlock>> for RawOptic {
#[derive(Debug)]
pub enum RawOpticBlock {
Rule(RawRule),
- SitePreference(RawSitePreference),
+ HostPreference(RawHostPreference),
Ranking(RankingCoeff),
DiscardNonMatching,
}
@@ -106,7 +106,7 @@ pub struct RawRule {
}
#[derive(Debug, PartialEq)]
-pub enum RawSitePreference {
+pub enum RawHostPreference {
Like(String),
Dislike(String),
}
@@ -219,7 +219,7 @@ mod tests {
value: 100.0,
},
],
- site_preferences: vec![],
+ host_preferences: vec![],
discard_non_matching: false,
}
);
@@ -261,7 +261,7 @@ mod tests {
},
],
rankings: vec![],
- site_preferences: vec![],
+ host_preferences: vec![],
discard_non_matching: false,
}
);
@@ -304,7 +304,7 @@ mod tests {
},
],
rankings: vec![],
- site_preferences: vec![],
+ host_preferences: vec![],
discard_non_matching: true,
}
);
diff --git a/optics/src/lib.rs b/optics/src/lib.rs
index 3ff67a36..1792676d 100644
--- a/optics/src/lib.rs
+++ b/optics/src/lib.rs
@@ -17,10 +17,9 @@
pub mod ast;
mod lexer;
-use std::convert::TryFrom;
-
use ast::RankingCoeff;
use serde::{Deserialize, Serialize};
+use std::convert::TryFrom;
use thiserror::Error;
use utoipa::ToSchema;
@@ -81,13 +80,13 @@ impl TryFrom<RawOptic> for Optic {
rules.push(Rule::try_from(rule)?);
}
- let mut liked_sites = Vec::new();
- let mut disliked_sites = Vec::new();
+ let mut liked_hosts = Vec::new();
+ let mut disliked_hosts = Vec::new();
- for pref in raw.site_preferences {
+ for pref in raw.host_preferences {
match pref {
- ast::RawSitePreference::Like(site) => liked_sites.push(site),
- ast::RawSitePreference::Dislike(site) => disliked_sites.push(site),
+ ast::RawHostPreference::Like(host) => liked_hosts.push(host),
+ ast::RawHostPreference::Dislike(host) => disliked_hosts.push(host),
}
}
@@ -95,10 +94,10 @@ impl TryFrom<RawOptic> for Optic {
rules,
rankings: raw.rankings,
discard_non_matching: raw.discard_non_matching,
- site_rankings: SiteRankings {
- liked: liked_sites,
- disliked: disliked_sites,
- blocked: Vec::new(), // blocked sites are handled by `$discard` syntax.
+ host_rankings: HostRankings {
+ liked: liked_hosts,
+ disliked: disliked_hosts,
+ blocked: Vec::new(), // blocked hosts are handled by `$discard` syntax.
},
})
}
@@ -315,7 +314,7 @@ impl ToString for Action {
#[derive(Debug, PartialEq, Default, Clone, Serialize, Deserialize)]
pub struct Optic {
pub rankings: Vec<RankingCoeff>,
- pub site_rankings: SiteRankings,
+ pub host_rankings: HostRankings,
pub rules: Vec<Rule>,
pub discard_non_matching: bool,
}
@@ -342,7 +341,7 @@ impl ToString for Optic {
res.push_str(&format!("{};\n", ranking.to_string()));
}
- res.push_str(&self.site_rankings.to_string());
+ res.push_str(&self.host_rankings.to_string());
res
}
@@ -376,22 +375,22 @@ impl ToString for Rule {
#[derive(Debug, PartialEq, Default, Serialize, Deserialize, Clone, ToSchema)]
#[serde(rename_all = "camelCase")]
-pub struct SiteRankings {
+pub struct HostRankings {
pub liked: Vec<String>,
pub disliked: Vec<String>,
pub blocked: Vec<String>,
}
-impl ToString for SiteRankings {
+impl ToString for HostRankings {
fn to_string(&self) -> String {
let mut res = String::new();
for liked in &self.liked {
- res.push_str(&format!("Like(Site(\"{}\"));\n", liked));
+ res.push_str(&format!("Like(Domain(\"{}\"));\n", liked));
}
for disliked in &self.disliked {
- res.push_str(&format!("Dislike(Site(\"{}\"));\n", disliked));
+ res.push_str(&format!("Dislike(Domain(\"{}\"));\n", disliked));
}
for blocked in &self.blocked {
@@ -402,7 +401,7 @@ impl ToString for SiteRankings {
PatternPart::Raw(blocked.clone()),
PatternPart::Anchor,
],
- location: MatchLocation::Site,
+ location: MatchLocation::Domain,
}],
action: Action::Discard,
};
@@ -414,15 +413,15 @@ impl ToString for SiteRankings {
}
}
-impl SiteRankings {
+impl HostRankings {
pub fn rules(&self) -> Vec<Rule> {
self.blocked
.iter()
- .map(|site| Rule {
+ .map(|host| Rule {
matches: vec![Matching {
pattern: vec![
PatternPart::Anchor,
- PatternPart::Raw(site.clone()),
+ PatternPart::Raw(host.clone()),
PatternPart::Anchor,
],
location: MatchLocation::Domain,
@@ -434,21 +433,21 @@ impl SiteRankings {
pub fn into_optic(self) -> Optic {
Optic {
- site_rankings: self,
+ host_rankings: self,
..Default::default()
}
}
- pub fn merge_into(&mut self, site_rankings: SiteRankings) {
- self.liked.extend(site_rankings.liked);
- self.disliked.extend(site_rankings.disliked);
- self.blocked.extend(site_rankings.blocked);
+ pub fn merge_into(&mut self, host_rankings: HostRankings) {
+ self.liked.extend(host_rankings.liked);
+ self.disliked.extend(host_rankings.disliked);
+ self.blocked.extend(host_rankings.blocked);
}
}
#[cfg(test)]
mod tests {
- use crate::ast::RankingTarget;
+ use crate::ast::{RankingCoeff, RankingTarget};
use super::*;
#[test]
@@ -482,7 +481,7 @@ mod tests {
target: RankingTarget::Signal("bm25".to_string()),
value: 1.0,
}],
- site_rankings: SiteRankings {
+ host_rankings: HostRankings {
liked: vec!["liked.com".to_string()],
disliked: vec!["disliked.com".to_string()],
blocked: vec![],
diff --git a/optics/src/parser.lalrpop b/optics/src/parser.lalrpop
index f0d8a34e..ed5606db 100644
--- a/optics/src/parser.lalrpop
+++ b/optics/src/parser.lalrpop
@@ -19,7 +19,7 @@ pub Blocks: Vec<RawOpticBlock> = <Sep<";", Block>>;
Block: RawOpticBlock = {
<Rule> => RawOpticBlock::Rule(<>),
<Ranking> => RawOpticBlock::Ranking(<>),
- <SitePreference> => RawOpticBlock::SitePreference(<>),
+ <HostPreference> => RawOpticBlock::HostPreference(<>),
"DiscardNonMatching" => RawOpticBlock::DiscardNonMatching,
}
@@ -87,9 +87,9 @@ RankingTarget: RankingTarget = {
"Signal" "(" <StringLiteral> ")" => RankingTarget::Signal(<>.to_string()),
}
-SitePreference: RawSitePreference = {
- "Like" "(" "Site" "(" <StringLiteral> ")" ")" => RawSitePreference::Like(<>.to_string()),
- "Dislike" "(" "Site" "(" <StringLiteral> ")" ")" => RawSitePreference::Dislike(<>.to_string())
+HostPreference: RawHostPreference = {
+ "Like" "(" "Domain" "(" <StringLiteral> ")" ")" => RawHostPreference::Like(<>.to_string()),
+ "Dislike" "(" "Domain" "(" <StringLiteral> ")" ")" => RawHostPreference::Dislike(<>.to_string())
}
extern {