Skip to content

Commit

Permalink
fix comment issues
Browse files Browse the repository at this point in the history
  • Loading branch information
qindazhu committed Jul 24, 2020
1 parent 9ba5dc7 commit 9f8e8ea
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 30 deletions.
6 changes: 3 additions & 3 deletions k2/csrc/aux_labels.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class AuxLabels1Mapper {
: labels_in_(labels_in), arc_map_(arc_map) {}

/*
Do enough work to know now much memory will be needed, and output
Do enough work to know how much memory will be needed, and output
that information
@param [out] aux_size The number of lists in the output AuxLabels
(equals num-arcs in the output FSA) and
Expand Down Expand Up @@ -110,7 +110,7 @@ class AuxLabels2Mapper {
: labels_in_(labels_in), arc_map_(arc_map) {}

/*
Do enough work that know now much memory will be needed, and output
Do enough work that know how much memory will be needed, and output
that information
@param [out] aux_size The number of lists in the output AuxLabels
(equals num-arcs in the output FSA) and
Expand Down Expand Up @@ -152,7 +152,7 @@ class FstInverter {
: fsa_in_(fsa_in), labels_in_(labels_in) {}

/*
Do enough work that know now much memory will be needed, and output
Do enough work to know how much memory will be needed, and output
that information
@param [out] fsa_size The num-states and num-arcs of the FSA
will be written to here
Expand Down
2 changes: 1 addition & 1 deletion k2/csrc/connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Connection {
explicit Connection(const Fsa &fsa_in) : fsa_in_(fsa_in) {}

/*
Do enough work to know now much memory will be needed, and output
Do enough work to know how much memory will be needed, and output
that information
@param [out] fsa_size The num-states and num-arcs of the output FSA
will be written to here
Expand Down
2 changes: 1 addition & 1 deletion k2/csrc/determinize.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Determinizer {
}

/*
Do enough work to know now much memory will be needed, and output
Do enough work to know how much memory will be needed, and output
that information
@param [out] fsa_size The num-states and num-arcs of the output FSA
will be written to here
Expand Down
2 changes: 1 addition & 1 deletion k2/csrc/fsa_equivalent.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class RandPath {
}

/*
Do enough work to know now much memory will be needed, and output
Do enough work to know how much memory will be needed, and output
that information
@param [out] fsa_size The num-states and num-arcs of the output FSA
will be written to here
Expand Down
4 changes: 2 additions & 2 deletions k2/csrc/fsa_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class StringToFsa {
explicit StringToFsa(const std::string &s) : s_(s) {}

/*
Do enough work to know now much memory will be needed, and output
Do enough work to know how much memory will be needed, and output
that information
@param [out] fsa_size The num-states and num-arcs of the output FSA
will be written to here
Expand Down Expand Up @@ -297,7 +297,7 @@ class RandFsaGenerator {
explicit RandFsaGenerator(const RandFsaOptions &opts) : opts_(opts) {}

/*
Do enough work to know now much memory will be needed, and output
Do enough work to know how much memory will be needed, and output
that information
@param [out] fsa_size The num-states and num-arcs of the generated FSA
will be written to here
Expand Down
2 changes: 1 addition & 1 deletion k2/csrc/intersect.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Intersection {
Intersection(const Fsa &a, const Fsa &b) : a_(a), b_(b) {}

/*
Do enough work to know now much memory will be needed, and output
Do enough work to know how much memory will be needed, and output
that information
@param [out] fsa_size The num-states and num-arcs of the output FSA
will be written to here
Expand Down
2 changes: 1 addition & 1 deletion k2/csrc/rmepsilon.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class EpsilonsRemover {
}

/*
Do enough work to know now much memory will be needed, and output
Do enough work to know how much memory will be needed, and output
that information
@param [out] fsa_size The num-states and num-arcs of the output FSA
will be written to here
Expand Down
2 changes: 1 addition & 1 deletion k2/csrc/topsort.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TopSorter {
explicit TopSorter(const Fsa &fsa_in) : fsa_in_(fsa_in) {}

/*
Do enough work to know now much memory will be needed, and output
Do enough work to know how much memory will be needed, and output
that information
@param [out] fsa_size The num-states and num-arcs of the output FSA
will be written to here
Expand Down
6 changes: 3 additions & 3 deletions k2/python/csrc/fsa_algo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ void PyBindArcSort(py::module &m) {
"get_output",
[](PyClass &self, k2::Fsa *fsa_out,
k2::Array1<int32_t *> *arc_map = nullptr) {
self.GetOutput(fsa_out,
arc_map == nullptr ? nullptr : arc_map->data);
return self.GetOutput(fsa_out,
arc_map == nullptr ? nullptr : arc_map->data);
},
py::arg("fsa_out"), py::arg("arc_map").none(true));

m.def(
"_arc_sort",
[](k2::Fsa *fsa, k2::Array1<int32_t *> *arc_map = nullptr) {
k2::ArcSort(fsa, arc_map == nullptr ? nullptr : arc_map->data);
return k2::ArcSort(fsa, arc_map == nullptr ? nullptr : arc_map->data);
},
"in-place version of ArcSorter", py::arg("fsa"),
py::arg("arc_map").none(true));
Expand Down
4 changes: 2 additions & 2 deletions k2/python/csrc/properties.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// k2/python/csrc/property.cc
// k2/python/csrc/properties.cc

// Copyright (c) 2020 Xiaomi Corporation (author: Haowen Qiu)

Expand All @@ -17,7 +17,7 @@
// We can make it accept `None` with `std::optional` in pybind11, but
// that will require C++17, so we here choose to write a version without
// `order`.
bool IsAcyclic(const k2::Fsa &fsa) {
static bool IsAcyclic(const k2::Fsa &fsa) {
return k2::IsAcyclic(fsa /*, std::vector<int32_t>* order = nullptr*/);
}

Expand Down
29 changes: 15 additions & 14 deletions k2/python/k2/fsa_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,27 @@ class ArcSorter(_ArcSorter):
def __init__(self, fsa_in: Fsa):
super().__init__(fsa_in.get_base())

def get_sizes(self, array_size: IntArray2):
super().get_sizes(array_size)
def get_sizes(self, array_size: IntArray2) -> None:
return super().get_sizes(array_size)

def get_output(self, fsa_out: Fsa, arc_map: IntArray1 = None):
super().get_output(fsa_out.get_base(),
arc_map.get_base() if arc_map is not None else None)
def get_output(self, fsa_out: Fsa, arc_map: IntArray1 = None) -> None:
return super().get_output(
fsa_out.get_base(),
arc_map.get_base() if arc_map is not None else None)


def arc_sort(fsa: Fsa, arc_map: IntArray1 = None):
_arc_sort(fsa.get_base(),
arc_map.get_base() if arc_map is not None else None)
def arc_sort(fsa: Fsa, arc_map: IntArray1 = None) -> None:
return _arc_sort(fsa.get_base(),
arc_map.get_base() if arc_map is not None else None)


class TopSorter(_TopSorter):

def __init__(self, fsa_in: Fsa):
super().__init__(fsa_in.get_base())

def get_sizes(self, array_size: IntArray2):
super().get_sizes(array_size)
def get_sizes(self, array_size: IntArray2) -> None:
return super().get_sizes(array_size)

def get_output(self, fsa_out: Fsa, state_map: IntArray1 = None) -> bool:
return super().get_output(
Expand All @@ -52,8 +53,8 @@ class Connection(_Connection):
def __init__(self, fsa_in: Fsa):
super().__init__(fsa_in.get_base())

def get_sizes(self, array_size: IntArray2):
super().get_sizes(array_size)
def get_sizes(self, array_size: IntArray2) -> None:
return super().get_sizes(array_size)

def get_output(self, fsa_out: Fsa, arc_map: IntArray1 = None) -> bool:
return super().get_output(
Expand All @@ -66,8 +67,8 @@ class Intersection(_Intersection):
def __init__(self, fsa_a: Fsa, fsa_b: Fsa):
super().__init__(fsa_a.get_base(), fsa_b.get_base())

def get_sizes(self, array_size: IntArray2):
super().get_sizes(array_size)
def get_sizes(self, array_size: IntArray2) -> None:
return super().get_sizes(array_size)

def get_output(self,
fsa_out: Fsa,
Expand Down

0 comments on commit 9f8e8ea

Please sign in to comment.