au.org.ala.names.search
Class ALANameIndexer

java.lang.Object
  extended by au.org.ala.names.search.ALANameIndexer
Direct Known Subclasses:
DwcaNameIndexer

public class ALANameIndexer
extends java.lang.Object

Creates the Lucene index based on the names that are exported from http://code.google.com/p/ala-portal/source/browse/trunk/ala-names-generator/src/main/resources/create-dumps.sql

Author:
Natasha

Nested Class Summary
static class ALANameIndexer.IndexField
           
 
Constructor Summary
ALANameIndexer()
           
 
Method Summary
 void addAdditionalName(java.lang.String lsid, java.lang.String scientificName, java.lang.String author, LinnaeanRankClassification cl)
           
 void commit()
           
 void commit(boolean close, boolean merge)
           
 org.apache.lucene.document.Document createALAIndexDocument(java.lang.String name, java.lang.String id, java.lang.String lsid, java.lang.String author, LinnaeanRankClassification cl)
           
 org.apache.lucene.document.Document createALAIndexDocument(java.lang.String name, java.lang.String id, java.lang.String lsid, java.lang.String author, java.lang.String rank, java.lang.String rankId, java.lang.String left, java.lang.String right, LinnaeanRankClassification cl)
           
protected  org.apache.lucene.document.Document createALASynonymDocument(java.lang.String scientificName, java.lang.String author, java.lang.String id, java.lang.String lsid, java.lang.String nameLsid, java.lang.String acceptedLsid, java.lang.String acceptedId, float boost, java.lang.String synonymType)
           
 void createIndex(java.lang.String exportsDir, java.lang.String indexDir, boolean generateSciNames, boolean generateCommonNames)
          Creates the index from the specified checklist bank names usage export file into the specified index directory.
 void createIndex(java.lang.String exportsDir, java.lang.String indexDir, java.lang.String acceptedFile, java.lang.String synonymFile, java.lang.String irmngDwca, boolean generateSciNames, boolean generateCommonNames)
           
protected  org.apache.lucene.index.IndexWriter createIndexWriter(java.io.File directory, org.apache.lucene.analysis.Analyzer analyzer, boolean replace)
          Creates an index writer in the specified directory.
 void createIrmngIndex(java.lang.String exportsDir, java.lang.String indexDir)
          Creates the IRMNG homonym index based on the DWCA and species homonyms supplied from the NSL
 void deleteName(java.lang.String lsid)
          Deletes the entry that has the supplied lsid.
protected  org.apache.lucene.document.Document getCommonNameDocument(java.lang.String cn, java.lang.String sn, java.lang.String lsid, float boost)
           
protected  org.apache.lucene.document.Document getCommonNameDocument(java.lang.String cn, java.lang.String sn, java.lang.String lsid, float boost, boolean checkAccepted)
           
 java.lang.String getIndexDirectory()
           
protected  void indexIrmngDwcA(org.apache.lucene.index.IndexWriter iw, java.lang.String archiveDirectory)
          Indexes the IRMNG homonyms from the supplied DWCA direcory
 void init()
           
static void main(java.lang.String[] args)
          Generates the Lucene index required for the name matching API.
 void setIndexDirectory(java.lang.String indexDirectory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ALANameIndexer

public ALANameIndexer()
Method Detail

init

public void init()
          throws java.lang.Exception
Throws:
java.lang.Exception

createIndex

public void createIndex(java.lang.String exportsDir,
                        java.lang.String indexDir,
                        boolean generateSciNames,
                        boolean generateCommonNames)
                 throws java.lang.Exception
Creates the index from the specified checklist bank names usage export file into the specified index directory.

Parameters:
exportsDir - The directory that contains the exports that are necesary to generate the index.
indexDir - The directory in which the 2 indices will be created.
generateSciNames - true when the scientific name index should be created
generateCommonNames - true when the common name index should be generated
Throws:
java.lang.Exception

createIrmngIndex

public void createIrmngIndex(java.lang.String exportsDir,
                             java.lang.String indexDir)
                      throws java.lang.Exception
Creates the IRMNG homonym index based on the DWCA and species homonyms supplied from the NSL

Parameters:
exportsDir -
indexDir -
Throws:
java.lang.Exception

createIndex

public void createIndex(java.lang.String exportsDir,
                        java.lang.String indexDir,
                        java.lang.String acceptedFile,
                        java.lang.String synonymFile,
                        java.lang.String irmngDwca,
                        boolean generateSciNames,
                        boolean generateCommonNames)
                 throws java.lang.Exception
Throws:
java.lang.Exception

createIndexWriter

protected org.apache.lucene.index.IndexWriter createIndexWriter(java.io.File directory,
                                                                org.apache.lucene.analysis.Analyzer analyzer,
                                                                boolean replace)
                                                         throws java.lang.Exception
Creates an index writer in the specified directory. It will create/recreate the target directory

Parameters:
directory -
analyzer -
Returns:
Throws:
java.lang.Exception

addAdditionalName

public void addAdditionalName(java.lang.String lsid,
                              java.lang.String scientificName,
                              java.lang.String author,
                              LinnaeanRankClassification cl)
                       throws java.lang.Exception
Throws:
java.lang.Exception

deleteName

public void deleteName(java.lang.String lsid)
                throws java.lang.Exception
Deletes the entry that has the supplied lsid. It will also delete all the synonyms associated with it

Parameters:
lsid -
Throws:
java.lang.Exception

commit

public void commit()
            throws java.lang.Exception
Throws:
java.lang.Exception

commit

public void commit(boolean close,
                   boolean merge)
            throws java.lang.Exception
Parameters:
merge - whether or not to merge the index
close - whether or not to close the index
Throws:
java.lang.Exception

indexIrmngDwcA

protected void indexIrmngDwcA(org.apache.lucene.index.IndexWriter iw,
                              java.lang.String archiveDirectory)
                       throws java.lang.Exception
Indexes the IRMNG homonyms from the supplied DWCA direcory

Parameters:
iw - The index writer to write the lucene docs to
archiveDirectory - The directory in which the IRMNG DWCA has been unzipped.
Throws:
java.lang.Exception

getCommonNameDocument

protected org.apache.lucene.document.Document getCommonNameDocument(java.lang.String cn,
                                                                    java.lang.String sn,
                                                                    java.lang.String lsid,
                                                                    float boost)

getCommonNameDocument

protected org.apache.lucene.document.Document getCommonNameDocument(java.lang.String cn,
                                                                    java.lang.String sn,
                                                                    java.lang.String lsid,
                                                                    float boost,
                                                                    boolean checkAccepted)

createALAIndexDocument

public org.apache.lucene.document.Document createALAIndexDocument(java.lang.String name,
                                                                  java.lang.String id,
                                                                  java.lang.String lsid,
                                                                  java.lang.String author,
                                                                  LinnaeanRankClassification cl)

createALAIndexDocument

public org.apache.lucene.document.Document createALAIndexDocument(java.lang.String name,
                                                                  java.lang.String id,
                                                                  java.lang.String lsid,
                                                                  java.lang.String author,
                                                                  java.lang.String rank,
                                                                  java.lang.String rankId,
                                                                  java.lang.String left,
                                                                  java.lang.String right,
                                                                  LinnaeanRankClassification cl)

createALASynonymDocument

protected org.apache.lucene.document.Document createALASynonymDocument(java.lang.String scientificName,
                                                                       java.lang.String author,
                                                                       java.lang.String id,
                                                                       java.lang.String lsid,
                                                                       java.lang.String nameLsid,
                                                                       java.lang.String acceptedLsid,
                                                                       java.lang.String acceptedId,
                                                                       float boost,
                                                                       java.lang.String synonymType)

getIndexDirectory

public java.lang.String getIndexDirectory()

setIndexDirectory

public void setIndexDirectory(java.lang.String indexDirectory)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Generates the Lucene index required for the name matching API. eg au.org.ala.names.search.ALANameIndexer "/data/exports" "/data/lucene/namematching" Extra optional args that should appear after the directory names -sn: Only create the indexes necessary for the scientific name lookups -cn: Only create the indexes necessary for the common name lookups

Parameters:
args -
Throws:
java.lang.Exception


Copyright © 2014. All Rights Reserved.