IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

avec Java Discussion :

Suppression des mots vides d'un texte


Sujet :

avec Java

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    100
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 100
    Points : 36
    Points
    36
    Par défaut Suppression des mots vides d'un texte
    Bonjour,

    Je travaille sur l'indexation par le calcul du texte, et je cherche à créer une fonction (Java) qui permet la suppression des mots vides (et, le, la, les ....) dans une fichier texte.

    Quelqu'un aurait-il une solution pour ça ?

    Merci

  2. #2
    Membre confirmé Avatar de benratti
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    471
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mai 2004
    Messages : 471
    Points : 649
    Points
    649
    Par défaut
    Si tu arrives à écrire une expression régulière correspondant à ta définition de "mot vide", il te suffit d'utiliser la méthode replaceAll de la classe String.

    A toi de te débrouiller pour récupérer la chaine de caractère contenu dans ton fichier.

  3. #3
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Pour information, des logiciels comme Lucene font déjà ce genre de travail qui est loin d'être simple.

  4. #4
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    100
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 100
    Points : 36
    Points
    36
    Par défaut
    Merci,

    J'ai déjà créé ma classe pour le calcul d’occurrence et des tf.idf, parmi ces mots il y a les mots vides qui ne servent à rien, je veux les éliminer.
    J'ai utilisé StringTokenizer pour éliminer tout ce qui est ASCII et chiffre mais les mots je ne sais pas s'il y a quelqu'un qui l'a déjà fait.

  5. #5
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Rien de pré-mâché, tu te fais ta liste de mots à ignorer et ensuite, en avant pour le nettoyage.

  6. #6
    Membre régulier Avatar de nounouuuuu201186
    Femme Profil pro
    Stagiaire
    Inscrit en
    Juillet 2011
    Messages
    169
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Stagiaire
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juillet 2011
    Messages : 169
    Points : 107
    Points
    107
    Par défaut
    Bonjour AI_LINUX,

    J'ai travaillé avec Lucene. Je pense qu'avant de calculer le tfidf, il vaut mieux faire un prétraitement pour votre texte en éliminant les mots inutiles(de genre le,la..)
    Vous avez à créer une liste contenant les mots vides, puis l'utiliser au sein de votre code.
    J'ai travaillé sur la langue anglaise et voici la liste que j'ai utilisée:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    a
    about
    above
    across
    after
    again
    against
    all
    almost
    alone
    along
    already
    also
    although
    always
    among
    an
    and
    another
    any
    anybody
    anyone
    anything
    anywhere
    are
    area
    areas
    around
    as
    ask
    asked
    asking
    asks
    at
    away
    b
    back
    backed
    backing
    backs
    be
    became
    because
    become
    becomes
    been
    before
    began
    behind
    being
    beings
    best
    better
    between
    big
    both
    br
    but
    by
    c
    came
    can
    cannot
    case
    cases
    certain
    certainly
    clear
    clearly
    come
    could
    d
    did
    differ
    different
    differently
    do
    does
    done
    down
    downed
    downing
    downs
    during
    e
    each
    early
    either
    end
    ended
    ending
    ends
    enough
    even
    evenly
    ever
    every
    everybody
    everyone
    everything
    everywhere
    f
    face
    faces
    fact
    facts
    far
    felt
    few
    find
    finds
    first
    for
    four
    from
    full
    fully
    further
    furthered
    furthering
    furthers
    g
    gave
    general
    generally
    get
    gets
    give
    given
    gives
    go
    going
    good
    goods
    got
    great
    greater
    greatest
    group
    grouped
    grouping
    groups
    h
    had
    has
    have
    having
    he
    her
    here
    herself
    high
    higher
    highest
    him
    himself
    his
    how
    however
    i
    if
    important
    in
    interest
    interested
    interesting
    interests
    into
    is
    it
    its
    itself
    j
    just
    k
    keep
    keeps
    kind
    knew
    know
    known
    knows
    l
    large
    largely
    last
    later
    latest
    least
    less
    let
    lets
    like
    likely
    long
    longer
    longest
    m
    made
    make
    making
    man
    many
    may
    me
    member
    members
    men
    might
    more
    most
    mostly
    mr
    mrs
    much
    must
    my
    myself
    n
    necessary
    need
    needed
    needing
    needs
    never
    new
    newer
    newest
    next
    no
    nobody
    non
    noone
    not
    nothing
    now
    nowhere
    number
    numbers
    o
    of
    off
    often
    old
    older
    oldest
    on
    once
    one
    only
    open
    opened
    opening
    opens
    or
    order
    ordered
    ordering
    orders
    other
    others
    our
    out
    over
    p
    part
    parted
    parting
    parts
    per
    perhaps
    place
    places
    point
    pointed
    pointing
    points
    possible
    present
    presented
    presenting
    presents
    problem
    problems
    put
    puts
    q
    quite
    r
    rather
    really
    right
    right
    room
    rooms
    s
    said
    same
    saw
    say
    says
    second
    seconds
    see
    seem
    seemed
    seeming
    seems
    sees
    several
    shall
    she
    should
    show
    showed
    showing
    shows
    side
    sides
    since
    small
    smaller
    smallest
    so
    some
    somebody
    someone
    something
    somewhere
    state
    states
    still
    still
    such
    sure
    t
    take
    taken
    than
    that
    the
    their
    them
    then
    there
    therefore
    these
    they
    thing
    things
    think
    thinks
    this
    those
    though
    thought
    thoughts
    three
    through
    thus
    to
    today
    together
    too
    took
    toward
    turn
    turned
    turning
    turns
    two
    u
    under
    until
    up
    upon
    us
    use
    used
    uses
    v
    very
    w
    want
    wanted
    wanting
    wants
    was
    way
    ways
    we
    well
    wells
    went
    were
    what
    when
    where
    whether
    which
    while
    who
    whole
    whose
    why
    will
    with
    within
    without
    work
    worked
    working
    works
    would
    x
    y
    year
    years
    yet
    you
    young
    younger
    youngest
    your
    yours
    z

  7. #7
    Membre régulier
    Inscrit en
    Novembre 2010
    Messages
    221
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 221
    Points : 92
    Points
    92
    Par défaut Suppression des mots vides d'un texte
    slt je connaissais pas Lucence mais grâce à toi je l'ai découvert et après une brève découverte je pense également qu'elle pourrais être une solution à ton problème.
    alors va si !
    a++

Discussions similaires

  1. Réponses: 4
    Dernier message: 22/07/2010, 16h46
  2. Réponses: 1
    Dernier message: 23/04/2010, 12h34
  3. Traitement des lignes [suppression des lignes vides]
    Par turbo_chess dans le forum Linux
    Réponses: 4
    Dernier message: 22/03/2007, 10h16
  4. Recuperer des mots d'un fichier texte
    Par Beyou dans le forum C
    Réponses: 8
    Dernier message: 03/01/2007, 14h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo