diff --git a/docs/guide/equivalence.ipynb b/docs/guide/equivalence.ipynb index d73b417..5db3464 100644 --- a/docs/guide/equivalence.ipynb +++ b/docs/guide/equivalence.ipynb @@ -270,7 +270,7 @@ ".highlight .vg { color: #19177C } /* Name.Variable.Global */\n", ".highlight .vi { color: #19177C } /* Name.Variable.Instance */\n", ".highlight .vm { color: #19177C } /* Name.Variable.Magic */\n", - ".highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
44.0\n",
+ ".highlight .il { color: #666666 } /* Literal.Number.Integer.Long */50.0\n",
"
\n"
],
"text/plain": [
@@ -286,10 +286,10 @@
"from stix2.v21 import Campaign\n",
"\n",
"c1 = Campaign(\n",
- " name=\"there\",)\n",
+ " name=\"Someone Attacks Somebody\",)\n",
"\n",
"c2 = Campaign(\n",
- " name=\"something\",)\n",
+ " name=\"Another Campaign\",)\n",
"print(env.semantically_equivalent(c1, c2))"
]
},
@@ -1144,7 +1144,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Some object types do not have a defined method for calculating semantic equivalence and by default will raise an [error](../api/stix2.exceptions.rst#stix2.exceptions.SemanticEquivalenceUnsupportedTypeError)."
+ "Some object types do not have a defined method for calculating semantic equivalence and by default will give a warning and a result of zero."
]
},
{
@@ -1153,12 +1153,93 @@
"metadata": {},
"outputs": [
{
- "ename": "SemanticEquivalenceUnsupportedTypeError",
- "evalue": "report type has no semantic equivalence implementation!",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31mSemanticEquivalenceUnsupportedTypeError\u001b[0m\u001b[0;31m:\u001b[0m report type has no semantic equivalence implementation!\n"
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "'report' type has no semantic equivalence method to call!\n"
]
+ },
+ {
+ "data": {
+ "text/html": [
+ "0\n",
+ "
\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
@@ -1448,6 +1529,136 @@
"}\n",
"print(env.semantically_equivalent(foo1, foo2, **weights))"
]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Detailed Results\n",
+ "\n",
+ "If your logging level is set to `DEBUG` or higher, the function will log more detailed results. These show the semantic equivalence and weighting for each property that is checked, to show how the final result was arrived at."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Starting semantic equivalence process between: 'threat-actor--54dc2aac-6fde-4a68-ae2a-0c0bc575ed70' and 'threat-actor--c51bce3b-a067-4692-ab77-fcdefdd3f157'\n",
+ "--\t\tpartial_string_based 'Evil Org' 'James Bond'\tresult: '0.56'\n",
+ "'name' check -- weight: 60, contributing score: 33.6\n",
+ "--\t\tpartial_list_based '['crime-syndicate']' '['spy']'\tresult: '0.0'\n",
+ "'threat_actor_types' check -- weight: 20, contributing score: 0.0\n",
+ "--\t\tpartial_list_based '['super-evil']' '['007']'\tresult: '0.0'\n",
+ "'aliases' check -- weight: 20, contributing score: 0.0\n",
+ "Matching Score: 33.6, Sum of Weights: 100.0\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "33.6\n",
+ "
\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 17,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import logging\n",
+ "logging.basicConfig(format='%(message)s')\n",
+ "logger = logging.getLogger()\n",
+ "logger.setLevel(logging.DEBUG)\n",
+ "\n",
+ "ta3 = ThreatActor(\n",
+ " threat_actor_types=[\"crime-syndicate\"],\n",
+ " name=\"Evil Org\",\n",
+ " aliases=[\"super-evil\"],\n",
+ ")\n",
+ "ta4 = ThreatActor(\n",
+ " threat_actor_types=[\"spy\"],\n",
+ " name=\"James Bond\",\n",
+ " aliases=[\"007\"],\n",
+ ")\n",
+ "print(env.semantically_equivalent(ta3, ta4))"
+ ]
}
],
"metadata": {