val resId=Document.multinomialSample(cands.map((cand:Candidate)=>cand.support.asInstanceOf[Float]).toArray,
cands.map((cand:Candidate)=>cand.resource.id).toArray)

is to initialize a resource id to each surfaceform/mention, which is
sampled according to the number of occurrences of each
entity/resource, i.e., the cand.support. So I think there is no need
to compute P(e|sf) explicitly.


Regards,

Wei



On Sun, Aug 18, 2013 at 10:28 PM, Jo Daiber <notifications@github.com>wrote:

> In
> core/src/main/scala/org/dbpedia/spotlight/db/entitytopic/EntityTopicModel.scala:
>
> > +  }
> > +
> > +  def mapResult(doc:Document):Map[SurfaceFormOccurrence, List[DBpediaResourceOccurrence]]={
> > +    var map=Map[SurfaceFormOccurrence, List[DBpediaResourceOccurrence]]()
> > +    if(doc!=null)
> > +      (doc.mentions,doc.entityOfMention).zipped.foreach((mention,entity)=>map+=(mention->List(Factory.DBpediaResourceOccurrence.from(mention,searcher.resStore.getResource(entity),0.0))))
> > +    map
> > +  }
> > +
> > +  def inference(paragraph: Paragraph):Document={
> > +    val surfaceOccrs=paragraph.getOccurrences().asScala
> > +    val resOccrs=new ListBuffer[DBpediaResourceOccurrence]()
> > +    surfaceOccrs.foreach((sfOccr:SurfaceFormOccurrence)=>{
> > +      val cands=searcher.getCandidates(sfOccr.surfaceForm)
> > +      if(cands.size>0){
> > +        val resId=Document.multinomialSample(cands.map((cand:Candidate)=>cand.support.asInstanceOf[Float]).toArray, cands.map((cand:Candidate)=>cand.resource.id).toArray)
>
> Are you sure you want cand.support here? Support is c(sf, entity); if you
> want the probability, you have to use prior (which is P(e | sf); if you
> need P(sf | e), you would have to calculate it yourself.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/dbpedia-spotlight/dbpedia-spotlight/pull/204/files#r5831623>
> .
>