feat: some experiments
This commit is contained in:
@@ -16,19 +16,19 @@ import (
|
||||
func DetectType(markdownContent string) (string, error) {
|
||||
defaultSchemaContent, err := registry.GetTemplate("_default")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not get schema: %w", err)
|
||||
return "", fmt.Errorf("could not get schema -> %w", err)
|
||||
}
|
||||
|
||||
defaultSchema, err := template.CompileTemplate(defaultSchemaContent)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to compile template: %w", err)
|
||||
return "", fmt.Errorf("failed to compile template -> %w", err)
|
||||
}
|
||||
|
||||
blocks := matcher.MatchBlocksFuzzy(markdownContent, defaultSchema, 0.3)
|
||||
|
||||
result, err := decoders.Parse(blocks)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to parse blocks: %w", err)
|
||||
return "", fmt.Errorf("failed to parse blocks -> %w", err)
|
||||
}
|
||||
|
||||
if result, ok := result.(map[string]any); ok {
|
||||
@@ -45,7 +45,7 @@ func MatchBlocks(markdownContent, templateContent string) ([]matcher.Block, erro
|
||||
|
||||
tpl, err := template.CompileTemplate(templateContent)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to compile template: %w", err)
|
||||
return nil, fmt.Errorf("failed to compile template -> %w", err)
|
||||
}
|
||||
|
||||
return matcher.MatchBlocksFuzzy(markdownContent, tpl, 0.3), nil
|
||||
@@ -59,21 +59,21 @@ func ParseFile(markdownContent string) (any, error) {
|
||||
|
||||
contentType, err := DetectType(markdownContent)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not detect type: %w", err)
|
||||
return nil, fmt.Errorf("could not detect type -> %w", err)
|
||||
}
|
||||
timings["detect_type"] = time.Since(startDetectType).Milliseconds()
|
||||
|
||||
startGetTemplate := time.Now()
|
||||
templateContent, err := registry.GetTemplate(contentType)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get schema: %w", err)
|
||||
return nil, fmt.Errorf("could not get schema -> %w", err)
|
||||
}
|
||||
timings["get_template"] = time.Since(startGetTemplate).Milliseconds()
|
||||
|
||||
startTemplate := time.Now()
|
||||
tpl, err := template.CompileTemplate(templateContent)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to compile template: %w", err)
|
||||
return nil, fmt.Errorf("failed to compile template -> %w", err)
|
||||
}
|
||||
timings["template_compilation"] = time.Since(startTemplate).Milliseconds()
|
||||
|
||||
@@ -82,7 +82,7 @@ func ParseFile(markdownContent string) (any, error) {
|
||||
|
||||
result, err := decoders.Parse(blocks)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse blocks: %w", err)
|
||||
return nil, fmt.Errorf("failed to parse blocks -> %w", err)
|
||||
}
|
||||
timings["markdown_parsing"] = time.Since(startMarkdown).Milliseconds()
|
||||
|
||||
@@ -102,7 +102,7 @@ func ParseFileWithTemplate(markdownContent string, templateContent string) (any,
|
||||
|
||||
tpl, err := template.CompileTemplate(templateContent)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to compile template: %w", err)
|
||||
return nil, fmt.Errorf("failed to compile template -> %w", err)
|
||||
}
|
||||
timings["template_compilation"] = time.Since(startTemplate).Milliseconds()
|
||||
|
||||
@@ -111,7 +111,7 @@ func ParseFileWithTemplate(markdownContent string, templateContent string) (any,
|
||||
|
||||
result, err := decoders.Parse(blocks)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse blocks: %w", err)
|
||||
return nil, fmt.Errorf("failed to parse blocks -> %w", err)
|
||||
}
|
||||
timings["markdown_parsing"] = time.Since(startMarkdown).Milliseconds()
|
||||
|
||||
|
Reference in New Issue
Block a user