Question about synset

31 views
Skip to first unread message

yt...@ucsc.edu

unread,
Nov 16, 2015, 12:20:41 AM11/16/15
to DKPro WSD users
Hi,

I am new to nlp and trying to use DKPro WSD to get wordnet synset of a word in a sentence. For example, the input sentence is 'I went to the bank to deposit money.', and I want to get the synset of word 'bank' in this context. 
I found that nltk has the lesk tool which does this, but it gives different output each time I run the script.
The sample code in Python is as follows:


from nltk.wsd import lesk
sent = ['I', 'went', 'to', 'the', 'bank', 'to', 'deposit', 'money', '.']
print(lesk(sent, 'bank', 'n'))


And this will return a synset like:
Synset('depository_financial_institution.n.01')

Can anybody point me how to implement this in DKPro? Thanks a lot!

Tristan Miller

unread,
Nov 16, 2015, 6:07:13 AM11/16/15
to dkpro-w...@googlegroups.com
Greetings.
DKPro WSD is built with large-scale processing in mind, so the normal
way would be to build a UIMA pipline which starts by calling a
collection reader to read in a whole set of documents you want
disambiguated. This approach is illustrated with various classes in the
"examples" module.

If you really have just one sentence you want to disambiguate, you can
bypass the UIMA stuff and do something like the following:

SenseInventory wordnet = new WordNetSynsetSenseInventory(
new URL("file:///path/to/extjwnl/properties/file.xml"));

SimplifiedLesk simplifiedLesk = new SimplifiedLesk(wordnet,
new SetOverlap(), new NoNormalization(), new StringSplit(),
new StringSplit());

Map<String, Double> senseMap =
simplifiedLesk.getDisambiguation("bank",
POS.NOUN, "I went to the to deposit money");
System.out.println(senseMap);

This will print all matching noun synsets of "bank" and their
corresponding scores.

Regards,
Tristan

--
Tristan Miller, Research Scientist
Ubiquitous Knowledge Processing Lab (UKP-TUDA)
Department of Computer Science, Technische Universität Darmstadt
Tel: +49 6151 16 6166 | Web: http://www.ukp.tu-darmstadt.de/

signature.asc

yt...@ucsc.edu

unread,
Nov 17, 2015, 12:55:35 AM11/17/15
to DKPro WSD users
Hi Tristan,

Thanks a lot for the response!
I downloaded the source from github and I am trying to run the examples, but I am getting errors like 'EnglishStopLemmatizer.java:21: error: package org.apache.uima.fit.factory does not exist',
Can I know how to build and run the example code?

Thanks,
Yanfei

Tristan Miller

unread,
Nov 17, 2015, 5:23:43 AM11/17/15
to dkpro-w...@googlegroups.com
Dear Yanfei,

On 17/11/15 06:55 AM, yt...@ucsc.edu wrote:
> Thanks a lot for the response!
> I downloaded the source from github and I am trying to run the examples,
> but I am getting errors like 'EnglishStopLemmatizer.java:21: error:
> package org.apache.uima.fit.factory does not exist',
> Can I know how to build and run the example code?

You're probably getting this error because you haven't installed all of
DKPro WSD's dependencies. DKPro WSD uses Maven for its dependency
management, so it is convenient to use Maven rather than installing all
the dependencies manually.

If you are using an IDE such as Eclipse, just install the usual Maven
plugin if you haven't already, and that should take care of everything;
you'll be able to run the DKPro WSD examples the same way you run any
other class. Alternatively you can install standalone Maven and invoke
it from the command line to build DKPro WSD. (Invoking "mvn clean
install" ought to do it, or "mvn -DskipTests=true clean install" if you
want to skip all the lengthy JUnit tests.)

To add DKPro WSD as a dependency to your own Maven project, you need to
add a few lines to its pom.xml file as described here:
https://dkpro.github.io/dkpro-wsd/downloads/
signature.asc
Message has been deleted

Tristan Miller

unread,
Nov 20, 2015, 4:40:16 AM11/20/15
to dkpro-w...@googlegroups.com
Greetings.

On 17/11/15 11:56 PM, yt...@ucsc.edu wrote:
> Thanks for your response!
> I installed maven and downloaded the source code from github. In the
> directory 'dkpro-wsd', I ran '$ mvn clean install', it downloaded some
> pom files, but when it comes to this file, it just stopped there. The
> following is the message I am getting:
>
> [INFO] Scanning for projects...
>
> Downloading:
> http://zoidberg.ukp.informatik.tu-darmstadt.de/artifactory/public-releases/de/tudarmstadt/ukp/dkpro/lexsemresource/de.tudarmstadt.ukp.dkpro.lexsemresource-asl/0.8.1/de.tudarmstadt.ukp.dkpro.lexsemresource-asl-0.8.1.pom
>
>
> Can you please tell me how to solve this problem, and if what I did was
> correct? Thanks a lot!

That's not an error message; it's just informational logging telling you
that it's downloading a POM. If there is an actual error message you're
getting? (It will be marked with the text "[ERROR]".) If so, please
post it. Otherwise, the build probably completed successfully and you
can now run the examples from DKPro WSD or use the framework in your own
Maven applications.
signature.asc

yt...@ucsc.edu

unread,
Nov 20, 2015, 5:22:51 PM11/20/15
to DKPro WSD users
Dear Tristan,

Thanks! After I run 'mvn clean install', this time it downloaded all the POMs, but at the end it showed some error messages as following:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project de.tudarmstadt.ukp.dkpro.wsd.io: There are test failures.

[ERROR] 

[ERROR] Please refer to /Users/yanfeitu/dkpro-wsd/de.tudarmstadt.ukp.dkpro.wsd.io/target/surefire-reports for the individual test results.

[ERROR] -> [Help 1]

[ERROR] 

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR] 

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

[ERROR] 

[ERROR] After correcting the problems, you can resume the build with the command

[ERROR]   mvn <goals> -rf :de.tudarmstadt.ukp.dkpro.wsd.io


Do you know how to fix this?


Thanks,

Yanfei

Tristan Miller

unread,
Nov 23, 2015, 10:15:40 AM11/23/15
to dkpro-w...@googlegroups.com
Greetings.

On 20/11/15 11:22 PM, yt...@ucsc.edu wrote:
> Thanks! After I run 'mvn clean install', this time it downloaded all the
> POMs, but at the end it showed some error messages as following:
>
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test)
> on project de.tudarmstadt.ukp.dkpro.wsd.io: There are test failures.
>
> [ERROR]
>
> [ERROR] Please refer to
> /Users/yanfeitu/dkpro-wsd/de.tudarmstadt.ukp.dkpro.wsd.io/target/surefire-reports
> for the individual test results.

I don't know why the tests are failing -- if you want, you can send me
the file containing the test results (by private e-mail, not on-list)
and I can have a look. But in the meantime I suggest you simply build
the program without running the tests as suggested in my post of 17
November.
signature.asc
Reply all
Reply to author
Forward
0 new messages