********************************* Analysis Tool --- :mod:`analyzer` ********************************* .. automodule:: libshorttext.analyzer :members: :undoc-members: :inherited-members: :show-inheritance: Analyzer and Other Auxiliary Classes ==================================== .. autoclass:: libshorttext.analyzer.Analyzer :members: :undoc-members: :inherited-members: :show-inheritance: Auxiliary Classes ----------------- .. currentmodule:: libshorttext.analyzer :class:`Analyzer` has two auxiliary classes: :class:`InstanceSet` and :class:`TextInstance`. :class:`InstanceSet` is a set of instances. It is used to indicate which instances :class:`Analyzer` should consider. Each instance in :class:`InstanceSet` is a :class:`TextInstance` instance. .. autoclass:: libshorttext.analyzer.InstanceSet :members: :undoc-members: :inherited-members: :show-inheritance: .. autoclass:: libshorttext.analyzer.TextInstance :members: :undoc-members: :inherited-members: :show-inheritance: .. _selectorfunctions: Built-in Instance Selector Functions ==================================== .. currentmodule:: libshorttext.analyzer Four selector functions are defined in :mod:`analyzer`. They should be used with :meth:`InstanceSet.select`. .. autofunction:: reverse .. autofunction:: sort_by_dec .. autofunction:: subset .. autofunction:: with_labels .. autofunction:: wrong User-defined Selector Functions ------------------------------- Users can define a selector function by themselves. A selector function's input is a list of :class:`TextInstance`, and the return value should be another list of :class:`TextInstance`. For example, :func:`wrong` is equivalent to the following example:: def wrong(insts): wrong_label = lambda inst: inst.true_y != inst.predicted_y wrong_insts = filter(wrong_label, insts) return list(wrong_insts) Refer to :class:`TextInstance` for the instance members. :mod:`analyzer` provides a function :func:`selectorize` to convert some simple `rules` to a selector function. The example above can be further simplified by :func:`selectorize`. .. autofunction:: selectorize