Documentation
¶
Index ¶
- func DrawPoint(img *image.RGBA, point *types.Point, config *types.HighlightConfig)
- func ExtractFirstUniqueHTMLID(htmlFragment string) (string, error)
- func ExtractFirstUniqueXMLID(xmlFragment string) (string, error)
- func GenerateUniqueId(id string) string
- func GetStructFields(i any, fieldNames ...string) (structName string, fields map[string]reflect.Value, err error)
- func ParseElementSpec(result any) (*types.ElementSpec, error)
- func ParseFloatValue(v any) (float64, error)
- func ParseJSON(text string) (string, error)
- func ParseLocation(result any) (*types.Location, error)
- func ParseLocatorMap(result any) (map[string][]string, error)
- func ParseLocatorValidationResult(result any) (bool, error)
- func ParseLocators(result any) ([]string, error)
- func RemapPoint(point *types.Point, originalResolution *types.Resolution, ...) *types.Point
- func RemapPointInverse(point *types.Point, originalResolution *types.Resolution, ...) *types.Point
- func ScaleAndPadImage(img image.Image, targetResolution *types.Resolution) image.Image
- func SortRerankChunks(chunks []string, results []types.RerankResult) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrawPoint ¶
DrawPoint draws a point on an image. Parameters:
- img: The image to draw on
- point: The point to draw
- opts: The options for the draw
func ExtractFirstUniqueHTMLID ¶
ExtractFirstUniqueHTMLID finds and returns the first ID attribute from a top-level element in an HTML fragment. Parameters:
- htmlFragment: A string containing HTML markup to analyze
Returns:
- string: The first ID attribute value found
- error: If no ID is found or if HTML parsing fails
The function works by: 1. Wrapping the fragment in a root element for proper parsing 2. Creating a DOM tree from the HTML 3. Traversing the tree to find the first element with an ID attribute
func ExtractFirstUniqueXMLID ¶
ExtractFirstUniqueXMLID finds and returns the first ID attribute from a top-level element in an XML fragment. Parameters:
- xmlFragment: A string containing XML markup to analyze
Returns:
- string: The first ID attribute value found
- error: If no ID is found or if XML parsing fails
func GenerateUniqueId ¶
GenerateUniqueId generates a unique ID from a given string using MD5 hashing.
Parameters:
- id: The input string to generate a unique ID from
Returns:
- string: The unique ID generated from the input string
func GetStructFields ¶
func GetStructFields(i any, fieldNames ...string) (structName string, fields map[string]reflect.Value, err error)
GetStructFields returns the struct name and field values from an interface. Parameters:
- i: The interface to get the fields from
- fieldNames: The names of the fields to retrieve
Returns:
- string: The name of the struct
- map[string]reflect.Value: A map of field names to their reflected values
- error: An error if the interface is not a struct
func ParseElementSpec ¶
func ParseElementSpec(result any) (*types.ElementSpec, error)
ParseElementSpec parses the result of a minified DOM into an ElementSpec. Parameters:
- result: The result of a minified DOM
Returns:
- *types.ElementSpec: The parsed element spec
- error: Any error that occurred during the parsing
func ParseFloatValue ¶
ParseFloatValue tries to parse the given value to a float64.
Parameters:
- v: The value to parse
Returns:
- float64: The parsed value
- error: An error if the given value is not a float64, int, or string
func ParseJSON ¶
ParseJSON parses a JSON string from a text string and repairs it if possible. Parameters:
- text: The text to parse
Returns:
- string: The parsed JSON
- error: Any error that occurred during the parsing
func ParseLocation ¶
ParseLocation parses the result of a location into a Location. Parameters:
- result: The result of a location
Returns:
- *types.Location: The parsed location
- error: Any error that occurred during the parsing
func ParseLocatorMap ¶
ParseLocatorMap parses the result of a locator map into a map of string slices. Parameters:
- result: The result of a locator map
Returns:
- map[string][]string: The parsed locator map
- error: Any error that occurred during the parsing
func ParseLocators ¶
ParseLocators parses the result of a locators into a slice of strings. Parameters:
- result: The result of a locators
Returns:
- []string: The parsed locators
- error: Any error that occurred during the parsing
func RemapPoint ¶
func RemapPoint(point *types.Point, originalResolution *types.Resolution, targetResolution *types.Resolution) *types.Point
RemapPoint maps a point from the padded image coordinates back to the original image coordinates.
Parameters:
- point: The point in the padded image (e.g., where the user clicked)
- originalResolution: The resolution of the original image
- targetResolution: The resolution of the target image
Returns:
- *types.Point: The remapped point in the original image's coordinates
func RemapPointInverse ¶
func RemapPointInverse(point *types.Point, originalResolution *types.Resolution, targetResolution *types.Resolution) *types.Point
RemapPointInverse maps a point from the original image coordinates to the padded image coordinates.
func ScaleAndPadImage ¶
ScaleAndPadImage scales an image while maintaining aspect ratio and adds off-white padding to fit the target resolution.
Parameters:
- input: The input image in bytes
- targetResolution: The target resolution
Returns:
- image.Image: The scaled and padded image
- error: Any error that occurred during the scaling and padding
func SortRerankChunks ¶
func SortRerankChunks(chunks []string, results []types.RerankResult) []string
SortRerankChunks reorders a list of text chunks based on their relevance scores. Parameters:
- chunks: Original array of text chunks to be sorted
- results: Array of RerankResult containing relevance scores and indices
Returns a new array containing only the valid chunks, ordered by their relevance scores. If no valid results are found, returns the original chunks array unchanged.
Types ¶
This section is empty.