Commit 9ba2c442 authored by Grzegorz Kostkowski's avatar Grzegorz Kostkowski

Changes with resources

parent b753bceb
Pipeline #444 failed with stage
in 40 seconds
......@@ -11,7 +11,28 @@
; - resource_class - name of class from resource.resources module used to create
; instance of this resource.
[concept-node-mapping]
name = concept-node-mapping
required_resources =
resource_class =
[concept-vector-mapping]
name = concept-vector-mapping
required_resources =
resource_class =
\ No newline at end of file
resource_class =
[concept-vector-mapping]
name = concept-vector-mapping
required_resources =
resource_class =
[v_id-lod_url-map]
name = v_id-lod_url-mapping
required_resources = graph,concepts_categories_mapping
resource_class = GraphIndexResource
[v_id_vector_map]
name = v_id_vector_map
required_resources = graph,categories_vectors
resource_class =
......@@ -12,32 +12,40 @@
; Keep in mind that only files included in instalation setup.py file will be
; available in 'data' directory.
[graph]
;graph_file_path = graph-2018-11-13-categories-broaders-narrowers-e-weight.graphml
name = category-graph
type = GraphResource
; path to file with concept -> category mapping: It can be zipped,
; pickled dict (*.bin.zip), zipped plain text (*.txt.zip) or plain text (*.txt)
;concepts_categories_mapping = concept_category_index_only_dbpedia_concepts_reduced_v5_at_least_one.txt.zip
[dbpedia-graph]
name = dbpedia-graph
resource_class = GraphResource
graph_file_path = graph-2018-11-13-categories-broader-narrower-weighted-001-filtered-meaningless.graphml
;[plwn-graph]
;name = plwn-graph
;type = GraphResource
;graph_file_path =
[concepts_categories_mapping]
name = concepts_categories_mapping
type = IndexBuilder
resource_class = IndexBuilder
; path to txt file with wikipedia2vec vectors
;categories_vectors = categories_vectors_v2.txt.zip
path = concept_category_index_all_sources_extended_reduced_at_least_one_v7.bin.zip
;[concepts-syn_id-mapping]
;name = concepts-syn_id-mapping
;type = IndexBuilder
;path =
[categories-vectors]
name = categories_vectors
type =
categories_vectors = cats_keyed_vectors_v2.bin.zip
resource_class =
path = cats_keyed_vectors_v2.bin.zip
;concepts_vectors = concepts_vectors.txt.zip
[concepts-vectors]
concepts_vectors = concepts_keyed_vectors.bin.zip
name = concepts-vectors
path = concepts_keyed_vectors.bin.zip
resource_class =
; path to file with list of categories which will be used to filter list
; of results
......@@ -47,10 +55,21 @@ edge_weights_prop = 'rel_w'
; IDF-based weights (normalised) for lemmas (orths)
[ranking-weights]
name = ranking_weights
orth_idf_weights = idf-dict2_norm_sorted.tsv
name = orth_idf_w_map
resource_class =
path = idf-dict2_norm_sorted.tsv
[categories-labels]
name = categories_labels
type =
cats_labels = categories_pl_labels_lowercase_v4.txt
resource_class =
path = categories_pl_labels_lowercase_v4.txt
[cat_weights]
name = cat_weights
resource_class =
path =
[orth_idf_w_map]
name =
resource_class =
path =
\ No newline at end of file
......@@ -25,6 +25,10 @@ class ResourcesManager(object):
def get_resource_by_name(self, name):
return self._resources.get(name, None)
# runtime_resource ??
def register_resource(self):
pass
def register_resources(self):
'''
Based on configuration, determines resources to load and register them.
......
......@@ -80,6 +80,29 @@ class GraphResource(Resource):
graph = gt.load_graph(self._path)
self._resource = graph
class GraphIndexResource(Resource):
def __init__(self, name, path, required_resources=None):
super(GraphIndexResource, self).__init__(name=name)
self._path = path
self.check(required_resources)
self._required_resources = required_resources
self.prepare()
def check(self, required_resources):
"""
Check if dict contains all required resources.
"""
import graph_tool
assert len(required_resources) == 1
res = required_resources.items()[0]
assert isinstance(res, graph_tool.Graph)
def prepare(self):
import graph_tool as gt
log.debug("Preparing '{}' ...".format(self.name))
raise NotImplementedError
# TODO
class WosedonGraphResource(Resource):
def __init__(self, name, path):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment