Answers.Body: <p>Yes, you could use clustering: Encode your features as a feature vector and feed it into a clustering algorithm (see <a href="https://onlinelibrary.wiley.com/doi/book/10.1002/9780470316801" rel="nofollow noreferrer">Finding Groups in Data</a> for a comprehensive description of these). You could use agglomerative clustering, which would give you groups of similar items; perhaps different level headings will be clustered together.</p>
  
  <p>Alternatively you could try a decision tree, something like <a href="https://en.wikipedia.org/wiki/ID3_algorithm" rel="nofollow noreferrer">ID3</a>, which would also be suitable; for this you'd need some annotated training data, though. But with a small amount of data you might solve it, if your items are clearly separated.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-17T16:59:59.283Z
Answers.LastActivityDate: 2020-04-17T16:59:59.283Z
Answers.UserDisplayName: Oliver Mason
Answers.Body: <p>Here im trying to answer, yes you could use clustering to parse pdf document. it similar of how the text mining works (you can read from <a href="https://guides.library.duke.edu/c.php?g=289707&amp;p=1930855" rel="nofollow noreferrer">here</a>). </p>
  
  <p>and for the clustering method, you could probably use K-NN methods, K-Means, agglomerative hierarchical clustering, and the other methods based on your preference. or u could use naive bayes alternatively. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-22T00:47:33.993Z
Answers.Text: Hi @Nicho Santoso, welcome to AI.SE, please give more details about your answer and don't just give an external link, add another explanation or summary about the content of the link so this answer will still be useful for future reader if the link is broken
Answers.UserDisplayName: malioboro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-21T13:27:44.577Z
Answers.LastActivityDate: 2020-04-21T13:27:44.577Z
Answers.UserDisplayName: Nicho Santoso
Body: <p>I'm a bit new to AI and I'd like to use some kind of clustering algorithm to solve a problem:</p>
  
  <p>I'm trying to parse pdf documents to get headings and titles. I can parse pdf to html and I'm then able to get some information on the lines of the document. I've identified some properties that can be useful for identifying the headings.</p>
  
  <ul>
  <li>font-size (int): of course it's quite usual that heading's font-size is bigger than normal text</li>
  <li>font-family (string): it's possible for headings to be  bold so font-family may differ</li>
  <li>left property (int): it's also possible that headings are aligned a bit to the right, there's an indentation that's not always there on normal paragraphs</li>
  <li>bonus boolean: I have identified some properties that I can combine to get a boolean value. When the boolean is set to true it can increase the chances of the paragraph being a heading.</li>
  </ul>
  
  <p>Of course, these are not rules that apply to all headings. Some headings may follow some of these but not all of them. It could also be possible that some 'normal' paragraphs follow all these points, but what I've seen is that, in general, those rules where what made headings different from paragraphs.</p>
  
  <p>With this information, is there a way of doing what I'm looking for? As I said, I'm new to AI even though I have a background in CS and mathematics. I thought clustering could be interesting since I'm trying to create 2 clusters: headings and normal paragraphs.</p>
  
  <p>What algorithm do you think might work for this use case. Should I look outside clustering?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-17T21:13:57.840Z
Comments.Text: Welcome to SE:AI!
Comments.UserDisplayName: DukeZhou
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-18T00:48:17.097Z
Comments.Text: Hi and welcome to AI SE :) I just a quick note. To attract more readers next time, try to provide a more descriptive title of your problem ;)
Comments.UserDisplayName: nbro
Tags: <machine-learning><natural-language-processing><unsupervised-learning><clustering>
Title: Could clustering be used to parse pdf documents to get headings and titles?
UserDisplayName: Wylex
ThreadText: # Could clustering be used to parse pdf documents to get headings and titles?
  
  (Asked by: username_0 on 2020-04-17)
  
  I'm a bit new to AI and I'd like to use some kind of clustering algorithm to solve a problem:
  
  I'm trying to parse pdf documents to get headings and titles. I can parse pdf to html and I'm then able to get some information on the lines of the document. I've identified some properties that can be useful for identifying the headings.
  
  * font-size (int): of course it's quite usual that heading's font-size is bigger than normal text
  * font-family (string): it's possible for headings to be bold so font-family may differ
  * left property (int): it's also possible that headings are aligned a bit to the right, there's an indentation that's not always there on normal paragraphs
  * bonus boolean: I have identified some properties that I can combine to get a boolean value. When the boolean is set to true it can increase the chances of the paragraph being a heading.
  
  Of course, these are not rules that apply to all headings. Some headings may follow some of these but not all of them. It could also be possible that some 'normal' paragraphs follow all these points, but what I've seen is that, in general, those rules where what made headings different from paragraphs.
  
  With this information, is there a way of doing what I'm looking for? As I said, I'm new to AI even though I have a background in CS and mathematics. I thought clustering could be interesting since I'm trying to create 2 clusters: headings and normal paragraphs.
  
  What algorithm do you think might work for this use case. Should I look outside clustering?
  
  **Tags:** machine-learning, natural-language-processing, unsupervised-learning, clustering
  
  > **Comments:**
  > **username_1**: Welcome to SE:AI!  
  > **username_2**: Hi and welcome to AI SE :) I just a quick note. To attract more readers next time, try to provide a more descriptive title of your problem ;)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2020-04-17. Score: 2
  
  Yes, you could use clustering: Encode your features as a feature vector and feed it into a clustering algorithm (see [Finding Groups in Data](https://onlinelibrary.wiley.com/doi/book/10.1002/9780470316801) for a comprehensive description of these). You could use agglomerative clustering, which would give you groups of similar items; perhaps different level headings will be clustered together.
  
  Alternatively you could try a decision tree, something like [ID3](https://en.wikipedia.org/wiki/ID3_algorithm), which would also be suitable; for this you'd need some annotated training data, though. But with a small amount of data you might solve it, if your items are clearly separated.
  
  
  ---
  
  ### Answer by username_4 on 2020-04-21. Score: 0
  
  Here im trying to answer, yes you could use clustering to parse pdf document. it similar of how the text mining works (you can read from [here](https://guides.library.duke.edu/c.php?g=289707&p=1930855)).
  
  and for the clustering method, you could probably use K-NN methods, K-Means, agglomerative hierarchical clustering, and the other methods based on your preference. or u could use naive bayes alternatively.
  
  > **Comments:**
  > **username_5**: Hi @username_4, welcome to AI.SE, please give more details about your answer and don't just give an external link, add another explanation or summary about the content of the link so this answer will still be useful for future reader if the link is broken  
  
  ---
  
  