コード例 #1
0
ファイル: test_range.py プロジェクト: LALMAN2000/bnosa
def test_rangess():
    rss = rangess()
    assert len(rss) == 0

    rss.resize(5)
    assert len(rss) == 5
    for rs in rss:
        assert len(rs) == 0

    rss.clear()
    assert len(rss) == 0

    rs1 = ranges()
    rs1.append(range(1, 2))
    rs1.append(range(3, 4))

    rs2 = ranges()
    rs2.append(range(5, 6))
    rs2.append(range(7, 8))

    rss.extend([rs1, rs2])
    assert rss[0][0].begin == 1
    assert rss[0][1].begin == 3
    assert rss[1][0].begin == 5
    assert rss[1][1].begin == 7
    assert rss[0][0].end == 2
    assert rss[0][1].end == 4
    assert rss[1][0].end == 6
    assert rss[1][1].end == 8

    ser = pickle.dumps(rss, 2)
    deser = pickle.loads(ser)
    assert rss == deser
コード例 #2
0
            vects.append(no_cap)
    return vects


def print_segment(sentence, names):
    words = sentence.split()
    for name in names:
        for i in name:
            sys.stdout.write(words[i] + " ")
        sys.stdout.write("\n")


# Now let's make some training data.  Each example is a sentence as well as a
# set of ranges which indicate the locations of any names.
names = dlib.ranges()  # make an array of dlib.range objects.
segments = dlib.rangess()  # make an array of arrays of dlib.range objects.
sentences = []

sentences.append("The other day I saw a man named Jim Smith")
# We want to detect person names.  So we note that the name is located within
# the range [8, 10).  Note that we use half open ranges to identify segments.
# So in this case, the segment identifies the string "Jim Smith".
names.append(dlib.range(8, 10))
segments.append(names)
names.clear()  # make names empty for use again below

sentences.append("Davis King is the main author of the dlib Library")
names.append(dlib.range(0, 2))
segments.append(names)
names.clear()
コード例 #3
0
    return vects


def print_segment(sentence, names):
    words = sentence.split()
    for name in names:
        for i in name:
            sys.stdout.write(words[i] + " ")
        sys.stdout.write("\n")



# Now lets make some training data.  Each example is a sentence as well as a set of ranges
# which indicate the locations of any names.   
names = dlib.ranges()     # make an array of dlib.range objects.
segments = dlib.rangess() # make an array of arrays of dlib.range objects.
sentences = []


sentences.append("The other day I saw a man named Jim Smith")
# We want to detect person names.  So we note that the name is located within the
# range [8, 10).  Note that we use half open ranges to identify segments.  So in 
# this case, the segment identifies the string "Jim Smith".
names.append(dlib.range(8, 10))
segments.append(names)
names.clear() # make names empty for use again below


sentences.append("Davis King is the main author of the dlib Library")
names.append(dlib.range(0, 2))
segments.append(names)
コード例 #4
0
ファイル: sequence_segmenter.py プロジェクト: kavonm/Dlib
    return vects


def print_segment(sentence, names):
    words = sentence.split()
    for name in names:
        for i in name:
            sys.stdout.write(words[i] + " ")
        sys.stdout.write("\n")



# Now lets make some training data.  Each example is a sentence as well as a set of ranges
# which indicate the locations of any names.   
names = dlib.ranges()
segments = dlib.rangess()
sentences = []


sentences.append("The other day I saw a man named Jim Smith")
# We want to detect person names.  So we note that the name is located within the
# range [8, 10).  Note that we use half open ranges to identify segments.  So in 
# this case, the segment identifies the string "Jim Smith".
names.append(dlib.range(8, 10))
segments.append(names)
names.clear() # make names empty for use again below


sentences.append("Davis King is the main author of the dlib Library")
names.append(dlib.range(0, 2))
segments.append(names)