An open API service indexing awesome lists of open source software.

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

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
}
```