Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions RDF_Map.prop
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ DEFAULT_GRID_TYPE H2_DB
#SET THE DEFAULT SCRIPTING LANGUAGE
#THIS WILL DETERMINE IF WE SWITCH TO R OR PY IN CLEAN/ANALYTICS
DEFAULT_SCRIPTING_LANGUAGE R
#SET DEFAULT INSIGHTS RDBMS
#SET DEFAULT INSIGHTS RDBMS
#CURRENTLY ONLY SUPPORT VALUES OF : H2_DB OR SQLITE
#DEFAULT IS H2_DB IF THIS IS REMOVED
DEFAULT_INSIGHTS_RDBMS H2_DB

#SIZE LIMIT FOR ROW by COL
#SIZE LIMIT FOR ROW by COL
#FOR NO LIMIT USE -1
FRAME_SIZE_LIMIT -1
#DO WE LIMIT FOR NATIVE FRAMES
Expand Down Expand Up @@ -269,7 +269,7 @@ REDIS_CLUSTER_MAX_ATTEMPTS=5
SENSITIVE_KEYS
SECRET_STORE_ENABLED false
#HASHICORP_VAULT, AZURE_KEYVAULT or AWS_SECRETS_MANAGER
SECRET_STORE_TYPE
SECRET_STORE_TYPE
#Base Paths For Resources
SECRETS_DB_PATH semoss-db
SECRETS_STORAGE_PATH semoss-storage
Expand All @@ -281,33 +281,33 @@ SECRETS_PROJECT_PATH semoss-project
SECRETS_VENV_PATH semoss-venv

#Hashicorp Vault
VAULT_ADDR
VAULT_TOKEN
VAULT_ADDR
VAULT_TOKEN

#Azure KeyVault
#Note SECRET_*_PATH can only be contain alphanumeric and dashes
#ClientSecretCredential if passing in client/secret/tenant
AZURE_AUTHENTICATE_MODE
AZURE_KEYVAULT_NAME
AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
AZURE_TENANT_ID
AZURE_AUTHENTICATE_MODE
AZURE_KEYVAULT_NAME
AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
AZURE_TENANT_ID

#AWS Secrets Manager
#Note SECRETS_*_PATH can contain alphanumeric and /_+=.@-
#Leave the access key blank to use the default AWS credential chain
AWS_SECRETS_MANAGER_REGION
AWS_SECRETS_MANAGER_ENDPOINT
AWS_SECRETS_MANAGER_ACCESS_KEY
AWS_SECRETS_MANAGER_SECRET_KEY
AWS_SECRETS_MANAGER_SESSION_TOKEN
AWS_SECRETS_MANAGER_KMS_KEY_ID
AWS_SECRETS_MANAGER_REGION
AWS_SECRETS_MANAGER_ENDPOINT
AWS_SECRETS_MANAGER_ACCESS_KEY
AWS_SECRETS_MANAGER_SECRET_KEY
AWS_SECRETS_MANAGER_SESSION_TOKEN
AWS_SECRETS_MANAGER_KMS_KEY_ID

# ------------------------------------------------------------
# Security
# ------------------------------------------------------------
#SAML CONFIG
SAML_PROP_LOC C:\\workspace\\Semoss\\saml\\mesoc\\conf
SAML_PROP_LOC C:\\workspace\\Semoss\\saml\\mesoc\\conf
SAML_FEDERATION_LOG_PATH C:\\workspace\\Semoss\\saml\\mesoc\\conf\\debug\\Federation

#POST MESSAGE SPECIFIC KEYS
Expand All @@ -317,8 +317,8 @@ PM_SEMOSS_EXECUTE_SQL_ENCRYPTION_PASSWORD password123
VIRUS_SCANNING_ENABLED false
VIRUS_SCANNING_METHOD ClamAV
CLAMAV_SCANNING_PORT 3310
CLAMAV_SCANNING_ADDRESS
CLAMAV_SCANNING_FS
CLAMAV_SCANNING_ADDRESS
CLAMAV_SCANNING_FS

# ------------------------------------------------------------
# Admin only actions
Expand Down Expand Up @@ -389,4 +389,4 @@ MYSQL_KEYWORDS KEY,VALUES

SQL_SERVER_KEYWORDS GROUP

PROBHIBITED_HEADERS ALL,CHECK,CONSTRAINT,CROSS,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,DISTINCT,EXCEPT,EXISTS,FALSE,FETCH,FOR,FOREIGN,FROM,FULL,HAVING,INNER,INTERSECT,IS,JOIN,LIKE,LIMIT,MINUS,NATURAL,NOT,NULL,OFFSET,ON,ORDER,PRIMARY,ROWNUM,SELECT,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY,TRUE,UNION,UNIQUE,WHERE,WITH
PROBHIBITED_HEADERS ALL,CHECK,CONSTRAINT,CROSS,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,DISTINCT,EXCEPT,EXISTS,FALSE,FETCH,FOR,FOREIGN,FROM,FULL,HAVING,INNER,INTERSECT,IS,JOIN,LIKE,LIMIT,MINUS,NATURAL,NOT,NULL,OFFSET,ON,ORDER,PRIMARY,ROWNUM,SELECT,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY,TRUE,UNION,UNIQUE,WHERE,WITH
10 changes: 9 additions & 1 deletion src/prerna/collaboration/BrainClassifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ record Message(String from, List<String> to, List<String> cc, String at, String
}

/** A topic the thread can be filed under. */
record TopicOption(String id, String name, String description) {
record TopicOption(String id, String name, String description, List<String> keywords, List<String> personIds) {
public TopicOption {
keywords = keywords == null ? List.of() : List.copyOf(keywords);
personIds = personIds == null ? List.of() : List.copyOf(personIds);
}

public TopicOption(String id, String name, String description) {
this(id, name, description, List.of(), List.of());
}
}

/**
Expand Down
143 changes: 143 additions & 0 deletions src/prerna/collaboration/BrainFilingSignals.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*******************************************************************************
* Copyright 2015 Defense Health Agency (DHA)
*
* If your use of this software does not include any GPLv2 components:
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ----------------------------------------------------------------------------
* If your use of this software includes any GPLv2 components:
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*******************************************************************************/
package prerna.collaboration;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;

final class BrainFilingSignals {

// One contribution per topic, not per keyword or occurrence.
static final double KEYWORD_WEIGHT = 0.10;
private static final String EVIDENCE_KEY = "filingEvidence";

private BrainFilingSignals() {
}

static BrainClassifier.Scores apply(BrainClassifier.Scores scores, List<BrainClassifier.TopicOption> topics,
String subject, List<BrainClassifier.Message> messages, Set<String> senderIds, Set<String> rejected) {
Map<String, Double> adjusted = new LinkedHashMap<>(scores.topics());
Map<String, Object> evidence = new LinkedHashMap<>();
boolean boosted = false;
for (BrainClassifier.TopicOption topic : topics) {
if (BrainThreadClassifier.OTHER_TOPIC.equals(topic.id()) || rejected.contains(topic.id())
|| !adjusted.containsKey(topic.id())) {
continue;
}
List<Map<String, Object>> matches = keywordMatches(topic.keywords(), subject, messages);
List<String> people = topic.personIds().stream().filter(senderIds::contains).distinct().toList();
Map<String, Object> topicEvidence = new LinkedHashMap<>();
topicEvidence.put("keywordMatches", matches);
topicEvidence.put("matchedSenderIds", people);
topicEvidence.put("keywordWeight", matches.isEmpty() ? 0.0 : KEYWORD_WEIGHT);
evidence.put(topic.id(), topicEvidence);
if (!matches.isEmpty()) {
adjusted.put(topic.id(), adjusted.get(topic.id()) + KEYWORD_WEIGHT);
boosted = true;
}
}
if (boosted) {
double total = adjusted.values().stream().mapToDouble(Double::doubleValue).sum();
if (!Double.isFinite(total) || total <= 0) {
throw new IllegalStateException("Invalid adjusted topic scores");
}
adjusted.replaceAll((id, score) -> score / total);
}
Map<String, Object> filing = new LinkedHashMap<>();
filing.put("modelScores", scores.topics());
filing.put("topics", evidence);
Map<String, Object> raw = new LinkedHashMap<>();
if (scores.raw() != null) {
raw.putAll(scores.raw());
}
raw.put(EVIDENCE_KEY, filing);
return new BrainClassifier.Scores(adjusted, scores.fyi(), scores.automated(), scores.urgency(), raw);
}

static Map<String, Object> forLink(BrainClassifier.Scores scores, String topicId, int baseConfidence,
int confidence, boolean topicVipApplied) {
Map<String, Object> signals = new LinkedHashMap<>();
signals.put("version", 1);
signals.put("topicScores", scores.topics());
signals.put("baseConfidence", baseConfidence);
signals.put("finalConfidence", confidence);
signals.put("topicVipApplied", topicVipApplied);
signals.put("topicVipPoints", topicVipApplied ? confidence - baseConfidence : 0);
signals.put("keywordMatches", List.of());
signals.put("matchedSenderIds", List.of());
if (scores.raw() != null && scores.raw().get(EVIDENCE_KEY) instanceof Map<?, ?> filing) {
signals.put("modelScores", filing.get("modelScores"));
if (filing.get("topics") instanceof Map<?, ?> topics
&& topics.get(topicId) instanceof Map<?, ?> evidence) {
signals.put("keywordMatches", evidence.get("keywordMatches"));
signals.put("matchedSenderIds", evidence.get("matchedSenderIds"));
signals.put("keywordWeight", evidence.get("keywordWeight"));
}
}
return signals;
}

static List<Map<String, Object>> keywordMatches(List<String> keywords, String subject,
List<BrainClassifier.Message> messages) {
List<Map<String, Object>> matches = new ArrayList<>();
Set<String> seen = new LinkedHashSet<>();
for (String keyword : keywords) {
if (keyword == null || keyword.isBlank()) {
continue;
}
String value = keyword.strip();
if (!seen.add(value.toLowerCase(Locale.ROOT))) {
continue;
}
Pattern pattern = Pattern.compile(
"(?<![\\p{L}\\p{N}_])" + Pattern.quote(value) + "(?![\\p{L}\\p{N}_])",
Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
if (matches(pattern, subject)) {
matches.add(Map.of("keyword", value, "field", "subject"));
continue;
}
for (int i = 0; i < messages.size(); i++) {
if (matches(pattern, messages.get(i).text())) {
matches.add(Map.of("keyword", value, "field", "body", "messageIndex", i));
break;
}
}
}
return matches;
}

private static boolean matches(Pattern pattern, String text) {
return text != null && pattern.matcher(text).find();
}
}
6 changes: 5 additions & 1 deletion src/prerna/collaboration/BrainReviewUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ private BrainReviewUtils() {

// ---- read ----

// open: newest first; resolved: most recently resolved first
/**
* Open reviews are newest first; resolved reviews are most recently resolved first.
* Topic-choice reviews include data.candidateSignals keyed by topic id, capturing
* the filing evidence when the question was last open. Older reviews may omit it.
*/
public static Map<String, Object> listReview(User user, String status, int limit, int offset) {
Pair<String, String> owner = CollaborationDbUtils.ownerOf(user);
String ownerId = owner.getValue0();
Expand Down
Loading
Loading