...
If no suitable match is found, the function returns undefined.
Flow chart
...
Code Block | ||
---|---|---|
| ||
flowchart TD
Start --> DoesCommentTextExist{Does comment text exist on page?}
DoesCommentTextExist -->|Yes| DoesExactMatchExist{Does exact match before and after comment text?}
DoesCommentTextExist -->|No| UnmatchedCommentSection[Unmatched Comment Section]
DoesExactMatchExist -->|Yes| AttachComment[Attach Comment To This ADF Node]
DoesExactMatchExist -->|No| CalculateLevenshtein
subgraph WholeBeforeAfter
CalculateLevenshtein[Calculate Levenshtein Distance Between Before and After text] --> SortByMinimumDistance[Sort by minimum distance]
SortByMinimumDistance --> IsFirstItemMinimumDistanceUnder40{Is first item minimum distance under 40 changes?}
end
IsFirstItemMinimumDistanceUnder40 -->|Yes| AttachComment
IsFirstItemMinimumDistanceUnder40 -->|No| GetXWordsBeforeAfterComment[Get X Words before and after comment]
subgraph WordsBeforeAfter
GetXWordsBeforeAfterComment --> TrimBeforeAndAfterToSameLength
TrimBeforeAndAfterToSameLength --> CalculateWordsLevenshtein
CalculateWordsLevenshtein --> IsDistanceLessThan50percentCharacters{IsDistanceLessThan50percentCharacters}
IsDistanceLessThan50percentCharacters -->|Yes| AddToChecks
IsDistanceLessThan50percentCharacters -->|Yes| CalculateWordsLevenshtein
IsDistanceLessThan50percentCharacters -->|No| CalculateWordsLevenshtein
AddToChecks --> SortByWordsMinimumDistance
SortByWordsMinimumDistance --> IsThereAnyItems{IsThereAnyItems}
end
IsThereAnyItems -->|Yes| AttachComment
IsThereAnyItems -->|No| UnmatchedCommentSection |