Skip to content

Commit 02ee6fe

Browse files
authored
Merge pull request #451 from impresso/develop
Release v3.0.5
2 parents 34873da + 71c14d9 commit 02ee6fe

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

src/schema/schemas/ContentItem.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"items": { "type": "string" }
111111
},
112112
"collections": {
113-
"oneOf": [
113+
"anyOf": [
114114
{ "type": "array", "items": { "type": "string" } },
115115
{ "type": "array", "items": { "$ref": "./Collection.json" } }
116116
]

src/schema/schemas/ImpressoNerRequest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
"minLength": 1,
1111
"maxLength": 3999,
1212
"description": "Text to be processed for named entity recognition"
13+
},
14+
"method": {
15+
"type": "string",
16+
"enum": ["ner", "ner-nel", "nel"],
17+
"default": "ner",
18+
"description": "NER method to be used: `ner` (default), `ner-nel` (named entity recognition with named entity linking) and `nel` (linking only - enclose entities in [START] [END] tags)."
1319
}
1420
},
1521
"required": ["text"]

src/services/impresso-ner/impresso-ner.class.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import axios, { AxiosResponse } from 'axios'
33

44
export interface RequestPayload {
55
text: string
6+
method: 'ner' | 'ner-nel'
67
}
78

89
interface DownstreamRequestBody {
@@ -93,20 +94,25 @@ export interface ImpressoNerResponse {
9394
}
9495

9596
export interface ImpressoNerServiceOptions {
96-
impressoNerServiceUrl: string
97+
impressoNerServiceBaseUrl: string
9798
}
9899

100+
const MethodToUrl = { ner: 'ner', 'ner-nel': 'ner-nel', nel: 'nel' }
101+
99102
export class ImpressoNerService {
100-
url: string
103+
baseUrl: string
101104

102105
constructor(options: ImpressoNerServiceOptions) {
103-
this.url = options.impressoNerServiceUrl
106+
this.baseUrl = options.impressoNerServiceBaseUrl
104107
}
105108

106109
async create(data: RequestPayload, params: Params) {
107-
const { text } = data
110+
const { text, method } = data
111+
112+
const url = `${this.baseUrl}/${MethodToUrl[method]}/`
113+
108114
const response = await axios.post<DownstreamResponse, AxiosResponse<DownstreamResponse>, DownstreamRequestBody>(
109-
this.url,
115+
url,
110116
{ data: text }
111117
)
112118
if (response.status !== 200) {

src/services/impresso-ner/impresso-ner.schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import type { ServiceSwaggerOptions } from 'feathers-swagger'
22
import { getRequestBodyContent, getStandardResponses } from '../../util/openapi'
33

44
export const docs: ServiceSwaggerOptions = {
5-
description: 'Impresso Named Entity Recognition',
5+
description: 'Various tools',
66
securities: ['create'],
77
operations: {
88
create: {
99
operationId: 'performNer',
10-
description: 'Perform Named Entity Recognition of a text',
10+
description: 'Perform named entity recognition (and optional named entity linking) of a text',
1111
requestBody: {
1212
content: getRequestBodyContent('ImpressoNerRequest'),
1313
},

src/services/impresso-ner/impresso-ner.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import hooks from './impresso-ner.hooks'
66
import { docs } from './impresso-ner.schema'
77

88
export default (app: ImpressoApplication) => {
9-
const url = app.get('impressoNerServiceUrl') ?? 'https://impresso-annotation.epfl.ch/api/ner/'
10-
const service = new ImpressoNerService({ impressoNerServiceUrl: url })
9+
const url = app.get('impressoNerServiceUrl') ?? 'https://impresso-annotation.epfl.ch/api'
10+
const service = new ImpressoNerService({ impressoNerServiceBaseUrl: url })
1111

1212
app.use('/tools/ner', service, {
1313
events: [],

0 commit comments

Comments
 (0)