https://github.com/mitica/text-country
Finds country in text
https://github.com/mitica/text-country
country country-code extractor text text-country
Last synced: 11 months ago
JSON representation
Finds country in text
- Host: GitHub
- URL: https://github.com/mitica/text-country
- Owner: mitica
- Created: 2018-05-21T12:06:21.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-30T19:22:38.000Z (over 7 years ago)
- Last Synced: 2025-07-01T17:23:11.754Z (12 months ago)
- Topics: country, country-code, extractor, text, text-country
- Language: TypeScript
- Size: 570 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# text-country
Finds country in text.
## Usage
``` ts
import textCountry from 'text-country';
const lang = 'en';
const text = 'Ministry of Foreign Affairs of Moldova'; // Moldova => md
const results = textCountry(text, lang);
// [{ "country": "md", "rating": 1 }]
```
## API
### (text: string, lang: string, options?: Options): CountryRating[]
Returns a list of founded countries ordered by rating.
#### TS Types
```ts
type Options = {
// returns first found country
firstFound?: boolean
}
type CountryRating = {
country: string
rating: number
}
```