From 7873e126c24b1d49b08731fcf9f6a67ce6404900 Mon Sep 17 00:00:00 2001 From: Jeffery Painter Date: Thu, 15 Feb 2024 08:51:29 -0500 Subject: [PATCH] Disabling the LCS caching for now as it provides inconsistent results --- .../kernel/metric/ConceptSimilarityServiceImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ctakes-ytex/src/main/java/org/apache/ctakes/ytex/kernel/metric/ConceptSimilarityServiceImpl.java b/ctakes-ytex/src/main/java/org/apache/ctakes/ytex/kernel/metric/ConceptSimilarityServiceImpl.java index 42f70a50..23ead79e 100644 --- a/ctakes-ytex/src/main/java/org/apache/ctakes/ytex/kernel/metric/ConceptSimilarityServiceImpl.java +++ b/ctakes-ytex/src/main/java/org/apache/ctakes/ytex/kernel/metric/ConceptSimilarityServiceImpl.java @@ -50,6 +50,14 @@ * */ public class ConceptSimilarityServiceImpl implements ConceptSimilarityService { + + // The original implementation included code to cache LCS's to save + // computation time. However, this resulted in distance metrics that + // were inconsistent when calling subsequent CUI pairs. To ensure + // replicable results across calls to the similarity service, the + // caching mechanism should be disabled for now. + private static boolean ENABLE_LCS_CACHING = false; + private static final Log log = LogFactory .getLog(ConceptSimilarityServiceImpl.class); @@ -630,7 +638,9 @@ private int getLCSFromCache(ConcRel cr1, ConcRel cr2, Set lcses) { .getConceptID() : cr1.getConceptID()); String cacheKey = cacheKeyBuilder.toString(); Element e = this.lcsCache != null ? this.lcsCache.get(cacheKey) : null; - if (e != null) { + + // If the LCS cache is disabled, we will fall through + if (e != null && ENABLE_LCS_CACHING == true) { // hit the cache - unpack the lcs if (e.getObjectValue() != null) { Object[] val = (Object[]) e.getObjectValue();