mirror of
https://github.com/leon-ai/leon.git
synced 2024-12-26 02:04:08 +03:00
feat(tcp server): add Country information to City
This commit is contained in:
parent
166175192d
commit
64858ec6fe
@ -169,14 +169,15 @@ export default class NER {
|
||||
|
||||
if (spacyEntities.length > 0) {
|
||||
spacyEntities.forEach(({ entity, resolution }) => {
|
||||
const value = StringHelper.ucFirst(resolution.value)
|
||||
const spacyEntity = {
|
||||
[entity]: {
|
||||
options: {
|
||||
[resolution.value]: [StringHelper.ucFirst(resolution.value)]
|
||||
[resolution.value]: [value]
|
||||
}
|
||||
}
|
||||
}
|
||||
this.spacyData.set(`${entity}-${resolution.value}`, resolution)
|
||||
this.spacyData.set(`${entity}-${value}`, resolution)
|
||||
|
||||
MODEL_LOADER.mainNLPContainer.addEntities(spacyEntity, BRAIN.lang)
|
||||
})
|
||||
|
@ -386,26 +386,27 @@ interface SpacyEntity<
|
||||
entity: T
|
||||
}
|
||||
|
||||
interface SpacyLocationCountryData {
|
||||
name: string
|
||||
iso: string
|
||||
iso3: string
|
||||
isonumeric: number
|
||||
continentcode: string
|
||||
capital: string
|
||||
population: number
|
||||
tld: string
|
||||
currencycode: string
|
||||
currencyname: string
|
||||
phone: string
|
||||
languages: string
|
||||
neighbours: string
|
||||
}
|
||||
export interface SpacyLocationCountryEntity
|
||||
extends SpacyEntity<
|
||||
'location:country',
|
||||
{
|
||||
value: string
|
||||
data: {
|
||||
name: string
|
||||
iso: string
|
||||
iso3: string
|
||||
isonumeric: number
|
||||
continentcode: string
|
||||
capital: string
|
||||
population: number
|
||||
tld: string
|
||||
currencycode: string
|
||||
currencyname: string
|
||||
phone: string
|
||||
languages: string
|
||||
neighbours: string
|
||||
}
|
||||
data: SpacyLocationCountryData
|
||||
}
|
||||
> {}
|
||||
export interface SpacyLocationCityEntity
|
||||
@ -419,6 +420,7 @@ export interface SpacyLocationCityEntity
|
||||
latitude: number
|
||||
longitude: number
|
||||
countrycode: string
|
||||
country: SpacyLocationCountryData
|
||||
population: number
|
||||
alternatenames: string[]
|
||||
time_zone: {
|
||||
|
@ -12,7 +12,7 @@ export const run: ActionFunction = async function (params) {
|
||||
}
|
||||
}
|
||||
|
||||
if (cityEntity == null) {
|
||||
if (cityEntity == null || cityEntity.resolution.data == null) {
|
||||
return await leon.answer({
|
||||
key: 'city_not_found'
|
||||
})
|
||||
@ -33,7 +33,7 @@ export const run: ActionFunction = async function (params) {
|
||||
minutes: zeroPad(currentDate.getMinutes()),
|
||||
seconds: zeroPad(currentDate.getSeconds()),
|
||||
city: cityEntity.resolution.data.name,
|
||||
country: time_zone.country_code
|
||||
country: cityEntity.resolution.data.country.name
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -104,6 +104,12 @@ def extract_spacy_entities(utterance):
|
||||
entity += ':city'
|
||||
resolution['data'] = cities[city]
|
||||
resolution['data']['time_zone'] = get_time_zone_data(cities[city]['timezone'])
|
||||
|
||||
for country in countries:
|
||||
if countries[country]['iso'] == cities[city]['countrycode']:
|
||||
resolution['data']['country'] = countries[country]
|
||||
break
|
||||
|
||||
break
|
||||
|
||||
entities.append({
|
||||
|
Loading…
Reference in New Issue
Block a user