getNamedEntities
Summary
Returns the entities from text based on model-based or datafile-based entity extraction. Parameters to control entity extraction should be specified by setting Entity Options.
This method provides a wrapper around the underlying C API method lxaGetNamedEntities.
Syntax
salience6.getNamedEntities(oSession, acConfigurationID)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| An identifier for a configuration added through addConfiguration, or empty string for default configuration |
Returns
If successful, returns a Python list containing the following items:
| Normalized form of the entity |
---|---|
| Type of entity (Company, Person, Place, Product, etc.) |
| Descriptive label for the entity |
| Sentiment score for the entity |
| A measure of how much evidence the sentiment score was based on (1 to 7) |
| Whether the entity passed any confidence queries |
| Whether the document is about this entity |
| A summary of the document related to this entity |
| A list of objects providing mention information for the entity |
| A list of objects providing theme information for the entity |
| A dictionary of entity objects providing labeled references to entities related to this entity (currently used by meta-entities, likely to be expanded). |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareTextFromFile(session,'/path/to/aFile.txt')
if (ret==0):
entities = se6.getNamedEntities(session,"")
for entity in entities:
print entity["normalized_form"], entity["type"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
getUserEntities
Summary
Returns the user-defined entities from text. This is based on the entity list specified through the User Entity List option. Other parameters to control entity extraction should be specified by setting additional Entity Options. These options must be set before calling this method.
This method provides a wrapper around the underlying C API method lxaGetUserDefinedEntities.
Syntax
salience6.getUserEntities(oSession, acConfigurationID)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| An identifier for a configuration added through addConfiguration, or empty string for default configuration |
Returns
If successful, returns a Python list containing the following items:
| Normalized form of the entity |
---|---|
| Type of entity (Company, Person, Place, Product, etc.) |
| Descriptive label for the entity |
| Sentiment score for the entity |
| A measure of how much evidence the sentiment score was based on (1 to 7) |
| Whether the entity passed any confidence queries |
| Whether the document is about this entity |
| A summary of the document related to this entity |
| A list of objects providing mention information for the entity |
| A list of objects providing theme information for the entity |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareTextFromFile(session,'/path/to/aFile.txt')
if (ret==0):
se6.setOption_UserEntityList(session, '/path/to/list.cdl')
entities = se6.getUserEntities(session, "")
for entity in entities:
print entity["normalized_form"], entity["type"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
getNamedEntityRelationships
Summary
Gets the relationships between named entities within the text.
This method provides a wrapper around the underlying C API method lxaGetNamedEntityRelationships.
Syntax
salience6.getNamedEntityRelationships(oSession, acConfigurationID)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| An identifier for a configuration added through addConfiguration, or empty string for default configuration |
Returns
If successful, returns a Python list containing the following items:
| A list of the entities that are related, with mention information about each entity |
---|---|
| Type of relationship as defined in the relationship pattern files (Occupation, etc.) |
| A measure of confidence in the relationship detection for the entities |
| A placeholder for an extra information that can be detected about the relationship |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareTextFromFile(session,'/path/to/aFile.txt')
if (ret==0):
relations = se6.getNamedEntityRelationships(session, "")
for relation in relations:
print relation["type"],
relation["entities"][0]["normalized_form"],
relation["entities"][1]["normalized_form"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
getNamedEntityOpinions
Summary
Gets the opinions expressed by named entities within the text.
This method provides a wrapper around the underlying C API method lxaGetNamedEntityOpinions.
Syntax
salience6.getNamedEntityOpinions(oSession, acConfigurationID)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| An identifier for a configuration added through addConfiguration, or empty string for default configuration |
Returns
If successful, returns a Python list containing the following items:
| A named entity within the content that is expressing an opinion |
---|---|
| A structure of information about the entity or theme which is the subject of the opinion |
| An indicator specifying if the topic of the opinion is an entity (0) or theme (1) |
| A sentiment score calculated for the opinion |
| A quotation in which the opinion was expressed, if available |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareTextFromFile(session,'/path/to/aFile.txt')
if (ret==0):
opinions = se6.getNamedEntityOpinions(session, "")
for opinion in opinions:
if (opinion["isTheme"]==0):
print opinion["speaker"]["normalized_form"],
opinion["topic"]["normalized_form"],
opinion["quotation"]
else:
print opinion["speaker"]["normalized_form"],
opinion["topic"]["theme"],
opinion["quotation"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
getUserEntityRelationships
Summary
Gets the relationships between user-defined entities within the text. User-defined entities are based on the entity list specified through the User Entity List option. Other parameters to control entity extraction should be specified by setting additional Entity Options. These options must be set before calling this method.
This method provides a wrapper around the underlying C API method lxaGetUserEntityRelationships.
Syntax
salience6.getUserEntityRelationships(oSession, acConfigurationID)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| An identifier for a configuration added through addConfiguration, or empty string for default configuration |
Returns
If successful, returns a Python list containing the following items:
| A list of the entities that are related, with mention information about each entity |
---|---|
| Type of relationship as defined in the relationship pattern files (Occupation, etc.) |
| A measure of confidence in the relationship detection for the entities |
| A placeholder for an extra information that can be detected about the relationship |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareTextFromFile(session,'/path/to/aFile.txt')
if (ret==0):
se6.setOption_UserEntityList(session,'/path/to/list.cdl')
relations = se6.getUserEntityRelationships(session, "")
for relation in relations:
print relation["type"],
relation["entities"][0]["normalized_form"],
relation["entities"][1]["normalized_form"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
getUserEntityOpinions
Summary
Gets the opinions expressed by user-defined entities within the text. User-defined entities are based on the entity list specified through the User Entity List option. Other parameters to control entity extraction should be specified by setting additional Entity Options. These options must be set before calling this method.
This method provides a wrapper around the underlying C API method lxaGetUserEntityOpinions.
Syntax
salience6.getNamedEntityOpinions(oSession, acConfigurationID)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| An identifier for a configuration added through addConfiguration, or empty string for default configuration |
Returns
If successful, returns a Python list containing the following items:
| A named entity within the content that is expressing an opinion |
---|---|
| A structure of information about the entity or theme which is the subject of the opinion |
| An indicator specifying if the topic of the opinion is an entity (0) or theme (1) |
| A sentiment score calculated for the opinion |
| A quotation in which the opinion was expressed, if available |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareTextFromFile(session,'/path/to/aFile.txt')
if (ret==0):
se6.setOption_UserEntityList(session,'/path/to/list.cdl')
opinions = se6.getUserEntityOpinions(session, "")
for opinion in opinions:
if (opinion["isTheme"]==0):
print opinion["speaker"]["normalized_form"],
opinion["topic"]["normalized_form"],
opinion["quotation"]
else:
print opinion["speaker"]["normalized_form"],
opinion["topic"]["theme"],
opinion["quotation"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
Updated 7 months ago