Skip to content

Commit 0c1007b

Browse files
committed
refactor: unify API design style and enhance interoperability between packages
1 parent 0cce884 commit 0c1007b

50 files changed

Lines changed: 4298 additions & 711 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,74 @@
55

66
> Natural language processing tools, powered by Demo Macro.
77
8+
## Introduction
9+
10+
NLPTools is a comprehensive collection of natural language processing utilities designed to simplify text analysis, comparison, and manipulation. The project is structured as a monorepo with multiple specialized packages that can be used together or independently.
11+
12+
## Features
13+
14+
- **Text Similarity**: Multiple algorithms for measuring text similarity (Levenshtein, Jaccard, Cosine)
15+
- **Text Comparison**: Tools for comparing and finding differences between texts
16+
- **Text Segmentation**: Utilities for breaking text into paragraphs, sentences, phrases, and words
17+
- **Language Support**: Support for multiple languages with automatic language detection
18+
- **Modular Design**: Use only what you need with independent packages
19+
20+
## Installation
21+
22+
```bash
23+
# Install the main package with all utilities
24+
pnpm install @nlptools/nlptools
25+
26+
# Or install individual packages as needed
27+
pnpm install @nlptools/similarity
28+
pnpm install @nlptools/comparison
29+
pnpm install @nlptools/segmentation
30+
pnpm install @nlptools/core
31+
```
32+
33+
## Quick Start
34+
35+
```ts
36+
// Import from the main package
37+
import {
38+
createSimilarityMeasure,
39+
createComparator,
40+
createSegmenter,
41+
} from "@nlptools/nlptools";
42+
43+
// Calculate text similarity
44+
const similarity = createSimilarityMeasure("levenshtein").calculate(
45+
"Hello world",
46+
"Hello there",
47+
);
48+
console.log(`Similarity: ${similarity.similarity}`);
49+
50+
// Compare texts and get differences
51+
const diff = createComparator("diff").compare("Hello world", "Hello there");
52+
console.log(diff.differences);
53+
54+
// Segment text into sentences
55+
const sentences = createSegmenter("sentences").segment(
56+
"Hello world! How are you today?",
57+
);
58+
console.log(sentences.segments);
59+
```
60+
861
## Packages
962

10-
- [nlptools](./packages/nlptools/README.md)
11-
- [@nlptools/comparison](./packages/comparison/README.md)
12-
- [@nlptools/segmentation](./packages/segmentation/README.md)
13-
- [@nlptools/similarity](./packages/similarity/README.md)
63+
- [nlptools](./packages/nlptools/README.md) - Main package that includes all modules
64+
- [@nlptools/similarity](./packages/similarity/README.md) - Text similarity algorithms
65+
- [@nlptools/comparison](./packages/comparison/README.md) - Text comparison utilities
66+
- [@nlptools/segmentation](./packages/segmentation/README.md) - Text segmentation tools
67+
- [@nlptools/core](./packages/core/README.md) - Core utilities and interfaces
68+
69+
## Documentation
70+
71+
Each package contains detailed documentation and examples. See the individual package READMEs for more information.
72+
73+
## Contributing
74+
75+
Contributions are welcome! Please feel free to submit a Pull Request.
1476

1577
## License
1678

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"javascript": {
1010
"formatter": {
11-
"trailingComma": "es5"
11+
"trailingCommas": "es5"
1212
}
1313
}
1414
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"build": "pnpm -r prepack",
88
"dev": "pnpm -r prepack --stub",
9-
"check": "biome check . --apply-unsafe && biome format . --write",
9+
"check": "biome check . --write --unsafe && biome format . --write",
1010
"format": "prettier --write --list-different . --ignore-path .gitignore",
1111
"edge": "pnpm -r exec bump version",
1212
"release": "pnpm -r exec bump version -r patch",
@@ -38,5 +38,6 @@
3838
"@types/node": "22.5.3",
3939
"prettier": "3.3.3",
4040
"unbuild": "2.0.0"
41-
}
41+
},
42+
"packageManager": "pnpm@10.6.1+sha512.40ee09af407fa9fbb5fbfb8e1cb40fbb74c0af0c3e10e9224d7b53c7658528615b2c92450e74cfad91e3a2dcafe3ce4050d80bda71d757756d2ce2b66213e9a3"
4243
}

0 commit comments

Comments
 (0)