Package edu.wiki.api.concept

Examples of edu.wiki.api.concept.IConceptIterator


   
    if(cv == null){
      System.exit(1);
    }
   
    IConceptIterator it = cv.orderedIterator();
   
    HashMap<Integer, Double> vals = new HashMap<Integer, Double>(10);
    HashMap<Integer, String> titles = new HashMap<Integer, String>(10);
   
    String inPart = "(";
   
    int count = 0;
    while(it.next() && count < 10){
      inPart += it.getId() + ",";
      vals.put(it.getId(),it.getValue());
      count++;
    }
   
    inPart = inPart.substring(0,inPart.length()-1) + ")";
       
    ResultSet r = stmtQuery.executeQuery(strTitles + inPart);
    while(r.next()){
      titles.put(r.getInt(1), new String(r.getBytes(2),"UTF-8"));
    }
   
    count = 0;
    it.reset();
    while(it.next() && count < 10){
      int id = it.getId();
      System.out.println(id + "\t\t" + titles.get(id) + "\t\t" + vals.get(id));
      count++;
    }
   
View Full Code Here


   
    if(cv == null){
      System.exit(1);
    }
   
    IConceptIterator it = cv.orderedIterator();
   
    HashMap<Integer, Double> vals = new HashMap<Integer, Double>(10);
    HashMap<Integer, String> titles = new HashMap<Integer, String>(10);
   
    String inPart = "(";
   
    int count = 0;
    while(it.next() && count < 20){
      inPart += it.getId() + ",";
      vals.put(it.getId(),it.getValue());
      count++;
    }
   
    inPart = inPart.substring(0,inPart.length()-1) + ")";
       
    ResultSet r = stmtQuery.executeQuery(strTitles + inPart);
    while(r.next()){
      titles.put(r.getInt(1), new String(r.getBytes(2),"UTF-8"));
    }
   
    count = 0;
    it.reset();
    while(it.next() && count < 20){
      int id = it.getId();
      System.out.println(id + "\t\t" + titles.get(id) + "\t\t" + vals.get(id));
      count++;
    }
   
View Full Code Here

            response.getWriter().append("null") ;
          }
         
          else {
            final IConceptVector ncv = esa.getNormalVector(cv, limit);
            final IConceptIterator it = ncv.orderedIterator();
           
            HashMap<Integer, Double> vals = new HashMap<Integer, Double>(10);
            HashMap<Integer, String> titles = new HashMap<Integer, String>(10);
           
            String inPart = "(";
           
            int count = 0;
            while(it.next() && count < limit){
              inPart += it.getId() + ",";
              vals.put(it.getId(),it.getValue());
              count++;
            }
           
            inPart = inPart.substring(0,inPart.length()-1) + ")";
               
            ResultSet r = stmtQuery.executeQuery(strTitles + inPart);
            while(r.next()){
              titles.put(r.getInt(1), new String(r.getBytes(2),"UTF-8"));
            }
           
           
            it.reset();
            count = 0;
            while(it.next() && count < limit){
              int id = it.getId();
              response.getWriter().append(id + "\t" + titles.get(id) + "\t" + df.format(vals.get(id)) + "\n") ;
              count++;
            }
          }
          return ;
View Full Code Here

   * @param cv
   * @return
   */
  public IConceptVector getNormalVector(IConceptVector cv, int LIMIT){
    IConceptVector cv_normal = new TroveConceptVector( LIMIT);
    IConceptIterator it;
   
    if(cv == null)
      return null;
   
    it = cv.orderedIterator();
   
    int count = 0;
    while(it.next()){
      if(count >= LIMIT) break;
      cv_normal.set(it.getId(), it.getValue());
      count++;
    }
   
    return cv_normal;
  }
View Full Code Here

   * @param LIMIT
   * @return
   * @throws SQLException
   */
  public IConceptVector getLinkVector(IConceptVector cv, boolean moreGeneral, double ALPHA, int LIMIT) throws SQLException {
    IConceptIterator it;
   
    if(cv == null)
      return null;
   
    it = cv.orderedIterator();
   
    int count = 0;
    ArrayList<Integer> pages = new ArrayList<Integer>();
           
    TIntFloatHashMap valueMap2 = new TIntFloatHashMap(1000);
    TIntFloatHashMap valueMap3 = new TIntFloatHashMap();
   
    ArrayList<Integer> npages = new ArrayList<Integer>();
   
    HashMap<Integer, Float> secondMap = new HashMap<Integer, Float>(1000);
   
   
    this.clean();
       
    // collect article objects
    while(it.next()){
      pages.add(it.getId());
      valueMap2.put(it.getId(),(float) it.getValue());
      count++;
    }
   
    // prepare inlink counts
    setInlinkCounts(pages);
View Full Code Here

  }
 
  public double calcSimilarity( IConceptVector v0, IConceptVector v1 ) {
    m_scorer.reset( v0.getData(), v1.getData(), 1 );
   
    IConceptIterator it0 = v0.iterator();
    while( it0.next() ) {
      double value1 = v1.get( it0.getId() );
      if( value1 > 0 ) {
        m_scorer.addConcept( it0.getId(), it0.getValue(), it0.getId(), value1, 1 );
      }
    }
   
    m_scorer.finalizeScore( v0.getData(), v1.getData() );
   
View Full Code Here

    valueMap.put( key, valueMap.get( key ) + d );
  }

  @Override
  public void add( IConceptVector v ) {
    IConceptIterator it = v.iterator();
    while( it.next() ) {
      add( it.getId(), it.getValue() );
    }
  }
View Full Code Here

   
    if(cv == null){
      System.exit(1);
    }
   
    IConceptIterator it = cv.orderedIterator();
   
    HashMap<Integer, Double> vals = new HashMap<Integer, Double>(10);
    HashMap<Integer, String> titles = new HashMap<Integer, String>(10);
   
    String inPart = "(";
   
    int count = 0;
    while(it.next() && count < 10){
      inPart += it.getId() + ",";
      vals.put(it.getId(),it.getValue());
      count++;
    }
   
    inPart = inPart.substring(0,inPart.length()-1) + ")";
       
    ResultSet r = stmtQuery.executeQuery(strTitles + inPart);
    while(r.next()){
      titles.put(r.getInt(1), new String(r.getBytes(2),"UTF-8"));
    }
   
    count = 0;
    it.reset();
    while(it.next() && count < 10){
      int id = it.getId();
      System.out.println(id + "\t\t" + titles.get(id) + "\t\t" + vals.get(id));
      count++;
    }
   
View Full Code Here

TOP

Related Classes of edu.wiki.api.concept.IConceptIterator

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.