getCollectionThemes
Summary
Retrieves the themes extracted across all documents in the collection. These results can be adjusted through the available Collection Options, which must be set before this call is made.
This method provides a wrapper around the underlying C API method lxaGetCollectionThemes.
Syntax
salience6.getCollectionThemes(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 of theme items containing the following information:
| The text of the theme |
---|---|
| The stemmed version of the theme |
| The normalized version of the theme |
| 2 (indicates collection theme) |
| The number of themes rolled up into this theme |
| A sentiment score derived by aggregating the sentences from collection documents that contain the theme into a single document |
| The number of sentiment phrases used in determining sentiment score above |
| Not used for collection themes |
| Not used for collection themes |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
if (ret==0):
themes = se6.getCollectionThemes(session, "")
for theme in themes:
print theme["theme"], theme["sentiment"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
getCollectionFacets
Summary
Retrieves the facets extracted across all documents in the collection. These results can be adjusted through the available Collection Options, which must be set before this call is made.
This method provides a wrapper around the underlying C API method lxaGetCollectionFacets.
Syntax
salience6.getCollectionFacets(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 of theme items containing the following information:
| The text of the facet |
---|---|
| The count of occurrences for the facet |
| The number of occurrences which are associated with positive sentiment |
| The number of occurrences which are associated with negative sentiment |
| The number of occurrences which are associated with neutral sentiment |
| A list of tuples containing information about facet mentions |
| A list of tuples containing information about positive mentions of a facet, based on the value of the Neutral Upper Bound option |
| A list of tuples containing information about negative mentions of a facet, based on the value of the Neutral Lower Bound option |
| A list of tuples containing information about neutral mentions of a facet, based on the value of the Neutral Upper Bound and Neutral Lower Bound options |
| A list of structures containing information about the attributes for the facet |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
if (ret==0):
facets = se6.getCollectionFacets(session, "")
for facet in facets:
print facet["facet"], facet["total_hits"]
for attribute in facet["attributes"]:
print attribute["attribute"], len(attribute["mentions"])
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
getCollectionQueryDefinedTopics
Summary
Returns the topics determined for the collection via user-defined queries. Before calling this method, you must specify the topic list using the Topic List option.
This method provides a wrapper around the underlying C API method lxaGetCollectionQueryDefinedTopics.
Syntax
salience6.getCollectionQueryDefinedTopics(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 of items containing the following information about topics:
| The label for the topic |
---|---|
| The number of documents in the collection with hits for the query topic |
| 0 (not used) |
| An average of the sentiment values for topic hits within the collection |
| A list of collection document IDs containing query matches |
| 0 (indicates query topic result) |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
if (ret==0):
topics = se6.getCollectionQueryDefinedTopics(session, "")
for topic in topics:
print topic["topic"], topic["hits"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
getCollectionConceptDefinedTopics
Summary
Returns the topics determined for the collection via the Salience 6 Concept Matrix. Before calling this method, you must specify a concept topic list using the Concept Topic List option.
This method provides a wrapper around the underlying C API method lxaGetCollectionConceptDefinedTopics.
Syntax
salience6.getCollectionConceptDefinedTopics(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 of items containing the following information about topics:
| The label for the topic |
---|---|
| The number of documents in the collection with hits for the query topic |
| 0 (not used) |
| An average of the sentiment values for topic hits within the collection |
| A list of collection document IDs containing query matches |
| 1 (indicates concept topic result) |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
if (ret==0):
topics = se6.getCollectionConceptDefinedTopics(session, "")
for topic in topics:
print topic["topic"], topic["hits"], topic["score"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
getCollectionEntities
Summary
Returns the entities from collection based on model-based or datafile-based entity extraction. Parameters to control entity extraction should be specified by setting Entity Options. Other adjustments can be made through the available Collection Options, which must be set before this call is made.
This method provides a wrapper around the underlying C API method lxaGetCollectionEntities.
Syntax
salience6.getCollectionEntities(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 of items containing the following information:
| The normalized form for the entity |
---|---|
| The entity type (Person, Place, Company, Product, etc.) |
| A descriptive label for the entity |
| The number of occurrences of the entity within the collection |
| The occurrences of the entity within the collection associated with positive sentiment |
| The occurrences of the entity within the collection associated with negative sentiment |
| The occurrences of the entity within the collection associated with neutral sentiment |
| A list of structures containing information about occurrences of the entity |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
if (ret==0):
entities = se6.getCollectionEntities(session, "")
for entity in entities:
print entity["normalized"], entity["type"], entity["hits"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
getCollectionUserEntities
Summary
Returns the user-defined entities from the collection. This is based on the entity list specified through the User Entity List option. Other adjustments can be made through the available Collection Options, which must be set before this call is made.
This method provides a wrapper around the underlying C API method lxaGetCollectionUserEntities.
Syntax
salience6.getCollectionUserEntities(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 of items containing the following information:
| The normalized form for the entity |
---|---|
| The entity type (Person, Place, Company, Product, etc.) |
| A descriptive label for the entity |
| The number of occurrences of the entity within the collection |
| The occurrences of the entity within the collection associated with positive sentiment |
| The occurrences of the entity within the collection associated with negative sentiment |
| The occurrences of the entity within the collection associated with neutral sentiment |
| A list of structures containing information about occurrences of the entity |
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
if (ret==0):
entities = se6.getCollectionUserEntities(session, "")
for entity in entities:
print entity["normalized"], entity["type"], entity["hits"]
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
Updated about a year ago