From 1d2cce5abec9b688966d3cc8852ac4ef9cf95abd Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 23 Sep 2025 08:41:58 -0300 Subject: [PATCH 1/2] Added actions --- .../extract-entities/extract-entities.mjs | 51 +++++++++ .../actions/match-names/match-names.mjs | 39 +++++++ .../actions/translate-name/translate-name.mjs | 35 ++++++ .../rosette_text_analytics/package.json | 2 +- .../rosette_text_analytics.app.mjs | 106 +++++++++++++++++- 5 files changed, 227 insertions(+), 6 deletions(-) create mode 100644 components/rosette_text_analytics/actions/extract-entities/extract-entities.mjs create mode 100644 components/rosette_text_analytics/actions/match-names/match-names.mjs create mode 100644 components/rosette_text_analytics/actions/translate-name/translate-name.mjs diff --git a/components/rosette_text_analytics/actions/extract-entities/extract-entities.mjs b/components/rosette_text_analytics/actions/extract-entities/extract-entities.mjs new file mode 100644 index 0000000000000..ce68a01a4ef79 --- /dev/null +++ b/components/rosette_text_analytics/actions/extract-entities/extract-entities.mjs @@ -0,0 +1,51 @@ +import app from "../../rosette_text_analytics.app.mjs"; + +export default { + key: "rosette_text_analytics-extract-entities", + name: "Extract Entities", + description: "Extract entities from content using Rosette. [See the documentation](https://documentation.babelstreet.com/analytics/text-analytics/entity-extractor/extract-entities)", + version: "0.0.1", + type: "action", + props: { + app, + content: { + propDefinition: [ + app, + "content", + ], + }, + calculateConfidence: { + propDefinition: [ + app, + "calculateConfidence", + ], + }, + calculateSalience: { + propDefinition: [ + app, + "calculateSalience", + ], + }, + includeDBpediaTypes: { + propDefinition: [ + app, + "includeDBpediaTypes", + ], + }, + }, + async run({ $ }) { + const response = await this.app.extractEntities({ + $, + data: { + content: this.content, + options: { + calculateConfidence: this.calculateConfidence, + calculateSalience: this.calculateSalience, + includeDBpediaTypes: this.includeDBpediaTypes, + }, + }, + }); + $.export("$summary", "Successfully extracted " + response.entities.length + " entities"); + return response; + }, +}; diff --git a/components/rosette_text_analytics/actions/match-names/match-names.mjs b/components/rosette_text_analytics/actions/match-names/match-names.mjs new file mode 100644 index 0000000000000..5d91e5add947c --- /dev/null +++ b/components/rosette_text_analytics/actions/match-names/match-names.mjs @@ -0,0 +1,39 @@ +import app from "../../rosette_text_analytics.app.mjs"; + +export default { + key: "rosette_text_analytics-match-names", + name: "Match Names", + description: "Compare two names using Rosette. [See the documentation](https://documentation.babelstreet.com/analytics/match-names/name-similarity/match-names)", + version: "0.0.1", + type: "action", + props: { + app, + nameOne: { + propDefinition: [ + app, + "nameOne", + ], + }, + nameTwo: { + propDefinition: [ + app, + "nameTwo", + ], + }, + }, + async run({ $ }) { + const response = await this.app.matchName({ + $, + data: { + name1: { + text: this.nameOne, + }, + name2: { + text: this.nameTwo, + }, + }, + }); + $.export("$summary", "Successfully compared names, resulting in a score of " + response.score); + return response; + }, +}; diff --git a/components/rosette_text_analytics/actions/translate-name/translate-name.mjs b/components/rosette_text_analytics/actions/translate-name/translate-name.mjs new file mode 100644 index 0000000000000..7e57f06c5bad2 --- /dev/null +++ b/components/rosette_text_analytics/actions/translate-name/translate-name.mjs @@ -0,0 +1,35 @@ +import app from "../../rosette_text_analytics.app.mjs"; + +export default { + key: "rosette_text_analytics-translate-name", + name: "Translate Name", + description: "Translate name using Rosette. [See the documentation](https://documentation.babelstreet.com/analytics/match-names/name-translation/translate-names)", + version: "0.0.1", + type: "action", + props: { + app, + name: { + propDefinition: [ + app, + "name", + ], + }, + targetLanguage: { + propDefinition: [ + app, + "targetLanguage", + ], + }, + }, + async run({ $ }) { + const response = await this.app.translateName({ + $, + data: { + name: this.name, + targetLanguage: this.targetLanguage, + }, + }); + $.export("$summary", "Successfully translated name with " + response.confidence + " confidence"); + return response; + }, +}; diff --git a/components/rosette_text_analytics/package.json b/components/rosette_text_analytics/package.json index 3a2550861116b..ad526de205786 100644 --- a/components/rosette_text_analytics/package.json +++ b/components/rosette_text_analytics/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/rosette_text_analytics", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Rosette Text Analytics Components", "main": "rosette_text_analytics.app.mjs", "keywords": [ diff --git a/components/rosette_text_analytics/rosette_text_analytics.app.mjs b/components/rosette_text_analytics/rosette_text_analytics.app.mjs index 97d451e23d4b3..aaf99009b773a 100644 --- a/components/rosette_text_analytics/rosette_text_analytics.app.mjs +++ b/components/rosette_text_analytics/rosette_text_analytics.app.mjs @@ -1,11 +1,107 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "rosette_text_analytics", - propDefinitions: {}, + propDefinitions: { + nameOne: { + type: "string", + label: "Name One", + description: "Primary name for comparison or translation", + }, + nameTwo: { + type: "string", + label: "Name Two", + description: "Secondary name for comparison", + }, + name: { + type: "string", + label: "Name", + description: "Name to be translated", + }, + targetLanguage: { + type: "string", + label: "Target Language", + description: "Target language code for translation or analysis", + async options() { + const response = await this.getLanguages(); + const languages = response.supportedLanguagePairs; + return languages.map(({ target }) => ({ + label: target.language, + value: target.language, + })); + }, + }, + content: { + type: "string", + label: "Content", + description: "Text content to extract entities from", + }, + calculateConfidence: { + type: "boolean", + label: "Calculate Confidence", + description: "Include confidence scores in entity extraction results", + optional: true, + }, + calculateSalience: { + type: "boolean", + label: "Calculate Salience", + description: "Include salience values indicating entity relevance", + optional: true, + }, + includeDBpediaTypes: { + type: "boolean", + label: "Include DBpedia Types", + description: "Include DBpedia types associated with extracted entities", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.rosette.com/rest"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + "X-RosetteAPI-Key": `${this.$auth.api_key}`, + ...headers, + }, + }); + }, + async matchName(args = {}) { + return this._makeRequest({ + path: "/v1/name-similarity", + method: "post", + ...args, + }); + }, + async translateName(args = {}) { + return this._makeRequest({ + path: "/v1/name-translation", + method: "post", + ...args, + }); + }, + async extractEntities(args = {}) { + return this._makeRequest({ + path: "/v1/entities", + method: "post", + ...args, + }); + }, + async getLanguages(args = {}) { + return this._makeRequest({ + path: "/v1/name-translation/supported-languages", + ...args, + }); }, }, -}; \ No newline at end of file +}; From edfa58a2ea6753f89062e7feafcd37d229dc339a Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 23 Sep 2025 08:51:14 -0300 Subject: [PATCH 2/2] Added actions --- components/rosette_text_analytics/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/rosette_text_analytics/package.json b/components/rosette_text_analytics/package.json index ad526de205786..7a12cdd905982 100644 --- a/components/rosette_text_analytics/package.json +++ b/components/rosette_text_analytics/package.json @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } }