<p>What you're describing is known as <a href="https://en.wikipedia.org/wiki/Coreference#Coreference_resolution" rel="nofollow noreferrer">coreference resolution</a>. More specifically, this example is <a href="https://en.wikipedia.org/wiki/Anaphora_(linguistics)#Anaphora_resolution_%E2%80%93_centering_theory" rel="nofollow noreferrer">anaphora resolution</a>. The short answer is that this is an open research question and there is no well-established solution.</p>
<p>You mentioned <a href="https://github.com/huggingface" rel="nofollow noreferrer">Hugging Face</a> in your question. The <a href="https://spacy.io/universe/project/neuralcoref" rel="nofollow noreferrer">neuralcoref</a> module in spaCy is itself from Hugging Face (note the reflexive anaphor used for emphasis in this sentence). If you're not a spaCy kind of person, then there's also <a href="https://nlp.stanford.edu/software/dcoref.shtml" rel="nofollow noreferrer">Stanford's</a> <a href="https://stanfordnlp.github.io/CoreNLP/" rel="nofollow noreferrer">CoreNLP</a> in Java that has coreference resolution. A <a href="https://github.com/dasmith/stanford-corenlp-python" rel="nofollow noreferrer">Python wrapper</a> is also available.</p>
<p>I also wanted to address a couple other topics you mentioned. You are right in that they're all somewhat connected. But you need to scope down your goal/research question because what you're aiming to achieve is too difficult for a first task. Named entity recognition, constituency parsing, and sentiment analysis. Pick just one to focus on.</p>

CC BY-SA 4.0
2021-02-12T15:32:49.873Z
Thanks for your answer.  I'm new to this field so this information is very useful for my research.  I saw CoreNLP and was debating on using it.  I think I'll need to make some hybrid solution, which uses CoreNLP to analyize the subject, and some savvy rules to maintain track of the subject
johnny 5
CC BY-SA 4.0
2021-02-12T19:44:32.830Z
You're welcome! Part of the difficulty in getting start with NLP is understanding the correct terms to call things. One you know the right term you can often find useful answers.
CorruptedHeapScapeGoat
CC BY-SA 4.0
2021-02-12T02:06:52.683Z
2021-02-12T02:06:52.683Z
CorruptedHeapScapeGoat
<p>I'm working on Sentiment Analysis, using HuggingFace to perform sentiment analysis on articles</p>
<pre><code> classifier = pipeline('sentiment-analysis', model=&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;)
 classifier(['We are very happy to show you the  Transformers library.',  &quot;We hope you don't hate it.&quot;])
</code></pre>
<p>This returns</p>
<blockquote>
<p>label: POSITIVE, with score: 0.9998</p>
</blockquote>
<blockquote>
<p>label: NEGATIVE, with score: 0.5309</p>
</blockquote>
<p>Now I'm trying to understand how to keep track of a subject when performing the sentiment analysis.</p>
<p>Suppose I'm given a sentence like this.</p>
<blockquote>
<p>StackExchange is a great website. It helps users answer questions.  Hopefully, someone will help answer this question.</p>
</blockquote>
<p>I would like to keep track of the subject when performing sentiment analysis. In the example above, in the 2nd sentence 'it' refers to 'StackExchange'. I would like to be able to do track a subject between sentences.</p>
<p>Now, I could try to manually try to parse this by finding the verb and trying to figure find the phrase that comes before it. However, it doesn't sound like a very safe or accurate way to find the subject.</p>
<p>Alternatively, I could train similar to a Named Entity Recognition. However, finding a dataset for this is very hard, and training it would be very time-consuming.</p>
<p>How can I keep track of an entity within an article?</p>

<natural-language-processing><bert><sentiment-analysis>
How to keep track of the subject/entity in a sentence?
johnny 5
# How to keep track of the subject/entity in a sentence?

(Asked by: username_0 on 2021-02-11)

I'm working on Sentiment Analysis, using HuggingFace to perform sentiment analysis on articles
 classifier = pipeline('sentiment-analysis', model="nlptown/bert-base-multilingual-uncased-sentiment")
 classifier(['We are very happy to show you the  Transformers library.',  "We hope you don't hate it."])

This returns

label: POSITIVE, with score: 0.9998


label: NEGATIVE, with score: 0.5309

Now I'm trying to understand how to keep track of a subject when performing the sentiment analysis.
Suppose I'm given a sentence like this.

StackExchange is a great website. It helps users answer questions.  Hopefully, someone will help answer this question.

I would like to keep track of the subject when performing sentiment analysis. In the example above, in the 2nd sentence 'it' refers to 'StackExchange'. I would like to be able to do track a subject between sentences.
Now, I could try to manually try to parse this by finding the verb and trying to figure find the phrase that comes before it. However, it doesn't sound like a very safe or accurate way to find the subject.
Alternatively, I could train similar to a Named Entity Recognition. However, finding a dataset for this is very hard, and training it would be very time-consuming.
How can I keep track of an entity within an article?

**Tags:** natural-language-processing, bert, sentiment-analysis


---

## 1 answers

### Answer by username_1 on 2021-02-12. Score: 2 | Accepted answer

What you're describing is known as [coreference resolution](https://en.wikipedia.org/wiki/Coreference#Coreference_resolution). More specifically, this example is [anaphora resolution](https://en.wikipedia.org/wiki/Anaphora_(linguistics)#Anaphora_resolution_%E2%80%93_centering_theory). The short answer is that this is an open research question and there is no well-established solution.

You mentioned [Hugging Face](https://github.com/huggingface) in your question. The [neuralcoref](https://spacy.io/universe/project/neuralcoref) module in spaCy is itself from Hugging Face (note the reflexive anaphor used for emphasis in this sentence). If you're not a spaCy kind of person, then there's also [Stanford's](https://nlp.stanford.edu/software/dcoref.shtml) [CoreNLP](https://stanfordnlp.github.io/CoreNLP/) in Java that has coreference resolution. A [Python wrapper](https://github.com/dasmith/stanford-corenlp-python) is also available.

I also wanted to address a couple other topics you mentioned. You are right in that they're all somewhat connected. But you need to scope down your goal/research question because what you're aiming to achieve is too difficult for a first task. Named entity recognition, constituency parsing, and sentiment analysis. Pick just one to focus on.

> **Comments:**
> **username_0**: Thanks for your answer.  I'm new to this field so this information is very useful for my research.  I saw CoreNLP and was debating on using it.  I think I'll need to make some hybrid solution, which uses CoreNLP to analyize the subject, and some savvy rules to maintain track of the subject  
> **username_1**: You're welcome! Part of the difficulty in getting start with NLP is understanding the correct terms to call things. One you know the right term you can often find useful answers.  

---

