ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
WordLevelDiff Class Reference
+ Inheritance diagram for WordLevelDiff:
+ Collaboration diagram for WordLevelDiff:

Public Member Functions

 WordLevelDiff ($orig_lines, $closing_lines)
 
 _split ($lines)
 
 orig ()
 Get the original set of lines. More...
 
 closing ()
 Get the closing set of lines. More...
 
- Public Member Functions inherited from MappedDiff
 MappedDiff ($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines)
 Constructor. More...
 
- Public Member Functions inherited from Diff
 Diff ($from_lines, $to_lines)
 Constructor. More...
 
 reverse ()
 Compute reversed Diff. More...
 
 isEmpty ()
 Check for empty diff. More...
 
 lcs ()
 Compute the length of the Longest Common Subsequence (LCS). More...
 
 orig ()
 Get the original set of lines. More...
 
 closing ()
 Get the closing set of lines. More...
 
 _check ($from_lines, $to_lines)
 Check a Diff for validity. More...
 

Data Fields

const MAX_LINE_LENGTH = 10000
 
- Data Fields inherited from Diff
 $edits
 

Detailed Description

Definition at line 1632 of file class.WordLevelDiff.php.

Member Function Documentation

◆ _split()

WordLevelDiff::_split (   $lines)

Definition at line 1648 of file class.WordLevelDiff.php.

1648 {
1649 $fname = 'WordLevelDiff::_split';
1650 //wfProfileIn( $fname );
1651
1652 $words = array();
1653 $stripped = array();
1654 $first = true;
1655 foreach ( $lines as $line ) {
1656 # If the line is too long, just pretend the entire line is one big word
1657 # This prevents resource exhaustion problems
1658 if ( $first ) {
1659 $first = false;
1660 } else {
1661 $words[] = "\n";
1662 $stripped[] = "\n";
1663 }
1664 if ( strlen( $line ) > self::MAX_LINE_LENGTH ) {
1665 $words[] = $line;
1666 $stripped[] = $line;
1667 } else {
1668 $m = array();
1669 if (preg_match_all('/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs',
1670 $line, $m))
1671 {
1672 $words = array_merge( $words, $m[0] );
1673 $stripped = array_merge( $stripped, $m[1] );
1674 }
1675 }
1676 }
1677 //wfProfileOut( $fname );
1678 return array($words, $stripped);
1679 }

Referenced by WordLevelDiff().

+ Here is the caller graph for this function:

◆ closing()

WordLevelDiff::closing ( )

Get the closing set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

Returns
array The sequence of strings.

Reimplemented from Diff.

Definition at line 1697 of file class.WordLevelDiff.php.

1697 {
1698 $fname = 'WordLevelDiff::closing';
1699 //wfProfileIn( $fname );
1700 $closing = new _HWLDF_WordAccumulator;
1701
1702 foreach ($this->edits as $edit) {
1703 if ($edit->type == 'copy')
1704 $closing->addWords($edit->closing);
1705 elseif ($edit->closing)
1706 $closing->addWords($edit->closing, 'ins');
1707 }
1708 $lines = $closing->getLines();
1709 //wfProfileOut( $fname );
1710 return $lines;
1711 }
closing()
Get the closing set of lines.

References _HWLDF_WordAccumulator\addWords().

+ Here is the call graph for this function:

◆ orig()

WordLevelDiff::orig ( )

Get the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

Returns
array The original sequence of strings.

Reimplemented from Diff.

Definition at line 1681 of file class.WordLevelDiff.php.

1681 {
1682 $fname = 'WordLevelDiff::orig';
1683 //wfProfileIn( $fname );
1684 $orig = new _HWLDF_WordAccumulator;
1685
1686 foreach ($this->edits as $edit) {
1687 if ($edit->type == 'copy')
1688 $orig->addWords($edit->orig);
1689 elseif ($edit->orig)
1690 $orig->addWords($edit->orig, 'del');
1691 }
1692 $lines = $orig->getLines();
1693 //wfProfileOut( $fname );
1694 return $lines;
1695 }
orig()
Get the original set of lines.

References _HWLDF_WordAccumulator\addWords().

+ Here is the call graph for this function:

◆ WordLevelDiff()

WordLevelDiff::WordLevelDiff (   $orig_lines,
  $closing_lines 
)

Definition at line 1636 of file class.WordLevelDiff.php.

1636 {
1637 $fname = 'WordLevelDiff::WordLevelDiff';
1638 //wfProfileIn( $fname );
1639
1640 list ($orig_words, $orig_stripped) = $this->_split($orig_lines);
1641 list ($closing_words, $closing_stripped) = $this->_split($closing_lines);
1642
1643 $this->MappedDiff($orig_words, $closing_words,
1644 $orig_stripped, $closing_stripped);
1645 //wfProfileOut( $fname );
1646 }
MappedDiff($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines)
Constructor.

References _split(), and MappedDiff\MappedDiff().

+ Here is the call graph for this function:

Field Documentation

◆ MAX_LINE_LENGTH

const WordLevelDiff::MAX_LINE_LENGTH = 10000

Definition at line 1634 of file class.WordLevelDiff.php.


The documentation for this class was generated from the following file: