Package org.dbpedia.spotlight.model

Examples of org.dbpedia.spotlight.model.Text


            i++;
            if (i == 100)
                break;

            spotter.extract(
                    new Text(
                            new Scanner(textFile).useDelimiter("\\A").next()
                    )
            );

            consumption.addLast((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024));
 
View Full Code Here


    public void setUp() throws Exception {
        super.setUp();
    client = new WikiMachineClient();
   
    text = new Text("Google Inc. is an American multinational public corporation " +
        "invested in Internet search, cloud computing, and advertising " +
        "technologies. Google hosts and develops a number of Internet-based " +
        "services and products, and generates profit primarily from advertising " +
        "through its AdWords program.");
    }
View Full Code Here

                + "and his son Dom Pedro II. On 7 September 1822, Pedro declared the independence of Brazil and, after waging a "
                + "successful war against his father's kingdom, was acclaimed on 12 October as Pedro I, the first Emperor of Brazil. ";

        text= URLEncoder.encode(text, "utf-8");

        List<DBpediaResource> response = c.extract(new Text(text));

        DBpediaResource[] expectedEntities = {new DBpediaResource("Son"), new  DBpediaResource("Pedro_I_of_Brazil"), new  DBpediaResource("Territory_%28administrative_division%29"), new  DBpediaResource("Brazil"), new  DBpediaResource("Monarchy"), new  DBpediaResource("Father"), new  DBpediaResource("Governance"), new  DBpediaResource("Pedro_I_of_Brazil"), new  DBpediaResource("Wars_of_succession"), new  DBpediaResource("Empire_of_Brazil"), new  DBpediaResource("Pedro_II_of_Brazil"), new  DBpediaResource("Brazilian_Declaration_of_Independence"), new  DBpediaResource("Politics_of_the_Empire_of_Brazil"), new  DBpediaResource("Constitutional_monarchy"), new  DBpediaResource("October"), new  DBpediaResource("September"), new  DBpediaResource("Emperor"), new  DBpediaResource("Nation"), new  DBpediaResource("Government")};
        //TODO sort and compare
        assertEquals(Arrays.asList(expectedEntities).size(),response.size());
View Full Code Here

      JSONArray texts = jsonObject.getJSONArray(domain);
      List<SurfaceFormOccurrence> extracted = new LinkedList<SurfaceFormOccurrence>();

      long start = System.currentTimeMillis();
      for(int i = 0; i < texts.length(); i++) {
        extracted.addAll(spotter.extract(new Text(texts.getString(i))));
      }
      long end = System.currentTimeMillis();

      System.out.println("Domain: " + domain);
      System.out.println("# occurrences: " + extracted.size());
View Full Code Here

        String clientIp = request.getRemoteAddr();

        try {
            String textToProcess = ServerUtils.getTextToProcess(text, inUrl);
            List<SurfaceFormOccurrence> spots = annotationInterface.spot(spotterName, new Text(textToProcess));
            String response = new Annotation(new Text(text), spots).toXML();
            return ServerUtils.ok(response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST). entity(ServerUtils.print(e)).type(MediaType.TEXT_HTML).build());
        }
View Full Code Here

  else if (accept.equals("application/rdf+xml"))
      format = "rdfxml";
 
        try {
            String textToProcess = ServerUtils.getTextToProcess(text, inUrl);
            List<SurfaceFormOccurrence> spots = annotationInterface.spot(spotterName, new Text(textToProcess));
      String response = NIFOutputFormatter.fromSurfaceFormOccs(text, spots, format, prefix);
            return ServerUtils.ok(response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST). entity(ServerUtils.print(e)).type(accept).build());
View Full Code Here

        String clientIp = request.getRemoteAddr();

        try {
            String textToProcess = ServerUtils.getTextToProcess(text, inUrl);
            List<SurfaceFormOccurrence> spots = annotationInterface.spot(spotterName, new Text(textToProcess));
            String response = new Annotation(new Text(text), spots).toJSON();
            return ServerUtils.ok(response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST). entity(ServerUtils.print(e)).type(MediaType.TEXT_HTML).build());
        }
View Full Code Here

        String clientIp = request.getRemoteAddr();

        try {
            String textToProcess = ServerUtils.getTextToProcess(text, inUrl);
            List<SurfaceFormOccurrence> spots = annotationInterface.spot(spotterName, new Text(textToProcess));
            String response = new Annotation(new Text(text), spots).toXML();
            return ServerUtils.ok(response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST). entity(ServerUtils.print(e)).type(MediaType.TEXT_HTML).build());
        }
View Full Code Here

        String clientIp = request.getRemoteAddr();

        try {
            String textToProcess = ServerUtils.getTextToProcess(text, inUrl);
            List<SurfaceFormOccurrence> spots = annotationInterface.spot(spotterName, new Text(text));
            String response = new Annotation(new Text(text), spots).toJSON();
            return ServerUtils.ok(response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST). entity(ServerUtils.print(e)).type(MediaType.TEXT_HTML).build());
        }
View Full Code Here

                            @DefaultValue(SpotlightConfiguration.DEFAULT_TYPES) @QueryParam("types") String resourceTypesString,
                            @DefaultValue("250") @QueryParam("n") int nHits) {

        try {
            List<OntologyType> ontologyTypes = Factory.ontologyType().fromCSVString(resourceTypesString);
            return ok(asJSON(new Text(text), nHits, ontologyTypes));
        } catch (Exception e) {
            e.printStackTrace();
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST). entity(ServerUtils.print(e)).type(MediaType.APPLICATION_JSON).build());
        }
    }
View Full Code Here

TOP

Related Classes of org.dbpedia.spotlight.model.Text

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.