Examples of Annotation


Examples of org.codehaus.backport175.reader.Annotation

    public void testAccessAnnotation() {
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < INVOCATIONS; i++) {
            final AnnotationReader reader = AnnotationReader.getReaderFor(test.reader.Target.METHOD.getDeclaringClass());
            Annotation annotation = reader.getAnnotation("test.TestAnnotations$VoidTyped", test.reader.Target.METHOD);
        }
        long time = System.currentTimeMillis() - startTime;
        double timePerInvocationNormalMethod = time / (double) INVOCATIONS;
        System.out.println("backport175 API : " + timePerInvocationNormalMethod);
    }
View Full Code Here

Examples of org.dbpedia.spotlight.uima.response.Annotation

        request += line;
        numLines++;
      }

     
      Annotation response = null;
      boolean retry = false;
      int retryCount = 0;
      do{
        try{

          LOG.info("Sending request to the server");

          WebResource r = c.resource(SPOTLIGHT_ENDPOINT);
          response =
              r.queryParam("text", request)
              .queryParam("confidence", "" + CONFIDENCE)
              .queryParam("support", "" + SUPPORT)
              .queryParam("types", TYPES)
              .queryParam("sparql", SPARQL)
              .queryParam("policy", POLICY)
              .queryParam("coreferenceResolution",
                  Boolean.toString(COREFERENCE_RESOLUTION))
              .queryParam("spotter", SPOTTER)
              .queryParam("disambiguator", DISAMBIGUATOR)
              .type("application/x-www-form-urlencoded;charset=UTF-8")
              .accept(MediaType.TEXT_XML)
              .post(Annotation.class);
          retry = false;
        } catch (Exception e){
          //In case of a failure, try sending the request with a 2 second delay at least three times before throwing an exception
          LOG.error("Server request failed. Will try again in 2 seconds..", e);
          LOG.error("Failed request payload: " +request);
          try {
            Thread.sleep(2000);
          } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            LOG.error("Thread interrupted",e1);
          }
          if (retryCount++ < 3){
            retry = true
          } else {
            throw new AnalysisEngineProcessException("The server request failed", null);
          }
        }
      }while(retry);
         
          LOG.info("Server request completed. Writing to the index");
          /*
           * Add the results to the AnnotationIndex
           */
          for (Resource resource : response.getResources()) {
            JCasResource res = new JCasResource(aJCas);
            res.setBegin(documentOffset + new Integer(resource.getOffset()));
            res.setEnd(documentOffset + new Integer(resource.getOffset())
            + resource.getSurfaceForm().length());
            res.setSimilarityScore(new Double(resource.getSimilarityScore()));
View Full Code Here

Examples of org.dbpedia.spotlight.web.rest.output.Annotation

    // Annotation interface
    public Annotation process(String text, double confidence, int support, String ontologyTypesString,
                              String sparqlQuery, boolean blacklist, boolean coreferenceResolution, Spotter spotter, ParagraphDisambiguatorJ disambiguator)
            throws SearchException, ItemNotFoundException, InputException, SpottingException {

        Annotation annotation = new Annotation(text);
        List<Spot> spots = new LinkedList<Spot>();

        Text textObject = new Text(text);
        textObject.setFeature(new Score("confidence", confidence));

        if(Server.getTokenizer() != null)
            Server.getTokenizer().tokenizeMaybe(textObject);

        List<SurfaceFormOccurrence> entityMentions = spotter.extract(textObject);
        if (entityMentions.size()==0) return annotation; //nothing to disambiguate
        Paragraph paragraph = Factory.paragraph().fromJ(entityMentions);
        LOG.info(String.format("Spotted %d entity mentions.",entityMentions.size()));

        Map<SurfaceFormOccurrence,List<DBpediaResourceOccurrence>> entityCandidates = disambiguator.bestK(paragraph,k);
        LOG.info(String.format("Disambiguated %d candidates with %s.",entityCandidates.size(),disambiguator.name()));

        Enumeration.Value listColor = blacklist ? FilterPolicy$.MODULE$.Blacklist() : FilterPolicy$.MODULE$.Whitelist();

        /*The previous addition of filter to the Candidates requests (which has usability questioned) produce the error described at issue #136.
          To solve it, this feature for this argument (Candidates) is disabled, setting coreferenceResolution to false ever. Ignoring the user's configuration.
        */
        Boolean unableCoreferenceResolution = false;
        FilterElement filter = new OccsFilter(confidence, support, ontologyTypesString, sparqlQuery, blacklist, unableCoreferenceResolution, Server.getSimilarityThresholds(), Server.getSparqlExecute());

        Map<SurfaceFormOccurrence,List<DBpediaResourceOccurrence>> filteredEntityCandidates = new HashMap<SurfaceFormOccurrence,List<DBpediaResourceOccurrence>>();;

        for (Map.Entry<SurfaceFormOccurrence,List<DBpediaResourceOccurrence>> entry : entityCandidates.entrySet())
        {
            List<DBpediaResourceOccurrence> result = filter.accept(new FilterOccsImpl() ,entry.getValue());

            if (!result.isEmpty())
                filteredEntityCandidates.put(entry.getKey(), result);
        }

        for(SurfaceFormOccurrence sfOcc : filteredEntityCandidates.keySet()) {
            Spot spot = Spot.getInstance(sfOcc);
            List<Resource> resources = new LinkedList<Resource>();
            for(DBpediaResourceOccurrence occ : filteredEntityCandidates.get(sfOcc)) {
                Resource resource = Resource.getInstance(occ);
                resources.add(resource);
            }
            spot.setResources(resources);
            spots.add(spot);
        }
        annotation.setSpots(spots);
        return annotation;
    }
View Full Code Here

Examples of org.dbwiki.data.annotation.Annotation

          }
        }
        int annotationID = rs.getInt(ViewDataColAnnotationID);
        if (!rs.wasNull()) {
          if (!node.annotation().contains(annotationID)) {
            node.annotation().add(new Annotation(annotationID, rs.getString(ViewDataColAnnotationText), rs.getString(ViewDataColAnnotationDate), database.users().get(rs.getInt(ViewDataColAnnotationUser))));
          }
        }
      }
      System.out.println(i);
      rs.close();
View Full Code Here

Examples of org.drools.definition.type.Annotation

        assertEquals( "org.drools.test.Bean", bean.getName() );
        assertEquals( "Bean", bean.getSimpleName() );
        assertEquals( "org.drools.test", bean.getPackageName() );

        assertEquals( 1, bean.getClassAnnotations().size() );
        Annotation ann = bean.getClassAnnotations().get( 0 );
        assertEquals( "org.drools.compiler.TypeDeclarationTest$KlassAnnotation", ann.getName() );
        assertEquals( "klass", ann.getPropertyValue( "value" ) );
        assertEquals( String.class, ann.getPropertyType( "value" ) );

        assertEquals( 2, bean.getMetaData().size() );
        assertEquals( "event", bean.getMetaData().get( "role" ) );

        FactField field = bean.getField( "name" );
        assertNotNull( field );
        assertEquals( 1, field.getFieldAnnotations().size() );
        Annotation fnn = field.getFieldAnnotations().get( 0 );

        assertEquals( "org.drools.compiler.TypeDeclarationTest$FieldAnnotation", fnn.getName() );
        assertEquals( "fld", fnn.getPropertyValue( "prop" ) );
        assertEquals( String.class, fnn.getPropertyType( "prop" ) );

        assertEquals( 1, field.getMetaData().size() );
        assertTrue( field.getMetaData().containsKey( "key" ) );

    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.Annotation

    String version= project.getOption(JavaCore.COMPILER_COMPLIANCE, true);

    if (!binding.getDeclaringClass().isInterface()
        || !JavaModelUtil.isVersionLessThan(version, JavaCore.VERSION_1_6))
    {
      final Annotation marker= rewrite.getAST().newMarkerAnnotation();
      marker.setTypeName(rewrite.getAST().newSimpleName(annotation)); //$NON-NLS-1$
      rewrite.getListRewrite(decl, MethodDeclaration.MODIFIERS2_PROPERTY).insertFirst(marker, null);
    }
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.Annotation

    addNewUnits(logger, units);
  }

  private Object createAnnotationInstance(TreeLogger logger,
      Expression expression) {
    Annotation annotation = (Annotation) expression;

    // Determine the annotation class
    TypeBinding resolvedType = annotation.resolvedType;
    Class<?> classLiteral = getClassLiteral(logger, resolvedType);
    if (classLiteral == null) {
      return null;
    }

    Class<? extends java.lang.annotation.Annotation> clazz = classLiteral.asSubclass(java.lang.annotation.Annotation.class);

    // Build the map of identifiers to values.
    Map<String, Object> identifierToValue = new HashMap<String, Object>();
    for (MemberValuePair mvp : annotation.memberValuePairs()) {
      // Method name
      String identifier = String.valueOf(mvp.name);

      // Value
      Expression expressionValue = mvp.value;
View Full Code Here

Examples of org.eclipse.jdt.internal.core.Annotation

    }
    return typeArguments;
  }
  public static IAnnotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation, String memberValuePairName) {
    char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.'));
    return new Annotation(parent, new String(typeName), memberValuePairName);
  }
View Full Code Here

Examples of org.eclipse.jface.text.source.Annotation

 
  @SuppressWarnings("unchecked")
  public static MarkerAnnotation findMarkerAnnotationByTypeAndOffset(String type, int offset, ISourceViewer sourceViewer) {
    Iterator<Annotation> annotations = sourceViewer.getAnnotationModel().getAnnotationIterator();
    while (annotations.hasNext()) {
      Annotation tmpAnnotation = annotations.next();
      if (tmpAnnotation instanceof MarkerAnnotation) {
        MarkerAnnotation markerAnnotation = (MarkerAnnotation) tmpAnnotation;
        try {
          if (markerAnnotation.getMarker().getType().equals(type)) {
            Integer charStart = markerAnnotation.getMarker().getAttribute(IMarker.CHAR_START, -1);
View Full Code Here

Examples of org.eclipse.persistence.internal.libraries.asm.attrs.Annotation

     * Return the JPA transient annotation for weaving.
     */
    protected RuntimeVisibleAnnotations getTransientAnnotation(){
        RuntimeVisibleAnnotations attrs = new RuntimeVisibleAnnotations();
        //Annotation transientAnnotation = new Annotation("Ljavax/persistence/Transient;");
        Annotation transientAnnotation = new Annotation(Type.getDescriptor(javax.persistence.Transient.class));
        if (isJAXBOnPath()) {
            try {
                attrs.annotations.add(new Annotation(Type.getDescriptor(Class.forName("javax.xml.bind.annotation.XmlTransient"))));
            } catch (Exception exception) {}
        }
        attrs.annotations.add(transientAnnotation);
        return attrs;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.