Skip to content

Commit 1b13d4d

Browse files
author
JW Wesson
committed
update readme and examples
1 parent 7ff1a60 commit 1b13d4d

File tree

4 files changed

+44
-13
lines changed

4 files changed

+44
-13
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,32 @@ For full code examples, see [here][examples].
4646
### Creating a `TxClient`
4747
This is the object that you will use to perform API calls. You create it with your account credentials and the `TxClient` makes the raw API calls for you. These credentials can be found in the [Tx Console][portal]. Be sure to select the correct `DataCenter` for your account.
4848
```java
49-
TxClient client = new TxClient("12345678", "abcdefghijklmnopqrstuvwxyz", DataCenter.US);
49+
TxClientSettings settings = new TxClientSettings();
50+
settings.AccountId = "12345678";
51+
settings.ServiceKey = "abcdefghijklmnopqrstuvwxyz";
52+
settings.DataCenter = DataCenter.US;
53+
TxClient client = new TxClient(settings);
5054
```
5155

5256
For self-hosted customers, you can create a `DataCenter` object with your custom URL using the constructor provided on that class.
5357

58+
### Using the various `TxClient` services
59+
The `TxClient` has the following services available:
60+
- `parser()`
61+
- `geocoder()`
62+
- `formatter()`
63+
- `skillsIntelligence()`
64+
- `searchMatchV1()`
65+
- `searchMatchV2()`
66+
67+
Each service exposes certain API functionality via its methods. For example, to parse a resume you would do something like:
68+
```java
69+
TxClient client;//created or injected however
70+
ParseResumeResponse parseResponse = client.parser().parseResume(...);
71+
```
72+
73+
For the complete list of methods on each service and their method signatures, check out our [online Javadoc][javadoc_url].
74+
5475
### Handling errors and the `TxException`
5576
Every call to any of the methods in the `TxClient` should be wrapped in a `try/catch` block. Any 4xx/5xx level errors will cause a `TxException` to be thrown. Sometimes these are a normal and expected part of the Tx API. For example, if you have a website where users upload resumes, sometimes a user will upload a scanned image as their resume. Textkernel does not process these, and will return a `422 Unprocessable Entity` response which will throw a `TxException`. You should handle any `TxException` in a way that makes sense in your application.
5677

examples/indexing/Create an Index and Add Documents.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@ import com.textkernel.tx.models.resume.ParsedResume;
88

99
public class ParsingExample {
1010
public static void main(String[] args) {
11-
TxClient client = new TxClient("12345678", "abcdefghijklmnopqrstuvwxyz", DataCenter.US);
11+
TxClientSettings settings = new TxClientSettings();
12+
settings.AccountId = "12345678";
13+
settings.ServiceKey = "abcdefghijklmnopqrstuvwxyz";
14+
settings.DataCenter = DataCenter.US;
15+
TxClient client = new TxClient(settings);
1216

1317
ParsedResume parsedResume1 = ...;//output from Resume Parser
1418
ParsedResume parsedResume2 = ...;//output from Resume Parser
1519

1620
String indexId = "myResumes";
1721

1822
try {
19-
client.createIndex(IndexType.Resume, indexId);
20-
client.indexDocument(parsedResume1, indexId, "resume-1", null);
21-
client.indexDocument(parsedResume2, indexId, "resume-2", null);
23+
client.searchMatchV1().createIndex(IndexType.Resume, indexId);
24+
client.searchMatchV1().indexDocument(parsedResume1, indexId, "resume-1", null);
25+
client.searchMatchV1().indexDocument(parsedResume2, indexId, "resume-2", null);
2226

2327
//if we get here, it was 200-OK and all operations succeeded
2428
System.out.println("Success!");

examples/parsing/Basic Parsing.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import java.time.format.DateTimeFormatter;
2121

2222
public class ParsingExample {
2323
public static void main(String[] args) throws IOException {
24-
TxClient client = new TxClient("12345678", "abcdefghijklmnopqrstuvwxyz", DataCenter.US);
24+
TxClientSettings settings = new TxClientSettings();
25+
settings.AccountId = "12345678";
26+
settings.ServiceKey = "abcdefghijklmnopqrstuvwxyz";
27+
settings.DataCenter = DataCenter.US;
28+
TxClient client = new TxClient(settings);
2529

2630
//A Document is an unparsed File (PDF, Word Doc, etc)
2731
Document doc = new Document("resume.docx");
@@ -31,7 +35,7 @@ public class ParsingExample {
3135
ParseRequest request = new ParseRequest(doc, new ParseOptions());
3236

3337
try {
34-
ParseResumeResponse response = client.parseResume(request);
38+
ParseResumeResponse response = client.parser().parseResume(request);
3539
//if we get here, it was 200-OK and all operations succeeded
3640

3741
//now we can use the response to output some of the data from the resume

examples/parsing/Parsing With Geocoding and Indexing.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ import com.textkernel.tx.exceptions.TxUsableResumeException;
77
import com.textkernel.tx.models.Document;
88
import com.textkernel.tx.models.api.geocoding.GeocodeOptions;
99
import com.textkernel.tx.models.api.geocoding.GeocodeProvider;
10-
import com.textkernel.tx.models.api.indexes.IndexSingleDocumentInfo;
10+
import com.textkernel.tx.models.api.indexes.IndexingOptionsGeneric;
1111
import com.textkernel.tx.models.api.parsing.ParseOptions;
1212
import com.textkernel.tx.models.api.parsing.ParseRequest;
1313
import com.textkernel.tx.models.api.parsing.ParseResumeResponse;
1414
import java.io.IOException;
1515

1616
public class ParsingExample {
1717
public static void main(String[] args) throws IOException {
18-
TxClient client = new TxClient("12345678", "abcdefghijklmnopqrstuvwxyz", DataCenter.US);
18+
TxClientSettings settings = new TxClientSettings();
19+
settings.AccountId = "12345678";
20+
settings.ServiceKey = "abcdefghijklmnopqrstuvwxyz";
21+
settings.DataCenter = DataCenter.US;
22+
TxClient client = new TxClient(settings);
1923

2024
//A Document is an unparsed File (PDF, Word Doc, etc)
2125
Document doc = new Document("resume.docx");
@@ -24,15 +28,13 @@ public class ParsingExample {
2428
options.GeocodeOptions = new GeocodeOptions();
2529
options.GeocodeOptions.IncludeGeocoding = true;
2630

27-
options.IndexingOptions = new IndexSingleDocumentInfo();
28-
options.IndexingOptions.IndexId = "myResumes";
29-
options.IndexingOptions.DocumentId = "abc-123";
31+
options.IndexingOptions = new IndexingOptionsGeneric("abc-123", "myResumes", null);
3032

3133
//create a request to send
3234
ParseRequest request = new ParseRequest(doc, options);
3335

3436
try {
35-
ParseResumeResponse response = client.parseResume(request);
37+
ParseResumeResponse response = client.parser().parseResume(request);
3638
//if we get here, it was 200-OK and all operations succeeded
3739

3840
System.out.println("Success!");

0 commit comments

Comments
 (0)