How to run Wikibrain in Eclipse!

65 views
Skip to first unread message

Partha Pakray

unread,
Dec 15, 2014, 3:56:14 PM12/15/14
to wiki...@googlegroups.com
Dear all,

Here are some steps: How to run in Eclipse ...


Step 2: Create a java Project at Workspace in Eclipse
Step 3: Add wikibrain-withdeps-0.4.1.jar  file to your class path in Eclipse
Step 4: One sample code by Shilad: 
-------------------------------------------------------------------
package org.wikibrain.cookbook;
import org.wikibrain.conf.ConfigurationException;
import org.wikibrain.conf.Configurator;
import org.wikibrain.core.cmd.Env;
import org.wikibrain.core.cmd.EnvBuilder;
import org.wikibrain.core.dao.DaoException;
import org.wikibrain.core.dao.LocalPageDao;
import org.wikibrain.core.jooq.tables.LocalPage;
import org.wikibrain.core.lang.Language;
import org.wikibrain.core.lang.LocalId;
import org.wikibrain.core.model.Title;
import org.wikibrain.phrases.PhraseAnalyzer;
import org.wikibrain.sr.SRMetric;
import org.wikibrain.sr.SRResult;
import org.wikibrain.sr.SRResultList;

import antlr.StringUtils;
import antlr.collections.List;
import edu.emory.mathcs.backport.java.util.Arrays;

import java.io.IOException;
//import java.util.ArrayList;
import java.util.LinkedHashMap;

/**
 * @author Shilad Sen
 */
public class QuickStart {
    public static void main(String args[]) throws Exception {
    
     Env env = new EnvBuilder().setConfigFile("/home/partha/customized.conf").build();
     //Env env = new EnvBuilder().build();
     Configurator conf = env.getConfigurator();
     LocalPageDao lpDao = conf.get(LocalPageDao.class);
     Language simple = Language.getByLangCode("simple");

     // Retrieve the "ensemble" sr metric for simple english 
     SRMetric sr = conf.get(
             SRMetric.class, "ensemble",
             "language", simple.getLangCode());

    
     String pairs[][] = new String[][] {
             { "cat", "kitty" },
             { "obama", "president" },
             { "tires", "car" },
             { "java", "computer" },
             { "dog", "computer" },
     };      

     for (String pair[] : pairs) {
         SRResult s = sr.similarity(pair[0], pair[1], false); 
         System.out.println(s.getScore() + ": '" + pair[0] + "', '" + pair[1] + "'"); 
     }    
    }
}
-----------------------------------------------------------------------

Step 5: open wikibrain-withdeps-0.4.1.jar by right click and open with "Oracle Java 7 Runtime" the you will get a gui then give the Base Directory (Workspace Java Project Path) then click  click in Semantic Relatedness box and finally click run and wait until the message is like "LOADING COMPLETED SUCCESSFULLY!"

Step 6: Run QuickStart.java 

Enjoy!


Thanks,
Partha Pakray
=============================================
Research Engineer
Research & Development Specialist
Masaryk University

=============================================

Reply all
Reply to author
Forward
0 new messages