Skip to content

Commit

Permalink
Merge branch 'master' into Linux-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennifer Oliver committed Jan 4, 2017
2 parents 2fb0b78 + 8aaea38 commit 578ba85
Show file tree
Hide file tree
Showing 642 changed files with 13,232 additions and 583 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export PATH=swift-3.0.2-RELEASE-ubuntu14.04/usr/bin:$PATH ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then rm Source/SupportingFiles/Credentials.swift ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then swift build ; fi
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then swift test ; fi
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then swift test ; fi
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Change Log
==========

## Version 0.12.0

_2016-12-22_

This release adds support for the Discovery service.

## Version 0.11.0

_2016-12-06_
Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ let package = Package(
Target(name: "AlchemyVisionV1", dependencies: [.Target(name: "RestKit")]),
Target(name: "ConversationV1", dependencies: [.Target(name: "RestKit")]),
Target(name: "DialogV1", dependencies: [.Target(name: "RestKit")]),
Target(name: "DiscoveryV1", dependencies: [.Target(name: "RestKit")]),
Target(name: "DocumentConversionV1", dependencies: [.Target(name: "RestKit")]),
Target(name: "LanguageTranslatorV2", dependencies: [.Target(name: "RestKit")]),
Target(name: "NaturalLanguageClassifierV1", dependencies: [.Target(name: "RestKit")]),
Expand Down
133 changes: 133 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ There are many resources to help you build your first cognitive application with
* [AlchemyData News](#alchemydata-news)
* [AlchemyLanguage](#alchemylanguage)
* [Conversation](#conversation)
* [Discovery] (#discovery)
* [Document Conversion](#document-conversion)
* [Language Translator](#language-translator)
* [Natural Language Classifier](#natural-language-classifier)
Expand Down Expand Up @@ -325,6 +326,138 @@ The following links provide more information about the IBM Conversation service:
* [IBM Watson Conversation - Service Page](http://www.ibm.com/watson/developercloud/conversation.html)
* [IBM Watson Conversation - Documentation](http://www.ibm.com/watson/developercloud/doc/conversation/overview.shtml)

## Discovery

The IBM Discovery Service allows for rapid automated ingestion and feature enrichment of unstructured data. Enrichments of documents ingested include concepts, relationship extraction and sentiment analysis through Natural Language Processing. With the IBM Discovery service you can take advantage of IBM Watson algorithms to take your unstructured data, enrich it, and query it to return the information you need from it.

The following example shows how to instantiate a Discivery object:

```swift
import DiscoveryV1

let username = "your-username-here"
let password = "your-password-here"
let version = "YYYY-MM-DD" // use today's date for the most recent version
let discovery = Discovery(username: username, password: password, version: version)
}
```
The following example demonstrates how to create a Discovery environment and collection with the default configuration, and add documents to the collection.

```swift
let failure = { (error: Error) in print(error) }

// Create and store the environment ID for you to access later:
var environmentID: String?
let environmentName = "your-environment-name-here"

discovery.createEnvironment(
withName: environmentName,
withSize: .zero,
withDescription: testDescription,
failure: failure)
{
environment in
self.environmentID = environment.environmentID
}

// Wait for the environment to be ready before creating a collection:
bool environmentReady = false
while (!environmentReady) {
discovery.getEnvironment(withName: environmentName, failure: failure)
{
environment in
if environment.status == "active" {
self.environmentReady = true
}
}
}

// Create a collection and store the collection ID for you to access later:
var collectionID: String?

let collectionName = "your-collection-name-here"
discovery.createCollection(
withEnvironmentID: environmentID!,
withName: collectionName,
withDescription: collectionDescription,
withConfigurationID: configurationID,
failure: failure)
{
collection in
self.collectionID = collection.collectionID
}

// Wait for the collection to be "available" before adding a document:
bool collectionReady = false
while (!collectionReady) {
discovery.listCollectionDetails(
withEnvironmentID: environmentID!,
withCollectionID: collectionID!,
failure: failWithError)
{
collection in
if collection.status == CollectionStatus.active {
self.collectionReady = true
}
}

// Add a document to the collection with the saved environment and collection ID:
guard let file = Bundle(for: type(of: self)).url(forResource: "your-Document-Name", withExtension: "document-type") else {
XCTFail("Unable to locate your-Document-Name.document-type")
return
}
discovery.addDocumentToCollection(
withEnvironmentID: environmentID!,
withCollectionID: collectionID!,
file: file,
failure: failWithError)
{
document in
NSLog(document)
}

```
The following example demonstrates how to perform a query on the Discovery instance using the `KennedySpeech.html` we have within our `DiscoveryV1Tests` folder:

```swift
/// String to search for within the documents.
let query = "United Nations"

/// Find the max sentiment score for entities within the enriched text.
let aggregation = "max(enriched_text.entities.sentiment.score)"

/// Specify which portion of the document hierarchy to return.
let returnHierarchies = "enriched_text.entities.sentiment,enriched_text.entities.text"

discovery.queryDocumentsInCollection(
withEnvironmentID: environmentID!,
withCollectionID: collectionID!,
withQuery: query,
withAggregation: aggregation,
return: returnHierarchies,
failure: failWithError)
{
queryResponse in
if let results = queryResponse.results {
for result in results {
if let entities = result.entities {
for entity in entities {
NSLog(entity)
}
}
}
}
}
```

The following links provide more information about the IBM Discovery service:

* [IBM Discovery - Service Page](http://www.ibm.com/watson/developercloud/discovery.html)
* [IBM Discovery - Documentation] (http://www.ibm.com/watson/developercloud/doc/discovery/)
* [IBM Discovery - API Reference](https://www.ibm.com/watson/developercloud/discovery/api/v1/)
* [IBM Discovery - API Explorer](https://watson-api-explorer.mybluemix.net/apis/discovery-v1)
* [IBM Discovery - Query Building](http://www.ibm.com/watson/developercloud/doc/discovery/query-reference.shtml#parameters)

## Document Conversion

The IBM Watson Document Conversion Service converts a single HTML, PDF, or Microsoft Word™ document. The input document is transformed into normalized HTML, plain text, or a set of JSON-formatted Answer units that can be used with other Watson services, like the Watson Retrieve and Rank Service.
Expand Down
Loading

0 comments on commit 578ba85

Please sign in to comment.