Returns an iterator over string.split(). This is efficient in combination with cooccurrence(), since the string may be very long (e.g., Brown corpus).
(string, sep="\t\n\x0b\x0c\r ")
| 446 | #--- WORD CO-OCCURRENCE ---------------------------------------------------------------------------- |
| 447 | |
| 448 | def isplit(string, sep="\t\n\x0b\x0c\r "): |
| 449 | """ Returns an iterator over string.split(). |
| 450 | This is efficient in combination with cooccurrence(), |
| 451 | since the string may be very long (e.g., Brown corpus). |
| 452 | """ |
| 453 | a = [] |
| 454 | for ch in string: |
| 455 | if ch not in sep: |
| 456 | a.append(ch) |
| 457 | continue |
| 458 | if a: yield "".join(a); a=[] |
| 459 | if a: yield "".join(a) |
| 460 | |
| 461 | def cooccurrence(iterable, window=(-1,-1), match=lambda x: False, filter=lambda x: True, normalize=lambda x: x): |
| 462 | """ Returns the co-occurence matrix of terms in the given iterable |
nothing calls this directly
no test coverage detected
searching dependent graphs…