Examples of CandidateData


Examples of org.dbpedia.spotlight.spot.cooccurrence.features.data.CandidateData

    /**
     * Occurrence data of the candidate
     */

    CandidateData candidateData = null;
    try {
      candidateData = dataProvider.getCandidateData(surfaceFormOccurrence.surfaceForm().name());
    } catch (ItemNotFoundException e) {

      /**
       * No information about the candidate available.
       *
       * This means that no co-occurrence data can be gathered for the candidate.
       */

      LOG.debug("No occurrence data for " + surfaceFormOccurrence.surfaceForm());
    }

    if (candidateData != null) {

      List<TaggedToken> leftContext = null;
      try {
        leftContext = ((TaggedText) surfaceFormOccurrence.context()).taggedTokenProvider().getLeftContext(surfaceFormOccurrence, 2);
      } catch (ItemNotFoundException ignored) {}

      CandidateData left1 = null;
      if(leftContext.size() > 0) {
        try {
          left1 = dataProvider.getCandidateData(leftContext.get(0).getToken());
        } catch (ItemNotFoundException ignored) {}
      }

      CandidateData left2 = null;
      if(leftContext.size() > 1) {
        try {
          left2 = dataProvider.getCandidateData(leftContext.get(1).getToken());
        } catch (ItemNotFoundException ignored) {}
      }

      List<TaggedToken> rightContext = null;
      try {
        rightContext = ((TaggedText) surfaceFormOccurrence.context()).taggedTokenProvider().getRightContext(surfaceFormOccurrence, 2);
      } catch (ItemNotFoundException ignored) {}

      CandidateData right1 = null;
      if(rightContext.size() > 0) {
        try {
          right1 = dataProvider.getCandidateData(rightContext.get(0).getToken());
        } catch (ItemNotFoundException ignored) {}
      }

      CandidateData right2 = null;
      if(rightContext.size() > 1) {
        try {
          right2 = dataProvider.getCandidateData(rightContext.get(1).getToken());
        } catch (ItemNotFoundException ignored) {}
      }
View Full Code Here

Examples of org.dbpedia.spotlight.spot.cooccurrence.features.data.CandidateData

    TaggedText text = (TaggedText) surfaceFormOccurrence.context();
    List<TaggedToken> candidateTokens = text.taggedTokenProvider().getTaggedTokens(surfaceFormOccurrence);
    int termSize = candidateTokens.size();

    TaggedToken firstTaggedToken = candidateTokens.get(0);
    CandidateData firstTaggedTokenData = null;
    try {
      firstTaggedTokenData = dataProvider.getCandidateData(firstTaggedToken.getToken());
    } catch (ItemNotFoundException e) {
      //No information about the token!
    }


    CandidateData secondTaggedTokenData = null;
    if(candidateTokens.size() > 1){
      TaggedToken secondTaggedToken = candidateTokens.get(1);
      try {
        secondTaggedTokenData = dataProvider.getCandidateData(secondTaggedToken.getToken());
      } catch (ItemNotFoundException e) {
        //No information about the token!
      }
    }

    TaggedToken lastTaggedToken = candidateTokens.get(candidateTokens.size()-1);
    CandidateData lastTaggedTokenData = null;
    try {
      lastTaggedTokenData = dataProvider.getCandidateData(lastTaggedToken.getToken());
    } catch (ItemNotFoundException e) {
      //No information about the token!
    }


    CandidateData lastBut1TaggedTokenData = null;

    if(candidateTokens.size() > 1) {
      TaggedToken lastBut1TaggedToken = candidateTokens.get(candidateTokens.size()-2);
      try {
        lastBut1TaggedTokenData = dataProvider.getCandidateData(lastBut1TaggedToken.getToken());
      } catch (ItemNotFoundException e) {
        //No information about the token!
      }
    }


    /**
     * Left context
     */

    List<TaggedToken> leftContext = null;
    try {
      leftContext = text.taggedTokenProvider().getLeftContext(surfaceFormOccurrence, 2);
    } catch (ItemNotFoundException ignored) {}

    CandidateData left1 = null;
    if(leftContext != null && leftContext.size() > 0) {
      try {
        String token;
        if(leftContext.size() == 1) {
          /**
           * There are no more tokens to the left, the token is sentence initial.
           */
          token = leftContext.get(0).getToken().toLowerCase();

        }else{
          token = leftContext.get(0).getToken();

        }
        left1 = dataProvider.getCandidateData(token);
      } catch (ItemNotFoundException e) {
        //No information about the token
      }
    }


    /**
     * Right context
     */

    List<TaggedToken> rightContext = null;
    try {
      rightContext = text.taggedTokenProvider().getRightContext(surfaceFormOccurrence, 2);
    } catch (ItemNotFoundException ignored) {}

    CandidateData right1 = null;
    if(rightContext != null && rightContext.size() > 0) {
      try {
        right1 = dataProvider.getCandidateData(rightContext.get(0).getToken());
      } catch (ItemNotFoundException e) {
        //No information about the token
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.