miner

Argument mining module

Module Contents

Functions

select_by_topic(→ pandas.DataFrame)

Select arguments mentioning the given topic.

get_edges(→ List[Tuple[int]])

Get edges from argument dataframe.

get_edge_weights(→ List[float])

Get edge weights.

get_edge_table(→ pandas.DataFrame)

Get the edge dataframe.

get_node_labels(→ List[str])

Get labels of arguments given the attacking network.

get_node_table(→ pandas.DataFrame)

Get the node dataframe.

miner.select_by_topic(data: pandas.DataFrame, topic: int) pandas.DataFrame[source]

Select arguments mentioning the given topic.

Parameters:
  • data (pd.DataFrame) – The argument dataframe that must contain the ‘topics’ column.

  • topic (int) – The given topic to select.

Raises:

ValueError – if the ‘topics’ value of an argument is stored as something else other than a tuple (e.g. a list).

Returns:

Part of the original argument dataframe that only contains arguments mentioning the given topic.

Return type:

pd.DataFrame

miner.get_edges(data: pandas.DataFrame) List[Tuple[int]][source]

Get edges from argument dataframe.

Edges (attacks) only exist if the two arguments have different overall scores. Edges are tuple of source and target, which are indices of the corresponding argument in the input dataframe.

Parameters:

data (pd.DataFrame) – The argument dataframe that must have the ‘score’ column.

Returns:

The edge list.

Return type:

List[Tuple[int]]

miner.get_edge_weights(data: pandas.DataFrame, edges: List[Tuple[int]]) List[float][source]

Get edge weights.

Edge weights are computed as the difference between the coherence of the source and that of the target.

Parameters:
  • data (pd.DataFrame) – The argument dataframe that must have the ‘coherence’ column.

  • edges (List[Tuple[int]]) – The edge list.

Returns:

The list of edge weights.

Return type:

List[float]

miner.get_edge_table(edges: List[Tuple[int]], weights: List[float]) pandas.DataFrame[source]

Get the edge dataframe.

There will be three columns in the output dataframe, which are ‘source’, ‘target’, and ‘weight’. Together, they describe weighted directed edges from source to target argument. Note that there will be no negative weights in the output dataframe, instead, all values will be replace with their absolute values. For edges with negative weights, we swap their source and target.

Parameters:
  • edges (List[Tuple[int]]) – The edge list, which are tuples of source and target argument ids.

  • weights (List[float]) – The list of edge weights.

Raises:

ValueError – if size of the input lists doesn’t match.

Returns:

The result edge dataframe.

Return type:

pd.DataFrame

miner.get_node_labels(indices: List[int], sources: List[int], targets: List[int]) List[str][source]

Get labels of arguments given the attacking network.

Arguments are separated into two classes, ‘supportive’ and ‘defeated’, which generally means reliable and unreliable. The rule of detecting the labels is as follows: if an argument is attacked by another argument who is not attacked by any argument, then this argument is labeled as ‘defeated’; otherwise, it’s labeled as ‘supportive’. That means, if an argument appears in targets, where its corresponding source doesn’t, this argument will be labeled as ‘defeated’, and otherwise ‘supportive’.

Parameters:
  • indices (List[int]) – The node index list

  • sources (List[int]) – The source list of the attacking network.

  • targets (List[int]) – The target list of the attacking network.

Returns:

The label list.

Return type:

List[str]

miner.get_node_table(arg_ids: List[int], arguments: List[str], scores: List[int], labels: List[str]) pandas.DataFrame[source]

Get the node dataframe.

The node dataframe will contain 4 columns, that are ‘argument_id’, ‘argument’, ‘score’, and ‘label’.

Parameters:
  • arg_ids (List[int]) – The argument id list.

  • arguments (List[str]) – The argument text list.

  • scores (List[int]) – The list of argument overall score.

  • labels (List[str]) – The argument label list.

Returns:

The result node dataframe.

Return type:

pd.DataFrame