Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:53:43+00:00 2026-05-29T03:53:43+00:00

Currently I am on a source code plagiarims detection project, and I actually use

  • 0

Currently I am on a source code plagiarims detection project, and I actually use the different aspects of attributes of the input files (souce code files) to detect plagiarism among student assignments. For example, I now uses (number of identifiers/variables, number of methods used, number of lines of code ) and some other attributes to represent each source code file.

However, when I try to count the number of variables used, one problem is how to find out whether a variable has been used or not. Because the students could intentionally put some identifiers in to cover the plagiarism. However, as I tried to solve this, I found this one really tough. One approach to do this is to use Regular expression in java to handle finding identifiers, but after finding them, I stuck on how to check for usage or not. (What’s more, after this, I still need to find whether a java method is called or not. ) So writing my own version of regular expression could be very complicated.

I know in some IDE like netbeans the editor could instantly find out whether a variable is used or not and underline it. So I wonder if there is any good way for checking variables used or not.

Any suggestions on how to do checking variables would be good!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:53:43+00:00Added an answer on May 29, 2026 at 3:53 am

    For doing this kind of code analysis, you absolutely have to look into parser / compiler tools. You cannot determine whether a variable is used by searching for its mere name; you have to search for correct context as well.

    I suggest to have a look at ANTLR, which is a Java-based language parsing tool. It has a definition for parsing Java syntax available here. Don’t expect to find an easy solution for your problem that can be implemented in a couple of hours.

    Another Java-based tool is JavaCC. If you’re looking for example code showing how these tools can be used, take a look at PMD, which uses a parser built with JavaCC to analyze Java code.

    Another possibility is to write a plugin for an IDE that supports code analysis – you’d probably have a much simpler interface there to access the code structure, and as you said, lots of functionality is already available and can simply be called by your plugin.

    Yes, you can probably also hack your way with some regexes. Whether you want to do this depends on how exact you want your tool to be. Without parsing the source code, deciding whether an occurrence of a variable name is actually a usage of that variable is merely a heuristic guess.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had to modify some open source code to use in a C project.
Possible Duplicate: “The breakpoint will not currently be hit. The source code is different
I am currently starting using doxygen to document my source code. I have notice
I currently have CruiseControl.NET set up with SVN to automatically grab the code source
Currently my eclipse source folder display the entire package path and java files under
I currently mantain an open-source project hosted in SourceForge. My project is written in
I'm currently installing and configuring an open source project on a test server. I've
I currently have a website source code (no control over the source) which contains
We are currently using TFS as our source code repository, but I prefer NAnt
I am going through the source code for the above project and I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.