Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>All the commentators above are correct of course: A hashtag without spaces or other clear separators between the words (especially in English) is often ambiguous and cannot be parsed correctly in all cases.</p> <p>However, the idea of the word list is rather simple to implement and might yield useful (albeit sometimes wrong) results nevertheless, so I implemented a quick version of that:</p> <pre><code>wordList = '''awesome day of my life because i am great something some thing things unclear sun clear'''.split() wordOr = '|'.join(wordList) def splitHashTag(hashTag): for wordSequence in re.findall('(?:' + wordOr + ')+', hashTag): print ':', wordSequence for word in re.findall(wordOr, wordSequence): print word, print for hashTag in '''awesome-dayofmylife iamgreat something somethingsunclear'''.split(): print '###', hashTag splitHashTag(hashTag) </code></pre> <p>This prints:</p> <pre><code>### awesome-dayofmylife : awesome awesome : dayofmylife day of my life ### iamgreat : iamgreat i am great ### something : something something ### somethingsunclear : somethingsunclear something sun clear </code></pre> <p>And as you see it falls into the trap qstebom has set for it ;-)</p> <p>EDIT:</p> <p>Some explanations of the code above:</p> <p>The variable <code>wordOr</code> contains a string of all words, separated by a pipe symbol (<code>|</code>). In regular expressions that means "one of these words".</p> <p>The first <code>findall</code> gets a pattern which means "a sequence of one or more of these words", so it matches things like "dayofmylife". The <code>findall</code> finds all these sequences, so I iterate over them (<code>for wordSequence in …</code>). For each word sequence then I search each single word (also using <code>findall</code>) in the sequence and print that word.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload