Merge branch 'MISP:main' into cn

pull/959/head
Rony 2024-04-16 21:22:12 +05:30 committed by GitHub
commit d6c0a2110e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3232 additions and 1959 deletions

File diff suppressed because it is too large Load Diff

41
tools/NER/extract.py Normal file
View File

@ -0,0 +1,41 @@
import os
import json
import argparse
thisDir = os.path.dirname(__file__)
clusters = []
pathClusters = os.path.join(thisDir, '../../clusters')
pathGalaxies = os.path.join(thisDir, '../../galaxies')
skip_list = ["cancer.json", "handicap.json", "ammunitions.json", "firearms.json"]
for f in os.listdir(pathGalaxies):
if '.json' in f:
with open(os.path.join(pathGalaxies, f), 'r') as f_in:
galaxy_data = json.load(f_in)
if galaxy_data.get('namespace') != 'deprecated':
if f not in skip_list:
clusters.append(f)
clusters.sort()
for cluster in clusters:
fullPathClusters = os.path.join(pathClusters, cluster)
with open(fullPathClusters) as fp:
c = json.load(fp)
cluster_name = cluster.split(".")[0].upper()
l = f'{cluster_name}'
for v in c['values']:
if 'uuid' not in v:
continue
l += f",{v['value']}"
if 'meta' not in v:
continue
if 'synonyms' not in v['meta']:
continue
for synonym in v['meta']['synonyms']:
l += f',{synonym}'
print(l)

View File

@ -11,7 +11,7 @@ ghp-import==2.1.0
gitdb==4.0.11
GitPython==3.1.41
graphviz==0.20.1
idna==3.6
idna==3.7
Jinja2==3.1.3
Markdown==3.5.2
MarkupSafe==2.1.4