-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity-extractor-test.js
54 lines (40 loc) · 1.4 KB
/
entity-extractor-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const EntityExtractor = require('./entity-extractor');
const entityExtractor = new EntityExtractor();
async function testIt(){
let entities = await entityExtractor.analyze("");
console.log('Entities:');
entities.forEach(entity => {
console.log(entity.name);
console.log(` - Type: ${entity.type}, Salience: ${entity.salience}`);
if (entity.metadata && entity.metadata.wikipedia_url) {
console.log(` - Wikipedia URL: ${entity.metadata.wikipedia_url}`);
}
});
//return result;
}
/*
// Imports the Google Cloud client library
const language = require('@google-cloud/language');
// Creates a client
const client = new language.LanguageServiceClient();
async function testIt(){
const text = 'The queen of England is coming!';
// Prepares a document, representing the provided text
const document = {
content: text,
type: 'PLAIN_TEXT',
};
// Detects entities in the document
const [result] = await client.analyzeEntities({document});
const entities = result.entities;
console.log('Entities:');
entities.forEach(entity => {
console.log(entity.name);
console.log(` - Type: ${entity.type}, Salience: ${entity.salience}`);
if (entity.metadata && entity.metadata.wikipedia_url) {
console.log(` - Wikipedia URL: ${entity.metadata.wikipedia_url}`);
}
});
}
*/
testIt();