tokenClassifyResponseToEntities converts the wire-format response into the value type consumed by callers. Extracted so the conversion can be unit-tested without a real backend (see token_classify_test.go).
(resp *pb.TokenClassifyResponse)
| 130 | // the value type consumed by callers. Extracted so the conversion can be |
| 131 | // unit-tested without a real backend (see token_classify_test.go). |
| 132 | func tokenClassifyResponseToEntities(resp *pb.TokenClassifyResponse) []TokenEntity { |
| 133 | if resp == nil { |
| 134 | return nil |
| 135 | } |
| 136 | out := make([]TokenEntity, 0, len(resp.Entities)) |
| 137 | for _, e := range resp.Entities { |
| 138 | if e == nil { |
| 139 | continue |
| 140 | } |
| 141 | out = append(out, TokenEntity{ |
| 142 | Group: e.EntityGroup, |
| 143 | Start: int(e.Start), |
| 144 | End: int(e.End), |
| 145 | Score: e.Score, |
| 146 | Text: e.Text, |
| 147 | }) |
| 148 | } |
| 149 | return out |
| 150 | } |
no outgoing calls
no test coverage detected