Add soft-evidence to the Bayesian network to reason with it.

@param bn
@param nodeName
@param softEvidence
@throws ShanksException
549379
public static void addSoftEvidence(ProbabilisticNetwork bn,
            String nodeName, HashMap<String, Double> softEvidence)
            throws ShanksException {
        ProbabilisticNode targetNode = ShanksAgentBayesianReasoningCapability
                .getNode(bn, nodeName);
        boolean found = false;
        for (Node child : targetNode.getChildren()) {
            if (child.getName().equals(softEvidenceNodePrefix + nodeName)) {
                if (child.getStatesSize() == 2
                        && child.getStateAt(0).equals(triggerState)) {
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            // Create soft-evidence node
            ProbabilisticNode auxNode = new ProbabilisticNode();
            auxNode.setName(softEvidenceNodePrefix + nodeName);
            auxNode.setLabel(softEvidenceNodePrefix + nodeName);
            auxNode.appendState(triggerState);
            auxNode.appendState("NON" + triggerState);
            PotentialTable cpt = auxNode.getProbabilityFunction();
            cpt.addVariable(auxNode);
            for (int i = 0; i < cpt.tableSize(); i++) {
                cpt.setValue(i, (float) 0.5);
            }
            auxNode.initMarginalList();
            bn.addNode(auxNode);

            Edge edge = new Edge(targetNode, auxNode);
            try {
                bn.addEdge(edge);
                cpt = auxNode.getProbabilityFunction();
                for (int i = 0; i < cpt.tableSize(); i++) {
                    cpt.setValue(i, (float) 0.5);
                }
                auxNode.initMarginalList();
            } catch (Exception e) {
                throw new ShanksException(e);
            }
        }
        ShanksAgentBayesianReasoningCapability
                .updateSoftEvidenceAuxiliaryNodeCPT(bn, nodeName, softEvidence);
        ShanksAgentBayesianReasoningCapability.addEvidence(bn,
                softEvidenceNodePrefix + nodeName, triggerState);

    }
763765
public static Map<String, String> getEvidences(ProbabilisticNetwork bn) {

        HashMap<String, String> evidences = new HashMap<String, String>();
        for (Node n : bn.getNodes()) {
            ProbabilisticNode pn = (ProbabilisticNode) n;
            if (pn.hasEvidence()) {
                evidences.put(pn.getName(), pn.getStateAt(pn.getEvidence()));
            }
        }
        return evidences;
    }
481535
private void examineNode(Node node, boolean attributesOnly) {
		while(node != null && node.getNodeType() == Node.COMMENT_NODE) {
			node = node.getNextSibling();
		}
		if(node != null) {
			NamedNodeMap attributes = node.getAttributes();
			if(attributes != null) {
				for (int i = 0; i < attributes.getLength(); i++) {
					Node attribute = attributes.item(i);
					storeAttribute((Attr) attribute);
				}
			}

			if (!attributesOnly) {
				NodeList chields = node.getChildNodes();
				for (int i = 0; i < chields.getLength(); i++) {
					Node chield = chields.item(i);
					if (chield.getNodeType() == Node.ELEMENT_NODE)
						examineNode(chield, false);
				}
			}
		}
	}
797204
public boolean addToCorruptReplicasMap(Block blk, DatanodeDescriptor dn) {
    Collection<DatanodeDescriptor> nodes = getNodes(blk);
    if (nodes == null) {
      nodes = new TreeSet<DatanodeDescriptor>();
      corruptReplicasMap.put(blk, nodes);
    }
    boolean added = false;
    if (!nodes.contains(dn)) {
      added = nodes.add(dn);
      NameNode.stateChangeLog.info("BLOCK NameSystem.addToCorruptReplicasMap: "+
                                   blk.getBlockName() +
                                   " added as corrupt on " + dn.getName() +
                                   " by " + Server.getRemoteIp());
    } else {
      NameNode.stateChangeLog.info("BLOCK NameSystem.addToCorruptReplicasMap: "+
                                   "duplicate requested for " + 
                                   blk.getBlockName() + " to add as corrupt " +
                                   "on " + dn.getName() +
                                   " by " + Server.getRemoteIp());
    }
    return added;
  }
48780
public void addNode(Node n)
  {

    if (!m_mutable)
      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");

    this.addElement(n);
  }
84950
public void setProbability(int i, double v) { 
    if (TopicDistribution_Type.featOkTst && ((TopicDistribution_Type)jcasType).casFeat_probability == null)
      jcasType.jcas.throwFeatMissing("probability", "ch.epfl.bbp.uima.types.TopicDistribution");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((TopicDistribution_Type)jcasType).casFeatCode_probability), i);
    jcasType.ll_cas.ll_setDoubleArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((TopicDistribution_Type)jcasType).casFeatCode_probability), i, v);}
458097
public static void addSoftEvidence(BayesianReasonerShanksAgent agent,
            String nodeName, HashMap<String, Double> softEvidence)
            throws ShanksException {
        ShanksAgentBayesianReasoningCapability.addSoftEvidence(
                agent.getBayesianNetwork(), nodeName, softEvidence);
    }
664047
public synchronized void addEvidence(EvidenceType type, Evidence e) {
        if (null != type) {
            switch (type) {
                case VENDOR:
                    vendors.add(e);
                    break;
                case PRODUCT:
                    products.add(e);
                    break;
                case VERSION:
                    versions.add(e);
                    break;
                default:
                    break;
            }
        }
    }
1109068
public static HashMap<String, Float> getNodeStatesHypotheses(
            ProbabilisticNetwork bn, String nodeName) throws ShanksException {
        ProbabilisticNode node = ShanksAgentBayesianReasoningCapability
                .getNode(bn, nodeName);
        HashMap<String, Float> result = new HashMap<String, Float>();
        int statesNum = node.getStatesSize();
        for (int i = 0; i < statesNum; i++) {
            String status = node.getStateAt(i);
            Float hypothesis = node.getMarginalAt(i);
            result.put(status, hypothesis);
        }
        return result;
    }
76111
public static void loadNetwork(BayesianReasonerShanksAgent agent)
            throws ShanksException {
        Network bn = ShanksAgentBayesianReasoningCapability.loadNetwork(agent
                .getBayesianNetworkFilePath());
        agent.setBayesianNetwork(bn);
    }
1068020
public static void addEvidence(Network bn, String nodeName, String status)
            throws ShanksException {

        if (bn == null || nodeName == null || status == null) {
            throw new ShanksException("Null parameter in addEvidence method.");
        }
        try {
            if (!bn.isPropagatedEvidence(nodeName)) {
                if (bn.isRealEvidence(nodeName)) {
                    bn.clearEvidence(nodeName);
                }
                bn.setEvidence(nodeName, status);
                bn.updateBeliefs();
            }
        } catch (Exception e) {
            bn.updateBeliefs();
            HashMap<String, Float> belief = ShanksAgentBayesianReasoningCapability
                    .getNodeStatesHypotheses(bn, nodeName);

            String msg = e.getMessage() + " -> values for node: " + nodeName
                    + " -> ";
            boolean zeroBel = false;
            for (Entry<String, Float> entry : belief.entrySet()) {
                if (status.equals(entry.getKey()) && entry.getValue() == 0.0f) {
                    zeroBel = true;
                    // Impossible value calculated by inference (this is because the BN is a big shit...
                    // But it is not a real error...
                    break;
                }
                msg = msg + entry.getKey() + "-" + entry.getValue() + " ";
            }
            if (!zeroBel) {
                throw new ShanksException(msg);
            }
        }
    }
929488
public void addFalsePositive(Key key) {
    if (key == null) {
      throw new NullPointerException("key can not be null");
    }

    int[] h = hash.hash(key);
    hash.clear();

    for (int i = 0; i < nbHash; i++) {
      fpVector[h[i]].add(key);
    }
  }
1248721
function pull_seeds(entity, test_p){
	each(entity.annotations(), function(ann){
	    
	    //console.log(ann.key(), ann.value_type(), ann.value());
	    
	    // Is it an evidence annotation.
	    if( ! test_p(ann) ){
		// Skip.
		//console.log('skip folding with failed test');
	    }else{
		//console.log('start folding with passed test');

		// If so, and the individual in question exists, it is
		// the jumping off point for the evidence folding
		// subgraph.
		var ref_node_id = ann.value();
		var ref_node = anchor.get_node(ref_node_id);
		if( ref_node ){
		    seeds[ref_node_id] = entity;
		}
	    }
	});
    }
731565
public void heartbeatNode (String nodeName)
    {
        updatePartial(NodeRecord.getKey(nodeName),
                      NodeRecord.LAST_UPDATED, new Timestamp(System.currentTimeMillis()));
    }
273546
def from_uncharted_json_serialized_dict(
        cls, _dict, minimum_evidence_pieces_required: int = 1
    ):
        
        sts = _dict["statements"]
        G = nx.DiGraph()
        for s in sts:
            if len(s["evidence"]) >= minimum_evidence_pieces_required:
                subj, obj = s["subj"], s["obj"]
                if (
                    subj["db_refs"]["concept"] is not None
                    and obj["db_refs"]["concept"] is not None
                ):
                    subj_name, obj_name = [
                        "/".join(s[x]["db_refs"]["concept"].split("/")[:])
                        for x in ["subj", "obj"]
                    ]
                    G.add_edge(subj_name, obj_name)
                    subj_delta = s["subj_delta"]
                    obj_delta = s["obj_delta"]

                    for delta in (subj_delta, obj_delta):
                        # TODO : Ensure that all the statements provided by
                        # Uncharted have unambiguous polarities.
                        if delta["polarity"] is None:
                            delta["polarity"] = 1

                    influence_stmt = Influence(
                        Concept(subj_name, db_refs=subj["db_refs"]),
                        Concept(obj_name, db_refs=obj["db_refs"]),
                        subj_delta=s["subj_delta"],
                        obj_delta=s["obj_delta"],
                        evidence=[
                            INDRAEvidence(
                                source_api=ev["source_api"],
                                annotations=ev["annotations"],
                                text=ev["text"],
                                epistemics=ev.get("epistemics"),
                            )
                            for ev in s["evidence"]
                        ],
                    )
                    influence_sts = G.edges[subj_name, obj_name].get(
                        "InfluenceStatements", []
                    )
                    influence_sts.append(influence_stmt)
                    G.edges[subj_name, obj_name][
                        "InfluenceStatements"
                    ] = influence_sts

        for concept, indicator in _dict[
            "concept_to_indicator_mapping"
        ].items():
            if indicator is not None:
                indicator_source, indicator_name = (
                    indicator["name"].split("/")[0],
                    "/".join(indicator["name"].split("/")[1:]),
                )
                if concept in G:
                    if G.nodes[concept].get("indicators") is None:
                        G.nodes[concept]["indicators"] = {}
                    G.nodes[concept]["indicators"][indicator_name] = Indicator(
                        indicator_name, indicator_source
                    )

        self = cls(G)
        self.assign_uuids_to_nodes_and_edges()
        return self
1191931
public static Boolean getYesNoAttrVal(final NamedNodeMap nnm, final String name)
      throws SAXException {
    String val = getAttrVal(nnm, name);

    if (val == null) {
      return null;
    }

    if ((!"yes".equals(val)) && (!"no".equals(val))) {
      throw new SAXException("Invalid attribute value: " + val);
    }

    return new Boolean("yes".equals(val));
  }
707537
public static HashMap<String, HashMap<String, Float>> getAllHypotheses(
            Network bn) throws ShanksException {
        HashMap<String, HashMap<String, Float>> result = new HashMap<String, HashMap<String, Float>>();
        for (int node : bn.getAllNodes()) {
            String nodeName = bn.getNodeName(node);
            HashMap<String, Float> hypotheses = ShanksAgentBayesianReasoningCapability
                    .getNodeStatesHypotheses(bn, nodeName);
            result.put(nodeName, hypotheses);
        }
        return result;
    }