Making Coreference Resolution your bitch with OpenNLP 1.5.0

First thing’s first–what is coreference resolution?

Co-reference means that multiple expressions in a sentence or document refer to the same thing. OpenNLP contains a “linker” that analyzes the tokens of a sentences to identify which chunks of text refer to the same things (e.g., people, organizations, events).

Take, for example, the sentence “John drove to Judy’s house. He made her dinner.” In this example both John and He refer to the same entity (John); and Judy and her refer to the same, different entity (Judy). Don’t expect OpenNLP to get this 100% correct. Even a simple example like this is a difficult problem.

Picking up where I left off once upon a time (and finally wrapping up this series), here are links to the old material:

  • How to use the OpenNLP 1.5.0 Parser
  • Making Coreference Resolution your bitch with OpenNLP 1.5.0 (you’re reading it!)
  • (more…)

    How to use the OpenNLP 1.5.0 Parser

    After a brief (*cough*cough*) delay, I’m back to figure out how in the world to use this Open NLP Parser. First, a quick refresher:

  • How to use the OpenNLP 1.5.0 Parser (surprise, you’re reading it)
  • Making Coreference Resolution your bitch with OpenNLP 1.5.0
  • Getting Started

    I’m only going to warn you once: this is a long post. Go grab a beer or a glass of wine or some coffee before starting. It’s long. Now I’ve warned you twice.

    (more…)

    Part-of-Speech (POS) Tagging with OpenNLP 1.5.0

    Continuing from where I left off, I’m going to quickly touch on part-of-speech tagging before moving on. It’s actually pretty straightforward once you’re set up to run OpenNLP. This all assumes that you’ve already done sentence detection and tokenization. If you haven’t, go back to the beginning. Here are the links to the rest of my posts:

  • How to use the OpenNLP 1.5.0 Parser
  • Making Coreference Resolution your bitch with OpenNLP 1.5.0
  • Getting Started

    model files

    Only one additional model file is needed for part-of-speech tagging.

    (more…)

    Unable to locate the Javac Compiler with Maven and Eclipse

    Unable to locate the Javac Compiler in:
    C:\Program Files\Java\jre6\..\lib\tools.jar
    Please ensure you are using JDK 1.4 or above and
    not a JRE (the com.sun.tools.javac.Main class is required).
    In most cases you can change the location of your Java
    installation by setting the JAVA_HOME environment variable.

    The solution that worked for me (tested on both 32- and 64-bit Eclipse/Java) was not to change the eclipse.ini, but to instead set the Runtime JRE on the JRE tab of the Run/Debug Configuration dialog to use the appropriate JDK, either as the “Workspace default JRE” or the “Alternate JRE”

    Does that work for anybody else?

    Getting Android to call onActivityResult() after onSearchRequested()

    Because everything is handled through the SearchManager in Android, onActivityResult() is not typically called after onSearchRequested().

    What I was looking for was a clean way to get search results back to the activity that originally called onSearchRequested().

    I first tried the most obvious approach of calling setResult() and finish() from the search result (searchable) activity, but because the activity isn’t launched using startActivityForResult() it doesn’t work. (Complicating things further, the SearchManager is the one launching the activity so it really doesn’t even work in theory).

    Solution: I had to make the original calling activity also the searchable activity, so my entry in the manifest looks like this:

       <activity android:name=".MyBaseActivity"
                 android:launchMode="singleTop">
    
          <!-- MyBaseActivity is also the searchable activity -->
          <intent-filter>
             <action android:name="android.intent.action.SEARCH" />
          </intent-filter>
          <meta-data android:name="android.app.searchable"
                     android:resource="@xml/searchable"/>
    
          <!-- enable the base activity to send searches to itself -->
          <meta-data android:name="android.app.default_searchable"
                     android:value=".MyBaseActivity" />
       </activity>
    

    Then, as described in the android documentation, I created a handleActivity method in which I manually start the search activity for result:

       private void handleIntent(Intent intent) {
          // Get the intent, verify the action and get the query
          if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            String query = intent.getStringExtra(SearchManager.QUERY);
            // manually launch the real search activity
            final Intent searchIntent = new Intent(getApplicationContext(),
                  MySearchActivity.class);
            // add query to the Intent Extras
            searchIntent.putExtra(SearchManager.QUERY, query);
            startActivityForResult(searchIntent, ACTIVITY_REQUEST_CODE);
          }
    

    From there it is just a matter of having the search activity perform its search as normal and, when a result is clicked, call setResult and finish. The original activity will then get the result as expected in the MyBaseActivity.onActivityResult method.