Ejemplo n.º 1
0
 def referenced(self):
     """
     @param self: the object itself
     @return the referenced sites by Apache Stanbol EntityHub
     """
     stanbol = get_stanbol(self.context)
     res = stanbol.entityHubSite().get_referenced_sites()
     return res
Ejemplo n.º 2
0
 def referenced(self):
     """
     @param self: the object itself
     @return the referenced sites by Apache Stanbol EntityHub
     """
     stanbol = get_stanbol(self.context)
     res = stanbol.entityHubSite().get_referenced_sites()
     return res
Ejemplo n.º 3
0
def stanbol_indexer_handler(obj, event):
    obj._stanbol_enhancements = None
    stanbol = get_stanbol(obj)
    try:           
        obj._stanbol_enhancements = stanbol.engines(obj.SearchableText(), 'rdfjson')
    except Exception, e:
        msg = "Problem while using Stanbol server for automatic "+\
              "enhancement.\n%s" % str(e)
        IStatusMessage(obj.REQUEST).addStatusMessage(msg, type='error')
Ejemplo n.º 4
0
 def __call__(self):
     """
     Method called when EntityHubProxy is called
     @param self: the object itself
     @return: the Stanbol EntityHub results
     """
     response = self.request.response
     stanbol = get_stanbol(self.context)
     #TODO
     return ''
Ejemplo n.º 5
0
def stanbol_indexer_handler(obj, event):
    obj._stanbol_enhancements = None
    stanbol = get_stanbol(obj)
    try:
        obj._stanbol_enhancements = stanbol.engines(obj.SearchableText(),
                                                    'rdfjson')
    except Exception, e:
        msg = "Problem while using Stanbol server for automatic "+\
              "enhancement.\n%s" % str(e)
        IStatusMessage(obj.REQUEST).addStatusMessage(msg, type='error')
Ejemplo n.º 6
0
 def __call__(self):
     """
     Method called when EntityHubProxy is called
     @param self: the object itself
     @return: the Stanbol EntityHub results 
     """
     response = self.request.response
     stanbol = get_stanbol(self.context)
     #TODO
     return ''
Ejemplo n.º 7
0
 def engineCall(self, data):
     """
     Returns the graph resulting from processing data with Stanbol engine
     @param self: the object itself
     @param data: data to process
     @return the rdflib graph
     """
     stanbol = get_stanbol(self.context)
     res = stanbol.engines(payload=data, format='rdfxml', parsed=True)
     return res
Ejemplo n.º 8
0
 def engineCall(self, data):
     """
     Returns the graph resulting from processing data with Stanbol engine
     @param self: the object itself
     @param data: data to process
     @return the rdflib graph
     """
     stanbol = get_stanbol(self.context)
     res = stanbol.engines(payload=data, format='rdfxml', parsed=True)
     return res
Ejemplo n.º 9
0
 def entity(self):
     """
     @param self: the object itself
     @return informations on the requested entity
     """
     if self.request.form['id']:
         uri = self.request.form['id']
     stanbol = get_stanbol(self.context)
     ehs = stanbol.entityHubSite
     if uri:
         res = ehs.get_entity(uri)
         return res
     return ''
Ejemplo n.º 10
0
 def entity(self):
     """
     @param self: the object itself
     @return informations on the requested entity
     """
     if self.request.form['id']:
         uri = self.request.form['id']
     stanbol = get_stanbol(self.context)
     ehs = stanbol.entityHubSite
     if uri:
         res = ehs.get_entity(uri)
         return res
     return '' 
Ejemplo n.º 11
0
 def __call__(self):
     """
     Method called when EntityHubSiteProxy is called
     @param self: the object itself
     @return: the Stanbol EntityHub sites results
     """
     response = self.request.response
     stanbol = get_stanbol(self.context)
     print self.request["URL"]
     req = self.request["URL"].split("sites")
     req = req[1]
     #TODO
     return ''
Ejemplo n.º 12
0
 def __call__(self):
     """
     Method called when EntityHubSiteProxy is called
     @param self: the object itself
     @return: the Stanbol EntityHub sites results 
     """
     response = self.request.response
     stanbol = get_stanbol(self.context)
     print self.request["URL"]
     req = self.request["URL"].split("sites")
     req = req[1]
     #TODO
     return ''
Ejemplo n.º 13
0
 def __call__(self):
     """
     Method called when EngineProxy is called
     @param self: the object itself
     @return: the Stanbol engines results in json format or an empty json
             object
     """
     #response = self.request.response
     stanbol = get_stanbol(self.context)
     print self.request.form
     try:
         print self.request.form['data']
         data = self.request.form['data']
         res = stanbol.engines(payload=data, format="jsonld", parsed=False)
         print res
         return res
     except:
         return '{}'
Ejemplo n.º 14
0
    def sparqlCall(self):
        """
        JQuery.PyProxy View for SparQL console
        @param self: the object itself
        @return sparql query result
        """
        jq = JQueryProxy()
        data = self.request.form.get('text')
        print self.request.stdin.getvalue()
        print data
        stanbol = get_stanbol(self.context)
        res = stanbol.sparql(data).body_string()
        print res
        res = res.replace('<', '&lt;')
        res = res.replace('>', '&gt;')
        jq("#sparql_result").html(res)

        return jq
Ejemplo n.º 15
0
 def __call__(self):
     """
     Method called when EngineProxy is called
     @param self: the object itself
     @return: the Stanbol engines results in json format or an empty json
             object
     """
     response = self.request.response
     stanbol = get_stanbol(self.context) 
     print self.request.form
     try:
         print self.request.form['data']
         data = self.request.form['data']
         res = stanbol.engines(payload=data, format="jsonld", parsed=False)
         print res
         return res
     except:
         return '{}' 
Ejemplo n.º 16
0
    def sparqlCall(self):
        """
        JQuery.PyProxy View for SparQL console
        @param self: the object itself
        @return sparql query result
        """
        jq = JQueryProxy()
        data = self.request.form.get('text')
        print self.request.stdin.getvalue()
        print data
        stanbol = get_stanbol(self.context)
        res = stanbol.sparql(data).body_string()
        print res
        res = res.replace('<', '&lt;')
        res = res.replace('>', '&gt;')
        jq("#sparql_result").html(res)

        return jq
Ejemplo n.º 17
0
    def find(self):
        """
        @param self: the object itself
        @return the id of related entities
        """
        # name
        # field
        # lang
        # limit
        # offset
        
        stanbol = get_stanbol(self.context)
        ehs = stanbol.entityHubSite
        try:
            _name = self.request.form['name']
        except:
            _name = None
        try:
            _field = self.request.form['field']
        except:
            _field = None
        try:
            _lang = self.request.form['lang']
        except:
            _lang = None
        try:
            _limit = self.request.form['limit']
        except:
            _limit = None
        try:
            _offset = self.request.form['offset']
        except:
            _offset = None

        res = ehs.find(
            name = _name, 
            field=_field, 
            lang=_lang, 
            limit=_limit,
            offset=_offset
        )
        return res
Ejemplo n.º 18
0
    def find(self):
        """
        @param self: the object itself
        @return the id of related entities
        """
        # name
        # field
        # lang
        # limit
        # offset

        stanbol = get_stanbol(self.context)
        ehs = stanbol.entityHubSite
        try:
            _name = self.request.form['name']
        except:
            _name = None
        try:
            _field = self.request.form['field']
        except:
            _field = None
        try:
            _lang = self.request.form['lang']
        except:
            _lang = None
        try:
            _limit = self.request.form['limit']
        except:
            _limit = None
        try:
            _offset = self.request.form['offset']
        except:
            _offset = None

        res = ehs.find(name=_name,
                       field=_field,
                       lang=_lang,
                       limit=_limit,
                       offset=_offset)
        return res