Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text 2 Measurements docs and GitHub action #88

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/publish-libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish to npm

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 14
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm install

- name: Build
run: npx nx build text-2-measurements

- name: Test
run: npx nx test text-2-measurements

- name: Publish
run: npx nx npm publish text-2-measurements
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ Thumbs.db
# Next.js
.next
.idea/
/.env
.env


# Ignore Smart Connections folder because embeddings file is large and updated frequently
.smart-connections
/.obsidian/
/.obsidian/
57 changes: 57 additions & 0 deletions libs/text-2-measurements/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Text2Measurements - Diet, Treatment, and Symptom Tracking with NLP

This library provides a way to convert natural language inputs into structured data about diet, treatment, and symptom tracking. It parses the user input, and can handle a wide range of inputs related to what the user ate, what treatments they took, and how severe their symptoms were.

## Features

- Converts complex linguistic inputs into a structured JSON format.
- Handles a variety of measurement units and variable categories.
- Can handle a wide range of diet, treatment, and symptom tracking statements.

## Installation

Clone this repository and navigate to the project root. Install the dependencies with npm:

```bash
yarn install
```

## Usage

### Processing a Single Statement

```typescript
import { processStatement } from './text-2-measurements';
const result = await processStatement("I ate a bowl of oatmeal for breakfast.");
```

### Processing Multiple Statements

```typescript
import { processStatements } from './text-2-measurements';
const results = await processStatements([
"I ate a bowl of oatmeal for breakfast.",
"Took 500mg of Paracetamol at 10 AM.",
"Experienced a headache around midday, severity was 3 out of 5."
]);
```

## Testing

To run the tests, execute:

```bash
npm run test
```

## Contributing

Contributions are welcome. Please open an issue or submit a pull request.

## License

This project is licensed under the MIT License.

## Contact

Please open an issue in this repository if you have any questions or need further guidance.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"regenerator-runtime": "0.13.7",
"rimraf": "^3.0.2",
"tslib": "^2.3.0",
"typechat": "^0.0.10",
"underscore.string": "^3.3.6"
},
"devDependencies": {
Expand Down Expand Up @@ -75,6 +76,7 @@
"fast-glob": "^3.2.12",
"jest": "29.4.3",
"jest-environment-jsdom": "29.4.3",
"jest-environment-node": "^29.4.1",
"jsonc-eslint-parser": "^2.1.0",
"nx": "15.9.2",
"openai": "^3.2.1",
Expand All @@ -85,4 +87,3 @@
"typescript": "5.1.6"
}
}

1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
],
"@curedao/sdk-typescript-node": ["libs/sdk-typescript-node/src/index.ts"],
"@curedao/test-helpers": ["libs/test-helpers/src/index.ts"],
"@curedao/text-2-measurements": ["libs/text-2-measurements/src/index.ts"],
"@curedao/url-helper": ["libs/url-helper/src/index.ts"]
}
},
Expand Down
115 changes: 113 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2558,6 +2558,16 @@
"@types/node" "*"
jest-mock "^29.5.0"

"@jest/environment@^29.6.1":
version "29.6.1"
resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.6.1.tgz#ee358fff2f68168394b4a50f18c68278a21fe82f"
integrity sha512-RMMXx4ws+Gbvw3DfLSuo2cfQlK7IwGbpuEWXCqyYDcqYTI+9Ju3a5hDnXaxjNsa6uKh9PQF2v+qg+RLe63tz5A==
dependencies:
"@jest/fake-timers" "^29.6.1"
"@jest/types" "^29.6.1"
"@types/node" "*"
jest-mock "^29.6.1"

"@jest/expect-utils@^28.1.3":
version "28.1.3"
resolved "https://registry.yarnpkg.com/@jest/expect-utils/-/expect-utils-28.1.3.tgz#58561ce5db7cd253a7edddbc051fb39dda50f525"
Expand Down Expand Up @@ -2612,6 +2622,18 @@
jest-mock "^29.5.0"
jest-util "^29.5.0"

"@jest/fake-timers@^29.6.1":
version "29.6.1"
resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-29.6.1.tgz#c773efddbc61e1d2efcccac008139f621de57c69"
integrity sha512-RdgHgbXyosCDMVYmj7lLpUwXA4c69vcNzhrt69dJJdf8azUrpRh3ckFCaTPNjsEeRi27Cig0oKDGxy5j7hOgHg==
dependencies:
"@jest/types" "^29.6.1"
"@sinonjs/fake-timers" "^10.0.2"
"@types/node" "*"
jest-message-util "^29.6.1"
jest-mock "^29.6.1"
jest-util "^29.6.1"

"@jest/globals@^28.1.3":
version "28.1.3"
resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-28.1.3.tgz#a601d78ddc5fdef542728309894895b4a42dc333"
Expand Down Expand Up @@ -2706,6 +2728,13 @@
dependencies:
"@sinclair/typebox" "^0.25.16"

"@jest/schemas@^29.6.0":
version "29.6.0"
resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.0.tgz#0f4cb2c8e3dca80c135507ba5635a4fd755b0040"
integrity sha512-rxLjXyJBTL4LQeJW3aKo0M/+GkCOXsO+8i9Iu7eDb6KwtP65ayoDsitrdPBtujxQ88k4wI2FNYfa6TOGwSn6cQ==
dependencies:
"@sinclair/typebox" "^0.27.8"

"@jest/source-map@^28.1.2":
version "28.1.2"
resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-28.1.2.tgz#7fe832b172b497d6663cdff6c13b0a920e139e24"
Expand Down Expand Up @@ -2840,6 +2869,18 @@
"@types/yargs" "^17.0.8"
chalk "^4.0.0"

"@jest/types@^29.6.1":
version "29.6.1"
resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.6.1.tgz#ae79080278acff0a6af5eb49d063385aaa897bf2"
integrity sha512-tPKQNMPuXgvdOn2/Lg9HNfUvjYVGolt04Hp03f5hAk878uwOLikN+JzeLY0HcVgKgFl9Hs3EIqpu3WX27XNhnw==
dependencies:
"@jest/schemas" "^29.6.0"
"@types/istanbul-lib-coverage" "^2.0.0"
"@types/istanbul-reports" "^3.0.0"
"@types/node" "*"
"@types/yargs" "^17.0.8"
chalk "^4.0.0"

"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2":
version "0.3.3"
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098"
Expand Down Expand Up @@ -4205,6 +4246,11 @@
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.25.24.tgz#8c7688559979f7079aacaf31aa881c3aa410b718"
integrity sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ==

"@sinclair/typebox@^0.27.8":
version "0.27.8"
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e"
integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==

"@sindresorhus/is@^4.0.0":
version "4.6.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f"
Expand Down Expand Up @@ -6217,7 +6263,7 @@ [email protected]:
dependencies:
follow-redirects "^1.10.0"

[email protected], axios@^1.0.0, axios@^1.3.4:
[email protected], axios@^1.0.0, axios@^1.3.4, axios@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f"
integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==
Expand Down Expand Up @@ -11226,6 +11272,18 @@ jest-environment-node@^28.1.1, jest-environment-node@^28.1.3:
jest-mock "^28.1.3"
jest-util "^28.1.3"

jest-environment-node@^29.4.1:
version "29.6.1"
resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-29.6.1.tgz#08a122dece39e58bc388da815a2166c58b4abec6"
integrity sha512-ZNIfAiE+foBog24W+2caIldl4Irh8Lx1PUhg/GZ0odM1d/h2qORAsejiFc7zb+SEmYPn1yDZzEDSU5PmDkmVLQ==
dependencies:
"@jest/environment" "^29.6.1"
"@jest/fake-timers" "^29.6.1"
"@jest/types" "^29.6.1"
"@types/node" "*"
jest-mock "^29.6.1"
jest-util "^29.6.1"

jest-environment-node@^29.5.0:
version "29.5.0"
resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-29.5.0.tgz#f17219d0f0cc0e68e0727c58b792c040e332c967"
Expand Down Expand Up @@ -11352,6 +11410,21 @@ jest-message-util@^29.5.0:
slash "^3.0.0"
stack-utils "^2.0.3"

jest-message-util@^29.6.1:
version "29.6.1"
resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-29.6.1.tgz#d0b21d87f117e1b9e165e24f245befd2ff34ff8d"
integrity sha512-KoAW2zAmNSd3Gk88uJ56qXUWbFk787QKmjjJVOjtGFmmGSZgDBrlIL4AfQw1xyMYPNVD7dNInfIbur9B2rd/wQ==
dependencies:
"@babel/code-frame" "^7.12.13"
"@jest/types" "^29.6.1"
"@types/stack-utils" "^2.0.0"
chalk "^4.0.0"
graceful-fs "^4.2.9"
micromatch "^4.0.4"
pretty-format "^29.6.1"
slash "^3.0.0"
stack-utils "^2.0.3"

jest-mock@^28.1.3:
version "28.1.3"
resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-28.1.3.tgz#d4e9b1fc838bea595c77ab73672ebf513ab249da"
Expand All @@ -11369,6 +11442,15 @@ jest-mock@^29.4.3, jest-mock@^29.5.0:
"@types/node" "*"
jest-util "^29.5.0"

jest-mock@^29.6.1:
version "29.6.1"
resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.6.1.tgz#049ee26aea8cbf54c764af649070910607316517"
integrity sha512-brovyV9HBkjXAEdRooaTQK42n8usKoSRR3gihzUpYeV/vwqgSoNfrksO7UfSACnPmxasO/8TmHM3w9Hp3G1dgw==
dependencies:
"@jest/types" "^29.6.1"
"@types/node" "*"
jest-util "^29.6.1"

jest-pnp-resolver@^1.2.2:
version "1.2.3"
resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e"
Expand Down Expand Up @@ -11641,6 +11723,18 @@ jest-util@^29.0.0, jest-util@^29.4.3, jest-util@^29.5.0:
graceful-fs "^4.2.9"
picomatch "^2.2.3"

jest-util@^29.6.1:
version "29.6.1"
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.6.1.tgz#c9e29a87a6edbf1e39e6dee2b4689b8a146679cb"
integrity sha512-NRFCcjc+/uO3ijUVyNOQJluf8PtGCe/W6cix36+M3cTFgiYqFOOW5MgN4JOOcvbUhcKTYVd1CvHz/LWi8d16Mg==
dependencies:
"@jest/types" "^29.6.1"
"@types/node" "*"
chalk "^4.0.0"
ci-info "^3.2.0"
graceful-fs "^4.2.9"
picomatch "^2.2.3"

jest-validate@^28.1.1, jest-validate@^28.1.3:
version "28.1.3"
resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-28.1.3.tgz#e322267fd5e7c64cea4629612c357bbda96229df"
Expand Down Expand Up @@ -14258,6 +14352,15 @@ pretty-format@^29.0.0, pretty-format@^29.5.0:
ansi-styles "^5.0.0"
react-is "^18.0.0"

pretty-format@^29.6.1:
version "29.6.1"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.6.1.tgz#ec838c288850b7c4f9090b867c2d4f4edbfb0f3e"
integrity sha512-7jRj+yXO0W7e4/tSJKoR7HRIHLPPjtNaUGG2xxKQnGvPNRkgWcQ0AZX6P4KBRJN4FcTBWb3sa7DVUJmocYuoog==
dependencies:
"@jest/schemas" "^29.6.0"
ansi-styles "^5.0.0"
react-is "^18.0.0"

pretty-time@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pretty-time/-/pretty-time-1.1.0.tgz#ffb7429afabb8535c346a34e41873adf3d74dd0e"
Expand Down Expand Up @@ -16549,6 +16652,14 @@ type-is@^1.6.14, type-is@^1.6.16, type-is@~1.6.18:
media-typer "0.3.0"
mime-types "~2.1.24"

typechat@^0.0.10:
version "0.0.10"
resolved "https://registry.yarnpkg.com/typechat/-/typechat-0.0.10.tgz#cb3c302cc218f078999c34eaf22aa6300dfb767b"
integrity sha512-iF/wLLaZWt4Q9WO8stpq3NKilAa4b8hnCD16EirdhaxzAYk80MCb1wnW1il7GhkMNJuhJUD38dxs8q4A/EdxJw==
dependencies:
axios "^1.4.0"
typescript "^5.1.3"

typed-array-length@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.4.tgz#89d83785e5c4098bec72e08b319651f0eac9c1bb"
Expand Down Expand Up @@ -16580,7 +16691,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.3.tgz#8d84219244a6b40b6fb2b33cc1c062f715b9e826"
integrity sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==

[email protected]:
[email protected], typescript@^5.1.3:
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
Expand Down
Loading