Package org.corrib.jonto.wordnet

Examples of org.corrib.jonto.wordnet.Synset


   * @return List of new QueryParameterEntries containing entries with the same value but different WordNet meaning
   */
  private List<QueryParameterEntry> giveMeaning(QueryParameterEntry qpe) {
    List<QueryParameterEntry> result = new ArrayList<QueryParameterEntry>();
    List<Synset> entryMeanings = new ArrayList<Synset>();
    Synset meaning = qpe.getMeaning();
    String value= qpe.getStringValue();
    List<KOSEntry> results = new ArrayList<KOSEntry>();
    if (meaning == null) {
     
     
      try {
       
        WordNetContext word =WordNetContext.getContext();
   //      results.addAll(ThesaurusStorage.getInstance().search(word,  "label:"+value));
        results.addAll(ThesaurusStorage.getInstance().search(word,  "label:"+value+" AND (type:synset OR type:tag)"));
        for(KOSEntry result2 : results)
        {
          Synset newmeaning = new Synset(word,result2.getURI(),null);
          entryMeanings.add(newmeaning);
         
        }
       
      } catch (IOException e) {
View Full Code Here


    List<QueryParameterEntry> result = new ArrayList<QueryParameterEntry>();
    List<Synset> entryMeanings = new ArrayList<Synset>();
    List<KOSEntry> results = new ArrayList<KOSEntry>();
   
    String value = qpe.getStringValue();
    Synset meaning = qpe.getMeaning();
    Double rank = qpe.getRanking();
    if(rank == Double.NaN || rank == null)
      rank = 0.0D;
   
    // -- first we will get all the meanings/senses of the word
    ////logger.info("PROCESSING VALUE: " + value);
    if (meaning == null) {
     
    /* 
      try {
       
        WordNetContext wordcontext =WordNetContext.getContext();
  //      results.addAll(ThesaurusStorage.getInstance().search(wordcontext,  "label:"+value));
        results.addAll(ThesaurusStorage.getInstance().search(wordcontext,  "label:"+value+" AND (type:synset OR type:tag)"));
        for(KOSEntry result2 : results)
        {
          Synset newmeaning = new Synset(wordcontext,result2.getURI());
          entryMeanings.add(newmeaning);
         
        }
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
//      Collection<WordNetClassification> wnc = WordNetClassification.getWordNetClassifications(value);
//      JOntoWord w = new JOntoWord(value);
//      entryMeanings.addAll(w.getMeanings());
  //    qpe.setMeaning(entryMeanings.get(0));
      //qp.removeValue(qpe);*/
    } else {
      entryMeanings.add(meaning);
    }

    List<Synset> targets = new ArrayList<Synset>();
    Map<Synset, String> temp = new HashMap<Synset, String>(); //used to check whether given pair of: Synset -> lema is already in the qpe
    try{
      /*
       * this adds WordNet word definition meanings to the query
       */
      WordNetContext wordcontext =WordNetContext.getContext();
      Collection<ThesaurusEntry> ttempsens = new HashSet<ThesaurusEntry>();
     
      for(Synset sens : entryMeanings){
        //for (ThesaurusEntry word : sens.getWordSenses()){
          Synset tempword = new Synset(wordcontext, sens.getURI(),null);
          if(!temp.containsKey(tempword)){
            QueryParameterEntry newqpe = new QueryParameterEntryImpl(sens.getLabel());
           
           
            newqpe.setMeaning(tempword);
            newqpe.setRanking((rank == 0 ) ? m2resource.wordnetBoost : m2resource.wordnetBoost * rank);
            ////logger.info("wynik33"+newqpe.getMeaning().getGlossaryDescription()+ " rank: " + newqpe.getRanking());
            if (newqpe.getMeaning()!=qpe.getMeaning())
            {
            result.add(newqpe);
            temp.put(tempword, sens.getLabel());
            }
          }else if (!temp.get(tempword).equals(sens.getLabel())){
            QueryParameterEntry newqpe = new QueryParameterEntryImpl(sens.getLabel());
           
           
            newqpe.setMeaning(tempword);
            newqpe.setRanking((rank == 0 ) ? m2resource.wordnetBoost : m2resource.wordnetBoost * rank);
            ////logger.info("wynik33"+newqpe.getMeaning().getGlossaryDescription() + " rank: " + newqpe.getRanking());
            if (newqpe.getMeaning()!=qpe.getMeaning())
            {
            result.add(newqpe);
            temp.put(tempword, sens.getLabel());
            }
          }
         
//        }
        //extend each meaning with some *NYM
//        targets.addAll(new ExpandSynset(sens).getTargets(pointer));
        //Synset tempword2 = new Synset(wordcontext, sens.getURI());
        //ttempsens.addAll(tempword2.getAntonyms());
        //sens.getAntonyms();
       
        try{
         
         
         
         
         
        if(precise)
        {
         
          if((Configuration.PrecisionAntonyms))
          {
          ttempsens.addAll(sens.getAntonyms()); //No sense ?
          }
          if((Configuration.PrecisionHypernyms))
          {
          ttempsens.addAll(sens.getHypernyms());
          }
          if((Configuration.PrecisionHyponyms))
          {
          ttempsens.addAll(sens.getHyponyms());
          }
          if((Configuration.PrecisionSynonyms))
          {
          ttempsens.addAll(sens.getSynonyms());
          }
        }
        else
        {
          if((Configuration.RecallAntonyms))
          {
          ttempsens.addAll(sens.getAntonyms()); //No sense ?
          }
          if((Configuration.RecallHypernyms))
          {
          ttempsens.addAll(sens.getHypernyms());
          }
          if((Configuration.RecallHyponyms))
          {
          ttempsens.addAll(sens.getHyponyms());
          }
          if((Configuration.RecallSynonyms))
          {
          ttempsens.addAll(sens.getSynonyms());
          }
       
        }
        }catch (Exception e){
          //logger.severe("Can not expand meanings with some *NYMs");
        }
       
        Collection<Synset> tempsens = new HashSet<Synset>();
        for(ThesaurusEntry tt : ttempsens)
        {

          tempsens.add(new Synset (wordcontext, tt.getURI(), null));
         
        }
        targets.addAll(tempsens);
       
         
      }
     
//    }catch (JWNLException e){
//      //logger.severe("Error getting expanded synset for meaning");
    }catch (Exception e){
      //logger.severe("Problems with getting expanded synset for meaning :  "+e);
    }
   
    /*
     * add *NYM synsets to the query
     */
   
    WordNetContext wordcontext;
    try {
      wordcontext = WordNetContext.getContext();
   
    for(Synset newSynset: targets){
//      for(ThesaurusEntry word : newSynset.getWordSenses()){
     
        Synset tempword = new Synset(wordcontext, newSynset.getURI(), null);
        if(!temp.containsKey(tempword)){
          QueryParameterEntry newqpe = new QueryParameterEntryImpl(newSynset.getLabel());
         
          newqpe.setMeaning(tempword);
          newqpe.setRanking((rank == 0 ) ? m2resource.wordnetBoost : m2resource.wordnetBoost * rank);
      //    //logger.info(newqpe.getMeaning().getGloss() + " rank: " + newqpe.getRanking());
          if (newqpe.getMeaning()!=qpe.getMeaning())
          {
          String newInfo = qpe.TellMeAbout()+tempword.getLabel()+ " - " +tempword.getGlossaryDescription() +" has been retrieved as a expansion of "+qpe.getMeaning().getLabel()+" using Wordnet ";
          newqpe.AddInfo(newInfo);
          result.add(newqpe);
          temp.put(tempword, newSynset.getLabel());
          }
        }else if (!temp.get(tempword).equals(newSynset.getLabel())){
          QueryParameterEntry newqpe = new QueryParameterEntryImpl(newSynset.getLabel());
         
          newqpe.setMeaning(tempword);
          newqpe.setRanking((rank == 0 ) ? m2resource.wordnetBoost : m2resource.wordnetBoost * rank);
      //    //logger.info(newqpe.getMeaning().getGloss() + " rank: " + newqpe.getRanking());
          if (newqpe.getMeaning()!=qpe.getMeaning())
          {
          String newInfo = qpe.TellMeAbout()+tempword.getLabel()+ " - " +tempword.getGlossaryDescription() +" has been retrieved as a expansion of "+qpe.getMeaning().getLabel()+" using Wordnet ";
          newqpe.AddInfo(newInfo);
          result.add(newqpe);
          temp.put(tempword, newSynset.getLabel());
          }
        }
View Full Code Here

TOP

Related Classes of org.corrib.jonto.wordnet.Synset

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.