---
title: "neighborsForString:maximumCount:maximumDistance:distanceType:"
framework: naturallanguage
role: symbol
role_heading: Instance Method
path: "naturallanguage/nlembedding/neighborsforstring:maximumcount:maximumdistance:distancetype:"
---

# neighborsForString:maximumCount:maximumDistance:distanceType:

Retrieves a limited number of strings, within a radius of a string, in the vocabulary.

## Declaration

```occ
- (NSArray<NSString *> *) neighborsForString:(NSString *) string maximumCount:(NSUInteger) maxCount maximumDistance:(NLDistance) maxDistance distanceType:(NLDistanceType) distanceType;
```

## Parameters

- `string`: A string in the embedding vocabulary.
- `maxCount`: The largest number of neighboring strings that the method can return in an array.
- `maxDistance`: The largest distance a neighbor can be from string.
- `distanceType`: A means of calculating distance that determines which formula the method uses to evaluate a neighbor’s distance from string.

## Return Value

Return Value An array of neighboring strings.

## See Also

### Finding strings and their distances in an embedding

- [neighborsForString:maximumCount:distanceType:](naturallanguage/nlembedding/neighborsforstring:maximumcount:distancetype:.md)
- [neighborsForVector:maximumCount:distanceType:](naturallanguage/nlembedding/neighborsforvector:maximumcount:distancetype:.md)
- [neighborsForVector:maximumCount:maximumDistance:distanceType:](naturallanguage/nlembedding/neighborsforvector:maximumcount:maximumdistance:distancetype:.md)
- [enumerateNeighborsForString:maximumCount:distanceType:usingBlock:](naturallanguage/nlembedding/enumerateneighborsforstring:maximumcount:distancetype:usingblock:.md)
- [enumerateNeighborsForString:maximumCount:maximumDistance:distanceType:usingBlock:](naturallanguage/nlembedding/enumerateneighborsforstring:maximumcount:maximumdistance:distancetype:usingblock:.md)
- [enumerateNeighborsForVector:maximumCount:distanceType:usingBlock:](naturallanguage/nlembedding/enumerateneighborsforvector:maximumcount:distancetype:usingblock:.md)
- [enumerateNeighborsForVector:maximumCount:maximumDistance:distanceType:usingBlock:](naturallanguage/nlembedding/enumerateneighborsforvector:maximumcount:maximumdistance:distancetype:usingblock:.md)
- [distanceBetweenString:andString:distanceType:](naturallanguage/nlembedding/distancebetweenstring:andstring:distancetype:.md)
- [NLDistance](naturallanguage/nldistance.md)
