ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
WordLevelDiff Class Reference
+ Inheritance diagram for WordLevelDiff:
+ Collaboration diagram for WordLevelDiff:

Public Member Functions

 __construct ($orig_lines, $closing_lines)
 Constructor. More...
 
 _split ($lines)
 
 orig ()
 Get the original set of lines. More...
 
 closing ()
 Get the closing set of lines. More...
 
- Public Member Functions inherited from MappedDiff
 __construct ( $from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines)
 Constructor. More...
 
- Public Member Functions inherited from Diff
 __construct ($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 1786 of file class.WordLevelDiff.php.

Constructor & Destructor Documentation

◆ __construct()

WordLevelDiff::__construct (   $from_lines,
  $to_lines 
)

Constructor.

Computes diff between sequences of strings.

Parameters
$from_linesarray An array of strings. (Typically these are lines from a file.)
$to_linesarray An array of strings.

Reimplemented from Diff.

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

1791 {
1792 $fname = 'WordLevelDiff::WordLevelDiff';
1793 //wfProfileIn( $fname );
1794
1795 list($orig_words, $orig_stripped) = $this->_split($orig_lines);
1796 list($closing_words, $closing_stripped) = $this->_split($closing_lines);
1797
1799 $orig_words,
1800 $closing_words,
1801 $orig_stripped,
1802 $closing_stripped
1803 );
1804 //wfProfileOut( $fname );
1805 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), and _split().

+ Here is the call graph for this function:

Member Function Documentation

◆ _split()

WordLevelDiff::_split (   $lines)

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

1808 {
1809 $fname = 'WordLevelDiff::_split';
1810 //wfProfileIn( $fname );
1811
1812 $words = array();
1813 $stripped = array();
1814 $first = true;
1815 foreach ($lines as $line) {
1816 # If the line is too long, just pretend the entire line is one big word
1817 # This prevents resource exhaustion problems
1818 if ($first) {
1819 $first = false;
1820 } else {
1821 $words[] = "\n";
1822 $stripped[] = "\n";
1823 }
1824 if (strlen($line) > self::MAX_LINE_LENGTH) {
1825 $words[] = $line;
1826 $stripped[] = $line;
1827 } else {
1828 $m = array();
1829 if (preg_match_all(
1830 '/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs',
1831 $line,
1832 $m
1833 )) {
1834 $words = array_merge($words, $m[0]);
1835 $stripped = array_merge($stripped, $m[1]);
1836 }
1837 }
1838 }
1839 //wfProfileOut( $fname );
1840 return array($words, $stripped);
1841 }

Referenced by __construct().

+ 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 1861 of file class.WordLevelDiff.php.

1862 {
1863 $fname = 'WordLevelDiff::closing';
1864 //wfProfileIn( $fname );
1865 $closing = new _HWLDF_WordAccumulator;
1866
1867 foreach ($this->edits as $edit) {
1868 if ($edit->type == 'copy') {
1869 $closing->addWords($edit->closing);
1870 } elseif ($edit->closing) {
1871 $closing->addWords($edit->closing, 'ins');
1872 }
1873 }
1874 $lines = $closing->getLines();
1875 //wfProfileOut( $fname );
1876 return $lines;
1877 }

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 1843 of file class.WordLevelDiff.php.

1844 {
1845 $fname = 'WordLevelDiff::orig';
1846 //wfProfileIn( $fname );
1847 $orig = new _HWLDF_WordAccumulator;
1848
1849 foreach ($this->edits as $edit) {
1850 if ($edit->type == 'copy') {
1851 $orig->addWords($edit->orig);
1852 } elseif ($edit->orig) {
1853 $orig->addWords($edit->orig, 'del');
1854 }
1855 }
1856 $lines = $orig->getLines();
1857 //wfProfileOut( $fname );
1858 return $lines;
1859 }

References _HWLDF_WordAccumulator\addWords().

+ Here is the call graph for this function:

Field Documentation

◆ MAX_LINE_LENGTH

const WordLevelDiff::MAX_LINE_LENGTH = 10000

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


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