You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by "Rupert Westenthaler (JIRA)" <ji...@apache.org> on 2012/09/10 12:14:07 UTC

[jira] [Created] (STANBOL-740) Adopt the KeywordLinkingEngine to use the AnalyzedText content part

Rupert Westenthaler created STANBOL-740:
-------------------------------------------

             Summary: Adopt the KeywordLinkingEngine to use the AnalyzedText content part
                 Key: STANBOL-740
                 URL: https://issues.apache.org/jira/browse/STANBOL-740
             Project: Stanbol
          Issue Type: Sub-task
            Reporter: Rupert Westenthaler
            Assignee: Rupert Westenthaler


The KeywordLinkingEngine currently does both NLP processing AND linking against the target vocabulary. Up to now this was the only possibility as separating those two things was not feasible with the limitations of the RDF metadata.

With the introduction of the AnalyzedText content part the NLP processing part needs no longer be part of the KeywordLinkingEngine.

This issue covers

* removal of the NLP related functionality from the KeywordLinkingEngine
* reimplementation of the linking part on top of the API provided by the AnalyzedText contentpart
* add support fore new features of the NLP chain
    * use lemmas - if available - for entity lookup
    * use POS tagset mappings to the OLIA ontology to decide what tokens to lookup

After this change the KeywordLinkingEngine will also be able to work in combination with any NLP framework that is integrated with the Stanbol NLP components (writes its data to the AnalyzedText content part). 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (STANBOL-740) Adopt the KeywordLinkingEngine to use the AnalyzedText content part

Posted by "Rupert Westenthaler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STANBOL-740?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rupert Westenthaler resolved STANBOL-740.
-----------------------------------------

    Resolution: Fixed

Considered as resolved by http://svn.apache.org/viewvc?rev=1412121&view=rev

The KeywordLinkingEngine is now a lot more powerful. The adapted version is mostly compatible with the current trunk version. Only the "Keyword Tokenizer" feature of the trunk version is no longer supported. Current configurations that activate this feature will still work, but ignore this configuration.

Enhancement Results for current configurations might change in some rare cases including:

* Labels that match less than 75% of the label tokens will no longer be suggested. The trunk version suggest all Labels that match more than two tokens. This will only affect suggestions with low confidence values
* The branch version fixes an unreported Bug in the algorithm used for matching labels. This fix will allow to detect matches where the text is "word1-word2" and the label mentions "word1 word2".

The main difference for users will be that they NEED to adapt their Enhancement Chains as the new KeywordLinkingEngine can no longer consume pain text but requires the AnalyzedText content part. The AnalyzedText needs also to provide Tokens!
                
> Adopt the KeywordLinkingEngine to use the AnalyzedText content part
> -------------------------------------------------------------------
>
>                 Key: STANBOL-740
>                 URL: https://issues.apache.org/jira/browse/STANBOL-740
>             Project: Stanbol
>          Issue Type: Sub-task
>            Reporter: Rupert Westenthaler
>            Assignee: Rupert Westenthaler
>
> The KeywordLinkingEngine currently does both NLP processing AND linking against the target vocabulary. Up to now this was the only possibility as separating those two things was not feasible with the limitations of the RDF metadata.
> With the introduction of the AnalyzedText content part the NLP processing part needs no longer be part of the KeywordLinkingEngine.
> This issue covers
> * removal of the NLP related functionality from the KeywordLinkingEngine
> * reimplementation of the linking part on top of the API provided by the AnalyzedText contentpart
> * add support fore new features of the NLP chain
>     * use lemmas - if available - for entity lookup
>     * use POS tagset mappings to the OLIA ontology to decide what tokens to lookup
> After this change the KeywordLinkingEngine will also be able to work in combination with any NLP framework that is integrated with the Stanbol NLP components (writes its data to the AnalyzedText content part). 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (STANBOL-740) Adopt the KeywordLinkingEngine to use the AnalyzedText content part

Posted by "Rupert Westenthaler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STANBOL-740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486009#comment-13486009 ] 

Rupert Westenthaler edited comment on STANBOL-740 at 11/17/12 10:06 AM:
------------------------------------------------------------------------

With revision 1403242 a first implementation of the KeywordLinkingEngine that is based on the Stanbol NLP prodessing Module (STABOL-733) is available in the stanbol-nlp-processing branch [2]. This comment is intended to be moved to the documentation of the Stanbol Webpage as soon as this version is re-integrated to the trunk.

edit: brings the documentation in line with revision http://svn.apache.org/viewvc?rev=1410404&view=rev

## Configuration

Only changes to the current version

### Removed Features

* Keyword Tokenizer (org.apache.stanbol.enhancer.engines.keywordextraction.keywordTokenizer): This allowed to use a special Tokenizer for matching keywords and alpha numeric IDs. This feature is no longer available as they KeywordLinkingEngine does no longer the tokenizing of parsed texts and has therefore no influence on how the text is tokenized. To preserve this feature a new Engine that is specialised for this task needed to be implemented.

### Deprecated Configuration

* __Min POS Tag Probability__ _(org.apache.stanbol.enhancer.engines.keywordextraction.minPosTagProbability)_: While still functional users should use the "prob" param supported by the _Processed Languages_ configuration. See the own section for details.

### Updated Features

* __Min Matched Tokens__ _org.apache.stanbol.enhancer.engines.keywordextraction.minFoundTokens_ [1..*]::int: The minimum number of matching tokens. Only "matchable" tokens are counted. For full matches (where all tokens of the Label do match tokens in the text) this parameter is ignored.

    This parameter is strongly related with the _Min Label Match Score_ Typical setting are

    1. _Min Matched Tokens_=1 and _Min Label Match Score_ > 0.5 (e.g. 0.75)
    2. _Min Matched Tokens_=2 and _Min Label Match Score_ <= 0.5 (e.g. 0.5)

    For Labels containing of one or two words both options do have the same result, but for Longer labels (1) is more restrictive than (2). The important thing is that both options ensures that Labels with more than one tokens will not be considered if only a single token does match the text.

    If used in combination with an disambiguation Engine one might want to consider to suggest Entities where only a single token of multi-token labels do match. In such cases a configuration like _Min Matched Tokens_=1 and _Min Label Match Score_ <= 0.5 (e.g. 0.4) might be considered. With such scenarios users will also want to considerable increase the value for _Max Suggestions_ (typically values > 10).

### New Features

* __Link ProperNouns only__ _(org.apache.stanbol.enhancer.engines.keywordextraction.properNounsState)_: This boolean switch allows easily to switch between linking all nouns (state=false) or only proper nouns (state=true). "Noun linking" is equivalent to the current behavior of the KeywordLinkingEngine while "ProperNoun linking" is more similar to using NER with the NamedEntityLinking engine. For linking against vocabularies that contain Entities typically mentioned in texts as ProperNouns activating this option will greatly improve performance as much less words need to be looked-up in the Vocabulary. When linking to a Vocabulary that defines Entities that might be mentioned as common nouns this option need to be deactivated.

* __Processed Languages__ _(org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages)_: This features allows (1) to explicitly define languages processed by the Engine and (2) allows to provide Language Specific Configurations. Language specific configurations will override/extend engine global configurations. See the next section for details

* __Max Search Token Distance__ _org.apache.stanbol.enhancer.engines.keywordextraction.maxSearchTokenDistance_ [1..*]::int:  The maximum number of Tokens searched around linked Tokens to be included in searches within the linked vocabulary (default value is '3'). As an Example in the text section "at the University of Munich a new procedure to" only "Munich" would be  looked-up in the Vocabulary in case "ProperNoun" linking is activated. However for searching possible matches in the Vocabulary it makes sense to use additional Tokens to reduce (and better rank) possible matches for for "Munich". Because of that "matchable" words surrounding looked-up tokens are considered to be included for searches in the Vocabulary. This parameter allows to configure the maximum distance of words that are used for such searches. Note that this parameter will not cause Words outside of a Chunk to be used for searches (unless "Ingore Chunks" option is activated).

* __Max Search Tokens__ _org.apache.stanbol.enhancer.engines.keywordextraction.maxSearchTokens_ [1..*]::int: The maximum number of Tokens used for searches in the Controlled Vocabulary (default value is '2'). This sets the maximum number of Tokens used in OR queries to the linked Vocabulary.

* _org.apache.stanbol.enhancer.engines.keywordextraction.lemmaMatching_  [true/false]: This allows to use the Lemma instead of the original token in the text for searching and matching Labels of Entities. Currently this feature is by default disabled

* __Min Label Match Score__ _org.apache.stanbol.enhancer.engines.keywordextraction.minLabelMatchFactor_ [0..1]::double: The "Label Score" [0..1] represents how much of the Label of an Entity matches with the Text. It compares the number of Tokens of the Label with the number of Tokens matched to the Text. Not exact matches for Tokens, or if the Tokens within the label do appear in an other order than in the text do also reduce this score. Entities are only considered if at least one of their labels cores higher than the minimum for all tree of _Min Label Match Score_, _Min Text Match Score_ and _Min Match Score_.

* __Min Text Match Score__ _org.apache.stanbol.enhancer.engines.keywordextraction.minTextMatchFactor_ [0..1]::double: The "Text Score" [0..1] represents how well the Label of an Entity matches to the selected Span in the Text. It compares the number of matched {@link Token} from the label with the number of Tokens enclosed by the Span in the Text an Entity is suggested for. Not exact matches for Tokens, or if the Tokens within the label do appear in an other order than in the text do also reduce this score. Entities are only considered if at least one of their labels cores higher than the minimum for all tree of _Min Label Match Score_, _Min Text Match Score_ and _Min Match Score_.

* __Min Match Score__ _org.apache.stanbol.enhancer.engines.keywordextraction.minTextMatchFactor_ [0..1]::double: Defined as the product of the "Text Score" with the "Label Score" - meaning that this value represents both how well the label matches the text and how much of the label is matched with the text. Entities are only considered if at least one of their labels cores higher than the minimum for all tree of _Min Label Match Score_, _Min Text Match Score_ and _Min Match Score_.

*_org.apache.stanbol.enhancer.engines.keywordextraction.dereferenceFields_: Allows to define additional fields that are included for dereferneced Entities. Only applied of "Dereference Entities" is enabled.


## Processed Language Configuration

With they key _'org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages'_ the processed language(s) and language specific configurations can be applied. The first usage of this configuration is to specify the languages processed by the engine and second to parse language specific how languages should be processed.

__1. Language Configuraiton:__

For the configuration of the processed languages the following syntax is used:

    de
    en
    
This would configure the Engine to only process German and English texts. It is also possible to explicitly exclude languages

    !fr
    !it
    *

This specifies that all Languages other than French and Italien are processed.

Values MUST BE parsed as Array or Vector. This is done by using the ["elem1","elem2",...] syntax as defined by OSGI ".config" files. The following example shows the two above examples combined to a single configuration.

    org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages=["!fr","!it","de","en","*"]


__2. Language specific Parameter__

In addition to specifying the processed languages this configuration can also be used to parse language specific parameters. The syntax for parameters is as follows

    {language};{param-name}={param-value};{param-name}={param-value}
    *;{param-name}={param-value};{param-name}={param-value}
    ;{param-name}={param-value};{param-name}={param-value}

The first line sets the parameter for {language}. The 2nd and 3rd line show that either the wildcard language '*' or the empty language '' can be used to configure parameters that are used as defaults for all languages.

### Language Processing Parameters

The following param-names are supported by the KeywordLinkingEngine

__Phrase level Parameters:__

* __pc__ {name}::LexicalCategory - The _Phrase Categories_ processed by the Engine. Valid values include the name's of members of the LexicalCategory enumeration (e.g. "Noun", "Verb", "Adjective", "Adposition", ...)
* __ptag__ {tag}::String - the _Phrase Tag_ processed by the Engine. This allows to configure the String tags as used by the Chunker of a Language. This should only be used of the Chunk types of the Chunker are not mapped with members of the LexicalCategory enumeration.
* __pprob__ [0..1)::double - the _Min Phrase Tag Probability_ for Chunks to be accepted as processable ('value/2' is sufficient for rejecting).
* __lmmtip__ [''/true/false]::boolean - the _Link Multiple Matchable Tokens in Phrases_ parameter. As the name says it allows to enable/disable the linking of multiple matchable tokens within the same Chunk. This is especially important if _Proper Noun Linking_ is active, as it allows to detect 'named entities' that are constituted by two common nouns. NOTE that 'lmmtip' is short for 'lmmtip=true'

__Token level Parameters:__

* __lc__ {name}::LexicalCategory - The linked _Token Categories_. Valid values include the name's of members of the LexicalCategory enumeration (e.g. "Noun", "Verb", "Adjective", "Adposition", …). Typical configurations include "lc=Noun" or an empty list ("lc" or "lc=") to deactivate all categories and provide more fine granular Pos or Tag level configuration. 
* __pos__ {name}::Pos - This linked _Pos Types_. Valid values include the name's of members of the Pos enumeration (e.g. "ProperNoun", "CommonNoun", "Infinitive", "Gerund", "PresentParticiple" and ~150 others). This parameter can be used to provide a very fine granular configuration. It is e.g. used by the _Link ProperNouns only_ setting to define that only "pos=ProperNoun" are linked.
* __tag__ {tag}::String - The linked _Pos Tags_. This parameter allows to configure POS tags as used by the POS tagger. This is useful if those Tags are not mapped to LexicalCategories or Pos types.
*__prob__ [0..1)::double - the _Min PosTag Probability_. This parameter replaces the formally used _Min POS tag probability_ _(org.apache.stanbol.enhancer.engines.keywordextraction.minPosTagProbability)_ property. It defines the minimum confidence so that a POS annotation is accepted for linkable and matchable tokens ('value/2' is sufficient for rejecting none linked/matched tokens).
* __uc__ {NONE/MATCH/LINK}::string - the _Upper Case Token Mode_ allows to configure how upper case words are treated. There are three possible modes: (1) NONE: defines that they are not specially treated; (2) MATCH defines that they are considered as matchable tokens (independent of the POS tag or the token length; (3) LINK: defines that they are in any case linked with the vocabulary. The default is "LINK" - as upper case words often represent named entities - with the exception of German ('de') where the mode is set to MATCH - as all Nouns in German are upper case.

NOTE: that tokens are linked if any of "lc", "pos" or "tag" match the configuration. This means that adding "lc=Noun" will render "pos=ProperNoun" useless as the Pos type ProperNoun is already included in the LexicalCategory Noun.

__Examples:__

The default configuration for the KeywordLinkingEngine uses the following setting

    *;lmmtip;uc=LINK;prop=0.75;pprob=0.75
    de;uc=MATCH
    es;lc=Noun
    nl;lc=Noun

The first line enable _Link Multiple Matchable Tokens in Phrases_ and linking of upper case tokens for all languages. In addition it sets the minimum probabilities for Pos- and Phrase annotations to 0.75 (what would be also the default). The following three lines provide additional language specific defaults. For German the upper case mode is reset to MATCH as in German all Nouns use upper case. For Spain and Dutch linking for the LexicalCategory Noun is enabled. This is because the OpenNLP POS tagger for those languages does not support ProperNoun's and therefore the Engine would not link any tokens if _Link ProperNouns only_ is enabled. The same configuration in the OSGI '.config' file syntax would look like follows

    org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages=["*;lmmtip;uc\=LINK;prop\=0.75;pprob\=0.75","de;uc\=MATCH","es;lc\=Noun","nl;lc\=Noun"]

The 2nd example shows how to define default settings without using the wildcard '*' that would enable processing of all languages. The following example shows an configuration that only enables English and ignores text in all other languages.

    ;lmmtip;uc=LINK;prop=0.75;pprob=0.75
    en
    de;uc=MATCH


## Extension Points

This section describes Interfaces that are used as Extension Points by the KeywordLinkingEngine

### EntitySearcher

The EntitySearch Interface is used by the KeywordLinkingEngine to search for Entities in the linked Vocabulary. Currently the StanbolEntityhub based implementations are instantiated based on the value of the _'org.apache.stanbol.enhancer.engines.keywordextraction.referencedSiteId'_. Users that want to use a different implementation of this Interface to be used for linking will need to extend the KeywordLinkingEngine and override the #activateEntitySearcher(ComponentContext context, Dictionary<String,Object> configuration) and #deactivateEntitySearcher(). Those methods are called during activation/deactivation of the KeywordLinkingEngine and are expected to set/unset the #entitySearcher field.

### LabelTokenizer

The LabelTokenizer interface is used to tokenize labels of Entities from the linked Vocabulary. As the matching process of the KeywordLinkingEngine is based on Tokens (words) multi-word labels (e.g. Univerity of Munich) need to be tokenized before they can be matched against the current context in the Text.

LabelTokenizer are OSGI services. Their configuration optionally can define the _'enhancer.engines.keywordextraction.labeltokenizer.languages'_ property. Values are considered to be language configurations. Configurations can explicitly include/exclude languages. Also a wildcard is supported (e.g. "en,de" would include English and German; "!it,!fr,*" would specify all languages expect Italian and French. If no configuration is provided than "*" (all languages) is assumed.

The KeywordLinkingEngine will - by default - always use the LabelTokenizer with the highest "service.ranking" for a given language to tokenize labels. By default it comes with an OpenNLP based Tokenizer implementation that registers itself for all languages with a "service.ranking" of "-1000".

Users that want to use a different Tokenizer need to register an implementation for the given language(s) with an higher "service.ranking". Users that want to provide there own LabelTokenizer and ignore the values provided by OSGI need to extend the KeywordLinkingEngine set the #labelTokenizer field themself AND override the #bindLabelTokenizer(LabelTokenizerManager ltm) and #unbindLabelTokenizer(LabelTokenizerManager ltm) methods in a way that they do NOT change the #labelTokenizer field.


[1] http://svn.apache.org/viewvc?rev=1403242&view=rev
[2] https://svn.apache.org/repos/asf/stanbol/branches/stanbol-nlp-processing
                
      was (Author: rwesten):
    With revision 1403242 a first implementation of the KeywordLinkingEngine that is based on the Stanbol NLP prodessing Module (STABOL-733) is available in the stanbol-nlp-processing branch [2]. This comment is intended to be moved to the documentation of the Stanbol Webpage as soon as this version is re-integrated to the trunk.


## Configuration

Only changes to the current version

### Removed Features

* Keyword Tokenizer (org.apache.stanbol.enhancer.engines.keywordextraction.keywordTokenizer): This allowed to use a special Tokenizer for matching keywords and alpha numeric IDs. This feature is no longer available as they KeywordLinkingEngine does no longer the tokenizing of parsed texts and has therefore no influence on how the text is tokenized. To preserve this feature a new Engine that is specialised for this task needed to be implemented.

### New Features

* __Link ProperNouns only__ _(org.apache.stanbol.enhancer.engines.keywordextraction.properNounsState)_: This boolean switch allows easily to switch between linking all nouns (state=false) or only proper nouns (state=true). "Noun linking" is equivalent to the current behavior of the KeywordLinkingEngine while "ProperNoun linking" is more similar to using NER with the NamedEntityLinking engine. For linking against vocabularies that contain Entities typically mentioned in texts as ProperNouns activating this option will greatly improve performance as much less words need to be looked-up in the Vocabulary. When linking to a Vocabulary that defines Entities that might be mentioned as common nouns this option need to be deactivated.

* __Processed Languages__ _(org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages)_: This features allows (1) to explicitly define languages processed by the Engine and (2) allows to provide Language Specific Configurations. Language specific configurations will override/extend engine global configurations. See the next section for details

* _org.apache.stanbol.enhancer.engines.keywordextraction.maxSearchTokenDistance_:  The maximum number of Tokens searched around linked Tokens to be included in searches within the linked vocabulary (default value is '3'). As an Example in the text section "at the University of Munich a new procedure to" only "Munich" would be  looked-up in the Vocabulary in case "ProperNoun" linking is activated. However for searching possible matches in the Vocabulary it makes sense to use additional Tokens to reduce (and better rank) possible matches for for "Munich". Because of that "matchable" words surrounding looked-up tokens are considered to be included for searches in the Vocabulary. This parameter allows to configure the maximum distance of words that are used for such searches. Note that this parameter will not cause Words outside of a Chunk to be used for searches (unless "Ingore Chunks" option is activated).

* _org.apache.stanbol.enhancer.engines.keywordextraction.masSearchTokens_: The maximum number of Tokens used for searches in the Controlled Vocabulary (default value is '2'). This sets the maximum number of Tokens used in OR queries to the linked Vocabulary.

*_org.apache.stanbol.enhancer.engines.keywordextraction.dereferenceFields_: Allows to define additional fields that are included for dereferneced Entities. Only applied of "Dereference Entities" is enabled.


### Processed Language Configuration

With they key _'org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages'_ the processed language(s) and language specific configurations can be applied.

For the configuration of the processed languages the following syntax is used:

    de
    en
    
This would configure the Engine to only process German and English texts. It is also possible to explicitly exclude languages

    !fr
    !it
    *
This specifies that all Languages other than French and Italien are processed.

Values MUST BE parsed as Array or Vector. This is done by using the ["elem1","elem2",...] syntax as defined by OSGI ".config" files. The following example shows the two above examples combined to a single configuration.

    org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages=["!fr","!it","de","en","*"]

In addition to specifying the processed languages this configuration can also be used to parse language specific parameters. The syntax for parameters is as follows

    {language};{param-name}={param-value};{param-name}={param-value}

The following param-names are supported by the KeywordLinkingEngine

* __lc__: This allows to parse LexicalCategories of words that shall be looked up in the Vocabulary. Valid values include the name's of members of the LexicalCategory enumeration (e.g. "Noun", "Verb", "Adjective", "Adposition", ...)
* __pos__: This allows to parse Pos types of words that shall be looked up in the Vocabulary. Valid values include the name's of members of the Pos enumeration (e.g. "ProperNoun", "CommonNoun", "Infinitive", "Gerund", "PresentParticiple" and ~150 others).
* __tag__: This allows to parse string tags used by the POS tagger for an language. Words that use those tags will be lokked-up with the vocabulary.
*__prob__: Allows a language specific setting of the _Min POS tag probability_ _(org.apache.stanbol.enhancer.engines.keywordextraction.minPosTagProbability)_. This value [0..1] is used to decide if a POS annotation is confident enough to use it for linking or rejecting ('value/2' is sufficient for rejecting).

Note that a word is linked if either "lc", "pos" or "tag" do match. So setting "pos=ProperNoun" will not have any effect if "lc=Noun" is already defined.

The following shows an "Processed Language Configuration" using all of the above mentioned features

    !fr
    !it
    nl;lc=Noun
    *;pos=ProperNoun

This would process all languages other that French and Italien; link all Nouns for Dutch texts and only ProperNouns for all others.

Users that want to define default parameters without using the "*" - wildcard language can use an empty language for parsing the parameters. Here an example

    nl;lc=Noun
    da
    en
    es
    pt
    sv
    de
    ;pos=ProperNoun

This explicitly includes the seven languages for that OpenNLP POS models are included in the Stanbol Full Launcher. In addition it sets "Noun" linking for Dutch - as the POS tagset for this language does not distinguish between ProperNouns and CommonNouns. For the other six languages only "ProperNouns" are linked.


Users that directly parse configurations as OSGI ".config" need to properly escape configured parameters. The following example shows the above configuration in the syntax used by ".config" files

    org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages=["nl;lc\=Noun","da","en","es","pt","sv","de",";pos\=ProperNoun"]

## Extension Points

This section describes Interfaces that are used as Extension Points by the KeywordLinkingEngine

### EntitySearcher

The EntitySearch Interface is used by the KeywordLinkingEngine to search for Entities in the linked Vocabulary. Currently the StanbolEntityhub based implementations are instantiated based on the value of the _'org.apache.stanbol.enhancer.engines.keywordextraction.referencedSiteId'_. Users that want to use a different implementation of this Interface to be used for linking will need to extend the KeywordLinkingEngine and override the #activateEntitySearcher(ComponentContext context, Dictionary<String,Object> configuration) and #deactivateEntitySearcher(). Those methods are called during activation/deactivation of the KeywordLinkingEngine and are expected to set/unset the #entitySearcher field.

### LabelTokenizer

The LabelTokenizer interface is used to tokenize labels of Entities from the linked Vocabulary. As the matching process of the KeywordLinkingEngine is based on Tokens (words) multi-word labels (e.g. Univerity of Munich) need to be tokenized before they can be matched against the current context in the Text.

LabelTokenizer are OSGI services. Their configuration optionally can define the _'enhancer.engines.keywordextraction.labeltokenizer.languages'_ property. Values are considered to be language configurations. Configurations can explicitly include/exclude languages. Also a wildcard is supported (e.g. "en,de" would include English and German; "!it,!fr,*" would specify all languages expect Italian and French. If no configuration is provided than "*" (all languages) is assumed.

The KeywordLinkingEngine will - by default - always use the LabelTokenizer with the highest "service.ranking" for a given language to tokenize labels. By default it comes with an OpenNLP based Tokenizer implementation that registers itself for all languages with a "service.ranking" of "-1000".

Users that want to use a different Tokenizer need to register an implementation for the given language(s) with an higher "service.ranking". Users that want to provide there own LabelTokenizer and ignore the values provided by OSGI need to extend the KeywordLinkingEngine set the #labelTokenizer field themself AND override the #bindLabelTokenizer(LabelTokenizerManager ltm) and #unbindLabelTokenizer(LabelTokenizerManager ltm) methods in a way that they do NOT change the #labelTokenizer field.


[1] http://svn.apache.org/viewvc?rev=1403242&view=rev
[2] https://svn.apache.org/repos/asf/stanbol/branches/stanbol-nlp-processing
                  
> Adopt the KeywordLinkingEngine to use the AnalyzedText content part
> -------------------------------------------------------------------
>
>                 Key: STANBOL-740
>                 URL: https://issues.apache.org/jira/browse/STANBOL-740
>             Project: Stanbol
>          Issue Type: Sub-task
>            Reporter: Rupert Westenthaler
>            Assignee: Rupert Westenthaler
>
> The KeywordLinkingEngine currently does both NLP processing AND linking against the target vocabulary. Up to now this was the only possibility as separating those two things was not feasible with the limitations of the RDF metadata.
> With the introduction of the AnalyzedText content part the NLP processing part needs no longer be part of the KeywordLinkingEngine.
> This issue covers
> * removal of the NLP related functionality from the KeywordLinkingEngine
> * reimplementation of the linking part on top of the API provided by the AnalyzedText contentpart
> * add support fore new features of the NLP chain
>     * use lemmas - if available - for entity lookup
>     * use POS tagset mappings to the OLIA ontology to decide what tokens to lookup
> After this change the KeywordLinkingEngine will also be able to work in combination with any NLP framework that is integrated with the Stanbol NLP components (writes its data to the AnalyzedText content part). 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (STANBOL-740) Adopt the KeywordLinkingEngine to use the AnalyzedText content part

Posted by "Rupert Westenthaler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STANBOL-740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13500083#comment-13500083 ] 

Rupert Westenthaler commented on STANBOL-740:
---------------------------------------------

## Linking Process:

The Linking Process consists of three major steps: First it consumes results of the NLP processing to determine tokens - words - that need to be linked with the configured vocabulary. Second the linking of entities based on their labels with the current section of the Text and third the writing of the enhancement results.


### Token Types

The KeywordLinkingEngine operates based on tokens (words). Those tokens are divided in the following Categories

* __Linkable Tokens__: This are words that are linked with the Vocabulary. This means that the engine will issue quires in the controlled vocabulary for those tokens
* __Matchable Tokens__: Matchable tokens are used to refine quires. For the matching of entity labels with the text those words are treated in the same way as linkable words. So the main difference is that matchable words alone will not cause the engine to query for Entities in the Controlled Vocabulary.
* __Other Tokens__: All other tokens in the text are not used for searches in the configured vocabulary. However during the matching of labels with the Text they are considered as they might also be present in labels of entities

"University of Salzburg" is a good example as 'University' - a common noun - can be considered a matchable token, 'of' an other- and 'Salzburg' as proper noun is a typical linkable token. As the engine only queries for linkable token a single query for 'Salzburg' would be issued against the vocabulary. However this query would also use the matchable token 'University' as a secondary query term. The token 'of' would only be considered during matching.

In addition to the token type the engine also determines the rolling parameters

* __Token Length__: The number of characters of a word. This is especially important for languages where no POS tagger is available.
* __Alpha-Numeric__: If a Token does contain an alpha or an numeric character. This is mainly used to skip processing of tokens that represent punctuation.
* __Upper Case__: Upper Case Tokens do often represent named entities. because of that the Engine keeps track of upper case words.
* __Token Phrase__: If a Token is member of a _processable_ Phrase. Phrases are groups of Tokens that can be detected by a Chunker. A typical examples are Noun Phrases.


### Consumed NLP Processing Results:

The KeywordLinkingEngine consumes NLP processing results from the AnalyzedText ContentPart of the processed ContentItem. The following list describes the consumed information and their usage in the linking process: 

1. __Language_ _(required)_: The Language of the Text is acquired from the Metadata of the ContentItem. It is required to search for labels in the correct language and also to correctly apply language specific configurations of the engine.
2. __Sentences__ _(optional)_: Sentence annotations are used as segments for the matching process. In addition for the first word of an Sentence the _Upper Case_ feature is NOT set. In the case that no Sentence Annotations are present the whole text is treated as a single Sentence.
3. __Tokens__ _(required)_: As this Engine is based on the processing of Tokens such information are absolutely required.
4. __POS Annotations__ _(optional)_: Part of Speech (POS) tags are used to determine the _Token Type_. The NLP processing module provides two enumerations that define POS types. The high level _Lexical Categories_ (16 members including "Noun", "Verb", "Adjective", "Adposition" ...) and the Pos enumeration with ~150 very detailed POS definitions (such as (e.g. "ProperNoun", "CommonNoun", "Infinitive", "Gerund", "PresentParticiple" …). In addition the engine can also be configured to use the string tag as used by the POS tagger. The mapping of the _POS Annotation_ to the _Token Type_ is provided by the Engine configuration and can be language specific.
5. __Phrase Annotation__ _(optional)_: Phrase Annotations of Chunks present in the AnalyzedText are checked against the configured processable phrase categories. The linking of Tokens is NOT limited to Tokens within processable phrases. Phrases are only used as additional context to improve the matching process. The _Lexical Category_ and the string tags used by the Chunker can be used to configure the processable Phrase categories.
6. __Lemma__ _(optional)_: The Lemma provided by the MorphoAnalysis annotation can be used for linking instead of the token as used within the text.


### Entity Linking:

The linking process is based the matching of labels of entities returned as result for searches for entities in the configured controlled vocabulary. In addition the engine can be configured to consider redirects for entities returned by searches.

Searches are issued only for _Linkable Tokens_ and may include up to _Max Search Tokens_ additional _Linkable-_ or _Matchable Tokens_. If the _Linkable Token_ is within an _Phrase_ than only other tokens within the same phrase are considered. Otherwise any _Linkable-_ or _Matchable Tokens_ within the configured _Max Search Token Distance_ is considered for the search.

Searches to the controlled vocabulary are issued using the _EntitySearcher_ interface and build like follows:

    {lt}@{lang} || {lt}@{dl} || [{at}@{lang} || {at}@{dl} ... ]

where:

    * {lt} ... the _Linkable Token_ for that the search is issued
    * {at} ... additional _Linkable-_ or _Matchable Tokens_ included in the search
    * {lang} ... the language of the text
    * {dl} ... the configured _Default Matching Language_. If {df} == {lang} than the or term(s) for the {dl} are omitted

For results of those queries the labels in the {lang} and {dl} are matched against the text. However {dl} labels are only considered if no match was found for labels in the language of the text. For matching labels with the Tokens of the text the engine need to tokenize the labels. This is done by using the _LabelTokenizer_ interface.

The matching process distinguishes between matchable and non-matchable Tokens as well as non-alpha-numeric Tokens that are completely ignored. Matching starts at the position of the _Linkable Token_ for that the search in the configured vocabulary was issued. From this position Tokens in the Label are matched with Tokens in the text until the first matchable or 2nd non-matchable token is not found. In a second round the same is done in the backward direction. The configured _Min Token Match Factor_ determines how exact tokens in the text must correspond to tokens in the label so that a match is considered. This is repeated for all labels of an Entity. The label match that covers the most tokens is than considered as the match for that Entity.

There are various parameters that can be used to fine tune the matching process. But the most important decision is if one want to include suggestions where labels with two tokens do only match a single _Matchable Token_ in the Text (e.g. "Barack Obama" matching "Obama" but also 1000+ "Tom {something}" matching "Tom"). The default configuration of the Engine excludes those but depending on the use case and the linked vocabulary users might want to change this. See the documentation of the _Min Matched Tokens_ and _Min Label Match Score_ for details and examples. 


### Writing Enhancement Results

This step covers the following steps:

* processing of redirects as configured by the _Redirect Mode_
* mapping of the Entity types to the dc:type values for fise:TextAnnotations as configured by the _Type Mappings_ configuration 
* if _Dereference Entities_ is enabled than information for all configured _Dereferenced Fields_ need to be obtained
* writing of the fise:TextAnnotations, fise:EntityAnnotations and dereferenced entities (if enabled) to the metadata of the processed ContentItem
                
> Adopt the KeywordLinkingEngine to use the AnalyzedText content part
> -------------------------------------------------------------------
>
>                 Key: STANBOL-740
>                 URL: https://issues.apache.org/jira/browse/STANBOL-740
>             Project: Stanbol
>          Issue Type: Sub-task
>            Reporter: Rupert Westenthaler
>            Assignee: Rupert Westenthaler
>
> The KeywordLinkingEngine currently does both NLP processing AND linking against the target vocabulary. Up to now this was the only possibility as separating those two things was not feasible with the limitations of the RDF metadata.
> With the introduction of the AnalyzedText content part the NLP processing part needs no longer be part of the KeywordLinkingEngine.
> This issue covers
> * removal of the NLP related functionality from the KeywordLinkingEngine
> * reimplementation of the linking part on top of the API provided by the AnalyzedText contentpart
> * add support fore new features of the NLP chain
>     * use lemmas - if available - for entity lookup
>     * use POS tagset mappings to the OLIA ontology to decide what tokens to lookup
> After this change the KeywordLinkingEngine will also be able to work in combination with any NLP framework that is integrated with the Stanbol NLP components (writes its data to the AnalyzedText content part). 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (STANBOL-740) Adopt the KeywordLinkingEngine to use the AnalyzedText content part

Posted by "Rupert Westenthaler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STANBOL-740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486009#comment-13486009 ] 

Rupert Westenthaler commented on STANBOL-740:
---------------------------------------------

With revision 1403242 a first implementation of the KeywordLinkingEngine that is based on the Stanbol NLP prodessing Module (STABOL-733) is available in the stanbol-nlp-processing branch [2]. This comment is intended to be moved to the documentation of the Stanbol Webpage as soon as this version is re-integrated to the trunk.


## Configuration

Only changes to the current version

### Removed Features

* Keyword Tokenizer (org.apache.stanbol.enhancer.engines.keywordextraction.keywordTokenizer): This allowed to use a special Tokenizer for matching keywords and alpha numeric IDs. This feature is no longer available as they KeywordLinkingEngine does no longer the tokenizing of parsed texts and has therefore no influence on how the text is tokenized. To preserve this feature a new Engine that is specialised for this task needed to be implemented.

### New Features

* __Link ProperNouns only__ _(org.apache.stanbol.enhancer.engines.keywordextraction.properNounsState)_: This boolean switch allows easily to switch between linking all nouns (state=false) or only proper nouns (state=true). "Noun linking" is equivalent to the current behavior of the KeywordLinkingEngine while "ProperNoun linking" is more similar to using NER with the NamedEntityLinking engine. For linking against vocabularies that contain Entities typically mentioned in texts as ProperNouns activating this option will greatly improve performance as much less words need to be looked-up in the Vocabulary. When linking to a Vocabulary that defines Entities that might be mentioned as common nouns this option need to be deactivated.

* __Processed Languages__ _(org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages)_: This features allows (1) to explicitly define languages processed by the Engine and (2) allows to provide Language Specific Configurations. Language specific configurations will override/extend engine global configurations. See the next section for details

* _org.apache.stanbol.enhancer.engines.keywordextraction.maxSearchTokenDistance_:  The maximum number of Tokens searched around linked Tokens to be included in searches within the linked vocabulary (default value is '3'). As an Example in the text section "at the University of Munich a new procedure to" only "Munich" would be  looked-up in the Vocabulary in case "ProperNoun" linking is activated. However for searching possible matches in the Vocabulary it makes sense to use additional Tokens to reduce (and better rank) possible matches for for "Munich". Because of that "matchable" words surrounding looked-up tokens are considered to be included for searches in the Vocabulary. This parameter allows to configure the maximum distance of words that are used for such searches. Note that this parameter will not cause Words outside of a Chunk to be used for searches (unless "Ingore Chunks" option is activated).

* _org.apache.stanbol.enhancer.engines.keywordextraction.masSearchTokens_: The maximum number of Tokens used for searches in the Controlled Vocabulary (default value is '2'). This sets the maximum number of Tokens used in OR queries to the linked Vocabulary.

*_org.apache.stanbol.enhancer.engines.keywordextraction.dereferenceFields_: Allows to define additional fields that are included for dereferneced Entities. Only applied of "Dereference Entities" is enabled.


### Processed Language Configuration

With they key _'org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages'_ the processed language(s) and language specific configurations can be applied.

For the configuration of the processed languages the following syntax is used:

    de
    en
    
This would configure the Engine to only process German and English texts. It is also possible to explicitly exclude languages

    !fr
    !it
    *
This specifies that all Languages other than French and Italien are processed.

Values MUST BE parsed as Array or Vector. This is done by using the ["elem1","elem2",...] syntax as defined by OSGI ".config" files. The following example shows the two above examples combined to a single configuration.

    org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages=["!fr","!it","de","en","*"]

In addition to specifying the processed languages this configuration can also be used to parse language specific parameters. The syntax for parameters is as follows

    {language};{param-name}={param-value};{param-name}={param-value}

The following param-names are supported by the KeywordLinkingEngine

* __lc__: This allows to parse LexicalCategories of words that shall be looked up in the Vocabulary. Valid values include the name's of members of the LexicalCategory enumeration (e.g. "Noun", "Verb", "Adjective", "Adposition", ...)
* __pos__: This allows to parse Pos types of words that shall be looked up in the Vocabulary. Valid values include the name's of members of the Pos enumeration (e.g. "ProperNoun", "CommonNoun", "Infinitive", "Gerund", "PresentParticiple" and ~150 others).
* __tag__: This allows to parse string tags used by the POS tagger for an language. Words that use those tags will be lokked-up with the vocabulary.
*__prob__: Allows a language specific setting of the _Min POS tag probability_ _(org.apache.stanbol.enhancer.engines.keywordextraction.minPosTagProbability)_. This value [0..1] is used to decide if a POS annotation is confident enough to use it for linking or rejecting ('value/2' is sufficient for rejecting).

Note that a word is linked if either "lc", "pos" or "tag" do match. So setting "pos=ProperNoun" will not have any effect if "lc=Noun" is already defined.

The following shows an "Processed Language Configuration" using all of the above mentioned features

    !fr
    !it
    nl;lc=Noun
    *;pos=ProperNoun

This would process all languages other that French and Italien; link all Nouns for Dutch texts and only ProperNouns for all others.

Users that want to define default parameters without using the "*" - wildcard language can use an empty language for parsing the parameters. Here an example

    nl;lc=Noun
    da
    en
    es
    pt
    sv
    de
    ;pos=ProperNoun

This explicitly includes the seven languages for that OpenNLP POS models are included in the Stanbol Full Launcher. In addition it sets "Noun" linking for Dutch - as the POS tagset for this language does not distinguish between ProperNouns and CommonNouns. For the other six languages only "ProperNouns" are linked.


Users that directly parse configurations as OSGI ".config" need to properly escape configured parameters. The following example shows the above configuration in the syntax used by ".config" files

    org.apache.stanbol.enhancer.engines.keywordextraction.processedLanguages=["nl;lc\=Noun","da","en","es","pt","sv","de",";pos\=ProperNoun"]

## Extension Points

This section describes Interfaces that are used as Extension Points by the KeywordLinkingEngine

### EntitySearcher

The EntitySearch Interface is used by the KeywordLinkingEngine to search for Entities in the linked Vocabulary. Currently the StanbolEntityhub based implementations are instantiated based on the value of the _'org.apache.stanbol.enhancer.engines.keywordextraction.referencedSiteId'_. Users that want to use a different implementation of this Interface to be used for linking will need to extend the KeywordLinkingEngine and override the #activateEntitySearcher(ComponentContext context, Dictionary<String,Object> configuration) and #deactivateEntitySearcher(). Those methods are called during activation/deactivation of the KeywordLinkingEngine and are expected to set/unset the #entitySearcher field.

### LabelTokenizer

The LabelTokenizer interface is used to tokenize labels of Entities from the linked Vocabulary. As the matching process of the KeywordLinkingEngine is based on Tokens (words) multi-word labels (e.g. Univerity of Munich) need to be tokenized before they can be matched against the current context in the Text.

LabelTokenizer are OSGI services. Their configuration optionally can define the _'enhancer.engines.keywordextraction.labeltokenizer.languages'_ property. Values are considered to be language configurations. Configurations can explicitly include/exclude languages. Also a wildcard is supported (e.g. "en,de" would include English and German; "!it,!fr,*" would specify all languages expect Italian and French. If no configuration is provided than "*" (all languages) is assumed.

The KeywordLinkingEngine will - by default - always use the LabelTokenizer with the highest "service.ranking" for a given language to tokenize labels. By default it comes with an OpenNLP based Tokenizer implementation that registers itself for all languages with a "service.ranking" of "-1000".

Users that want to use a different Tokenizer need to register an implementation for the given language(s) with an higher "service.ranking". Users that want to provide there own LabelTokenizer and ignore the values provided by OSGI need to extend the KeywordLinkingEngine set the #labelTokenizer field themself AND override the #bindLabelTokenizer(LabelTokenizerManager ltm) and #unbindLabelTokenizer(LabelTokenizerManager ltm) methods in a way that they do NOT change the #labelTokenizer field.


[1] http://svn.apache.org/viewvc?rev=1403242&view=rev
[2] https://svn.apache.org/repos/asf/stanbol/branches/stanbol-nlp-processing
                
> Adopt the KeywordLinkingEngine to use the AnalyzedText content part
> -------------------------------------------------------------------
>
>                 Key: STANBOL-740
>                 URL: https://issues.apache.org/jira/browse/STANBOL-740
>             Project: Stanbol
>          Issue Type: Sub-task
>            Reporter: Rupert Westenthaler
>            Assignee: Rupert Westenthaler
>
> The KeywordLinkingEngine currently does both NLP processing AND linking against the target vocabulary. Up to now this was the only possibility as separating those two things was not feasible with the limitations of the RDF metadata.
> With the introduction of the AnalyzedText content part the NLP processing part needs no longer be part of the KeywordLinkingEngine.
> This issue covers
> * removal of the NLP related functionality from the KeywordLinkingEngine
> * reimplementation of the linking part on top of the API provided by the AnalyzedText contentpart
> * add support fore new features of the NLP chain
>     * use lemmas - if available - for entity lookup
>     * use POS tagset mappings to the OLIA ontology to decide what tokens to lookup
> After this change the KeywordLinkingEngine will also be able to work in combination with any NLP framework that is integrated with the Stanbol NLP components (writes its data to the AnalyzedText content part). 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira