Message Boards Message Boards


Why "A symbol occurs in more than one context" in text analysis functions?

Posted 8 years ago
1 Reply
1 Total Likes

Recently noticed, that some new text analysis functions require a context. As I understand, they belong to certain package, but documentation doesn't mention it.

enter image description here

POSTED BY: Konstantin Nosov

It seems that the redfaced WordCount, WordCounts, and LetterCounts are shadowed by some other definitions in your working environment, cmp. the following sequence about Smith:

In[1]:= $ContextPath
Out[1]= {"PacletManager`", "System`", "Global`"}

In[2]:= {PhysicalUnits`Smith, BioDiversity`Smith}
Out[2]= {PhysicalUnits`Smith, BioDiversity`Smith}

In[3]:= $ContextPath = Join[{"PhysicalUnits`", "BioDiversity`"}, $ContextPath]
Out[3]= {"PhysicalUnits`", "BioDiversity`", "PacletManager`", "System`", "Global`"}

In[4]:= Context[Smith]
Out[4]= "PhysicalUnits`"

In[5]:= Smith = 3 (* not a good idea *); PhysicalUnits`Smith = 4; BioDiversity`Smith = 5;

In[6]:= Context[Smith]
Out[6]= "PhysicalUnits`"

In[8]:= Smith + Smith + BioDiversity`Smith (* 4 + 4 + 5 *)
Out[8]= 13

In[9]:= Global`Smith + Smith + BioDiversity`Smith (* 3 + 4 + 5 *)
During evaluation of In[9]:= Global`Smith::shdw: Symbol Smith appears in multiple contexts {Global`,PhysicalUnits`,BioDiversity`}; definitions in context Global` may shadow or be shadowed by other definitions. >>
Out[9]= 9 + Global`Smith

checkout whether some other packages are preloaded, which contain names nowadays given the above mentioned redfaced built-in functions.

POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract