---
title: "vector(for:)"
framework: createml
role: symbol
role_heading: Instance Method
path: "createml/mlwordembedding/vector(for:)"
---

# vector(for:)

Accesses the vector associated with the given string in the vocabulary.

## Declaration

```swift
func vector(for text: String) -> [Double]?
```

## Parameters

- `text`: A string in the vocabulary.

## Return Value

Return Value The vector associated with the string if present in the word embedding; otherwise, nil.

## See Also

### Testing a word embedding

- [prediction(from:maxCount:maxDistance:distanceType:)](createml/mlwordembedding/prediction(from:maxcount:maxdistance:distancetype:).md)
- [distance(between:and:distanceType:)](createml/mlwordembedding/distance(between:and:distancetype:).md)
- [NLDistanceType](naturallanguage/nldistancetype.md)
- [contains(_:)](createml/mlwordembedding/contains(_:).md)
