I want to find Word similarity Using WordNet - java

I am doing final year project on "web video categorization", in which one part is to find the similar (synonyms) words for a particular word and I want to remove similar terms from it.
I know Java language, so I chosen "Word Similarity For Java" ws4j
For that I have only used WS4J1.0.1 jar file , even I have not downloaded any extra files like WordNet lexical database or sqlite database to store it. Because in that website they have mentioned that all are contained as precompiled in this jar file.
When I executed Demo program SimilarityCalculationDemo.java, I got the following errors:
java.sql.BatchUpdateException: batch entry 0: [SQLITE_CORRUPT] The database disk image is malformed (database disk image is malformed)
at org.sqlite.Stmt.executeBatch(Stmt.java:226)
at org.sqlite.Stmt.executeBatch(Stmt.java:226)
at edu.cmu.lti.jawjaw.db.SQL.createIndexIfNotExists(SQL.java:118)
at edu.cmu.lti.jawjaw.db.SQL.createSQLConnection(SQL.java:98)
at edu.cmu.lti.jawjaw.db.SQL.<init>(SQL.java:55)
at edu.cmu.lti.jawjaw.db.SQL.<clinit>(SQL.java:45)
at edu.cmu.lti.jawjaw.db.WordDAO.findWordsByLemmaAndPos(WordDAO.java:124)
at edu.cmu.lti.jawjaw.util.WordNetUtil.wordToSynsets(WordNetUtil.java:38)
at edu.cmu.lti.lexical_db.NictWordNet.getAllConcepts(NictWordNet.java:38)
atedu.cmu.lti.ws4j.util.WordSimilarityCalculator.calcRelatednessOfWords(WordSimilarityCalculator.java:79)
at edu.cmu.lti.ws4j.RelatednessCalculator.calcRelatednessOfWords(RelatednessCalculator.java:61)
at web_cat.SimilarityCalculationDemo.run(SimilarityCalculationDemo.java:37)
at web_cat.SimilarityCalculationDemo.main(SimilarityCalculationDemo.java:43)
java.sql.SQLException: [SQLITE_CORRUPT] The database disk image is malformed (database disk image is malformed)
at org.sqlite.DB.newSQLException(DB.java:383)
at org.sqlite.DB.newSQLException(DB.java:387)
at org.sqlite.DB.throwex(DB.java:374)
at org.sqlite.NativeDB.prepare(Native Method)
at org.sqlite.DB.prepare(DB.java:123)
at org.sqlite.Stmt.execute(Stmt.java:113)
at edu.cmu.lti.jawjaw.db.SQL.setPragmaCacheSize(SQL.java:137)
at edu.cmu.lti.jawjaw.db.SQL.createSQLConnection(SQL.java:99)
at edu.cmu.lti.jawjaw.db.SQL.<init>(SQL.java:55)
at edu.cmu.lti.jawjaw.db.SQL.<clinit>(SQL.java:45)
at edu.cmu.lti.jawjaw.db.WordDAO.findWordsByLemmaAndPos(WordDAO.java:124)
at edu.cmu.lti.jawjaw.util.WordNetUtil.wordToSynsets(WordNetUtil.java:38)
at edu.cmu.lti.lexical_db.NictWordNet.getAllConcepts(NictWordNet.java:38)
at edu.cmu.lti.ws4j.util.WordSimilarityCalculator.calcRelatednessOfWords(WordSimilarityCalculator.java:79)
at edu.cmu.lti.ws4j.RelatednessCalculator.calcRelatednessOfWords(RelatednessCalculator.java:61)
at web_cat.SimilarityCalculationDemo.run(SimilarityCalculationDemo.java:37)
at web_cat.SimilarityCalculationDemo.main(SimilarityCalculationDemo.java:43)
java.sql.SQLException: [SQLITE_CORRUPT] The database disk image is malformed (database disk image is malformed)
at org.sqlite.DB.newSQLException(DB.java:383)
at org.sqlite.DB.newSQLException(DB.java:387)
at org.sqlite.DB.throwex(DB.java:374)
at org.sqlite.NativeDB.prepare(Native Method)
at org.sqlite.DB.prepare(DB.java:123)
at org.sqlite.PrepStmt.<init>(PrepStmt.java:42)
at org.sqlite.Conn.prepareStatement(Conn.java:404)
at org.sqlite.Conn.prepareStatement(Conn.java:399)
at org.sqlite.Conn.prepareStatement(Conn.java:383)
at edu.cmu.lti.jawjaw.db.SQL.prepareStatements(SQL.java:151)
at edu.cmu.lti.jawjaw.db.SQL.<init>(SQL.java:56)
at edu.cmu.lti.jawjaw.db.SQL.<clinit>(SQL.java:45)
at edu.cmu.lti.jawjaw.db.WordDAO.findWordsByLemmaAndPos(WordDAO.java:124)
at edu.cmu.lti.jawjaw.util.WordNetUtil.wordToSynsets(WordNetUtil.java:38)
at edu.cmu.lti.lexical_db.NictWordNet.getAllConcepts(NictWordNet.java:38)
at edu.cmu.lti.ws4j.util.WordSimilarityCalculator.calcRelatednessOfWords(WordSimilarityCalculator.java:79)
at edu.cmu.lti.ws4j.RelatednessCalculator.calcRelatednessOfWords(RelatednessCalculator.java:61)
at web_cat.SimilarityCalculationDemo.run(SimilarityCalculationDemo.java:37)
at web_cat.SimilarityCalculationDemo.main(SimilarityCalculationDemo.java:43)
Exception in thread "main" java.lang.NullPointerException
at edu.cmu.lti.jawjaw.db.WordDAO.findWordsByLemmaAndPos(WordDAO.java:125)
at edu.cmu.lti.jawjaw.util.WordNetUtil.wordToSynsets(WordNetUtil.java:38)
at edu.cmu.lti.lexical_db.NictWordNet.getAllConcepts(NictWordNet.java:38)
at edu.cmu.lti.ws4j.util.WordSimilarityCalculator.calcRelatednessOfWords(WordSimilarityCalculator.java:79)
at edu.cmu.lti.ws4j.RelatednessCalculator.calcRelatednessOfWords(RelatednessCalculator.java:61)
at web_cat.SimilarityCalculationDemo.run(SimilarityCalculationDemo.java:37)
at web_cat.SimilarityCalculationDemo.main(SimilarityCalculationDemo.java:43)
Java Result: 1
I am Using Netbeans IDE 7.4 with JDK 6.
Could any please assist me, how to overcome from this problem, because there is a less documentation available in the internet about ws4j.

Well, I could not reproduce your error. For me it just worked perfectly out of the box, using eclipse, so I'll try to help you reproducing exactly what I've did
download ws4j-1.0.1.jar from https://ws4j.googlecode.com/files/ws4j-1.0.1.jar and ensure it's size after the download is 41,362,723 bytes (at least, that's what eclipse told me in my linux box)
Use java 7
Create a simple eclipse project and drop the jar there. Then add the jar to the build path
(right click -> build path -> add)
Create an appropriate package and class to accommodate the demo class
Just run the demo and you'll get something like
edu.cmu.lti.ws4j.impl.HirstStOnge 0.0
edu.cmu.lti.ws4j.impl.LeacockChodorow 1.3862943611198906
edu.cmu.lti.ws4j.impl.Lesk 0.0
edu.cmu.lti.ws4j.impl.WuPalmer 0.4
edu.cmu.lti.ws4j.impl.Resnik 2.5031573470157453
edu.cmu.lti.ws4j.impl.JiangConrath 0.11150424023847051
edu.cmu.lti.ws4j.impl.Lin 0.3582442863008455
edu.cmu.lti.ws4j.impl.Path 0.14285714285714285
Done in 1951 msec.

Related

Internal Action was not loaded Error: java.lang.ClassNotFoundException

I am trying to run an implementation a jason code that is using some Internal Actions. The interpreter is showing that it was not possible to find the "java" code of the internal action, as showed:
Server running on http://191.36.8.42:3272
[aslparser] [peleus.asl:29] warning: The internal action class for 'org.soton.peleus.act.plan(Goals)' was not loaded! Error:
java.lang.ClassNotFoundException: org.soton.peleus.act.plan
[aslparser] [peleus.asl:42] warning: The internal action class for 'org.soton.peleus.act.isTrue(H)' was not loaded! Error:
java.lang.ClassNotFoundException: org.soton.peleus.act.isTrue
[peleus] Could not finish intention: intention 1: +des([on(b3,table),on(b2,b3),on(b1,b2)])[source(self)] <- ... org.soton.peleus.act.plan(Goals); !checkGoals(Goals); .print("Goals ",Goals," were satisfied") /
{Goals=[on(b3,table),on(b2,b3),on(b1,b2)]}Trigger: +des([on(b3,table),on(b2,b3),on(b1,b2)])[noenv,code(org.soton.peleus.act.plan([on(b3,table),on(b2,b3),on(b1,b2)])),code_line(29),code_src("peleus.asl"),error(action_failed),error_msg("no environment configured!"),source(self)]
[peleus] Adding belief clear(table)
This mas2j file is as following:
MAS peleus {
infrastructure: Centralised
agents:
peleus;
}
Part of agent code (written by Felipe Meneguzzi) is showed bellow:
//The next line is line 28
+des(Goals) : true
<- org.soton.peleus.act.plan(Goals);
!checkGoals(Goals);
.print("Goals ",Goals," were satisfied").
+!checkGoals([]) : true <- true.
//The next line is line 40
+!checkGoals([H|T]) : true
<- .print("Checking ", H);
org.soton.peleus.act.isTrue(H);
!checkGoals(T).
I guess it is about the folder structure, how to set up Jason to search for java files in specific locations?
The folders structure is like this:
Peleus\src\org\soton\peleus for java files
Peleus\examples for mas2j and asl tested project
It all depends on how you are executing the application.
If you are using java, the CLASSPATH should be defined to include the missing classes.
if you are using jason script (that uses Ant), the .mas2j file should include the class path as well.
More on that in the FAQ. Notice that CLASSPATH is where .class files are found, not .java source code files. The error regards a missing class, not a missing source code.

Jenkins SQLServer Choice Parameter - Retrieve data from database

I am trying to get data from SQL Server database table and show it as part of choice parameter as part of a Jenkins Job Build Parameters that I am trying to setup.
I am trying to figure out how to use Extensible Choice for this.
The Choice provider I used is "System Groovy Choice Parameter"
import groovy.sql.Sql
import com.microsoft.sqlserver.jdbc.SQLServerDriver
def output = []
def configuration = [
'dbInstance' : 'servername',
'dbPort' : 0000,
'dbName' : 'dbName',
'dbUser' : 'dbUser',
'dbPass' : 'dbPass'
]
def sql = Sql.newInstance("jdbc:sqlserver://${configuration.dbInstance}:${configuration.dbPort};"
+ "databaseName=" + configuration.dbName,
configuration.dbUser, configuration.dbPass,
'com.microsoft.sqlserver.jdbc.SQLServerDriver')
String sqlString = "SELECT * FROM dbTable"
sql.eachRow(sqlString){ row -> output.push(row[0])
}
return output.sort()
Below is the error I see. Which I understand I see because the jdbc driver is not present. I downloaded the driver from the link below:
https://www.microsoft.com/en-us/download/details.aspx?id=11774
I followed the instructions as to where it should be unzipped to as mentioned in the instructions.
I saw that the CLASSPATH variable is missing, so i went ahead and created the Environment variable with path: "C:\Program Files\sqljdbc_6.0\enu\sqljdbc.jar"
Error: unable to resolve class com.microsoft.sqlserver.jdbc.SQLServerDriver
How do i make sure that the script runs successfully and returns all the data to Extensible Choice. If there is anyother way to do this, I am open to suggestions.
Thank you very much
To resolve the issue I had to copy the "sqljdbc4.jar" file to the following location "C:\Java\jdk1.8.0_92\jre\lib\ext" since that is the path where the JAVA searches for the external jars. Use 4th version for the file which will have 4 in the file name as above as that is version Jenkins supports.

elasticsearch can't install head plugin

I am planing to install head pluging for elasticsearch.
in both these two official documentation, http://mobz.github.io/elasticsearch-head/ and http://docs.couchbase.com/admin/elastic/install-plugin.html they said to use this:
bin/plugin -install mobz/elasticsearch-head
I did, but i got the following error:
PS C:\elasticsearch-1.3.9\elasticsearch-1.3.9> bin/plugin -install mobz/elasticsearch-head
Exception in thread "main" org.elasticsearch.common.settings.SettingsException: Failed to load settings from [file:/C:/
lasticsearch-1.3.9/elasticsearch-1.3.9/config/elasticsearch.yml]
at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromStream(ImmutableSettings.java:947)
at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromUrl(ImmutableSettings.java:931)
at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareSettings(InternalSettingsPreparer.java:77)
at org.elasticsearch.plugins.PluginManager.main(PluginManager.java:382)
Caused by: unacceptable character ' ' (0x0) special characters are not allowed
in "'reader'", position 13489
at org.elasticsearch.common.jackson.dataformat.yaml.snakeyaml.reader.StreamReader.checkPrintable(StreamReader.j
va:93)
at org.elasticsearch.common.jackson.dataformat.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:192)
at org.elasticsearch.common.jackson.dataformat.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:146)
at org.elasticsearch.common.jackson.dataformat.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.j
va:1199)
at org.elasticsearch.common.jackson.dataformat.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.j
va:289)
at org.elasticsearch.common.jackson.dataformat.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:2
6)
at org.elasticsearch.common.jackson.dataformat.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.prod
ce(ParserImpl.java:195)
at org.elasticsearch.common.jackson.dataformat.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
at org.elasticsearch.common.jackson.dataformat.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:168)
at org.elasticsearch.common.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:331)
at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:50)
at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:60)
at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:45)
at org.elasticsearch.common.settings.loader.YamlSettingsLoader.load(YamlSettingsLoader.java:46)
at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromStream(ImmutableSettings.java:944)
... 3 more
as I was trying to diagnosis the error, I found that there might b something wrong in elasticsearch.yml file. I went to that file, and opened it using notpadd++, and it was all commented except the last three-four lines, they were letters not understandable. this is a print screen of them:
could you help please
In that file you shouldn't have those chars. Remove them and start over. Or take a clean instance of ES, take the config file from that and use it.

How can I configure jdee `find-class-source-file` to work with Cassandra source tree?

I'm trying to get Emacs+JDEE setup for a Java project I'm about to start on, but I'm having trouble getting JDEE to work properly. The first think that I want to tackle is being able to jump to the source file of a given class name. I'm using the Cassandra source as my playground for working with JDEE.
I've setup a fresh Ubuntu 12.04 VM with Emacs 23.3.1 as my test environment. I'm using openjdk-1.6 from the default Ubuntu repository and JDEE seems to be using it. I downloaded the jdee tar ball and extracted it into ~/.emacs.d. The Cassandra source tree is checkout into ~/cassandra. My ~/.emacs.d/init.el consists of the following:
(setq jde-sourcepath '("~/cassandra/src/java"))
(add-to-list 'load-path "~/.emacs.d/jdee-2.4.1/lisp")
(load "jde")
When I open ~/cassandra/src/java/org/apache/cassandra/db/ColumnFamily.java I want to be able to jump to the class org.apache.cassandra.config.CFMetaData. When I run jde-open-class-at-point on that class name I get the following error:
Cannot determine the class of "CFMetaData".
Likewise if I run
(jde-find-class-source "org.apache.cassandra.config.CFMetaData")
I get this error:
jde-read-class: No match for CFMetaData
What do I need to do to get JDEE to find the source files?
I'm not sure what is wrong exactly, but according to the documents, jde-open-class-at-point searches for the source file first in jde-sourcepath, then in jde-global-classpath, then in $CLASSPATH, then in the current directory. So maybe you need to set these varables.
And I post my jdee setting here, hope it can help: (it works well for me)
.emacs
(add-to-list 'load-path "~/.emacs.d/plugins/jdee-2.4.1/lisp")
(autoload 'jde-mode "jde" "JDE mode" t)
(setq auto-mode-alist
(append '(("\\.java\\'" . jde-mode)) auto-mode-alist))
And I use prj.el for each project:
prj.el
(jde-project-file-version "1.0")
(jde-set-variables
'(jde-jdk-registry (quote (("1.6" . "/usr/java/jdk1.7.0_51"))))
'(jde-jdk (quote ("1.6")))
'(jde-xref-db-base-directory "./xrefdb")
'(jde-xref-store-prefixes (quote ("")))
'(jde-build-function (quote jde-ant-build))
'(jde-ant-enable-find t)
'(jde-sourcepath (quote ("./src")))
'(jde-built-class-path (quote ("./bin")))
'(jde-global-classpath (quote ("./bin" "./src" "./lib")))
'(jde-electric-return-p t)
'(jde-enable-abbrev-mode t))

dbpedia spotlight dataset

In continuation of dbpedia spotlight dataset, I followed the instructions for updating my dataset but got the following error:
INFO 2012-06-19 11:58:04,300 main [MergedOccurrencesContextSearcher] - Using index at: org.apache.lucene.store.MMapDirectory#/home/user_name/new/spotlight/index lockFactory=org.apache.lucene.store.NativeFSLockFactory#671381e7
Exception in thread "main" java.io.FileNotFoundException: /home/user_name/new/spotlight/index/segments_bp (No such file or directory)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:233)
at org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:219)
at org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:345)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:265)
at org.apache.lucene.index.DirectoryReader$1.doBody(DirectoryReader.java:76)
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:709)
at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:72)
at org.apache.lucene.index.IndexReader.open(IndexReader.java:273)
at org.dbpedia.spotlight.lucene.search.BaseSearcher.<init>(BaseSearcher.java:67)
at org.dbpedia.spotlight.lucene.search.MergedOccurrencesContextSearcher.<init>(MergedOccurrencesContextSearcher.java:64)
at org.dbpedia.spotlight.model.SpotlightFactory.<init>(SpotlightFactory.scala:71)
at org.dbpedia.spotlight.web.rest.Server.main(Server.java:86)
I had been able to successfully use the spotter dictionary but couldn't use the index files.
Can you please help me?
Hard to help you without sufficient information. The message complains that a file is not there. Is the file there? Is the directory there?
Please paste the result of the command
ls -lah /home/user_name/new/spotlight/index

Categories